UNPKG

did-jwt

Version:

Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients

24 lines • 942 B
import { publicKeyToAddress as bip122 } from './bip122.js'; import { publicKeyToAddress as cosmos } from './cosmos.js'; import { toEthereumAddress } from '../Digest.js'; export function verifyBlockchainAccountId(publicKey, blockchainAccountId) { if (blockchainAccountId) { const chain = blockchainAccountId.split(':'); switch (chain[0]) { case 'bip122': chain[chain.length - 1] = bip122(publicKey, chain[chain.length - 1]); break; case 'cosmos': chain[chain.length - 1] = cosmos(publicKey, chain[1]); break; case 'eip155': chain[chain.length - 1] = toEthereumAddress(publicKey); break; default: return false; } return chain.join(':').toLowerCase() === blockchainAccountId.toLowerCase(); } return false; } //# sourceMappingURL=index.js.map