@interop/did-cli 0.10.0 → 0.10.1
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/CHANGELOG.md +58 -0
- package/dist/commands/collection-command.d.ts +169 -0
- package/dist/commands/collection-command.d.ts.map +1 -0
- package/dist/commands/collection-command.js +241 -0
- package/dist/commands/collection-command.js.map +1 -0
- package/dist/commands/did/create.d.ts +63 -0
- package/dist/commands/did/create.d.ts.map +1 -0
- package/dist/commands/did/create.js +625 -0
- package/dist/commands/did/create.js.map +1 -0
- package/dist/commands/did/manage.d.ts +68 -0
- package/dist/commands/did/manage.d.ts.map +1 -0
- package/dist/commands/did/manage.js +287 -0
- package/dist/commands/did/manage.js.map +1 -0
- package/dist/commands/did/service.d.ts +93 -0
- package/dist/commands/did/service.d.ts.map +1 -0
- package/dist/commands/did/service.js +324 -0
- package/dist/commands/did/service.js.map +1 -0
- package/dist/commands/did/webvh-update.d.ts +170 -0
- package/dist/commands/did/webvh-update.d.ts.map +1 -0
- package/dist/commands/did/webvh-update.js +402 -0
- package/dist/commands/did/webvh-update.js.map +1 -0
- package/dist/commands/did.d.ts +8 -8
- package/dist/commands/did.d.ts.map +1 -1
- package/dist/commands/did.js +27 -1519
- package/dist/commands/did.js.map +1 -1
- package/dist/commands/edv.d.ts +15 -6
- package/dist/commands/edv.d.ts.map +1 -1
- package/dist/commands/edv.js +38 -28
- package/dist/commands/edv.js.map +1 -1
- package/dist/commands/key.d.ts +104 -0
- package/dist/commands/key.d.ts.map +1 -1
- package/dist/commands/key.js +432 -402
- package/dist/commands/key.js.map +1 -1
- package/dist/commands/vc.d.ts +2 -1
- package/dist/commands/vc.d.ts.map +1 -1
- package/dist/commands/vc.js +88 -145
- package/dist/commands/vc.js.map +1 -1
- package/dist/commands/was/collection.d.ts.map +1 -1
- package/dist/commands/was/collection.js +31 -85
- package/dist/commands/was/collection.js.map +1 -1
- package/dist/commands/was/publish.d.ts.map +1 -1
- package/dist/commands/was/publish.js +16 -44
- package/dist/commands/was/publish.js.map +1 -1
- package/dist/commands/was/resource.d.ts.map +1 -1
- package/dist/commands/was/resource.js +24 -51
- package/dist/commands/was/resource.js.map +1 -1
- package/dist/commands/was/shared.d.ts +78 -0
- package/dist/commands/was/shared.d.ts.map +1 -1
- package/dist/commands/was/shared.js +84 -0
- package/dist/commands/was/shared.js.map +1 -1
- package/dist/commands/was/space.d.ts.map +1 -1
- package/dist/commands/was/space.js +10 -16
- package/dist/commands/was/space.js.map +1 -1
- package/dist/commands/was/tree.d.ts.map +1 -1
- package/dist/commands/was/tree.js +4 -6
- package/dist/commands/was/tree.js.map +1 -1
- package/dist/commands/was.d.ts.map +1 -1
- package/dist/commands/was.js +60 -74
- package/dist/commands/was.js.map +1 -1
- package/dist/commands/zcap.d.ts +0 -18
- package/dist/commands/zcap.d.ts.map +1 -1
- package/dist/commands/zcap.js +63 -155
- package/dist/commands/zcap.js.map +1 -1
- package/dist/documentLoader.d.ts +5 -0
- package/dist/documentLoader.d.ts.map +1 -0
- package/dist/documentLoader.js +29 -0
- package/dist/documentLoader.js.map +1 -0
- package/dist/edv/hmac.d.ts.map +1 -1
- package/dist/edv/hmac.js +12 -12
- package/dist/edv/hmac.js.map +1 -1
- package/dist/edv/recipients.d.ts +2 -0
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +12 -15
- package/dist/edv/recipients.js.map +1 -1
- package/dist/meta.d.ts +36 -11
- package/dist/meta.d.ts.map +1 -1
- package/dist/meta.js +95 -73
- package/dist/meta.js.map +1 -1
- package/dist/storage.d.ts +48 -13
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +40 -16
- package/dist/storage.js.map +1 -1
- package/dist/vc/issue.d.ts.map +1 -1
- package/dist/vc/issue.js +4 -7
- package/dist/vc/issue.js.map +1 -1
- package/dist/vc/verify.d.ts +10 -0
- package/dist/vc/verify.d.ts.map +1 -1
- package/dist/vc/verify.js +38 -1
- package/dist/vc/verify.js.map +1 -1
- package/dist/was/client.d.ts.map +1 -1
- package/dist/was/client.js +8 -2
- package/dist/was/client.js.map +1 -1
- package/dist/was/grant.d.ts +44 -0
- package/dist/was/grant.d.ts.map +1 -0
- package/dist/was/grant.js +78 -0
- package/dist/was/grant.js.map +1 -0
- package/dist/was/registry.d.ts.map +1 -1
- package/dist/was/registry.js +9 -2
- package/dist/was/registry.js.map +1 -1
- package/dist/zcap/delegate.d.ts.map +1 -1
- package/dist/zcap/delegate.js +1 -6
- package/dist/zcap/delegate.js.map +1 -1
- package/dist/zcap/signer.d.ts.map +1 -1
- package/dist/zcap/signer.js.map +1 -1
- package/package.json +5 -4
- package/dist/keys/webvh-driver.d.ts +0 -24
- package/dist/keys/webvh-driver.d.ts.map +0 -1
- package/dist/keys/webvh-driver.js +0 -73
- package/dist/keys/webvh-driver.js.map +0 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service-entry management for did:web and did:webvh DIDs. Builds and edits the
|
|
3
|
+
* `service` array (add/remove by id, with id normalization) and routes a
|
|
4
|
+
* service-array transform to the right per-method runner: did:web is a direct
|
|
5
|
+
* document edit, did:webvh appends a sparse log entry (advancing the
|
|
6
|
+
* pre-rotation ratchet when one is armed). The webvh log machinery is reused
|
|
7
|
+
* from `./webvh-update.js`.
|
|
8
|
+
*/
|
|
9
|
+
import { updateDID } from '@interop/did-method-webvh';
|
|
10
|
+
import { loadDidDocument, saveDidLog, saveToDids } from '../../storage.js';
|
|
11
|
+
import { resolveDidRef } from '../../meta.js';
|
|
12
|
+
import { webvhLogVerifier } from '../../documentLoader.js';
|
|
13
|
+
import { generateStagedKey } from '../../keys/webvh-update.js';
|
|
14
|
+
import { confirmAction, loadActiveSigner, loadStoredUpdateKeys, makeWebvhEntrySigner, persistUpdateKeysSidecar, resolveWebvhForUpdate, revealStagedSigner } from './webvh-update.js';
|
|
15
|
+
/**
|
|
16
|
+
* Expand a service id to a full DID URL. A bare fragment (`files`) or a
|
|
17
|
+
* leading-`#` fragment (`#files`) is resolved against the DID; a value that is
|
|
18
|
+
* already a full DID URL, or any absolute URI carrying a fragment, is returned
|
|
19
|
+
* unchanged.
|
|
20
|
+
*
|
|
21
|
+
* @param options {object}
|
|
22
|
+
* @param options.did {string}
|
|
23
|
+
* @param options.id {string}
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
export function normalizeServiceId({ did, id }) {
|
|
27
|
+
if (id.startsWith('#')) {
|
|
28
|
+
return `${did}${id}`;
|
|
29
|
+
}
|
|
30
|
+
if (id.startsWith('did:') || id.includes('#')) {
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
return `${did}#${id}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a service-endpoint entry from add-service options. Exactly one of
|
|
37
|
+
* `endpoint` (one or more endpoint values -- a single value stays a string,
|
|
38
|
+
* several become an array) or `endpointJson` (a raw JSON value) supplies the
|
|
39
|
+
* serviceEndpoint; a single `type` likewise stays a string.
|
|
40
|
+
*
|
|
41
|
+
* @param options {object}
|
|
42
|
+
* @param options.did {string}
|
|
43
|
+
* @param options.id {string}
|
|
44
|
+
* @param options.type {string[]}
|
|
45
|
+
* @param [options.endpoint] {string[]}
|
|
46
|
+
* @param [options.endpointJson] {string}
|
|
47
|
+
* @returns {ServiceEndpoint}
|
|
48
|
+
*/
|
|
49
|
+
export function buildServiceEntry({ did, id, type, endpoint, endpointJson }) {
|
|
50
|
+
const hasEndpoint = Boolean(endpoint?.length);
|
|
51
|
+
const hasEndpointJson = Boolean(endpointJson);
|
|
52
|
+
// True when both are supplied or neither is -- i.e. not exactly one.
|
|
53
|
+
if (hasEndpoint === hasEndpointJson) {
|
|
54
|
+
throw new Error('Provide exactly one of --endpoint or --endpoint-json.');
|
|
55
|
+
}
|
|
56
|
+
let serviceEndpoint;
|
|
57
|
+
if (endpointJson) {
|
|
58
|
+
try {
|
|
59
|
+
serviceEndpoint = JSON.parse(endpointJson);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
throw new Error('--endpoint-json must be valid JSON.');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
serviceEndpoint = endpoint.length === 1 ? endpoint[0] : endpoint;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
id: normalizeServiceId({ did, id }),
|
|
70
|
+
type: type.length === 1 ? type[0] : type,
|
|
71
|
+
serviceEndpoint
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Whether a stored service entry has the given (already-normalized, absolute)
|
|
76
|
+
* id. Service ids in a DID document may be relative (`#files`) or absolute, so
|
|
77
|
+
* the stored id is normalized against the DID before comparing.
|
|
78
|
+
*
|
|
79
|
+
* @param options {object}
|
|
80
|
+
* @param options.service {ServiceEndpoint}
|
|
81
|
+
* @param options.id {string} the normalized id to match.
|
|
82
|
+
* @param options.did {string}
|
|
83
|
+
* @returns {boolean}
|
|
84
|
+
*/
|
|
85
|
+
function serviceHasId({ service, id, did }) {
|
|
86
|
+
return (service.id !== undefined &&
|
|
87
|
+
normalizeServiceId({ did, id: service.id }) === id);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Append a service entry to the current array, rejecting a duplicate id.
|
|
91
|
+
*
|
|
92
|
+
* @param options {object}
|
|
93
|
+
* @param options.current {ServiceEndpoint[]}
|
|
94
|
+
* @param options.entry {ServiceEndpoint} its `id` is already normalized.
|
|
95
|
+
* @param options.did {string}
|
|
96
|
+
* @returns {ServiceEndpoint[]}
|
|
97
|
+
*/
|
|
98
|
+
export function addServiceEntry({ current, entry, did }) {
|
|
99
|
+
if (current.some(service => serviceHasId({ service, id: entry.id, did }))) {
|
|
100
|
+
throw new Error(`A service with id "${entry.id}" already exists.`);
|
|
101
|
+
}
|
|
102
|
+
return [...current, entry];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Remove the service entry with the given (normalized) id, rejecting a missing
|
|
106
|
+
* id.
|
|
107
|
+
*
|
|
108
|
+
* @param options {object}
|
|
109
|
+
* @param options.current {ServiceEndpoint[]}
|
|
110
|
+
* @param options.id {string} the normalized id to remove.
|
|
111
|
+
* @param options.did {string}
|
|
112
|
+
* @returns {ServiceEndpoint[]}
|
|
113
|
+
*/
|
|
114
|
+
export function removeServiceEntry({ current, id, did }) {
|
|
115
|
+
const next = current.filter(service => !serviceHasId({ service, id, did }));
|
|
116
|
+
if (next.length === current.length) {
|
|
117
|
+
throw new Error(`No service with id "${id}" found on the DID document.`);
|
|
118
|
+
}
|
|
119
|
+
return next;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Apply a service-array transform to a locally stored did:web document and
|
|
123
|
+
* re-save it. did:web has no history log, so this is a direct document edit;
|
|
124
|
+
* the `service` property is dropped entirely when the array empties out.
|
|
125
|
+
*
|
|
126
|
+
* @param options {object}
|
|
127
|
+
* @param options.did {string}
|
|
128
|
+
* @param options.transform {(current: ServiceEndpoint[], did: string) => ServiceEndpoint[]}
|
|
129
|
+
* @returns {Promise<number>} the process exit code
|
|
130
|
+
*/
|
|
131
|
+
async function runWebServiceUpdate({ did, transform }) {
|
|
132
|
+
let didDocument;
|
|
133
|
+
try {
|
|
134
|
+
didDocument = await loadDidDocument(did);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
console.error(`No locally stored did:web found for ${did}`);
|
|
138
|
+
return 1;
|
|
139
|
+
}
|
|
140
|
+
const current = Array.isArray(didDocument.service)
|
|
141
|
+
? didDocument.service
|
|
142
|
+
: [];
|
|
143
|
+
let next;
|
|
144
|
+
try {
|
|
145
|
+
next = transform(current, did);
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
console.error(err.message);
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
if (next.length > 0) {
|
|
152
|
+
didDocument.service = next;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
delete didDocument.service;
|
|
156
|
+
}
|
|
157
|
+
const docPath = await saveToDids({ method: 'web', did, data: didDocument });
|
|
158
|
+
console.error(`DID saved to ${docPath}`);
|
|
159
|
+
console.log(JSON.stringify({ id: didDocument.id, didDocument }, null, 2));
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Apply a service-array transform to a locally stored did:webvh DID by
|
|
164
|
+
* appending a sparse log entry that overlays only the `service` array. Update
|
|
165
|
+
* keys and document verification methods are carried forward unchanged -- with
|
|
166
|
+
* one exception: a pre-rotation-armed DID cannot author a key-neutral update
|
|
167
|
+
* (the library requires the staged key to sign), so the update-key ratchet is
|
|
168
|
+
* advanced as part of the change -- the staged key is revealed to sign and a
|
|
169
|
+
* fresh next key is staged.
|
|
170
|
+
*
|
|
171
|
+
* @param options {object}
|
|
172
|
+
* @param options.targetDid {string} the resolved did:webvh DID.
|
|
173
|
+
* @param options.transform {(current: ServiceEndpoint[], did: string) => ServiceEndpoint[]}
|
|
174
|
+
* @param [options.yes] {boolean} skip the confirmation prompt.
|
|
175
|
+
* @param [options.keepOldKey] {boolean} retain the retired update key secret
|
|
176
|
+
* (pre-rotation path only; default is to drop it).
|
|
177
|
+
* @returns {Promise<number>} the process exit code
|
|
178
|
+
*/
|
|
179
|
+
async function runWebvhServiceUpdate({ targetDid, transform, yes, keepOldKey }) {
|
|
180
|
+
let log;
|
|
181
|
+
let doc;
|
|
182
|
+
let meta;
|
|
183
|
+
try {
|
|
184
|
+
;
|
|
185
|
+
({ log, doc, meta } = await resolveWebvhForUpdate({
|
|
186
|
+
targetDid,
|
|
187
|
+
action: 'update services'
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
console.error(err.message);
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
// Compute the new service array from the current resolved document.
|
|
195
|
+
const current = Array.isArray(doc?.service) ? doc.service : [];
|
|
196
|
+
let services;
|
|
197
|
+
try {
|
|
198
|
+
services = transform(current, targetDid);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
console.error(err.message);
|
|
202
|
+
return 1;
|
|
203
|
+
}
|
|
204
|
+
const stored = await loadStoredUpdateKeys(targetDid);
|
|
205
|
+
// Choose the signer and key parameters. A sparse update normally omits
|
|
206
|
+
// updateKeys/nextKeyHashes so the keys carry forward untouched; a
|
|
207
|
+
// pre-rotation DID instead must reveal its staged key (which signs) and stage
|
|
208
|
+
// a fresh one in the same entry.
|
|
209
|
+
let signerKeyPair;
|
|
210
|
+
let updateKeys;
|
|
211
|
+
let nextKeyHashes;
|
|
212
|
+
let newActive;
|
|
213
|
+
let newStaged;
|
|
214
|
+
let retiredActive;
|
|
215
|
+
try {
|
|
216
|
+
if (meta.prerotation) {
|
|
217
|
+
;
|
|
218
|
+
({ signerKeyPair, newActive, retiredActive } = await revealStagedSigner({
|
|
219
|
+
stored,
|
|
220
|
+
meta,
|
|
221
|
+
targetDid,
|
|
222
|
+
action: 'update services'
|
|
223
|
+
}));
|
|
224
|
+
newStaged = await generateStagedKey();
|
|
225
|
+
updateKeys = [newActive.publicKeyMultibase];
|
|
226
|
+
nextKeyHashes = [newStaged.nextKeyHash];
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
;
|
|
230
|
+
({ signerKeyPair } = await loadActiveSigner({
|
|
231
|
+
stored,
|
|
232
|
+
meta,
|
|
233
|
+
targetDid,
|
|
234
|
+
action: 'update services'
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
console.error(err.message);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
const confirmed = await confirmAction({
|
|
243
|
+
message: `Update the services of ${targetDid}? This appends a new log entry ` +
|
|
244
|
+
'and is hard to undo.',
|
|
245
|
+
yes
|
|
246
|
+
});
|
|
247
|
+
if (!confirmed) {
|
|
248
|
+
console.error('Aborted.');
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
const signer = makeWebvhEntrySigner(signerKeyPair);
|
|
252
|
+
let result;
|
|
253
|
+
try {
|
|
254
|
+
result = await updateDID({
|
|
255
|
+
log,
|
|
256
|
+
signer,
|
|
257
|
+
verifier: webvhLogVerifier,
|
|
258
|
+
services,
|
|
259
|
+
...(updateKeys ? { updateKeys } : {}),
|
|
260
|
+
...(nextKeyHashes ? { nextKeyHashes } : {})
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
console.error(`Service update failed: ${err.message}`);
|
|
265
|
+
return 1;
|
|
266
|
+
}
|
|
267
|
+
const logPath = await saveDidLog({ did: result.did, log: result.log });
|
|
268
|
+
const docPath = await saveToDids({
|
|
269
|
+
method: 'webvh',
|
|
270
|
+
did: result.did,
|
|
271
|
+
data: result.doc
|
|
272
|
+
});
|
|
273
|
+
// Persist the advanced ratchet only on the pre-rotation path; an ordinary
|
|
274
|
+
// service update leaves the update-keys sidecar untouched.
|
|
275
|
+
if (meta.prerotation && newActive) {
|
|
276
|
+
const updateKeysPath = await persistUpdateKeysSidecar({
|
|
277
|
+
did: result.did,
|
|
278
|
+
newActive,
|
|
279
|
+
newStaged,
|
|
280
|
+
retiredActive,
|
|
281
|
+
stored,
|
|
282
|
+
keepOldKey
|
|
283
|
+
});
|
|
284
|
+
console.error(`Update keys saved to ${updateKeysPath}`);
|
|
285
|
+
console.error('Pre-rotation: the update key was advanced as part of this change.');
|
|
286
|
+
}
|
|
287
|
+
console.error(`DID document saved to ${docPath}`);
|
|
288
|
+
console.error(`DID history log saved to ${logPath}`);
|
|
289
|
+
console.log(JSON.stringify({ id: result.did, didDocument: result.doc }, null, 2));
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Resolve a DID reference, then route a service-array transform to the right
|
|
294
|
+
* per-method runner and return its exit code. did:web is a direct document
|
|
295
|
+
* edit; did:webvh appends a log entry.
|
|
296
|
+
*
|
|
297
|
+
* @param options {object}
|
|
298
|
+
* @param options.ref {string} a DID or a local metadata handle.
|
|
299
|
+
* @param options.transform {(current: ServiceEndpoint[], did: string) => ServiceEndpoint[]}
|
|
300
|
+
* @param [options.yes] {boolean} skip the did:webvh confirmation prompt.
|
|
301
|
+
* @param [options.keepOldKey] {boolean} did:webvh pre-rotation path only.
|
|
302
|
+
* @returns {Promise<number>} the process exit code
|
|
303
|
+
*/
|
|
304
|
+
export async function dispatchServiceUpdate({ ref, transform, yes, keepOldKey }) {
|
|
305
|
+
let resolved;
|
|
306
|
+
try {
|
|
307
|
+
resolved = await resolveDidRef({ ref });
|
|
308
|
+
}
|
|
309
|
+
catch (err) {
|
|
310
|
+
console.error(err.message);
|
|
311
|
+
return 1;
|
|
312
|
+
}
|
|
313
|
+
const did = resolved ?? ref;
|
|
314
|
+
if (did.startsWith('did:web:')) {
|
|
315
|
+
return runWebServiceUpdate({ did, transform });
|
|
316
|
+
}
|
|
317
|
+
if (did.startsWith('did:webvh:')) {
|
|
318
|
+
return runWebvhServiceUpdate({ targetDid: did, transform, yes, keepOldKey });
|
|
319
|
+
}
|
|
320
|
+
console.error('add-service/remove-service are only supported for did:web and ' +
|
|
321
|
+
'did:webvh DIDs');
|
|
322
|
+
return 1;
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/did/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAEL,SAAS,EAGV,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAEX,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EACL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,CAAA;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,GAAG,EACH,SAAS,EACT,GAAG,EACH,UAAU,EAMX;IACC,IAAI,QAA4B,CAAA;IAChC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAE,GAAa,CAAC,OAAO,CAAC,CAAA;QACrC,OAAO,CAAC,CAAA;IACV,CAAC;IACD,MAAM,GAAG,GAAG,QAAQ,IAAI,GAAG,CAAA;IAC3B,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,mBAAmB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,qBAAqB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAA;IAC9E,CAAC;IACD,OAAO,CAAC,KAAK,CACX,gEAAgE;QAC9D,gBAAgB,CACnB,CAAA;IACD,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { resolveDIDFromLog, type DIDLog } from '@interop/did-method-webvh';
|
|
2
|
+
import { Ed25519VerificationKey } from '@interop/ed25519-verification-key';
|
|
3
|
+
import { type WebvhUpdateKey, type WebvhUpdateKeys } from '../../storage.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parse a raw did:webvh history log (newline-delimited JSON) into the entry
|
|
6
|
+
* array the library's resolver/updater expect, ignoring blank lines.
|
|
7
|
+
*
|
|
8
|
+
* @param logText {string}
|
|
9
|
+
* @returns {DIDLog}
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseDidLog(logText: string): DIDLog;
|
|
12
|
+
/**
|
|
13
|
+
* Ask the user to confirm a hard-to-undo action. Returns true immediately when
|
|
14
|
+
* `--yes` was passed or when stdin is not an interactive TTY (so scripts and
|
|
15
|
+
* tests are not blocked); otherwise prompts and requires an explicit `y`.
|
|
16
|
+
*
|
|
17
|
+
* @param options {object}
|
|
18
|
+
* @param options.message {string}
|
|
19
|
+
* @param options.yes {boolean} the value of the `--yes` flag.
|
|
20
|
+
* @returns {Promise<boolean>}
|
|
21
|
+
*/
|
|
22
|
+
export declare function confirmAction({ message, yes }: {
|
|
23
|
+
message: string;
|
|
24
|
+
yes?: boolean;
|
|
25
|
+
}): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Load and resolve a locally stored did:webvh history log in preparation for an
|
|
28
|
+
* update, asserting it is updatable. The log is the source of truth for a
|
|
29
|
+
* stored did:webvh, so its absence is what "not locally stored" means.
|
|
30
|
+
*
|
|
31
|
+
* @param options {object}
|
|
32
|
+
* @param options.targetDid {string} the resolved did:webvh DID.
|
|
33
|
+
* @param options.action {string} verb used in error messages (e.g.
|
|
34
|
+
* `rotate keys`, `update services`).
|
|
35
|
+
* @returns {Promise<{ log, doc, meta }>}
|
|
36
|
+
* @throws {Error} with a user-facing message if the log is missing, fails to
|
|
37
|
+
* resolve, or the DID is deactivated.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveWebvhForUpdate({ targetDid, action }: {
|
|
40
|
+
targetDid: string;
|
|
41
|
+
action: string;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
log: DIDLog;
|
|
44
|
+
doc: Awaited<ReturnType<typeof resolveDIDFromLog>>['doc'];
|
|
45
|
+
meta: Awaited<ReturnType<typeof resolveDIDFromLog>>['meta'];
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a locally stored did:webvh DID from its history log (`.jsonl`) -- the
|
|
49
|
+
* source of truth for the current document and its accumulated parameters.
|
|
50
|
+
* Unlike `resolveWebvhForUpdate` this does not reject a deactivated DID, since
|
|
51
|
+
* `show` should still display it; it returns `undefined` when no log is stored
|
|
52
|
+
* so the caller can fall back to the stored document snapshot.
|
|
53
|
+
*
|
|
54
|
+
* @param did {string} the resolved did:webvh DID.
|
|
55
|
+
* @returns {Promise<{ doc, meta } | undefined>}
|
|
56
|
+
* @throws {Error} if a log exists but fails to resolve/verify.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveStoredWebvh(did: string): Promise<{
|
|
59
|
+
doc: Awaited<ReturnType<typeof resolveDIDFromLog>>['doc'];
|
|
60
|
+
meta: Awaited<ReturnType<typeof resolveDIDFromLog>>['meta'];
|
|
61
|
+
} | undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Load a did:webvh DID's update-keys sidecar, treating an absent file as
|
|
64
|
+
* `undefined` (no stored secrets) rather than an error.
|
|
65
|
+
*
|
|
66
|
+
* @param did {string}
|
|
67
|
+
* @returns {Promise<WebvhUpdateKeys | undefined>}
|
|
68
|
+
*/
|
|
69
|
+
export declare function loadStoredUpdateKeys(did: string): Promise<WebvhUpdateKeys | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Pre-rotation reveal: validate and load the staged (pre-committed) update key
|
|
72
|
+
* that must sign this entry, returning the signer key pair plus the records
|
|
73
|
+
* that make it the new active key and retire the current one.
|
|
74
|
+
*
|
|
75
|
+
* @param options {object}
|
|
76
|
+
* @param options.stored {WebvhUpdateKeys | undefined} the update-keys sidecar.
|
|
77
|
+
* @param options.meta {Awaited<ReturnType<typeof resolveDIDFromLog>>['meta']}
|
|
78
|
+
* @param options.targetDid {string}
|
|
79
|
+
* @param options.action {string} verb used in error messages.
|
|
80
|
+
* @returns {Promise<{ signerKeyPair, newActive, retiredActive }>}
|
|
81
|
+
* @throws {Error} if the staged secret is missing or has diverged from the
|
|
82
|
+
* log's committed nextKeyHashes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function revealStagedSigner({ stored, meta, targetDid, action }: {
|
|
85
|
+
stored: WebvhUpdateKeys | undefined;
|
|
86
|
+
meta: Awaited<ReturnType<typeof resolveDIDFromLog>>['meta'];
|
|
87
|
+
targetDid: string;
|
|
88
|
+
action: string;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
signerKeyPair: Ed25519VerificationKey;
|
|
91
|
+
newActive: WebvhUpdateKey;
|
|
92
|
+
retiredActive: WebvhUpdateKey;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Ordinary (non-pre-rotation) signer: the current active update key signs.
|
|
96
|
+
* Returns the signer key pair and the active record it was loaded from.
|
|
97
|
+
*
|
|
98
|
+
* @param options {object}
|
|
99
|
+
* @param options.stored {WebvhUpdateKeys | undefined} the update-keys sidecar.
|
|
100
|
+
* @param options.meta {Awaited<ReturnType<typeof resolveDIDFromLog>>['meta']}
|
|
101
|
+
* @param options.targetDid {string}
|
|
102
|
+
* @param options.action {string} verb used in error messages.
|
|
103
|
+
* @returns {Promise<{ signerKeyPair, activeRecord }>}
|
|
104
|
+
* @throws {Error} if the active secret is missing or no longer matches the
|
|
105
|
+
* log's updateKeys.
|
|
106
|
+
*/
|
|
107
|
+
export declare function loadActiveSigner({ stored, meta, targetDid, action }: {
|
|
108
|
+
stored: WebvhUpdateKeys | undefined;
|
|
109
|
+
meta: Awaited<ReturnType<typeof resolveDIDFromLog>>['meta'];
|
|
110
|
+
targetDid: string;
|
|
111
|
+
action: string;
|
|
112
|
+
}): Promise<{
|
|
113
|
+
signerKeyPair: Ed25519VerificationKey;
|
|
114
|
+
activeRecord: WebvhUpdateKey;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Build the entry signer for a did:webvh update from an update key pair.
|
|
118
|
+
*
|
|
119
|
+
* @param keyPair {Ed25519VerificationKey} mutated: its `id` is set in place.
|
|
120
|
+
* @returns the signer to pass to `updateDID`.
|
|
121
|
+
*/
|
|
122
|
+
export declare function makeWebvhEntrySigner(keyPair: Ed25519VerificationKey): import("@interop/did-method-webvh").Signer<import("@interop/did-method-webvh").SignableDocument> & import("@interop/did-method-webvh").Verifier;
|
|
123
|
+
/**
|
|
124
|
+
* Write the update-keys sidecar: the active key, the staged next key (or
|
|
125
|
+
* none), and any retired secrets. At creation there is no prior sidecar; after
|
|
126
|
+
* an advance/rotation the superseded active key is appended to `retired` only
|
|
127
|
+
* when `keepOldKey` asks to preserve it.
|
|
128
|
+
*
|
|
129
|
+
* @param options {object}
|
|
130
|
+
* @param options.did {string}
|
|
131
|
+
* @param options.newActive {WebvhUpdateKey}
|
|
132
|
+
* @param [options.newStaged] {WebvhUpdateKey & { nextKeyHash: string }}
|
|
133
|
+
* @param [options.retiredActive] {WebvhUpdateKey} the superseded active key.
|
|
134
|
+
* @param [options.stored] {WebvhUpdateKeys} the prior sidecar, if any.
|
|
135
|
+
* @param [options.keepOldKey] {boolean} retain the retired secret.
|
|
136
|
+
* @returns {Promise<string>} the saved sidecar path.
|
|
137
|
+
*/
|
|
138
|
+
export declare function persistUpdateKeysSidecar({ did, newActive, newStaged, retiredActive, stored, keepOldKey }: {
|
|
139
|
+
did: string;
|
|
140
|
+
newActive: WebvhUpdateKey;
|
|
141
|
+
newStaged?: WebvhUpdateKey & {
|
|
142
|
+
nextKeyHash: string;
|
|
143
|
+
};
|
|
144
|
+
retiredActive?: WebvhUpdateKey;
|
|
145
|
+
stored?: WebvhUpdateKeys;
|
|
146
|
+
keepOldKey?: boolean;
|
|
147
|
+
}): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Rotate the update (authorization) key of a locally stored did:webvh DID. By
|
|
150
|
+
* default advances key pre-rotation -- reveals the staged next key and stages a
|
|
151
|
+
* fresh one -- and never touches the document verification methods.
|
|
152
|
+
*
|
|
153
|
+
* @param options {object}
|
|
154
|
+
* @param options.didRef {string} The DID or metadata handle.
|
|
155
|
+
* @param [options.updateKey] {string[]} Rotate to specific update key(s).
|
|
156
|
+
* @param [options.enablePrerotation] {boolean} Turn pre-rotation on.
|
|
157
|
+
* @param [options.stopPrerotation] {boolean} Turn pre-rotation off.
|
|
158
|
+
* @param [options.keepOldKey] {boolean} Retain the retired update key secret.
|
|
159
|
+
* @param [options.yes] {boolean} Skip the confirmation prompt.
|
|
160
|
+
* @returns {Promise<number>} The process exit code.
|
|
161
|
+
*/
|
|
162
|
+
export declare function runRotateKeys(options: {
|
|
163
|
+
didRef: string;
|
|
164
|
+
updateKey?: string[];
|
|
165
|
+
enablePrerotation?: boolean;
|
|
166
|
+
stopPrerotation?: boolean;
|
|
167
|
+
keepOldKey?: boolean;
|
|
168
|
+
yes?: boolean;
|
|
169
|
+
}): Promise<number>;
|
|
170
|
+
//# sourceMappingURL=webvh-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webvh-update.d.ts","sourceRoot":"","sources":["../../../src/commands/did/webvh-update.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,iBAAiB,EAEjB,KAAK,MAAM,EACZ,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAA;AAUzB;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAO,EACP,GAAG,EACJ,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,SAAS,EACT,MAAM,EACP,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAA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