@veramo/utils
Advanced tools
Comparing version 3.1.2-next.59 to 3.1.2-next.65
@@ -6,2 +6,4 @@ import { DIDDocumentSection, IAgentContext, IIdentifier, IKey, IResolver } from '@veramo/core'; | ||
export declare function compressIdentifierSecp256k1Keys(identifier: IIdentifier): IKey[]; | ||
export declare function getEthereumAddress(verificationMethod: _NormalizedVerificationMethod): string | undefined; | ||
export declare function getChainIdForDidEthr(verificationMethod: _NormalizedVerificationMethod): number; | ||
export declare function mapIdentifierKeysToDoc(identifier: IIdentifier, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver>): Promise<_ExtendedIKey[]>; | ||
@@ -8,0 +10,0 @@ export declare function resolveDidOrThrow(didUrl: string, context: IAgentContext<IResolver>): Promise<DIDDocument>; |
@@ -49,3 +49,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractPublicKeyHex = exports.dereferenceDidKeys = exports.resolveDidOrThrow = exports.mapIdentifierKeysToDoc = exports.compressIdentifierSecp256k1Keys = exports.convertIdentifierEncryptionKeys = void 0; | ||
exports.extractPublicKeyHex = exports.dereferenceDidKeys = exports.resolveDidOrThrow = exports.mapIdentifierKeysToDoc = exports.getChainIdForDidEthr = exports.getEthereumAddress = exports.compressIdentifierSecp256k1Keys = exports.convertIdentifierEncryptionKeys = void 0; | ||
const ed25519_1 = require("@stablelib/ed25519"); | ||
@@ -110,2 +110,27 @@ const signing_key_1 = require("@ethersproject/signing-key"); | ||
} | ||
function getEthereumAddress(verificationMethod) { | ||
var _a, _b, _c, _d, _e; | ||
let vmEthAddr = (_a = verificationMethod.ethereumAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
if (!vmEthAddr) { | ||
if ((_b = verificationMethod.blockchainAccountId) === null || _b === void 0 ? void 0 : _b.includes('@eip155')) { | ||
vmEthAddr = (_c = verificationMethod.blockchainAccountId) === null || _c === void 0 ? void 0 : _c.split('@eip155')[0].toLowerCase(); | ||
} | ||
else if ((_d = verificationMethod.blockchainAccountId) === null || _d === void 0 ? void 0 : _d.startsWith('eip155')) { | ||
vmEthAddr = (_e = verificationMethod.blockchainAccountId.split(':')[2]) === null || _e === void 0 ? void 0 : _e.toLowerCase(); | ||
} | ||
} | ||
return vmEthAddr; | ||
} | ||
exports.getEthereumAddress = getEthereumAddress; | ||
function getChainIdForDidEthr(verificationMethod) { | ||
var _a, _b; | ||
if ((_a = verificationMethod.blockchainAccountId) === null || _a === void 0 ? void 0 : _a.includes('@eip155')) { | ||
return parseInt(verificationMethod.blockchainAccountId.split(':').slice(-1)[0]); | ||
} | ||
else if ((_b = verificationMethod.blockchainAccountId) === null || _b === void 0 ? void 0 : _b.startsWith('eip155')) { | ||
return parseInt(verificationMethod.blockchainAccountId.split(':')[1]); | ||
} | ||
throw new Error('blockchainAccountId does not include eip155 designation'); | ||
} | ||
exports.getChainIdForDidEthr = getChainIdForDidEthr; | ||
function mapIdentifierKeysToDoc(identifier, section = 'keyAgreement', context) { | ||
@@ -112,0 +137,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@veramo/utils", | ||
"description": "Helper methods for Veramo plugins", | ||
"version": "3.1.2-next.59+ef08c527", | ||
"version": "3.1.2-next.65+2092d401", | ||
"main": "build/index.js", | ||
@@ -13,3 +13,3 @@ "types": "build/index.d.ts", | ||
"@stablelib/ed25519": "^1.0.2", | ||
"@veramo/core": "^3.1.2-next.59+ef08c527", | ||
"@veramo/core": "^3.1.2-next.65+2092d401", | ||
"blakejs": "^1.1.1", | ||
@@ -27,3 +27,3 @@ "cross-fetch": "^3.1.4", | ||
"@types/uuid": "8.3.4", | ||
"typescript": "4.6.2" | ||
"typescript": "4.6.3" | ||
}, | ||
@@ -43,3 +43,3 @@ "files": [ | ||
"keywords": [], | ||
"gitHead": "ef08c527198df36283b2a2987ea6c8080fd2867d" | ||
"gitHead": "2092d401fc765572c5f6f80c248b1a43f3a7527a" | ||
} |
@@ -66,2 +66,23 @@ import { convertPublicKeyToX25519, convertSecretKeyToX25519 } from '@stablelib/ed25519' | ||
export function getEthereumAddress(verificationMethod: _NormalizedVerificationMethod) { | ||
let vmEthAddr = verificationMethod.ethereumAddress?.toLowerCase() | ||
if (!vmEthAddr) { | ||
if (verificationMethod.blockchainAccountId?.includes('@eip155')) { | ||
vmEthAddr = verificationMethod.blockchainAccountId?.split('@eip155')[0].toLowerCase() | ||
} else if (verificationMethod.blockchainAccountId?.startsWith('eip155')) { | ||
vmEthAddr = verificationMethod.blockchainAccountId.split(':')[2]?.toLowerCase() | ||
} | ||
} | ||
return vmEthAddr | ||
} | ||
export function getChainIdForDidEthr(verificationMethod: _NormalizedVerificationMethod): number { | ||
if (verificationMethod.blockchainAccountId?.includes('@eip155')) { | ||
return parseInt(verificationMethod.blockchainAccountId!.split(':').slice(-1)[0]) | ||
} else if (verificationMethod.blockchainAccountId?.startsWith('eip155')) { | ||
return parseInt(verificationMethod.blockchainAccountId!.split(':')[1]) | ||
} | ||
throw new Error('blockchainAccountId does not include eip155 designation') | ||
} | ||
export async function mapIdentifierKeysToDoc( | ||
@@ -68,0 +89,0 @@ identifier: IIdentifier, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
88915
36
1378