This repository was archived by the owner on Apr 3, 2023. It is now read-only.
Commit 6819ef8 1 parent 201f808 commit 6819ef8 Copy full SHA for 6819ef8
File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { generatePkceChallenge , generateCodeVerifier } from '../utils/uuid' ;
2
+
3
+ describe ( 'utils' , ( ) => {
4
+ describe ( 'uuid' , ( ) => {
5
+ describe ( 'generatePkceChallenge' , ( ) => {
6
+ it ( 'should generate a pkce challenge' , ( ) => {
7
+ // Arrange
8
+ const codeVerifier = generateCodeVerifier ( 96 ) ;
9
+
10
+ // Act
11
+ const pkceChallenge = generatePkceChallenge ( 'S256' , codeVerifier ) ;
12
+
13
+ // Assert
14
+ expect ( pkceChallenge . length ) . toBeGreaterThan ( 0 ) ;
15
+ } ) ;
16
+ } ) ;
17
+ } ) ;
18
+ } ) ;
Original file line number Diff line number Diff line change @@ -44,9 +44,8 @@ export function generatePkceChallenge(
44
44
// The use of the "plain" method is considered insecure and therefore not supported.
45
45
case 'S256' :
46
46
// hash codeVerifier, then encode as url-safe base64 without padding
47
- const hashBytes = sha256 . arrayBuffer ( codeVerifier ) ;
48
- // new Uint8Array(sha256_imported.arrayBuffer(codeVerifier));
49
- const encodedHash = fromByteArray ( hashBytes as Uint8Array )
47
+ const hashBytes = new Uint8Array ( sha256 . arrayBuffer ( codeVerifier ) ) ;
48
+ const encodedHash = fromByteArray ( hashBytes )
50
49
. replace ( / \+ / g, '-' )
51
50
. replace ( / \/ / g, '_' )
52
51
. replace ( / \= / g, '' ) ;
You can’t perform that action at this time.
0 commit comments