From 835a40b7f698b1d2a01ae0f0a8df28bcdaa529a1 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Sat, 26 Oct 2024 09:01:37 +0100 Subject: [PATCH] chore: fix chrome --- packages/crypto/src/keys/rsa/utils.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/crypto/src/keys/rsa/utils.ts b/packages/crypto/src/keys/rsa/utils.ts index 65a387306f..8e946423b3 100644 --- a/packages/crypto/src/keys/rsa/utils.ts +++ b/packages/crypto/src/keys/rsa/utils.ts @@ -121,10 +121,14 @@ export function jwkToPkix (jwk: JsonWebKey): Uint8Array { } function asn1jsIntegerToBase64 (int: asn1js.Integer): string { - const buf = int.valueBlock.valueHexView - const str = uint8ArrayToString(buf, 'base64url') + let buf = int.valueBlock.valueHexView - return str + // chrome rejects values with leading 0s + while (buf[0] === 0) { + buf = buf.subarray(1) + } + + return uint8ArrayToString(buf, 'base64url') } function bufToBn (u8: Uint8Array): bigint {