Skip to content

Commit

Permalink
[fix] revert back to b64
Browse files Browse the repository at this point in the history
  • Loading branch information
zetsuboii committed Jan 20, 2024
1 parent 6361903 commit 052fbfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Passkey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Passkey {
throw NotSupportedError;
}

const challengeBase64 = utils.toBase64Url(challenge);
const challengeBase64 = utils.hextoBase64(challenge);

const request = this.generateCreateRequest(
userId,
Expand Down Expand Up @@ -109,7 +109,7 @@ export class Passkey {
throw NotSupportedError;
}

const challengeBase64 = utils.toBase64Url(challenge);
const challengeBase64 = utils.hextoBase64(challenge);

const request = this.generateSignRequest(
credentialIds,
Expand All @@ -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('');
}
Expand All @@ -151,7 +151,7 @@ export class Passkey {
throw NotSupportedError;
}

const challengeBase64 = utils.toBase64Url(challenge);
const challengeBase64 = utils.hextoBase64(challenge);

const request = this.generateSignRequest(
credentialIds,
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down

0 comments on commit 052fbfc

Please sign in to comment.