From 052fbfc59288bf661a441f0a988efae193e12f4d Mon Sep 17 00:00:00 2001 From: zetsuboii Date: Sat, 20 Jan 2024 21:58:24 +0300 Subject: [PATCH] [fix] revert back to b64 --- src/Passkey.tsx | 8 ++++---- src/utils.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Passkey.tsx b/src/Passkey.tsx index eaa3fb5..5808d71 100644 --- a/src/Passkey.tsx +++ b/src/Passkey.tsx @@ -76,7 +76,7 @@ export class Passkey { throw NotSupportedError; } - const challengeBase64 = utils.toBase64Url(challenge); + const challengeBase64 = utils.hextoBase64(challenge); const request = this.generateCreateRequest( userId, @@ -109,7 +109,7 @@ export class Passkey { throw NotSupportedError; } - const challengeBase64 = utils.toBase64Url(challenge); + const challengeBase64 = utils.hextoBase64(challenge); const request = this.generateSignRequest( credentialIds, @@ -128,7 +128,7 @@ export class Passkey { ); } - const base64Decoded = utils.fromBase64Url(authResponse.response.signature); + const base64Decoded = utils.base64ToHex(authResponse.response.signature); const { r, s } = utils.derToRs(base64Decoded); return ['0x', r, s].join(''); } @@ -151,7 +151,7 @@ export class Passkey { throw NotSupportedError; } - const challengeBase64 = utils.toBase64Url(challenge); + const challengeBase64 = utils.hextoBase64(challenge); const request = this.generateSignRequest( credentialIds, diff --git a/src/utils.ts b/src/utils.ts index 4aaf1b5..c174610 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,11 +1,11 @@ import { Buffer } from 'buffer'; -export const fromBase64Url = (text: string) => { +export const base64ToHex = (text: string) => { return Buffer.from(text, 'base64').toString('hex'); }; -export const toBase64Url = (hex: string) => { - return Buffer.from(hex, 'hex').toString('base64url'); +export const hextoBase64 = (hex: string) => { + return Buffer.from(hex, 'hex').toString('base64'); }; /** Removes 0x from hex */