@sphereon/ssi-sdk-ext.did-utils 0.13.1-unstable.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/did-functions.d.ts +15 -7
- package/dist/did-functions.d.ts.map +1 -1
- package/dist/did-functions.js +315 -157
- package/dist/did-functions.js.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
- package/src/did-functions.ts +125 -24
package/dist/did-functions.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { _ExtendedIKey, _ExtendedVerificationMethod, _NormalizedVerificationMeth
|
|
|
3
3
|
import { DIDResolutionOptions, Resolvable } from 'did-resolver';
|
|
4
4
|
import { IDIDOptions, IIdentifierOpts } from './types';
|
|
5
5
|
import { JwkKeyUse } from '@sphereon/ssi-sdk-ext.key-utils';
|
|
6
|
-
export declare const getFirstKeyWithRelation: (identifier: IIdentifier, context: IAgentContext<IResolver>, vmRelationship?: DIDDocumentSection, errorOnNotFound?: boolean) => Promise<_ExtendedIKey | undefined>;
|
|
6
|
+
export declare const getFirstKeyWithRelation: (identifier: IIdentifier, context: IAgentContext<IResolver & IDIDManager>, vmRelationship?: DIDDocumentSection, errorOnNotFound?: boolean) => Promise<_ExtendedIKey | undefined>;
|
|
7
7
|
/**
|
|
8
8
|
* Dereferences keys from DID document and normalizes them for easy comparison.
|
|
9
9
|
*
|
|
@@ -41,22 +41,30 @@ export declare function extractPublicKeyHexWithJwkSupport(pk: _ExtendedVerificat
|
|
|
41
41
|
*
|
|
42
42
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
43
43
|
*/
|
|
44
|
-
export declare function mapIdentifierKeysToDocWithJwkSupport(identifier: IIdentifier, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver>, didDocument?: DIDDocument): Promise<_ExtendedIKey[]>;
|
|
44
|
+
export declare function mapIdentifierKeysToDocWithJwkSupport(identifier: IIdentifier, section: DIDDocumentSection | undefined, context: IAgentContext<IResolver & IDIDManager>, didDocument?: DIDDocument): Promise<_ExtendedIKey[]>;
|
|
45
45
|
export declare function getAgentDIDMethods(context: IAgentContext<IDIDManager>): Promise<string[]>;
|
|
46
46
|
export declare function getIdentifier(identifierOpts: IIdentifierOpts, context: IAgentContext<IDIDManager>): Promise<IIdentifier>;
|
|
47
47
|
export declare function getDID(identifierOpts: IIdentifierOpts): string;
|
|
48
48
|
export declare function toDID(identifier: string | IIdentifier | Partial<IIdentifier>): string;
|
|
49
49
|
export declare function toDIDs(identifiers?: (string | IIdentifier | Partial<IIdentifier>)[]): string[];
|
|
50
|
-
export declare function getKey(identifier: IIdentifier, verificationMethodSection: DIDDocumentSection | undefined, context: IAgentContext<IResolver>, keyId?: string): Promise<IKey>;
|
|
50
|
+
export declare function getKey(identifier: IIdentifier, verificationMethodSection: DIDDocumentSection | undefined, context: IAgentContext<IResolver & IDIDManager>, keyId?: string): Promise<IKey>;
|
|
51
51
|
export declare function determineKid(key: IKey, idOpts: IIdentifierOpts): string;
|
|
52
52
|
export declare function getSupportedDIDMethods(didOpts: IDIDOptions, context: IAgentContext<IDIDManager>): Promise<string[]>;
|
|
53
|
-
export declare function getAgentResolver(context: IAgentContext<IResolver>, opts?: {
|
|
54
|
-
|
|
53
|
+
export declare function getAgentResolver(context: IAgentContext<IResolver & IDIDManager>, opts?: {
|
|
54
|
+
localResolution?: boolean;
|
|
55
|
+
uniresolverResolution?: boolean;
|
|
56
|
+
resolverResolution?: boolean;
|
|
55
57
|
}): Resolvable;
|
|
56
58
|
export declare class AgentDIDResolver implements Resolvable {
|
|
57
59
|
private readonly context;
|
|
58
|
-
private readonly
|
|
59
|
-
|
|
60
|
+
private readonly resolverResolution;
|
|
61
|
+
private readonly uniresolverResolution;
|
|
62
|
+
private readonly localResolution;
|
|
63
|
+
constructor(context: IAgentContext<IResolver & IDIDManager>, opts?: {
|
|
64
|
+
uniresolverResolution?: boolean;
|
|
65
|
+
localResolution?: boolean;
|
|
66
|
+
resolverResolution?: boolean;
|
|
67
|
+
});
|
|
60
68
|
resolve(didUrl: string, options?: DIDResolutionOptions): Promise<DIDResolutionResult>;
|
|
61
69
|
}
|
|
62
70
|
export declare function toDidDocument(identifier?: IIdentifier, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-functions.d.ts","sourceRoot":"","sources":["../src/did-functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7I,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,6BAA6B,
|
|
1
|
+
{"version":3,"file":"did-functions.d.ts","sourceRoot":"","sources":["../src/did-functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7I,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,6BAA6B,EAO9B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAA;AAInF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,EAAuC,SAAS,EAAS,MAAM,iCAAiC,CAAA;AAEvG,eAAO,MAAM,uBAAuB,eACtB,WAAW,WACd,cAAc,SAAS,GAAG,WAAW,CAAC,mBAC9B,kBAAkB,oBACjB,OAAO,KACxB,QAAQ,aAAa,GAAG,SAAS,CAUnC,CAAA;AAGD;;;;;;;;;GASG;AACH,wBAAsB,gCAAgC,CACpD,WAAW,EAAE,WAAW,EACxB,OAAO,gCAAqC,EAC5C,OAAO,EAAE,aAAa,CAAC,SAAS,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AAC,CASrE"}
|
package/dist/did-functions.js
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
39
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
41
|
+
t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.asDidWeb = exports.toDidResolutionResult = exports.toDidDocument = exports.AgentDIDResolver = exports.getAgentResolver = exports.getSupportedDIDMethods = exports.determineKid = exports.getKey = exports.toDIDs = exports.toDID = exports.getDID = exports.getIdentifier = exports.getAgentDIDMethods = exports.mapIdentifierKeysToDocWithJwkSupport = exports.extractPublicKeyHexWithJwkSupport = exports.dereferenceDidKeysWithJwkSupport = exports.getFirstKeyWithRelation = void 0;
|
|
50
|
+
const did_uni_client_1 = require("@sphereon/did-uni-client");
|
|
51
|
+
const utils_1 = require("@veramo/utils");
|
|
3
52
|
// @ts-ignore
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
53
|
+
const elliptic_1 = __importDefault(require("elliptic"));
|
|
54
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
55
|
+
const transactions_1 = require("@ethersproject/transactions");
|
|
56
|
+
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
57
|
+
const getFirstKeyWithRelation = (identifier, context, vmRelationship, errorOnNotFound) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const section = vmRelationship !== null && vmRelationship !== void 0 ? vmRelationship : 'verificationMethod'; // search all VMs in case no relationship is provided
|
|
59
|
+
const matchedKeys = yield mapIdentifierKeysToDocWithJwkSupport(identifier, section, context);
|
|
10
60
|
if (Array.isArray(matchedKeys) && matchedKeys.length > 0) {
|
|
11
61
|
return matchedKeys[0];
|
|
12
62
|
}
|
|
@@ -14,7 +64,8 @@ export const getFirstKeyWithRelation = async (identifier, context, vmRelationshi
|
|
|
14
64
|
throw new Error(`Could not find key with relationship ${section} in DID document for ${identifier.did}`);
|
|
15
65
|
}
|
|
16
66
|
return undefined;
|
|
17
|
-
};
|
|
67
|
+
});
|
|
68
|
+
exports.getFirstKeyWithRelation = getFirstKeyWithRelation;
|
|
18
69
|
//TODO: Move to ssi-sdk/core and create PR upstream
|
|
19
70
|
/**
|
|
20
71
|
* Dereferences keys from DID document and normalizes them for easy comparison.
|
|
@@ -26,39 +77,42 @@ export const getFirstKeyWithRelation = async (identifier, context, vmRelationshi
|
|
|
26
77
|
*
|
|
27
78
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
28
79
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
function dereferenceDidKeysWithJwkSupport(didDocument, section = 'keyAgreement', context) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const convert = section === 'keyAgreement';
|
|
83
|
+
if (section === 'service') {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return (yield Promise.all((didDocument[section] || []).map((key) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
if (typeof key === 'string') {
|
|
88
|
+
try {
|
|
89
|
+
return (yield context.agent.getDIDComponentById({
|
|
90
|
+
didDocument,
|
|
91
|
+
didUrl: key,
|
|
92
|
+
section,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
42
98
|
}
|
|
43
|
-
|
|
44
|
-
return
|
|
99
|
+
else {
|
|
100
|
+
return key;
|
|
45
101
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
newKey.type = 'X25519KeyAgreementKey2019';
|
|
58
|
-
}
|
|
59
|
-
return newKey;
|
|
102
|
+
}))))
|
|
103
|
+
.filter(utils_1.isDefined)
|
|
104
|
+
.map((key) => {
|
|
105
|
+
const hexKey = extractPublicKeyHexWithJwkSupport(key, convert);
|
|
106
|
+
const { publicKeyHex, publicKeyBase58, publicKeyBase64, publicKeyJwk } = key, keyProps = __rest(key, ["publicKeyHex", "publicKeyBase58", "publicKeyBase64", "publicKeyJwk"]);
|
|
107
|
+
const newKey = Object.assign(Object.assign({}, keyProps), { publicKeyHex: hexKey });
|
|
108
|
+
if (convert && 'Ed25519VerificationKey2018' === newKey.type) {
|
|
109
|
+
newKey.type = 'X25519KeyAgreementKey2019';
|
|
110
|
+
}
|
|
111
|
+
return newKey;
|
|
112
|
+
});
|
|
60
113
|
});
|
|
61
114
|
}
|
|
115
|
+
exports.dereferenceDidKeysWithJwkSupport = dereferenceDidKeysWithJwkSupport;
|
|
62
116
|
/**
|
|
63
117
|
* Converts the publicKey of a VerificationMethod to hex encoding (publicKeyHex)
|
|
64
118
|
*
|
|
@@ -68,10 +122,10 @@ export async function dereferenceDidKeysWithJwkSupport(didDocument, section = 'k
|
|
|
68
122
|
*
|
|
69
123
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
70
124
|
*/
|
|
71
|
-
|
|
125
|
+
function extractPublicKeyHexWithJwkSupport(pk, convert = false) {
|
|
72
126
|
if (pk.publicKeyJwk) {
|
|
73
127
|
if (pk.publicKeyJwk.kty === 'EC') {
|
|
74
|
-
const secp256 = new
|
|
128
|
+
const secp256 = new elliptic_1.default.ec(pk.publicKeyJwk.crv === 'secp256k1' ? 'secp256k1' : 'p256');
|
|
75
129
|
// const prefix = pk.publicKeyJwk.crv === 'secp256k1' ? '04' : '03'
|
|
76
130
|
const x = u8a.fromString(pk.publicKeyJwk.x, 'base64url');
|
|
77
131
|
const y = u8a.fromString(pk.publicKeyJwk.y, 'base64url');
|
|
@@ -90,12 +144,13 @@ export function extractPublicKeyHexWithJwkSupport(pk, convert = false) {
|
|
|
90
144
|
return u8a.toString(u8a.fromString(pk.publicKeyJwk.x, 'base64url'), 'base16');
|
|
91
145
|
}
|
|
92
146
|
else if (pk.publicKeyJwk.kty === 'RSA') {
|
|
93
|
-
return hexKeyFromPEMBasedJwk(pk.publicKeyJwk, 'public');
|
|
147
|
+
return (0, ssi_sdk_ext_key_utils_1.hexKeyFromPEMBasedJwk)(pk.publicKeyJwk, 'public');
|
|
94
148
|
}
|
|
95
149
|
}
|
|
96
150
|
// delegate the other types to the original Veramo function
|
|
97
|
-
return extractPublicKeyHex(pk, convert);
|
|
151
|
+
return (0, utils_1.extractPublicKeyHex)(pk, convert);
|
|
98
152
|
}
|
|
153
|
+
exports.extractPublicKeyHexWithJwkSupport = extractPublicKeyHexWithJwkSupport;
|
|
99
154
|
/**
|
|
100
155
|
* Maps the keys of a locally managed {@link @veramo/core#IIdentifier | IIdentifier} to the corresponding
|
|
101
156
|
* {@link did-resolver#VerificationMethod | VerificationMethod} entries from the DID document.
|
|
@@ -112,45 +167,89 @@ export function extractPublicKeyHexWithJwkSupport(pk, convert = false) {
|
|
|
112
167
|
*
|
|
113
168
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
114
169
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const localKeys = identifier.keys.filter(isDefined);
|
|
123
|
-
// finally map the didDocument keys to the identifier keys by comparing `publicKeyHex`
|
|
124
|
-
const extendedKeys = documentKeys
|
|
125
|
-
.map((verificationMethod) => {
|
|
126
|
-
/*if (verificationMethod.type !== 'JsonWebKey2020') {
|
|
127
|
-
return null
|
|
128
|
-
}*/
|
|
129
|
-
const localKey = localKeys.find((localKey) => localKey.publicKeyHex === verificationMethod.publicKeyHex || verificationMethod.publicKeyHex?.startsWith(localKey.publicKeyHex));
|
|
130
|
-
if (localKey) {
|
|
131
|
-
const { meta, ...localProps } = localKey;
|
|
132
|
-
return { ...localProps, meta: { ...meta, verificationMethod } };
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return null;
|
|
170
|
+
function mapIdentifierKeysToDocWithJwkSupport(identifier, section = 'keyAgreement', context, didDocument) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
const didDoc = didDocument !== null && didDocument !== void 0 ? didDocument : (yield getAgentResolver(context)
|
|
173
|
+
.resolve(identifier.did)
|
|
174
|
+
.then((result) => result.didDocument));
|
|
175
|
+
if (!didDoc) {
|
|
176
|
+
throw Error(`Could not resolve DID ${identifier.did}`);
|
|
136
177
|
}
|
|
137
|
-
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
178
|
+
// const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys.find((key) => key.type === 'RSA') && didDocument
|
|
179
|
+
// We skip mapping in case the identifier is RSA and a did document is supplied.
|
|
180
|
+
const keys = didDoc ? [] : yield (0, utils_1.mapIdentifierKeysToDoc)(identifier, section, context);
|
|
181
|
+
// dereference all key agreement keys from DID document and normalize
|
|
182
|
+
const documentKeys = yield dereferenceDidKeysWithJwkSupport(didDoc, section, context);
|
|
183
|
+
const localKeys = section === 'keyAgreement' ? (0, utils_1.convertIdentifierEncryptionKeys)(identifier) : (0, utils_1.compressIdentifierSecp256k1Keys)(identifier);
|
|
184
|
+
// finally map the didDocument keys to the identifier keys by comparing `publicKeyHex`
|
|
185
|
+
const extendedKeys = documentKeys
|
|
186
|
+
.map((verificationMethod) => {
|
|
187
|
+
/*if (verificationMethod.type !== 'JsonWebKey2020') {
|
|
188
|
+
return null
|
|
189
|
+
}*/
|
|
190
|
+
const localKey = localKeys.find((localKey) => {
|
|
191
|
+
var _a;
|
|
192
|
+
return localKey.publicKeyHex === verificationMethod.publicKeyHex ||
|
|
193
|
+
((_a = verificationMethod.publicKeyHex) === null || _a === void 0 ? void 0 : _a.startsWith(localKey.publicKeyHex)) ||
|
|
194
|
+
compareBlockchainAccountId(localKey, verificationMethod);
|
|
195
|
+
});
|
|
196
|
+
if (localKey) {
|
|
197
|
+
const { meta } = localKey, localProps = __rest(localKey, ["meta"]);
|
|
198
|
+
return Object.assign(Object.assign({}, localProps), { meta: Object.assign(Object.assign({}, meta), { verificationMethod }) });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
.filter(utils_1.isDefined);
|
|
205
|
+
return keys.concat(extendedKeys);
|
|
206
|
+
});
|
|
143
207
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
208
|
+
exports.mapIdentifierKeysToDocWithJwkSupport = mapIdentifierKeysToDocWithJwkSupport;
|
|
209
|
+
/**
|
|
210
|
+
* Compares the `blockchainAccountId` of a `EcdsaSecp256k1RecoveryMethod2020` verification method with the address
|
|
211
|
+
* computed from a locally managed key.
|
|
212
|
+
*
|
|
213
|
+
* @returns true if the local key address corresponds to the `blockchainAccountId`
|
|
214
|
+
*
|
|
215
|
+
* @param localKey - The locally managed key
|
|
216
|
+
* @param verificationMethod - a {@link did-resolver#VerificationMethod | VerificationMethod} with a
|
|
217
|
+
* `blockchainAccountId`
|
|
218
|
+
*
|
|
219
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
220
|
+
*/
|
|
221
|
+
function compareBlockchainAccountId(localKey, verificationMethod) {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
if ((verificationMethod.type !== 'EcdsaSecp256k1RecoveryMethod2020' && verificationMethod.type !== 'EcdsaSecp256k1VerificationKey2019') ||
|
|
224
|
+
localKey.type !== 'Secp256k1') {
|
|
225
|
+
return false;
|
|
147
226
|
}
|
|
148
|
-
|
|
149
|
-
|
|
227
|
+
let vmEthAddr = (0, utils_1.getEthereumAddress)(verificationMethod);
|
|
228
|
+
if ((_a = localKey.meta) === null || _a === void 0 ? void 0 : _a.account) {
|
|
229
|
+
return vmEthAddr === ((_b = localKey.meta) === null || _b === void 0 ? void 0 : _b.account.toLowerCase());
|
|
150
230
|
}
|
|
151
|
-
|
|
231
|
+
const computedAddr = (0, transactions_1.computeAddress)('0x' + localKey.publicKeyHex).toLowerCase();
|
|
232
|
+
return computedAddr === vmEthAddr;
|
|
233
|
+
}
|
|
234
|
+
function getAgentDIDMethods(context) {
|
|
235
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
return (yield context.agent.didManagerGetProviders()).map((provider) => provider.toLowerCase().replace('did:', ''));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
exports.getAgentDIDMethods = getAgentDIDMethods;
|
|
240
|
+
function getIdentifier(identifierOpts, context) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
if (typeof identifierOpts.identifier === 'string') {
|
|
243
|
+
return context.agent.didManagerGet({ did: identifierOpts.identifier });
|
|
244
|
+
}
|
|
245
|
+
else if (typeof identifierOpts.identifier === 'object') {
|
|
246
|
+
return identifierOpts.identifier;
|
|
247
|
+
}
|
|
248
|
+
throw Error(`Cannot get agent identifier value from options`);
|
|
249
|
+
});
|
|
152
250
|
}
|
|
153
|
-
|
|
251
|
+
exports.getIdentifier = getIdentifier;
|
|
252
|
+
function getDID(identifierOpts) {
|
|
154
253
|
if (typeof identifierOpts.identifier === 'string') {
|
|
155
254
|
return identifierOpts.identifier;
|
|
156
255
|
}
|
|
@@ -159,7 +258,8 @@ export function getDID(identifierOpts) {
|
|
|
159
258
|
}
|
|
160
259
|
throw Error(`Cannot get DID from identifier value`);
|
|
161
260
|
}
|
|
162
|
-
|
|
261
|
+
exports.getDID = getDID;
|
|
262
|
+
function toDID(identifier) {
|
|
163
263
|
if (typeof identifier === 'string') {
|
|
164
264
|
return identifier;
|
|
165
265
|
}
|
|
@@ -168,121 +268,179 @@ export function toDID(identifier) {
|
|
|
168
268
|
}
|
|
169
269
|
throw Error(`No DID value present in identifier`);
|
|
170
270
|
}
|
|
171
|
-
|
|
271
|
+
exports.toDID = toDID;
|
|
272
|
+
function toDIDs(identifiers) {
|
|
172
273
|
if (!identifiers) {
|
|
173
274
|
return [];
|
|
174
275
|
}
|
|
175
276
|
return identifiers.map(toDID);
|
|
176
277
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
278
|
+
exports.toDIDs = toDIDs;
|
|
279
|
+
function getKey(identifier, verificationMethodSection = 'authentication', context, keyId) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
+
const keys = yield mapIdentifierKeysToDocWithJwkSupport(identifier, verificationMethodSection, context);
|
|
282
|
+
if (!keys || keys.length === 0) {
|
|
283
|
+
throw new Error(`No keys found for verificationMethodSection: ${verificationMethodSection} and did ${identifier.did}`);
|
|
284
|
+
}
|
|
285
|
+
const identifierKey = keyId ? keys.find((key) => key.kid === keyId || key.meta.verificationMethod.id === keyId) : keys[0];
|
|
286
|
+
if (!identifierKey) {
|
|
287
|
+
throw new Error(`No matching verificationMethodSection key found for keyId: ${keyId}`);
|
|
288
|
+
}
|
|
289
|
+
return identifierKey;
|
|
290
|
+
});
|
|
187
291
|
}
|
|
188
|
-
|
|
189
|
-
|
|
292
|
+
exports.getKey = getKey;
|
|
293
|
+
function determineKid(key, idOpts) {
|
|
294
|
+
var _a, _b, _c;
|
|
295
|
+
return (_c = (_b = (_a = key.meta) === null || _a === void 0 ? void 0 : _a.verificationMethod.id) !== null && _b !== void 0 ? _b : idOpts.kid) !== null && _c !== void 0 ? _c : key.kid;
|
|
190
296
|
}
|
|
191
|
-
|
|
192
|
-
|
|
297
|
+
exports.determineKid = determineKid;
|
|
298
|
+
function getSupportedDIDMethods(didOpts, context) {
|
|
299
|
+
var _a;
|
|
300
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
return (_a = didOpts.supportedDIDMethods) !== null && _a !== void 0 ? _a : (yield getAgentDIDMethods(context));
|
|
302
|
+
});
|
|
193
303
|
}
|
|
194
|
-
|
|
195
|
-
|
|
304
|
+
exports.getSupportedDIDMethods = getSupportedDIDMethods;
|
|
305
|
+
function getAgentResolver(context, opts) {
|
|
306
|
+
return new AgentDIDResolver(context, opts);
|
|
196
307
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
constructor(context, uniresolverFallback) {
|
|
308
|
+
exports.getAgentResolver = getAgentResolver;
|
|
309
|
+
class AgentDIDResolver {
|
|
310
|
+
constructor(context, opts) {
|
|
201
311
|
this.context = context;
|
|
202
|
-
this.
|
|
312
|
+
this.resolverResolution = (opts === null || opts === void 0 ? void 0 : opts.resolverResolution) !== false;
|
|
313
|
+
this.uniresolverResolution = (opts === null || opts === void 0 ? void 0 : opts.uniresolverResolution) !== false;
|
|
314
|
+
this.localResolution = (opts === null || opts === void 0 ? void 0 : opts.localResolution) !== false;
|
|
203
315
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (this.
|
|
210
|
-
|
|
316
|
+
resolve(didUrl, options) {
|
|
317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
let resolutionResult;
|
|
319
|
+
let origResolutionResult;
|
|
320
|
+
let err;
|
|
321
|
+
if (this.resolverResolution) {
|
|
322
|
+
try {
|
|
323
|
+
resolutionResult = yield this.context.agent.resolveDid({ didUrl, options });
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
err = error;
|
|
327
|
+
}
|
|
211
328
|
}
|
|
212
|
-
|
|
213
|
-
|
|
329
|
+
if (resolutionResult) {
|
|
330
|
+
origResolutionResult = resolutionResult;
|
|
331
|
+
if (resolutionResult.didDocument === null) {
|
|
332
|
+
resolutionResult = undefined;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (!resolutionResult && this.localResolution) {
|
|
336
|
+
try {
|
|
337
|
+
const did = didUrl.split('#')[0];
|
|
338
|
+
const iIdentifier = yield this.context.agent.didManagerGet({ did });
|
|
339
|
+
resolutionResult = toDidResolutionResult(iIdentifier, { did });
|
|
340
|
+
if (resolutionResult.didDocument) {
|
|
341
|
+
err = undefined;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (!err) {
|
|
346
|
+
err = error;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (resolutionResult) {
|
|
351
|
+
if (!origResolutionResult) {
|
|
352
|
+
origResolutionResult = resolutionResult;
|
|
353
|
+
}
|
|
354
|
+
if (!resolutionResult.didDocument) {
|
|
355
|
+
resolutionResult = undefined;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (!resolutionResult && this.uniresolverResolution) {
|
|
359
|
+
resolutionResult = yield new did_uni_client_1.UniResolver().resolve(didUrl, options);
|
|
360
|
+
if (!origResolutionResult) {
|
|
361
|
+
origResolutionResult = resolutionResult;
|
|
362
|
+
}
|
|
363
|
+
if (resolutionResult.didDocument) {
|
|
364
|
+
err = undefined;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (err) {
|
|
368
|
+
// throw original error
|
|
369
|
+
throw err;
|
|
370
|
+
}
|
|
371
|
+
if (!resolutionResult && !origResolutionResult) {
|
|
372
|
+
throw `Could not resolve ${didUrl}. Resolutions tried: online: ${this.resolverResolution}, local: ${this.localResolution}, uni resolver: ${this.uniresolverResolution}`;
|
|
373
|
+
}
|
|
374
|
+
return resolutionResult !== null && resolutionResult !== void 0 ? resolutionResult : origResolutionResult;
|
|
375
|
+
});
|
|
214
376
|
}
|
|
215
377
|
}
|
|
216
|
-
|
|
378
|
+
exports.AgentDIDResolver = AgentDIDResolver;
|
|
379
|
+
function toDidDocument(identifier, opts) {
|
|
380
|
+
var _a, _b, _c;
|
|
217
381
|
let didDocument = undefined;
|
|
218
382
|
if (identifier) {
|
|
219
|
-
const did = identifier.did
|
|
220
|
-
didDocument = {
|
|
221
|
-
'@context': 'https://www.w3.org/ns/did/v1',
|
|
222
|
-
id: did,
|
|
223
|
-
verificationMethod: identifier.keys.map((key) => {
|
|
383
|
+
const did = (_a = identifier.did) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.did;
|
|
384
|
+
didDocument = Object.assign(Object.assign(Object.assign({ '@context': 'https://www.w3.org/ns/did/v1', id: did, verificationMethod: identifier.keys.map((key) => {
|
|
224
385
|
const vm = {
|
|
225
386
|
controller: did,
|
|
226
387
|
id: key.kid.startsWith(did) && key.kid.includes('#') ? key.kid : `${did}#${key.kid}`,
|
|
227
|
-
publicKeyJwk: toJwk(key.publicKeyHex, key.type, {
|
|
228
|
-
use: ENC_KEY_ALGS.includes(key.type) ? JwkKeyUse.Encryption : JwkKeyUse.Signature,
|
|
388
|
+
publicKeyJwk: (0, ssi_sdk_ext_key_utils_1.toJwk)(key.publicKeyHex, key.type, {
|
|
389
|
+
use: ssi_sdk_ext_key_utils_1.ENC_KEY_ALGS.includes(key.type) ? ssi_sdk_ext_key_utils_1.JwkKeyUse.Encryption : ssi_sdk_ext_key_utils_1.JwkKeyUse.Signature,
|
|
229
390
|
key,
|
|
230
391
|
}),
|
|
231
392
|
type: 'JsonWebKey2020',
|
|
232
393
|
};
|
|
233
394
|
return vm;
|
|
395
|
+
}) }, ((!(opts === null || opts === void 0 ? void 0 : opts.use) || ((_b = opts === null || opts === void 0 ? void 0 : opts.use) === null || _b === void 0 ? void 0 : _b.includes(ssi_sdk_ext_key_utils_1.JwkKeyUse.Signature))) &&
|
|
396
|
+
identifier.keys && {
|
|
397
|
+
assertionMethod: identifier.keys.map((key) => {
|
|
398
|
+
return `${did}#${key.kid}`;
|
|
234
399
|
}),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
assertionMethod: identifier.keys.map((key) => {
|
|
238
|
-
return `${did}#${key.kid}`;
|
|
239
|
-
}),
|
|
240
|
-
authentication: identifier.keys.map((key) => {
|
|
241
|
-
return `${did}#${key.kid}`;
|
|
242
|
-
}),
|
|
400
|
+
authentication: identifier.keys.map((key) => {
|
|
401
|
+
return `${did}#${key.kid}`;
|
|
243
402
|
}),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}),
|
|
403
|
+
})), ((!(opts === null || opts === void 0 ? void 0 : opts.use) || ((_c = opts === null || opts === void 0 ? void 0 : opts.use) === null || _c === void 0 ? void 0 : _c.includes(ssi_sdk_ext_key_utils_1.JwkKeyUse.Encryption))) &&
|
|
404
|
+
identifier.keys &&
|
|
405
|
+
identifier.keys.filter((key) => key.type === 'X25519').length > 0 && {
|
|
406
|
+
keyAgreement: identifier.keys
|
|
407
|
+
.filter((key) => key.type === 'X25519')
|
|
408
|
+
.map((key) => {
|
|
409
|
+
if (key.kid.startsWith(did) && key.kid.includes('#')) {
|
|
410
|
+
return key.kid;
|
|
411
|
+
}
|
|
412
|
+
return `${did}#${key.kid}`;
|
|
255
413
|
}),
|
|
256
|
-
|
|
257
|
-
};
|
|
414
|
+
})), (identifier.services && identifier.services.length > 0 && { service: identifier.services }));
|
|
258
415
|
}
|
|
259
416
|
return didDocument;
|
|
260
417
|
}
|
|
261
|
-
|
|
262
|
-
|
|
418
|
+
exports.toDidDocument = toDidDocument;
|
|
419
|
+
function toDidResolutionResult(identifier, opts) {
|
|
420
|
+
var _a;
|
|
421
|
+
const didDocument = (_a = toDidDocument(identifier, opts)) !== null && _a !== void 0 ? _a : null; // null is used in case of errors and required by the did resolution spec
|
|
263
422
|
const resolutionResult = {
|
|
264
423
|
'@context': 'https://w3id.org/did-resolution/v1',
|
|
265
424
|
didDocument,
|
|
266
|
-
didResolutionMetadata: {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
!opts?.supportedMethods.includes(identifier.provider.replace('did:', '')) && { error: 'unsupportedDidMethod' }),
|
|
271
|
-
},
|
|
272
|
-
didDocumentMetadata: {
|
|
273
|
-
...(identifier?.alias && { equivalentId: identifier?.alias }),
|
|
274
|
-
},
|
|
425
|
+
didResolutionMetadata: Object.assign(Object.assign({}, (!didDocument && { error: 'notFound' })), (Array.isArray(opts === null || opts === void 0 ? void 0 : opts.supportedMethods) &&
|
|
426
|
+
identifier &&
|
|
427
|
+
!(opts === null || opts === void 0 ? void 0 : opts.supportedMethods.includes(identifier.provider.replace('did:', ''))) && { error: 'unsupportedDidMethod' })),
|
|
428
|
+
didDocumentMetadata: Object.assign({}, ((identifier === null || identifier === void 0 ? void 0 : identifier.alias) && { equivalentId: identifier === null || identifier === void 0 ? void 0 : identifier.alias })),
|
|
275
429
|
};
|
|
276
430
|
return resolutionResult;
|
|
277
431
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
432
|
+
exports.toDidResolutionResult = toDidResolutionResult;
|
|
433
|
+
function asDidWeb(hostnameOrDID) {
|
|
434
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
435
|
+
let did = hostnameOrDID;
|
|
436
|
+
if (!did) {
|
|
437
|
+
throw Error('Domain or DID expected, but received nothing.');
|
|
438
|
+
}
|
|
439
|
+
if (did.startsWith('did:web:')) {
|
|
440
|
+
return did;
|
|
441
|
+
}
|
|
442
|
+
return `did:web:${did.replace(/https?:\/\/([^/?#]+).*/i, '$1').toLowerCase()}`;
|
|
443
|
+
});
|
|
287
444
|
}
|
|
445
|
+
exports.asDidWeb = asDidWeb;
|
|
288
446
|
//# sourceMappingURL=did-functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-functions.js","sourceRoot":"","sources":["../src/did-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAIL,mBAAmB,EACnB,SAAS,EACT,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB,aAAa;AACb,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAElC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAEvG,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,UAAuB,EACvB,OAAiC,EACjC,cAAmC,EACnC,eAAyB,EACW,EAAE;IACtC,MAAM,OAAO,GAAG,cAAc,IAAI,oBAAoB,CAAA,CAAC,qDAAqD;IAC5G,MAAM,WAAW,GAAG,MAAM,oCAAoC,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAC5F,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QACxD,OAAO,WAAW,CAAC,CAAC,CAAC,CAAA;KACtB;IACD,IAAI,eAAe,KAAK,IAAI,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,wBAAwB,UAAU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AU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,KAAI,EAAE,YAAY,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,EAAE,CAAC,CAC9D;KACF,CAAA;IACD,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAvBD,sDAuBC;AAED,SAAsB,QAAQ,CAAC,aAAqB;;QAClD,IAAI,GAAG,GAAG,aAAa,CAAA;QACvB,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAA;SAC7D;QACD,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAC9B,OAAO,GAAG,CAAA;SACX;QACD,OAAO,WAAW,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAA;IAChF,CAAC;CAAA;AATD,4BASC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./did-functions"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,0CAAuB"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAwBa,QAAA,UAAU,GAAG,MAAM,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.did-utils",
|
|
3
3
|
"description": "DID Utils",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
8
|
"scripts": {
|
|
10
9
|
"build": "tsc --build",
|
|
11
10
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
12
11
|
},
|
|
13
12
|
"dependencies": {
|
|
13
|
+
"@ethersproject/transactions": "^5.7.0",
|
|
14
14
|
"@sphereon/did-uni-client": "^0.6.0",
|
|
15
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.
|
|
16
|
-
"@veramo/core": "
|
|
17
|
-
"@veramo/utils": "
|
|
18
|
-
"did-jwt": "
|
|
15
|
+
"@sphereon/ssi-sdk-ext.key-utils": "^0.14.0",
|
|
16
|
+
"@veramo/core": "4.2.0",
|
|
17
|
+
"@veramo/utils": "4.2.0",
|
|
18
|
+
"did-jwt": "6.11.6",
|
|
19
19
|
"did-resolver": "^4.1.0",
|
|
20
20
|
"elliptic": "^6.5.4",
|
|
21
21
|
"uint8arrays": "^3.1.1"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"author": "Sphereon <dev@sphereon.com>",
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"keywords": [],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "ac08f428579800ce176cab76741100b532a1471e"
|
|
39
39
|
}
|
package/src/did-functions.ts
CHANGED
|
@@ -4,21 +4,24 @@ import {
|
|
|
4
4
|
_ExtendedIKey,
|
|
5
5
|
_ExtendedVerificationMethod,
|
|
6
6
|
_NormalizedVerificationMethod,
|
|
7
|
+
compressIdentifierSecp256k1Keys,
|
|
8
|
+
convertIdentifierEncryptionKeys,
|
|
7
9
|
extractPublicKeyHex,
|
|
10
|
+
getEthereumAddress,
|
|
8
11
|
isDefined,
|
|
9
12
|
mapIdentifierKeysToDoc,
|
|
10
|
-
resolveDidOrThrow,
|
|
11
13
|
} from '@veramo/utils'
|
|
12
14
|
import { DIDResolutionOptions, Resolvable, VerificationMethod } from 'did-resolver'
|
|
13
15
|
// @ts-ignore
|
|
14
16
|
import elliptic from 'elliptic'
|
|
15
17
|
import * as u8a from 'uint8arrays'
|
|
16
18
|
import { IDIDOptions, IIdentifierOpts } from './types'
|
|
19
|
+
import { computeAddress } from '@ethersproject/transactions'
|
|
17
20
|
import { ENC_KEY_ALGS, hexKeyFromPEMBasedJwk, JwkKeyUse, toJwk } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
18
21
|
|
|
19
22
|
export const getFirstKeyWithRelation = async (
|
|
20
23
|
identifier: IIdentifier,
|
|
21
|
-
context: IAgentContext<IResolver>,
|
|
24
|
+
context: IAgentContext<IResolver & IDIDManager>,
|
|
22
25
|
vmRelationship?: DIDDocumentSection,
|
|
23
26
|
errorOnNotFound?: boolean
|
|
24
27
|
): Promise<_ExtendedIKey | undefined> => {
|
|
@@ -141,25 +144,39 @@ export function extractPublicKeyHexWithJwkSupport(pk: _ExtendedVerificationMetho
|
|
|
141
144
|
export async function mapIdentifierKeysToDocWithJwkSupport(
|
|
142
145
|
identifier: IIdentifier,
|
|
143
146
|
section: DIDDocumentSection = 'keyAgreement',
|
|
144
|
-
context: IAgentContext<IResolver>,
|
|
147
|
+
context: IAgentContext<IResolver & IDIDManager>,
|
|
145
148
|
didDocument?: DIDDocument
|
|
146
149
|
): Promise<_ExtendedIKey[]> {
|
|
147
|
-
const
|
|
150
|
+
const didDoc =
|
|
151
|
+
didDocument ??
|
|
152
|
+
(await getAgentResolver(context)
|
|
153
|
+
.resolve(identifier.did)
|
|
154
|
+
.then((result) => result.didDocument))
|
|
155
|
+
if (!didDoc) {
|
|
156
|
+
throw Error(`Could not resolve DID ${identifier.did}`)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// const rsaDidWeb = identifier.keys && identifier.keys.length > 0 && identifier.keys.find((key) => key.type === 'RSA') && didDocument
|
|
160
|
+
|
|
148
161
|
// We skip mapping in case the identifier is RSA and a did document is supplied.
|
|
149
|
-
const keys =
|
|
150
|
-
|
|
162
|
+
const keys = didDoc ? [] : await mapIdentifierKeysToDoc(identifier, section, context)
|
|
163
|
+
|
|
151
164
|
// dereference all key agreement keys from DID document and normalize
|
|
152
165
|
const documentKeys: VerificationMethod[] = await dereferenceDidKeysWithJwkSupport(didDoc, section, context)
|
|
153
166
|
|
|
154
|
-
const localKeys = identifier
|
|
167
|
+
const localKeys = section === 'keyAgreement' ? convertIdentifierEncryptionKeys(identifier) : compressIdentifierSecp256k1Keys(identifier)
|
|
168
|
+
|
|
155
169
|
// finally map the didDocument keys to the identifier keys by comparing `publicKeyHex`
|
|
156
170
|
const extendedKeys: _ExtendedIKey[] = documentKeys
|
|
157
171
|
.map((verificationMethod) => {
|
|
158
172
|
/*if (verificationMethod.type !== 'JsonWebKey2020') {
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
return null
|
|
174
|
+
}*/
|
|
161
175
|
const localKey = localKeys.find(
|
|
162
|
-
(localKey) =>
|
|
176
|
+
(localKey) =>
|
|
177
|
+
localKey.publicKeyHex === verificationMethod.publicKeyHex ||
|
|
178
|
+
verificationMethod.publicKeyHex?.startsWith(localKey.publicKeyHex) ||
|
|
179
|
+
compareBlockchainAccountId(localKey, verificationMethod)
|
|
163
180
|
)
|
|
164
181
|
if (localKey) {
|
|
165
182
|
const { meta, ...localProps } = localKey
|
|
@@ -173,6 +190,33 @@ export async function mapIdentifierKeysToDocWithJwkSupport(
|
|
|
173
190
|
return keys.concat(extendedKeys)
|
|
174
191
|
}
|
|
175
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Compares the `blockchainAccountId` of a `EcdsaSecp256k1RecoveryMethod2020` verification method with the address
|
|
195
|
+
* computed from a locally managed key.
|
|
196
|
+
*
|
|
197
|
+
* @returns true if the local key address corresponds to the `blockchainAccountId`
|
|
198
|
+
*
|
|
199
|
+
* @param localKey - The locally managed key
|
|
200
|
+
* @param verificationMethod - a {@link did-resolver#VerificationMethod | VerificationMethod} with a
|
|
201
|
+
* `blockchainAccountId`
|
|
202
|
+
*
|
|
203
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
204
|
+
*/
|
|
205
|
+
function compareBlockchainAccountId(localKey: IKey, verificationMethod: VerificationMethod): boolean {
|
|
206
|
+
if (
|
|
207
|
+
(verificationMethod.type !== 'EcdsaSecp256k1RecoveryMethod2020' && verificationMethod.type !== 'EcdsaSecp256k1VerificationKey2019') ||
|
|
208
|
+
localKey.type !== 'Secp256k1'
|
|
209
|
+
) {
|
|
210
|
+
return false
|
|
211
|
+
}
|
|
212
|
+
let vmEthAddr = getEthereumAddress(verificationMethod)
|
|
213
|
+
if (localKey.meta?.account) {
|
|
214
|
+
return vmEthAddr === localKey.meta?.account.toLowerCase()
|
|
215
|
+
}
|
|
216
|
+
const computedAddr = computeAddress('0x' + localKey.publicKeyHex).toLowerCase()
|
|
217
|
+
return computedAddr === vmEthAddr
|
|
218
|
+
}
|
|
219
|
+
|
|
176
220
|
export async function getAgentDIDMethods(context: IAgentContext<IDIDManager>) {
|
|
177
221
|
return (await context.agent.didManagerGetProviders()).map((provider) => provider.toLowerCase().replace('did:', ''))
|
|
178
222
|
}
|
|
@@ -215,7 +259,7 @@ export function toDIDs(identifiers?: (string | IIdentifier | Partial<IIdentifier
|
|
|
215
259
|
export async function getKey(
|
|
216
260
|
identifier: IIdentifier,
|
|
217
261
|
verificationMethodSection: DIDDocumentSection = 'authentication',
|
|
218
|
-
context: IAgentContext<IResolver>,
|
|
262
|
+
context: IAgentContext<IResolver & IDIDManager>,
|
|
219
263
|
keyId?: string
|
|
220
264
|
): Promise<IKey> {
|
|
221
265
|
const keys = await mapIdentifierKeysToDocWithJwkSupport(identifier, verificationMethodSection, context)
|
|
@@ -240,32 +284,89 @@ export async function getSupportedDIDMethods(didOpts: IDIDOptions, context: IAge
|
|
|
240
284
|
}
|
|
241
285
|
|
|
242
286
|
export function getAgentResolver(
|
|
243
|
-
context: IAgentContext<IResolver>,
|
|
287
|
+
context: IAgentContext<IResolver & IDIDManager>,
|
|
244
288
|
opts?: {
|
|
245
|
-
|
|
289
|
+
localResolution?: boolean // Resolve identifiers hosted by the agent
|
|
290
|
+
uniresolverResolution?: boolean // Resolve identifiers using universal resolver
|
|
291
|
+
resolverResolution?: boolean // Use registered drivers
|
|
246
292
|
}
|
|
247
293
|
): Resolvable {
|
|
248
|
-
return new AgentDIDResolver(context, opts
|
|
294
|
+
return new AgentDIDResolver(context, opts)
|
|
249
295
|
}
|
|
250
296
|
|
|
251
297
|
export class AgentDIDResolver implements Resolvable {
|
|
252
|
-
private readonly context: IAgentContext<IResolver>
|
|
253
|
-
private readonly
|
|
298
|
+
private readonly context: IAgentContext<IResolver & IDIDManager>
|
|
299
|
+
private readonly resolverResolution: boolean
|
|
300
|
+
private readonly uniresolverResolution: boolean
|
|
301
|
+
private readonly localResolution: boolean
|
|
254
302
|
|
|
255
|
-
constructor(
|
|
303
|
+
constructor(
|
|
304
|
+
context: IAgentContext<IResolver & IDIDManager>,
|
|
305
|
+
opts?: { uniresolverResolution?: boolean; localResolution?: boolean; resolverResolution?: boolean }
|
|
306
|
+
) {
|
|
256
307
|
this.context = context
|
|
257
|
-
this.
|
|
308
|
+
this.resolverResolution = opts?.resolverResolution !== false
|
|
309
|
+
this.uniresolverResolution = opts?.uniresolverResolution !== false
|
|
310
|
+
this.localResolution = opts?.localResolution !== false
|
|
258
311
|
}
|
|
259
312
|
|
|
260
313
|
async resolve(didUrl: string, options?: DIDResolutionOptions): Promise<DIDResolutionResult> {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
314
|
+
let resolutionResult: DIDResolutionResult | undefined
|
|
315
|
+
let origResolutionResult: DIDResolutionResult | undefined
|
|
316
|
+
let err: any
|
|
317
|
+
if (this.resolverResolution) {
|
|
318
|
+
try {
|
|
319
|
+
resolutionResult = await this.context.agent.resolveDid({ didUrl, options })
|
|
320
|
+
} catch (error: unknown) {
|
|
321
|
+
err = error
|
|
266
322
|
}
|
|
267
|
-
throw error
|
|
268
323
|
}
|
|
324
|
+
if (resolutionResult) {
|
|
325
|
+
origResolutionResult = resolutionResult
|
|
326
|
+
if (resolutionResult.didDocument === null) {
|
|
327
|
+
resolutionResult = undefined
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (!resolutionResult && this.localResolution) {
|
|
331
|
+
try {
|
|
332
|
+
const did = didUrl.split('#')[0]
|
|
333
|
+
const iIdentifier = await this.context.agent.didManagerGet({ did })
|
|
334
|
+
resolutionResult = toDidResolutionResult(iIdentifier, { did })
|
|
335
|
+
if (resolutionResult.didDocument) {
|
|
336
|
+
err = undefined
|
|
337
|
+
}
|
|
338
|
+
} catch (error: unknown) {
|
|
339
|
+
if (!err) {
|
|
340
|
+
err = error
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (resolutionResult) {
|
|
345
|
+
if (!origResolutionResult) {
|
|
346
|
+
origResolutionResult = resolutionResult
|
|
347
|
+
}
|
|
348
|
+
if (!resolutionResult.didDocument) {
|
|
349
|
+
resolutionResult = undefined
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (!resolutionResult && this.uniresolverResolution) {
|
|
353
|
+
resolutionResult = await new UniResolver().resolve(didUrl, options)
|
|
354
|
+
if (!origResolutionResult) {
|
|
355
|
+
origResolutionResult = resolutionResult
|
|
356
|
+
}
|
|
357
|
+
if (resolutionResult.didDocument) {
|
|
358
|
+
err = undefined
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (err) {
|
|
363
|
+
// throw original error
|
|
364
|
+
throw err
|
|
365
|
+
}
|
|
366
|
+
if (!resolutionResult && !origResolutionResult) {
|
|
367
|
+
throw `Could not resolve ${didUrl}. Resolutions tried: online: ${this.resolverResolution}, local: ${this.localResolution}, uni resolver: ${this.uniresolverResolution}`
|
|
368
|
+
}
|
|
369
|
+
return resolutionResult ?? origResolutionResult!
|
|
269
370
|
}
|
|
270
371
|
}
|
|
271
372
|
|