Skip to content

Commit e6eec8e

Browse files
committed
manfredsteyer#628 Generate a code_verifier and then base64url encode it
1 parent a1652dc commit e6eec8e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

projects/lib/src/oauth-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2087,23 +2087,23 @@ export class OAuthService extends AuthConfig implements OnDestroy {
20872087
* This alphabet uses a-z A-Z 0-9 _- symbols.
20882088
* Symbols order was changed for better gzip compression.
20892089
*/
2090-
const url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-';
2090+
const unreserved = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~';
20912091
let size = 45;
20922092
let id = '';
20932093

20942094
const crypto = self.crypto || self['msCrypto'];
20952095
if (crypto) {
20962096
const bytes = crypto.getRandomValues(new Uint8Array(size));
20972097
while (0 < size--) {
2098-
id += url[bytes[size] & 63];
2098+
id += unreserved[bytes[size] & 63];
20992099
}
21002100
} else {
21012101
while (0 < size--) {
2102-
id += url[Math.random() * 64 | 0];
2102+
id += unreserved[Math.random() * 64 | 0];
21032103
}
21042104
}
21052105

2106-
resolve(id);
2106+
resolve(base64UrlEncode(id));
21072107
});
21082108
}
21092109

0 commit comments

Comments
 (0)