@sphereon/ssi-sdk-ext.did-utils
Advanced tools
Comparing version 0.13.1-next.6 to 0.13.1-next.7
@@ -6,3 +6,3 @@ import { DIDDocument, DIDDocumentSection, DIDResolutionResult, IAgentContext, IDIDManager, IIdentifier, IKey, IResolver } from '@veramo/core'; | ||
import { JwkKeyUse } from '@sphereon/ssi-sdk-ext.key-utils'; | ||
export declare const getFirstKeyWithRelation: (identifier: IIdentifier, context: IAgentContext<IResolver>, vmRelationship?: DIDDocumentSection, errorOnNotFound?: boolean) => Promise<_ExtendedIKey | undefined>; | ||
export declare const getFirstKeyWithRelation: (identifier: IIdentifier, context: IAgentContext<IResolver & IDIDManager>, vmRelationship?: DIDDocumentSection, errorOnNotFound?: boolean) => Promise<_ExtendedIKey | undefined>; | ||
/** | ||
@@ -45,3 +45,3 @@ * Dereferences keys from DID document and normalizes them for easy comparison. | ||
*/ | ||
export declare function mapIdentifierKeysToDocWithJwkSupport(identifier: IIdentifier, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver>, didDocument?: DIDDocument): Promise<_ExtendedIKey[]>; | ||
export declare function mapIdentifierKeysToDocWithJwkSupport(identifier: IIdentifier, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver & IDIDManager>, didDocument?: DIDDocument): Promise<_ExtendedIKey[]>; | ||
export declare function getAgentDIDMethods(context: IAgentContext<IDIDManager>): Promise<string[]>; | ||
@@ -52,3 +52,3 @@ export declare function getIdentifier(identifierOpts: IIdentifierOpts, context: IAgentContext<IDIDManager>): Promise<IIdentifier>; | ||
export declare function toDIDs(identifiers?: (string | IIdentifier | Partial<IIdentifier>)[]): string[]; | ||
export declare function getKey(identifier: IIdentifier, verificationMethodSection: DIDDocumentSection | undefined, context: IAgentContext<IResolver>, keyId?: string): Promise<IKey>; | ||
export declare function getKey(identifier: IIdentifier, verificationMethodSection: DIDDocumentSection | undefined, context: IAgentContext<IResolver & IDIDManager>, keyId?: string): Promise<IKey>; | ||
export declare function determineKid(key: IKey, idOpts: IIdentifierOpts): string; | ||
@@ -55,0 +55,0 @@ export declare function getSupportedDIDMethods(didOpts: IDIDOptions, context: IAgentContext<IDIDManager>): Promise<string[]>; |
@@ -171,6 +171,11 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys[0].type === 'RSA' && didDocument; | ||
const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys.find((key) => key.type === 'RSA') && didDocument; | ||
// We skip mapping in case the identifier is RSA and a did document is supplied. | ||
const keys = rsaDidWeb ? [] : yield (0, utils_1.mapIdentifierKeysToDoc)(identifier, section, context); | ||
const didDoc = didDocument ? didDocument : yield (0, utils_1.resolveDidOrThrow)(identifier.did, context); | ||
const didDoc = didDocument !== null && didDocument !== void 0 ? didDocument : (yield getAgentResolver(context) | ||
.resolve(identifier.did) | ||
.then((result) => result.didDocument)); | ||
if (!didDoc) { | ||
throw Error(`Could not resolve DID ${identifier.did}`); | ||
} | ||
// dereference all key agreement keys from DID document and normalize | ||
@@ -177,0 +182,0 @@ const documentKeys = yield dereferenceDidKeysWithJwkSupport(didDoc, section, context); |
{ | ||
"name": "@sphereon/ssi-sdk-ext.did-utils", | ||
"description": "DID Utils", | ||
"version": "0.13.1-next.6+a678459", | ||
"version": "0.13.1-next.7+0f92566", | ||
"source": "src/index.ts", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
"@sphereon/did-uni-client": "^0.6.0", | ||
"@sphereon/ssi-sdk-ext.key-utils": "0.13.1-next.6+a678459", | ||
"@sphereon/ssi-sdk-ext.key-utils": "0.13.1-next.7+0f92566", | ||
"@veramo/core": "4.2.0", | ||
@@ -38,3 +38,3 @@ "@veramo/utils": "4.2.0", | ||
"keywords": [], | ||
"gitHead": "a678459a74b6b8a39f5b2229e790ca06a346d93e" | ||
"gitHead": "0f92566758eab0fe7edbf3ac8f04c32f6d9fdbb7" | ||
} |
@@ -10,3 +10,2 @@ import { UniResolver } from '@sphereon/did-uni-client' | ||
mapIdentifierKeysToDoc, | ||
resolveDidOrThrow, | ||
} from '@veramo/utils' | ||
@@ -22,3 +21,3 @@ import { DIDResolutionOptions, Resolvable, VerificationMethod } from 'did-resolver' | ||
identifier: IIdentifier, | ||
context: IAgentContext<IResolver>, | ||
context: IAgentContext<IResolver & IDIDManager>, | ||
vmRelationship?: DIDDocumentSection, | ||
@@ -146,9 +145,17 @@ errorOnNotFound?: boolean | ||
section: DIDDocumentSection = 'keyAgreement', | ||
context: IAgentContext<IResolver>, | ||
context: IAgentContext<IResolver & IDIDManager>, | ||
didDocument?: DIDDocument | ||
): Promise<_ExtendedIKey[]> { | ||
const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys[0].type === 'RSA' && didDocument | ||
const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys.find((key) => key.type === 'RSA') && didDocument | ||
// We skip mapping in case the identifier is RSA and a did document is supplied. | ||
const keys = rsaDidWeb ? [] : await mapIdentifierKeysToDoc(identifier, section, context) | ||
const didDoc = didDocument ? didDocument : await resolveDidOrThrow(identifier.did, context) | ||
const didDoc = | ||
didDocument ?? | ||
(await getAgentResolver(context) | ||
.resolve(identifier.did) | ||
.then((result) => result.didDocument)) | ||
if (!didDoc) { | ||
throw Error(`Could not resolve DID ${identifier.did}`) | ||
} | ||
// dereference all key agreement keys from DID document and normalize | ||
@@ -221,3 +228,3 @@ const documentKeys: VerificationMethod[] = await dereferenceDidKeysWithJwkSupport(didDoc, section, context) | ||
verificationMethodSection: DIDDocumentSection = 'authentication', | ||
context: IAgentContext<IResolver>, | ||
context: IAgentContext<IResolver & IDIDManager>, | ||
keyId?: string | ||
@@ -224,0 +231,0 @@ ): Promise<IKey> { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
73229
955