我正在尝试测试一些使用 MSAL 进行身份验证的组件。
到目前为止,我有一个简单的测试,测试我的组件是否可以渲染,如下所示:
// <MsalInstanceSnippet>
const msalInstance = new PublicClientApplication({
auth: {
clientId: config.appId,
redirectUri: config.redirectUri
},
cache: {
cacheLocation: 'sessionStorage',
storeAuthStateInCookie: true
}
});
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我收到以下错误:
BrowserAuthError: crypto_nonexistent: The crypto object or function is not available. Detail:Browser crypto or msCrypto object not available.
10 |
11 | // <MsalInstanceSnippet>
> 12 | const msalInstance = new PublicClientApplication({
| ^
13 | auth: {
14 | clientId: config.appId,
15 | redirectUri: config.redirectUri
at BrowserAuthError.AuthError [as constructor] (node_modules/@azure/msal-common/dist/error/AuthError.js:27:24)
at new BrowserAuthError …Run Code Online (Sandbox Code Playgroud)