File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { API_VERSION_HEADER_NAME , BASE64URL_REGEX } from './constants'
2
2
import { AuthInvalidJwtError } from './errors'
3
- import { base64UrlToUint8Array , stringFromBase64URL } from './base64url'
3
+ import { base64UrlToUint8Array , stringFromBase64URL , stringToBase64URL } from './base64url'
4
4
import { JwtHeader , JwtPayload , SupportedStorage } from './types'
5
5
6
6
export function expiresAt ( expiresIn : number ) {
@@ -276,10 +276,6 @@ async function sha256(randomString: string) {
276
276
. join ( '' )
277
277
}
278
278
279
- function base64urlencode ( str : string ) {
280
- return btoa ( str ) . replace ( / \+ / g, '-' ) . replace ( / \/ / g, '_' ) . replace ( / = + $ / , '' )
281
- }
282
-
283
279
export async function generatePKCEChallenge ( verifier : string ) {
284
280
const hasCryptoSupport =
285
281
typeof crypto !== 'undefined' &&
@@ -293,7 +289,7 @@ export async function generatePKCEChallenge(verifier: string) {
293
289
return verifier
294
290
}
295
291
const hashed = await sha256 ( verifier )
296
- return base64urlencode ( hashed )
292
+ return stringToBase64URL ( hashed )
297
293
}
298
294
299
295
export async function getCodeChallengeAndMethod (
You can’t perform that action at this time.
0 commit comments