diff options
author | Matthew Miller <matthew@millerti.me> | 2020-06-07 15:09:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-07 15:09:57 -0700 |
commit | 992a56a10fab7f651a936bcc65642664b9cd86bc (patch) | |
tree | 8a0bf34253858057e35a3aa996b911a97751e3af /packages/server/src/helpers/decodeClientDataJSON.ts | |
parent | b4c1bae58a11f7651dd44b7cfc7ba210ef09a605 (diff) | |
parent | c172c6afd507d8a690c8716bb37d551b9e99379a (diff) |
Merge pull request #24 from MasterKale/feature/improved-verification
feature/improved-verification
Diffstat (limited to 'packages/server/src/helpers/decodeClientDataJSON.ts')
-rw-r--r-- | packages/server/src/helpers/decodeClientDataJSON.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/packages/server/src/helpers/decodeClientDataJSON.ts b/packages/server/src/helpers/decodeClientDataJSON.ts index c0ebb2b..52bbf4c 100644 --- a/packages/server/src/helpers/decodeClientDataJSON.ts +++ b/packages/server/src/helpers/decodeClientDataJSON.ts @@ -1,15 +1,15 @@ -import asciiToBinary from './asciiToBinary'; +import base64url from 'base64url'; /** - * Decode an authenticator's base64-encoded clientDataJSON to JSON + * Decode an authenticator's base64url-encoded clientDataJSON to JSON */ export default function decodeClientDataJSON(data: string): ClientDataJSON { - const toString = asciiToBinary(data); + const toString = base64url.decode(data); const clientData: ClientDataJSON = JSON.parse(toString); - // `challenge` will be Base64-encoded here. Decode it for easier comparisons with what is provided - // as the expected value - clientData.challenge = Buffer.from(clientData.challenge, 'base64').toString('ascii'); + // `challenge` will be Base64URL-encoded here. Decode it for easier comparisons with what is + // provided as the expected value + clientData.challenge = base64url.decode(clientData.challenge); return clientData; } |