diff --git a/src/lib/__tests__/pkce.test.js b/src/lib/__tests__/pkce.test.js index 298cead..7992982 100644 --- a/src/lib/__tests__/pkce.test.js +++ b/src/lib/__tests__/pkce.test.js @@ -3,7 +3,7 @@ import { toSha256, toBase64Url, createRandomString, - createPKCECodeVerifier, + createPKCECodeChallenge, } from '../pkce' describe('createRandomString', () => { @@ -52,18 +52,18 @@ describe('toBase64Url', () => { }) }) -describe('createPKCECodeVerifier', () => { +describe('createPKCECodeChallenge', () => { test('creates code challenge', async () => { const codeVerifier = createRandomString(43) - const codeChallenge = await createPKCECodeVerifier(codeVerifier) + const codeChallenge = await createPKCECodeChallenge(codeVerifier) expect(codeChallenge).toHaveLength(43) }) test('creates unique code challenge', async () => { const codeVerifier = createRandomString(43) - const codeChallenge1 = await createPKCECodeVerifier(codeVerifier) - const codeChallenge2 = await createPKCECodeVerifier(codeVerifier) + const codeChallenge1 = await createPKCECodeChallenge(codeVerifier) + const codeChallenge2 = await createPKCECodeChallenge(codeVerifier) expect(codeChallenge1).toEqual(codeChallenge2) }) diff --git a/src/lib/pkce.ts b/src/lib/pkce.ts index 4891367..473a6a1 100644 --- a/src/lib/pkce.ts +++ b/src/lib/pkce.ts @@ -35,9 +35,9 @@ export const createRandomString = (length: number = 34): string => { return randomString; } -export const createPKCECodeVerifier = async (str: string): string => { - const hashed: Uint8Array = await toSha256(str) - const codeVerifier = toBase64Url(hashed) - return codeVerifier; +export const createPKCECodeChallenge = async (codeVerifies: string): string => { + const hashed: Uint8Array = await toSha256(codeVerifies) + const codeChallenge = toBase64Url(hashed) + return codeChallenge; }