@interop/did-method-peer 0.0.0-stage → 0.1.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/LICENSE.md +20 -0
- package/README.md +350 -2
- package/dist/DidPeerDriver.d.ts +223 -0
- package/dist/DidPeerDriver.d.ts.map +1 -0
- package/dist/DidPeerDriver.js +647 -0
- package/dist/DidPeerDriver.js.map +1 -0
- package/dist/codec.d.ts +8 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +7 -0
- package/dist/codec.js.map +1 -0
- package/dist/constants.d.ts +35 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +40 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/inputDocument.d.ts +71 -0
- package/dist/inputDocument.d.ts.map +1 -0
- package/dist/inputDocument.js +192 -0
- package/dist/inputDocument.js.map +1 -0
- package/dist/numalgo4.d.ts +137 -0
- package/dist/numalgo4.d.ts.map +1 -0
- package/dist/numalgo4.js +309 -0
- package/dist/numalgo4.js.map +1 -0
- package/dist/resources.d.ts +27 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +47 -0
- package/dist/resources.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +95 -4
package/dist/numalgo4.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure did:peer numalgo 4 codec: encode an input document into a long or
|
|
3
|
+
* short form, decode a long form back into its input document (verifying the
|
|
4
|
+
* hash), and contextualize a decoded document into a DID document. Everything
|
|
5
|
+
* here is synchronous, does no I/O and imports no key suite. References stay
|
|
6
|
+
* relative, exactly as the spec and the reference implementations leave them;
|
|
7
|
+
* the driver performs reference resolution on top of this output.
|
|
8
|
+
*/
|
|
9
|
+
import { base58 } from '@scure/base';
|
|
10
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
11
|
+
import { concatBytes } from '@noble/hashes/utils.js';
|
|
12
|
+
import { DIDResolutionError } from '@interop/data-integrity-core';
|
|
13
|
+
import { deepClone } from '@interop/did-io';
|
|
14
|
+
import { MAX_LONG_FORM_LENGTH, MULTIBASE_BASE58BTC_PREFIX, MULTICODEC_JSON_HEADER, MULTIHASH_SHA2_256_HEADER, NUMALGO_4_PREFIX } from './constants.js';
|
|
15
|
+
import { METHOD_PROPERTIES, isPlainObject } from './resources.js';
|
|
16
|
+
export { MAX_LONG_FORM_LENGTH } from './constants.js';
|
|
17
|
+
/**
|
|
18
|
+
* Matches a long form: a fixed `zQm` prefix (every hash is a base58btc
|
|
19
|
+
* sha2-256 multihash), 44 more base58 characters, then the encoded document,
|
|
20
|
+
* at least 6 base58 characters (what `{}` encodes to). Bitcoin alphabet.
|
|
21
|
+
*/
|
|
22
|
+
export const LONG_FORM_PATTERN = /^did:peer:4zQm[1-9A-HJ-NP-Za-km-z]{44}:z[1-9A-HJ-NP-Za-km-z]{6,}$/;
|
|
23
|
+
/**
|
|
24
|
+
* Matches a short form: `did:peer:4` followed by the 46-character hash.
|
|
25
|
+
*/
|
|
26
|
+
export const SHORT_FORM_PATTERN = /^did:peer:4zQm[1-9A-HJ-NP-Za-km-z]{44}$/;
|
|
27
|
+
const PROBLEM_TYPES = {
|
|
28
|
+
invalidDid: {
|
|
29
|
+
type: 'https://www.w3.org/ns/did#INVALID_DID',
|
|
30
|
+
title: 'The DID is invalid.'
|
|
31
|
+
},
|
|
32
|
+
invalidDidUrl: {
|
|
33
|
+
type: 'https://www.w3.org/ns/did#INVALID_DID_URL',
|
|
34
|
+
title: 'The DID URL is invalid.'
|
|
35
|
+
},
|
|
36
|
+
methodNotSupported: {
|
|
37
|
+
type: 'https://www.w3.org/ns/did#METHOD_NOT_SUPPORTED',
|
|
38
|
+
title: 'The DID method is not supported.'
|
|
39
|
+
},
|
|
40
|
+
notFound: {
|
|
41
|
+
type: 'https://www.w3.org/ns/did#NOT_FOUND',
|
|
42
|
+
title: 'The DID document was not found.'
|
|
43
|
+
},
|
|
44
|
+
internalError: {
|
|
45
|
+
type: 'https://www.w3.org/ns/did#INTERNAL_ERROR',
|
|
46
|
+
title: 'An internal error occurred during resolution.'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Builds a `DIDResolutionError` with the spec problem details for its code.
|
|
51
|
+
* The codec and the driver throw this directly (no private error class), so
|
|
52
|
+
* `CachedResolver.resolveDID()` produces the right envelope without a
|
|
53
|
+
* translation layer.
|
|
54
|
+
*
|
|
55
|
+
* @param options {object}
|
|
56
|
+
* @param options.code {IDIDResolutionErrorCode}
|
|
57
|
+
* @param options.message {string}
|
|
58
|
+
* @param [options.cause] {unknown}
|
|
59
|
+
*
|
|
60
|
+
* @returns {DIDResolutionError}
|
|
61
|
+
*/
|
|
62
|
+
export function resolutionError({ code, message, cause }) {
|
|
63
|
+
const problem = PROBLEM_TYPES[code];
|
|
64
|
+
return new DIDResolutionError(message, {
|
|
65
|
+
code,
|
|
66
|
+
problemDetails: problem ? { ...problem, detail: message } : undefined,
|
|
67
|
+
cause
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function invalidDid(message, cause) {
|
|
71
|
+
return resolutionError({ code: 'invalidDid', message, cause });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Produces the encoded document: the input document JSON-stringified without
|
|
75
|
+
* whitespace, UTF-8 encoded, prefixed with the multicodec `json` header and
|
|
76
|
+
* multibase base58btc encoded.
|
|
77
|
+
*/
|
|
78
|
+
function encodeDocument(inputDocument) {
|
|
79
|
+
const bytes = new TextEncoder().encode(JSON.stringify(inputDocument));
|
|
80
|
+
try {
|
|
81
|
+
return (MULTIBASE_BASE58BTC_PREFIX +
|
|
82
|
+
base58.encode(concatBytes(MULTICODEC_JSON_HEADER, bytes)));
|
|
83
|
+
}
|
|
84
|
+
catch (cause) {
|
|
85
|
+
// @scure/base refuses base58 inputs over 2048 bytes (quadratic encoder).
|
|
86
|
+
throw new Error(`Input document is too large to base58-encode (${bytes.length} bytes of JSON).`, { cause });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Hashes an encoded document string (including its leading `z`) with
|
|
91
|
+
* sha2-256 and returns the base58btc multibase of the sha2-256 multihash.
|
|
92
|
+
*/
|
|
93
|
+
function hashEncodedDocument(encodedDocument) {
|
|
94
|
+
const digest = sha256(new TextEncoder().encode(encodedDocument));
|
|
95
|
+
return (MULTIBASE_BASE58BTC_PREFIX +
|
|
96
|
+
base58.encode(concatBytes(MULTIHASH_SHA2_256_HEADER, digest)));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Encodes an input document into its long form. Does not validate; validation
|
|
100
|
+
* is the driver's job at `generate()` time.
|
|
101
|
+
*
|
|
102
|
+
* @param options {object}
|
|
103
|
+
* @param options.inputDocument {InputDocument}
|
|
104
|
+
*
|
|
105
|
+
* @returns {string} The long form `did:peer:4{hash}:{encoded document}`.
|
|
106
|
+
*/
|
|
107
|
+
export function encodeLongForm({ inputDocument }) {
|
|
108
|
+
const encodedDocument = encodeDocument(inputDocument);
|
|
109
|
+
const hash = hashEncodedDocument(encodedDocument);
|
|
110
|
+
return `${NUMALGO_4_PREFIX}${hash}:${encodedDocument}`;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Encodes an input document into its short form. Does not validate.
|
|
114
|
+
*
|
|
115
|
+
* @param options {object}
|
|
116
|
+
* @param options.inputDocument {InputDocument}
|
|
117
|
+
*
|
|
118
|
+
* @returns {string} The short form `did:peer:4{hash}`.
|
|
119
|
+
*/
|
|
120
|
+
export function encodeShortForm({ inputDocument }) {
|
|
121
|
+
return `${NUMALGO_4_PREFIX}${hashEncodedDocument(encodeDocument(inputDocument))}`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether a string starts with the numalgo 4 prefix `did:peer:4`.
|
|
125
|
+
*
|
|
126
|
+
* @param did {string}
|
|
127
|
+
*
|
|
128
|
+
* @returns {boolean}
|
|
129
|
+
*/
|
|
130
|
+
export function isDidPeer4(did) {
|
|
131
|
+
return typeof did === 'string' && did.startsWith(NUMALGO_4_PREFIX);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Whether a string matches the long form grammar. Does not verify the hash.
|
|
135
|
+
*
|
|
136
|
+
* @param did {string}
|
|
137
|
+
*
|
|
138
|
+
* @returns {boolean}
|
|
139
|
+
*/
|
|
140
|
+
export function isLongForm(did) {
|
|
141
|
+
return typeof did === 'string' && LONG_FORM_PATTERN.test(did);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Whether a string matches the short form grammar.
|
|
145
|
+
*
|
|
146
|
+
* @param did {string}
|
|
147
|
+
*
|
|
148
|
+
* @returns {boolean}
|
|
149
|
+
*/
|
|
150
|
+
export function isShortForm(did) {
|
|
151
|
+
return typeof did === 'string' && SHORT_FORM_PATTERN.test(did);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns the short form of a long form by string surgery (regex guarded). It
|
|
155
|
+
* does not verify the hash; callers that need that call `decode` first.
|
|
156
|
+
*
|
|
157
|
+
* @param options {object}
|
|
158
|
+
* @param options.did {string} - A long form.
|
|
159
|
+
*
|
|
160
|
+
* @throws {DIDResolutionError} `invalidDid` if `did` is not a long form.
|
|
161
|
+
*
|
|
162
|
+
* @returns {string} The short form.
|
|
163
|
+
*/
|
|
164
|
+
export function longToShort({ did }) {
|
|
165
|
+
if (!isLongForm(did)) {
|
|
166
|
+
throw invalidDid(`Not a did:peer numalgo 4 long form: "${String(did)}".`);
|
|
167
|
+
}
|
|
168
|
+
return did.slice(0, did.lastIndexOf(':'));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Decodes a long form into its input document, verifying the hash over the
|
|
172
|
+
* encoded document string exactly as present in the DID. Rejects anything that
|
|
173
|
+
* is not a numalgo 4 long form, a long form over `MAX_LONG_FORM_LENGTH`, a
|
|
174
|
+
* hash mismatch, a bad multicodec prefix, invalid UTF-8 or JSON, and a payload
|
|
175
|
+
* that is not a plain object. Returns a freshly parsed document on every call.
|
|
176
|
+
*
|
|
177
|
+
* @param options {object}
|
|
178
|
+
* @param options.did {string} - A long form.
|
|
179
|
+
*
|
|
180
|
+
* @throws {TypeError} If `did` is not a string.
|
|
181
|
+
* @throws {DIDResolutionError} With code `invalidDid` for every other failure.
|
|
182
|
+
*
|
|
183
|
+
* @returns {InputDocument} The input document, relative references intact.
|
|
184
|
+
*/
|
|
185
|
+
export function decode({ did }) {
|
|
186
|
+
if (typeof did !== 'string') {
|
|
187
|
+
throw new TypeError('"did" must be a string.');
|
|
188
|
+
}
|
|
189
|
+
if (!isDidPeer4(did)) {
|
|
190
|
+
throw invalidDid(`Not a did:peer numalgo 4 DID: "${did}".`);
|
|
191
|
+
}
|
|
192
|
+
if (did.length > MAX_LONG_FORM_LENGTH) {
|
|
193
|
+
throw invalidDid(`Long form exceeds the maximum length of ${MAX_LONG_FORM_LENGTH} characters.`);
|
|
194
|
+
}
|
|
195
|
+
if (isShortForm(did)) {
|
|
196
|
+
throw invalidDid(`Cannot decode a short form; the document is not recoverable from "${did}".`);
|
|
197
|
+
}
|
|
198
|
+
if (!isLongForm(did)) {
|
|
199
|
+
throw invalidDid(`Malformed did:peer numalgo 4 long form: "${did}".`);
|
|
200
|
+
}
|
|
201
|
+
const separator = did.lastIndexOf(':');
|
|
202
|
+
const hash = did.slice(NUMALGO_4_PREFIX.length, separator);
|
|
203
|
+
const encodedDocument = did.slice(separator + 1);
|
|
204
|
+
if (hashEncodedDocument(encodedDocument) !== hash) {
|
|
205
|
+
throw invalidDid('Long form hash does not match its encoded document; the DID is corrupt or tampered.');
|
|
206
|
+
}
|
|
207
|
+
let bytes;
|
|
208
|
+
try {
|
|
209
|
+
bytes = base58.decode(encodedDocument.slice(1));
|
|
210
|
+
}
|
|
211
|
+
catch (cause) {
|
|
212
|
+
throw invalidDid('Encoded document is not valid base58btc.', cause);
|
|
213
|
+
}
|
|
214
|
+
if (bytes.length < MULTICODEC_JSON_HEADER.length ||
|
|
215
|
+
bytes[0] !== MULTICODEC_JSON_HEADER[0] ||
|
|
216
|
+
bytes[1] !== MULTICODEC_JSON_HEADER[1]) {
|
|
217
|
+
throw invalidDid('Encoded document does not carry the multicodec json prefix.');
|
|
218
|
+
}
|
|
219
|
+
let parsed;
|
|
220
|
+
try {
|
|
221
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes.subarray(MULTICODEC_JSON_HEADER.length));
|
|
222
|
+
parsed = JSON.parse(text);
|
|
223
|
+
}
|
|
224
|
+
catch (cause) {
|
|
225
|
+
throw invalidDid('Encoded document is not valid UTF-8 JSON.', cause);
|
|
226
|
+
}
|
|
227
|
+
if (!isPlainObject(parsed)) {
|
|
228
|
+
throw invalidDid('Encoded document is not a JSON object.');
|
|
229
|
+
}
|
|
230
|
+
return parsed;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Contextualizes a decoded input document: deep-copies it, sets the root `id`,
|
|
234
|
+
* appends `alsoKnownAs`, and sets `controller` on every verification method
|
|
235
|
+
* (listed or embedded) that has no own `controller` property. Relative
|
|
236
|
+
* references are left relative. Total over hash-valid input: a shape it cannot
|
|
237
|
+
* handle is `invalidDid` rather than a bare `TypeError`.
|
|
238
|
+
*/
|
|
239
|
+
function contextualize({ inputDocument, did, alsoKnownAs }) {
|
|
240
|
+
const doc = deepClone(inputDocument);
|
|
241
|
+
doc.id = did;
|
|
242
|
+
if (!Object.hasOwn(doc, 'alsoKnownAs')) {
|
|
243
|
+
doc.alsoKnownAs = [alsoKnownAs];
|
|
244
|
+
}
|
|
245
|
+
else if (Array.isArray(doc.alsoKnownAs)) {
|
|
246
|
+
doc.alsoKnownAs.push(alsoKnownAs);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
throw invalidDid('"alsoKnownAs" in the encoded document is not an array.');
|
|
250
|
+
}
|
|
251
|
+
for (const property of METHOD_PROPERTIES) {
|
|
252
|
+
if (!Object.hasOwn(doc, property)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const entries = doc[property];
|
|
256
|
+
if (!Array.isArray(entries)) {
|
|
257
|
+
throw invalidDid(`"${property}" in the encoded document is not an array.`);
|
|
258
|
+
}
|
|
259
|
+
for (const entry of entries) {
|
|
260
|
+
if (typeof entry === 'string') {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (!isPlainObject(entry)) {
|
|
264
|
+
throw invalidDid(`"${property}" in the encoded document holds an entry that is neither a reference nor a verification method.`);
|
|
265
|
+
}
|
|
266
|
+
if (!Object.hasOwn(entry, 'controller')) {
|
|
267
|
+
entry.controller = did;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return doc;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Resolves a long form to its DID document: `decode` (regex, length and hash
|
|
275
|
+
* checks) followed by contextualization with the long form as `id` and the
|
|
276
|
+
* short form appended to `alsoKnownAs`. References stay relative.
|
|
277
|
+
*
|
|
278
|
+
* @param options {object}
|
|
279
|
+
* @param options.did {string} - A long form.
|
|
280
|
+
*
|
|
281
|
+
* @returns {IDIDDocument}
|
|
282
|
+
*/
|
|
283
|
+
export function resolveLongForm({ did }) {
|
|
284
|
+
const inputDocument = decode({ did });
|
|
285
|
+
return contextualize({
|
|
286
|
+
inputDocument,
|
|
287
|
+
did,
|
|
288
|
+
alsoKnownAs: longToShort({ did })
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Resolves a short form from its long form: decodes the long form (so the
|
|
293
|
+
* regex and hash checks run), then contextualizes with the short form as `id`
|
|
294
|
+
* and the long form appended to `alsoKnownAs`. References stay relative.
|
|
295
|
+
*
|
|
296
|
+
* @param options {object}
|
|
297
|
+
* @param options.longFormDid {string} - The long form previously seen.
|
|
298
|
+
*
|
|
299
|
+
* @returns {IDIDDocument}
|
|
300
|
+
*/
|
|
301
|
+
export function resolveShortForm({ longFormDid }) {
|
|
302
|
+
const inputDocument = decode({ did: longFormDid });
|
|
303
|
+
return contextualize({
|
|
304
|
+
inputDocument,
|
|
305
|
+
did: longToShort({ did: longFormDid }),
|
|
306
|
+
alsoKnownAs: longFormDid
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=numalgo4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numalgo4.js","sourceRoot":"","sources":["../src/numalgo4.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,kBAAkB,EAGnB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAGjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,mEAAmE,CAAA;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,yCAAyC,CAAA;AAE3E,MAAM,aAAa,GAAoD;IACrE,UAAU,EAAE;QACV,IAAI,EAAE,uCAAuC;QAC7C,KAAK,EAAE,qBAAqB;KAC7B;IACD,aAAa,EAAE;QACb,IAAI,E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AAG,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;IACrC,OAAO,aAAa,CAAC;QACnB,aAAa;QACb,GAAG;QACH,WAAW,EAAE,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;KAClC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,EAGZ;IACC,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAA;IAClD,OAAO,aAAa,CAAC;QACnB,aAAa;QACb,GAAG,EAAE,WAAW,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;QACtC,WAAW,EAAE,WAAW;KACzB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The properties whose entries are verification methods or references to
|
|
3
|
+
* them.
|
|
4
|
+
*/
|
|
5
|
+
export declare const METHOD_PROPERTIES: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Every property whose entries carry a resource id.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RESOURCE_PROPERTIES: string[];
|
|
10
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Finds the object entry with the given `id` across `properties`, searched in
|
|
13
|
+
* order. String entries are references and are skipped.
|
|
14
|
+
*
|
|
15
|
+
* @param options {object}
|
|
16
|
+
* @param options.document {Record<string, unknown>}
|
|
17
|
+
* @param options.id {string}
|
|
18
|
+
* @param [options.properties] {string[]} - Defaults to `RESOURCE_PROPERTIES`.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Record<string, unknown> | undefined}
|
|
21
|
+
*/
|
|
22
|
+
export declare function findResource({ document, id, properties }: {
|
|
23
|
+
document: Record<string, unknown>;
|
|
24
|
+
id: string;
|
|
25
|
+
properties?: string[];
|
|
26
|
+
}): Record<string, unknown> | undefined;
|
|
27
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAG7B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAoC,CAAA;AAEpE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAElC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,EAAE,EACF,UAAgC,EACjC,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAYtC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for walking the resource arrays of an input or DID document:
|
|
3
|
+
* `verificationMethod`, the five verification relationships and `service`.
|
|
4
|
+
* Imported by the codec, the input document helpers and the driver alike, so
|
|
5
|
+
* the plain-object test and the property lists exist once.
|
|
6
|
+
*/
|
|
7
|
+
import { VERIFICATION_RELATIONSHIPS } from '@interop/did-io';
|
|
8
|
+
/**
|
|
9
|
+
* The properties whose entries are verification methods or references to
|
|
10
|
+
* them.
|
|
11
|
+
*/
|
|
12
|
+
export const METHOD_PROPERTIES = [
|
|
13
|
+
'verificationMethod',
|
|
14
|
+
...VERIFICATION_RELATIONSHIPS
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Every property whose entries carry a resource id.
|
|
18
|
+
*/
|
|
19
|
+
export const RESOURCE_PROPERTIES = [...METHOD_PROPERTIES, 'service'];
|
|
20
|
+
export function isPlainObject(value) {
|
|
21
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Finds the object entry with the given `id` across `properties`, searched in
|
|
25
|
+
* order. String entries are references and are skipped.
|
|
26
|
+
*
|
|
27
|
+
* @param options {object}
|
|
28
|
+
* @param options.document {Record<string, unknown>}
|
|
29
|
+
* @param options.id {string}
|
|
30
|
+
* @param [options.properties] {string[]} - Defaults to `RESOURCE_PROPERTIES`.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Record<string, unknown> | undefined}
|
|
33
|
+
*/
|
|
34
|
+
export function findResource({ document, id, properties = RESOURCE_PROPERTIES }) {
|
|
35
|
+
for (const property of properties) {
|
|
36
|
+
const entries = document[property];
|
|
37
|
+
if (!Array.isArray(entries)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const match = entries.find(entry => isPlainObject(entry) && entry.id === id);
|
|
41
|
+
if (match) {
|
|
42
|
+
return match;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB;IACpB,GAAG,0BAA0B;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,iBAAiB,EAAE,SAAS,CAAC,CAAA;AAEpE,MAAM,UAAU,aAAa,CAC3B,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,QAAQ,EACR,EAAE,EACF,UAAU,GAAG,mBAAmB,EAKjC;IACC,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC5E,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the did:peer driver: the key suite registry shapes (the
|
|
3
|
+
* same contract `@interop/did-method-key` and `@interop/did-web-resolver`
|
|
4
|
+
* use, so one suite registers with every did-io driver), the input document
|
|
5
|
+
* type, and the `LongFormStore` the driver consults to resolve short forms.
|
|
6
|
+
*/
|
|
7
|
+
import type { AbstractKeyPair } from '@interop/data-integrity-core';
|
|
8
|
+
/**
|
|
9
|
+
* The id-less, relative-reference document a did:peer numalgo 4 DID is derived
|
|
10
|
+
* from. The codec never inspects its shape beyond what contextualization
|
|
11
|
+
* needs, so it is a plain JSON object.
|
|
12
|
+
*/
|
|
13
|
+
export type InputDocument = Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* A multibase-multikey deserializer: converts a `{publicKeyMultibase}` value
|
|
16
|
+
* into a live key pair instance.
|
|
17
|
+
*/
|
|
18
|
+
export type FromMultibase = (options: {
|
|
19
|
+
publicKeyMultibase: string;
|
|
20
|
+
}) => Promise<AbstractKeyPair>;
|
|
21
|
+
/**
|
|
22
|
+
* A key suite class usable for did:peer generation and key rebuilding via
|
|
23
|
+
* `DidPeerDriver.use({ keyPairClass })`. The static `multibaseHeader` (the
|
|
24
|
+
* 4-character multibase-multikey prefix, e.g. `z6Mk` for Ed25519) lets the
|
|
25
|
+
* driver register the suite without the caller knowing that prefix.
|
|
26
|
+
*/
|
|
27
|
+
export interface KeyPairClass {
|
|
28
|
+
multibaseHeader: string;
|
|
29
|
+
from: FromMultibase;
|
|
30
|
+
generate?: (options?: object) => Promise<AbstractKeyPair>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* An entry in the driver's registry of key suites, keyed by multibase header.
|
|
34
|
+
*/
|
|
35
|
+
export interface RegisteredKeyType {
|
|
36
|
+
fromMultibase: FromMultibase;
|
|
37
|
+
generate?: (options?: object) => Promise<AbstractKeyPair>;
|
|
38
|
+
enableEncryptionKeyDerivation?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The driver's memory of long forms, keyed by short form. A short form is only
|
|
42
|
+
* a hash, so it resolves only after its long form has been seen; the driver
|
|
43
|
+
* writes `set(shortForm, longForm)` from `generate()` and (with
|
|
44
|
+
* `rememberOnResolve`) from a successful long form `get()`, and reads
|
|
45
|
+
* `get(shortForm)` for a short form. Positional parameters, so that a plain
|
|
46
|
+
* `Map<string, string>` satisfies the interface and a persistent store returns
|
|
47
|
+
* promises from the same two methods. The driver never deletes; a store grows
|
|
48
|
+
* by one entry per distinct long form resolved, and the store implementer owns
|
|
49
|
+
* bounds and eviction.
|
|
50
|
+
*/
|
|
51
|
+
export interface LongFormStore {
|
|
52
|
+
get(shortForm: string): string | undefined | Promise<string | undefined>;
|
|
53
|
+
set(shortForm: string, longForm: string): unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Constructor options for `DidPeerDriver` and `driver()`.
|
|
57
|
+
*/
|
|
58
|
+
export interface DidPeerDriverOptions {
|
|
59
|
+
longFormStore?: LongFormStore;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a successful long form `get()` writes the long form store so the
|
|
62
|
+
* counterpart's short form resolves later. Default `true`; a verifier that
|
|
63
|
+
* only fetches key nodes sets it to `false`. `generate()` writes regardless.
|
|
64
|
+
*/
|
|
65
|
+
rememberOnResolve?: boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAEnE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEnD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE;IACpC,kBAAkB,EAAE,MAAM,CAAA;CAC3B,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;AAE9B;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,aAAa,CAAA;IACnB,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;IACzD,6BAA6B,CAAC,EAAE,OAAO,CAAA;CACxC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACxE,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/did-method-peer",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "A did:peer (numalgo 4) DID method driver for @interop/did-io: long and short form codec, DID document generation and resolution, for the browser, Node.js, and React Native.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "pnpm run clear && tsc",
|
|
8
|
+
"clear": "rimraf dist/*",
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"fix": "eslint --fix src test && pnpm run format",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.md\"",
|
|
12
|
+
"lint": "eslint src test",
|
|
13
|
+
"prepare": "pnpm run build",
|
|
14
|
+
"rebuild": "pnpm run clear && pnpm run build",
|
|
15
|
+
"typecheck": "tsc -p tsconfig.dev.json",
|
|
16
|
+
"test": "pnpm run fix && pnpm run lint && pnpm run typecheck && pnpm run test:node && pnpm run test:browser",
|
|
17
|
+
"test:browser": "playwright test",
|
|
18
|
+
"test:node": "vitest run",
|
|
19
|
+
"test:coverage": "vitest run --coverage"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE.md"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"react-native": "./dist/index.js",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./codec": {
|
|
34
|
+
"types": "./dist/codec.d.ts",
|
|
35
|
+
"react-native": "./dist/codec.js",
|
|
36
|
+
"import": "./dist/codec.js",
|
|
37
|
+
"default": "./dist/codec.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"module": "dist/index.js",
|
|
41
|
+
"browser": "dist/index.js",
|
|
42
|
+
"types": "dist/index.d.ts",
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@interop/bnid": "^6.0.2",
|
|
46
|
+
"@interop/data-integrity-core": "^8.10.0",
|
|
47
|
+
"@interop/did-io": "^4.3.0",
|
|
48
|
+
"@interop/x25519-key-agreement-key": "^5.4.3",
|
|
49
|
+
"@noble/hashes": "^2.2.0",
|
|
50
|
+
"@scure/base": "^2.2.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/js": "^10.0.1",
|
|
54
|
+
"@interop/ed25519-signature": "^7.2.5",
|
|
55
|
+
"@interop/ed25519-verification-key": "^8.2.2",
|
|
56
|
+
"@interop/jsonld-signatures": "^11.9.0",
|
|
57
|
+
"@interop/security-document-loader": "^10.1.6",
|
|
58
|
+
"@interop/zcap": "^11.4.0",
|
|
59
|
+
"@playwright/test": "^1.60.0",
|
|
60
|
+
"@types/node": "^26.0.1",
|
|
61
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
62
|
+
"eslint": "^10.4.0",
|
|
63
|
+
"eslint-config-prettier": "^10.1.8",
|
|
64
|
+
"globals": "^17.6.0",
|
|
65
|
+
"prettier": "^3.8.3",
|
|
66
|
+
"rimraf": "^6.1.3",
|
|
67
|
+
"typescript": "^6.0.3",
|
|
68
|
+
"typescript-eslint": "^8.59.4",
|
|
69
|
+
"vite": "^8.0.14",
|
|
70
|
+
"vitest": "^4.1.7"
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
},
|
|
75
|
+
"keywords": [
|
|
76
|
+
"did",
|
|
77
|
+
"did:peer",
|
|
78
|
+
"didcomm",
|
|
79
|
+
"did-io",
|
|
80
|
+
"isomorphic"
|
|
81
|
+
],
|
|
82
|
+
"packageManager": "pnpm@11.5.0",
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=24.0"
|
|
85
|
+
},
|
|
86
|
+
"author": {
|
|
87
|
+
"name": "Interop Alliance",
|
|
88
|
+
"url": "https://github.com/interop-alliance/"
|
|
89
|
+
},
|
|
90
|
+
"license": "MIT",
|
|
91
|
+
"repository": {
|
|
92
|
+
"type": "git",
|
|
93
|
+
"url": "git+https://github.com/interop-alliance/did-method-peer.git"
|
|
94
|
+
},
|
|
95
|
+
"homepage": "https://github.com/interop-alliance/did-method-peer",
|
|
96
|
+
"bugs": "https://github.com/interop-alliance/did-method-peer/issues"
|
|
97
|
+
}
|