did-jwt
Version:
Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients
27 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyBlockchainAccountId = verifyBlockchainAccountId;
const bip122_js_1 = require("./bip122.js");
const cosmos_js_1 = require("./cosmos.js");
const Digest_js_1 = require("../Digest.js");
function verifyBlockchainAccountId(publicKey, blockchainAccountId) {
if (blockchainAccountId) {
const chain = blockchainAccountId.split(':');
switch (chain[0]) {
case 'bip122':
chain[chain.length - 1] = (0, bip122_js_1.publicKeyToAddress)(publicKey, chain[chain.length - 1]);
break;
case 'cosmos':
chain[chain.length - 1] = (0, cosmos_js_1.publicKeyToAddress)(publicKey, chain[1]);
break;
case 'eip155':
chain[chain.length - 1] = (0, Digest_js_1.toEthereumAddress)(publicKey);
break;
default:
return false;
}
return chain.join(':').toLowerCase() === blockchainAccountId.toLowerCase();
}
return false;
}
//# sourceMappingURL=index.js.map