
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@vtfk/react-msal
Advanced tools
MSAL (Azure auth) React hook
npm install --save @vtfk/react-msal
config.js
export const config = {
auth: {
clientId: '<client-id>',
authority: 'https://login.microsoftonline.com/<tenant-id>',
redirectUri: '<https://app-hostname.com>',
postLogoutRedirectUri: '<https://direct-url.com'
},
cache: {
cacheLocation: 'sessionStorage',
storeAuthStateInCookie: false
}
}
// See valid values here: https://azuread.github.io/microsoft-authentication-library-for-js/ref/msal-browser/modules/_src_request_redirectrequest_.html
export const loginRequest = {
scopes: ['openid', 'profile', 'User.Read']
}
index.js
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import { MsalProvider } from '@vtfk/react-msal'
import { config, loginRequest } from './config'
ReactDOM.render(
<React.StrictMode>
<MsalProvider config={config} scopes={loginRequest}>
<App />
</MsalProvider>
</React.StrictMode>,
document.getElementById('root')
)
App.js
const App = () => {
const { isAuthenticated, login, authStatus } = useSession()
if (['pending'].includes(authStatus)) {
return <div>Loading...</div>
}
if (!isAuthenticated) {
console.log('app-!isAuth')
login(loginRequest)
return <></>
}
if (isAuthenticated && authStatus === 'finished') {
return <div>Hello authenticated user!</div>
}
}
The useSession() hook has these methods and objects available:
isAuthenticated
(bool)authStatus
(string) - values are: pending, finished, rejected, unknownuser
(object) - user object from MS Graph - exampletoken
(string) - access_token from MS GraphidToken
(string) - id_token from MS GraphpopupOpen
(bool) - true if login popup is openloginError
(object) - login error objectlogin
(function) - trigger login
logout
(function) - trigger logout (clears session storage and redirects to azure)getToken
(function) - gathers and returns the users access token
apiGet
(function) - gets data from provided URL using the users id_token
apiPost
(function) - posts the provided data to the URL using the users id_token
apiPut
(function) - updates/put the provided data to the URL using the users id_token
apiDelete
(function) - deletes data from provided URL using the users id_token
{
displayName: 'Trine Testesen',
givenName: 'Trine',
name: 'Trine Testesen',
onPremisesSamAccountName: 'tri0308',
surname: 'Testesen',
tenantId: '08f3813c-9f29-482f-9aec-16ef7cbf477a',
userPrincipalName: 'trine.testesen@vtfk.no',
username: 'trine.testesen@vtfk.no'
}
FAQs
MSAL/Azure React authentication hook
The npm package @vtfk/react-msal receives a total of 18 weekly downloads. As such, @vtfk/react-msal popularity was classified as not popular.
We found that @vtfk/react-msal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.