Skip to content

Commit eb978bc

Browse files
authored
Validate self when calling crypto provider
When generating noonce, SSR is failing due to self not being defined. This change will have it fall back when running on the server side.
1 parent a1652dc commit eb978bc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

projects/lib/src/oauth-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
20912091
let size = 45;
20922092
let id = '';
20932093

2094-
const crypto = self.crypto || self['msCrypto'];
2094+
const crypto = typeof self === 'undefined' ? null : (self.crypto || self['msCrypto']);
20952095
if (crypto) {
20962096
const bytes = crypto.getRandomValues(new Uint8Array(size));
20972097
while (0 < size--) {

0 commit comments

Comments
 (0)