File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
infrastructure/signature-validator/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import axios from "axios" ;
22import * as jose from "jose" ;
3- import { base58btc } from "multiformats/bases/base58" ;
3+
4+ // Dynamic import for base58btc to handle ESM module in CommonJS context
5+ let base58btcCache : { decode : ( input : string ) => Uint8Array } | null = null ;
6+
7+ async function getBase58btc ( ) {
8+ if ( ! base58btcCache ) {
9+ const base58Module = await import ( "multiformats/bases/base58" ) ;
10+ base58btcCache = base58Module . base58btc ;
11+ }
12+ return base58btcCache ;
13+ }
414
515/**
616 * Options for signature verification
@@ -59,6 +69,7 @@ async function decodeMultibasePublicKey(multibaseKey: string): Promise<Uint8Arra
5969
6070 // Try base58btc (standard multibase 'z' prefix)
6171 try {
72+ const base58btc = await getBase58btc ( ) ;
6273 return base58btc . decode ( encoded ) ;
6374 } catch ( error ) {
6475 throw new Error (
@@ -77,6 +88,7 @@ async function decodeSignature(signature: string): Promise<Uint8Array> {
7788 // If it starts with 'z', it's multibase base58btc
7889 if ( signature . startsWith ( "z" ) ) {
7990 try {
91+ const base58btc = await getBase58btc ( ) ;
8092 return base58btc . decode ( signature . slice ( 1 ) ) ;
8193 } catch ( error ) {
8294 throw new Error ( `Failed to decode multibase signature: ${ error instanceof Error ? error . message : String ( error ) } ` ) ;
You can’t perform that action at this time.
0 commit comments