Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1781,22 +1781,34 @@ export class OAuthService extends AuthConfig {
}

protected createNonce(): Promise<string> {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
if (this.rngUrl) {
throw new Error(
'createNonce with rng-web-api has not been implemented so far'
);
} else {
let text = '';
const possible =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
}

for (let i = 0; i < 40; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
/*
* This alphabet uses a-z A-Z 0-9 _- symbols.
* Symbols order was changed for better gzip compression.
*/
const url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-';
let size = 40;
let id = '';

const crypto = self.crypto || self.msCrypto;
if (crypto) {
const bytes = crypto.getRandomValues(new Uint8Array(size));
while (0 < size--) {
id += url[bytes[size] & 63];
}
} else {
while (0 < size--) {
id += url[Math.random() * 64 | 0];
}

resolve(text);
}

resolve(id);
});
}

Expand Down