@@ -785,8 +785,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
785
785
tap ( result => this . storeIdToken ( result ) ) ,
786
786
map ( _ => tokenResponse )
787
787
) ;
788
- }
789
- else {
788
+ } else {
790
789
return of ( tokenResponse ) ;
791
790
}
792
791
} ) )
@@ -1402,8 +1401,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
1402
1401
public tryLogin ( options : LoginOptions = null ) : Promise < boolean > {
1403
1402
if ( this . config . responseType === 'code' ) {
1404
1403
return this . tryLoginCodeFlow ( ) . then ( _ => true ) ;
1405
- }
1406
- else {
1404
+ } else {
1407
1405
return this . tryLoginImplicitFlow ( options ) ;
1408
1406
}
1409
1407
}
@@ -2141,26 +2139,28 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2141
2139
}
2142
2140
2143
2141
/*
2144
- * This alphabet uses a-z A-Z 0-9 _- symbols.
2145
- * Symbols order was changed for better gzip compression.
2142
+ * This alphabet is from:
2143
+ * https://tools.ietf.org/html/rfc7636#section-4.1
2144
+ *
2145
+ * [A-Z] / [a-z] / [0-9] / "-" / "." / "_" / "~"
2146
2146
*/
2147
- const url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz- ' ;
2147
+ const unreserved = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~ ' ;
2148
2148
let size = 45 ;
2149
2149
let id = '' ;
2150
2150
2151
2151
const crypto = self . crypto || self [ 'msCrypto' ] ;
2152
2152
if ( crypto ) {
2153
- const bytes = crypto . getRandomValues ( new Uint8Array ( size ) ) ;
2154
- while ( 0 < size -- ) {
2155
- id += url [ bytes [ size ] & 63 ] ;
2156
- }
2153
+ let bytes = new Uint8Array ( size ) ;
2154
+ crypto . getRandomValues ( bytes ) ;
2155
+ bytes = bytes . map ( x => unreserved . charCodeAt ( x % unreserved . length ) ) ;
2156
+ id = String . fromCharCode . apply ( null , bytes ) ;
2157
2157
} else {
2158
2158
while ( 0 < size -- ) {
2159
- id += url [ Math . random ( ) * 64 | 0 ] ;
2159
+ id += unreserved [ Math . random ( ) * unreserved . length | 0 ] ;
2160
2160
}
2161
2161
}
2162
2162
2163
- resolve ( id ) ;
2163
+ resolve ( base64UrlEncode ( id ) ) ;
2164
2164
} ) ;
2165
2165
}
2166
2166
0 commit comments