@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
+
## 0.10.1 - 2026-06-26
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `vc verify` now verifies credentials issued by `did:webvh` (and `did:web`)
|
|
8
|
+
issuers. Verification ran through `@interop/verifier-core`'s default document
|
|
9
|
+
loader, which resolves only `did:key` and `did:web`, so a `did:webvh` proof's
|
|
10
|
+
verification method could never be fetched and the signature was reported as
|
|
11
|
+
invalid. Verification now uses the CLI's shared loader (which registers the
|
|
12
|
+
`did:webvh` driver), passed through to `verifyCredential`.
|
|
13
|
+
- `vc issue --did` now accepts a metadata handle (not just a full DID id),
|
|
14
|
+
resolving it via the same lookup used by the other DID-referencing commands.
|
|
15
|
+
Previously passing a handle failed with a confusing `The "path" argument must
|
|
16
|
+
be of type string. Received undefined` error.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- The `list` / `show` / `meta` / `remove` subcommands and metadata handling of
|
|
21
|
+
the `vc`, `key`, and `zcap` command families now share a single
|
|
22
|
+
`src/commands/collection-command.ts` module (`runListCollection`,
|
|
23
|
+
`runMetaCollection`, `runRemoveCollection`, `resolveRefOrReport`,
|
|
24
|
+
`applyMetaEdits`, `requireSaveForMetaFlags`, and a unified `writeCreateMeta`),
|
|
25
|
+
replacing the near-identical clones previously copy-pasted across the three
|
|
26
|
+
files. `did`'s metadata edit and save-flag guard reuse the same helpers. No
|
|
27
|
+
behavior change.
|
|
28
|
+
- The `did` command file was split, mirroring `was/`: `src/commands/did.ts` now
|
|
29
|
+
holds only the `makeDidCommand()` wiring and delegates to `run*` functions in
|
|
30
|
+
`src/commands/did/` -- `create` (create / add-key), `service`
|
|
31
|
+
(add / remove-service), `manage` (get / show / list / meta / remove), and
|
|
32
|
+
`webvh-update` (the did:webvh log / update-key plumbing plus rotate-keys). The
|
|
33
|
+
in-`create` duplication was folded into shared `deriveSeed`,
|
|
34
|
+
`rejectSeedForNonDeterministic`, `resolveEcdsaCurveOrReport`, and
|
|
35
|
+
`printDidOutput` helpers (and a `DEFAULT_VERIFICATION_PURPOSES` constant), and
|
|
36
|
+
the `did.split(':')[1]` method-index idiom became `methodOf` in `storage.ts`.
|
|
37
|
+
No behavior change.
|
|
38
|
+
- All commands now share a single JSON-LD document loader (`src/documentLoader.ts`)
|
|
39
|
+
for DID resolution, DID-URL dereferencing, and context loading -- replacing the
|
|
40
|
+
per-module loaders previously built in `vc/issue`, `vc/verify` (none was passed
|
|
41
|
+
before), `edv/recipients`, `zcap/delegate`, and `commands/did`. The shared
|
|
42
|
+
loader resolves `did:key`, `did:web`, and `did:webvh`.
|
|
43
|
+
- `vc verify` prints a friendly `Cannot verify: ...` hint on stderr (stdout stays
|
|
44
|
+
machine-parseable JSON) when a proof's verification method uses a DID method the
|
|
45
|
+
loader has no driver for, distinguishing a loader misconfiguration from a
|
|
46
|
+
genuine invalid signature.
|
|
47
|
+
- Internal typing and consistency cleanups (no behavior change): the exported
|
|
48
|
+
key-pair shape is named once as `StoredKeyPair` in `storage.ts` (replacing the
|
|
49
|
+
three verbatim copies in `vc/issue`, `zcap/signer`, `was/client` and the inline
|
|
50
|
+
shapes in `storage`/`meta`); `loadMetaFromCollection` is generic over the
|
|
51
|
+
metadata type (so only the `keys` collection carries the key-specific `dids`
|
|
52
|
+
field); `loadFromCollection` / `saveToCollection` take an options object like
|
|
53
|
+
the rest of the storage helpers; `vc/issue` and `vc/verify` replace their
|
|
54
|
+
`as never` casts with typed ones; `edv/recipients` replaces `Record<string,
|
|
55
|
+
any>` with a named `VerificationMethodNode` type; `edv`'s encrypt functions
|
|
56
|
+
share an `EnvelopeOptions` type and a `resolveEncryptContextOrReport` wrapper;
|
|
57
|
+
and the `z6Mk` / `z6LS` multibase prefixes are named constants. Added the
|
|
58
|
+
file-level JSDoc header to `key.ts` and moved the `zcap revoke` stub message to
|
|
59
|
+
stderr.
|
|
60
|
+
|
|
3
61
|
## 0.10.0 - 2026-06-25
|
|
4
62
|
|
|
5
63
|
### Added
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the wallet "collection" command families (`vc`, `key`,
|
|
3
|
+
* and `zcap`), whose `list` / `show` / `meta` / `remove` subcommands and
|
|
4
|
+
* metadata handling are otherwise near-identical clones. Each command file
|
|
5
|
+
* declares its collection name and supplies the per-collection projection
|
|
6
|
+
* (how to load an item, turn it into a table row / JSON object, and resolve a
|
|
7
|
+
* reference); the control flow -- plain/json/empty/table listing, the
|
|
8
|
+
* set-or-clear metadata edits, and the resolve-then-validate preamble -- lives
|
|
9
|
+
* here once.
|
|
10
|
+
*/
|
|
11
|
+
import { type ItemMetadata, type KeyMetadata } from '../storage.js';
|
|
12
|
+
import { type Column } from '../table.js';
|
|
13
|
+
/**
|
|
14
|
+
* Guards the `--handle` / `--description` metadata flags against being given
|
|
15
|
+
* without `--save`. Prints the standard message to stderr and returns false
|
|
16
|
+
* when the combination is invalid; the caller chooses the exit code.
|
|
17
|
+
*
|
|
18
|
+
* @param options {object}
|
|
19
|
+
* @param [options.save] {boolean}
|
|
20
|
+
* @param [options.handle] {string}
|
|
21
|
+
* @param [options.description] {string}
|
|
22
|
+
* @returns {boolean} true when the flags are valid.
|
|
23
|
+
*/
|
|
24
|
+
export declare function requireSaveForMetaFlags({ save, handle, description }: {
|
|
25
|
+
save?: boolean;
|
|
26
|
+
handle?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Apply the `--handle` / `--description` set-or-clear edits to a metadata
|
|
31
|
+
* object in place: a defined non-empty value sets the field, an empty string
|
|
32
|
+
* clears it, and an undefined value leaves it untouched.
|
|
33
|
+
*
|
|
34
|
+
* @param meta {ItemMetadata} The metadata object to mutate.
|
|
35
|
+
* @param edits {object}
|
|
36
|
+
* @param [edits.handle] {string}
|
|
37
|
+
* @param [edits.description] {string}
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyMetaEdits(meta: ItemMetadata, { handle, description }: {
|
|
41
|
+
handle?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
}): void;
|
|
44
|
+
/**
|
|
45
|
+
* Write the `.meta.json` metadata sidecar of a freshly saved wallet item: the
|
|
46
|
+
* creation timestamp plus the handle and description when given. When
|
|
47
|
+
* `mergeExisting` is set, any existing sidecar is loaded first and its fields
|
|
48
|
+
* take precedence over `created` (so re-saving an already-stored item keeps
|
|
49
|
+
* its original timestamp) -- used by `vc import` / `vc issue --save`, which may
|
|
50
|
+
* re-store a credential that is already in the wallet.
|
|
51
|
+
*
|
|
52
|
+
* @param options {object}
|
|
53
|
+
* @param options.collection {string}
|
|
54
|
+
* @param options.storageId {string}
|
|
55
|
+
* @param options.created {string}
|
|
56
|
+
* @param [options.handle] {string}
|
|
57
|
+
* @param [options.description] {string}
|
|
58
|
+
* @param [options.mergeExisting] {boolean}
|
|
59
|
+
* @returns {Promise<void>}
|
|
60
|
+
*/
|
|
61
|
+
export declare function writeCreateMeta({ collection, storageId, created, handle, description, mergeExisting }: {
|
|
62
|
+
collection: string;
|
|
63
|
+
storageId: string;
|
|
64
|
+
created: string;
|
|
65
|
+
handle?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
mergeExisting?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve a wallet item reference, reporting failures to stderr and returning
|
|
71
|
+
* undefined: prints the thrown error message on an ambiguous handle, or the
|
|
72
|
+
* standard "No locally stored <noun> found for <ref>" message when nothing
|
|
73
|
+
* matches. Collapses the resolve-then-validate preamble shared by the
|
|
74
|
+
* `show` / `meta` / `remove` subcommands; callers do `if (!resolved) return 1`.
|
|
75
|
+
*
|
|
76
|
+
* @param options {object}
|
|
77
|
+
* @param options.resolve {(ref: string) => Promise<T | undefined>}
|
|
78
|
+
* @param options.ref {string}
|
|
79
|
+
* @param options.noun {string} The item noun for the not-found message.
|
|
80
|
+
* @returns {Promise<T | undefined>}
|
|
81
|
+
*/
|
|
82
|
+
export declare function resolveRefOrReport<T>({ resolve, ref, noun }: {
|
|
83
|
+
resolve: (ref: string) => Promise<T | undefined>;
|
|
84
|
+
ref: string;
|
|
85
|
+
noun: string;
|
|
86
|
+
}): Promise<T | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* Render a wallet collection listing: one id per line with `plain`, a JSON
|
|
89
|
+
* array with `json`, an empty result as no output, otherwise a column-aligned
|
|
90
|
+
* table. Shared by `vc list`, `key list`, and `zcap list`; each caller
|
|
91
|
+
* supplies how to load an item, project it to a row / JSON object, and the
|
|
92
|
+
* table columns. A `toEntry` returning undefined drops the item from the
|
|
93
|
+
* non-plain output (e.g. an id-less zcap).
|
|
94
|
+
*
|
|
95
|
+
* @param options {object}
|
|
96
|
+
* @param options.collection {string}
|
|
97
|
+
* @param [options.plain] {boolean}
|
|
98
|
+
* @param [options.json] {boolean}
|
|
99
|
+
* @param options.plainId {(item: Item, storageId: string) => string | undefined}
|
|
100
|
+
* The id to print in `--plain` mode; undefined skips the item.
|
|
101
|
+
* @param options.toEntry {(args: {storageId: string, item: Item, meta?: KeyMetadata}) => Entry | undefined | Promise<Entry | undefined>}
|
|
102
|
+
* @param options.toJson {(entry: Entry) => object}
|
|
103
|
+
* @param options.columns {Column[]}
|
|
104
|
+
* @param options.toRow {(entry: Entry) => string[]}
|
|
105
|
+
* @returns {Promise<number>} The process exit code.
|
|
106
|
+
*/
|
|
107
|
+
export declare function runListCollection<Item, Entry>({ collection, plain, json, plainId, toEntry, toJson, columns, toRow }: {
|
|
108
|
+
collection: string;
|
|
109
|
+
plain?: boolean;
|
|
110
|
+
json?: boolean;
|
|
111
|
+
plainId: (item: Item, storageId: string) => string | undefined;
|
|
112
|
+
toEntry: (args: {
|
|
113
|
+
storageId: string;
|
|
114
|
+
item: Item;
|
|
115
|
+
meta?: KeyMetadata;
|
|
116
|
+
}) => Entry | undefined | Promise<Entry | undefined>;
|
|
117
|
+
toJson: (entry: Entry) => object;
|
|
118
|
+
columns: Column[];
|
|
119
|
+
toRow: (entry: Entry) => string[];
|
|
120
|
+
}): Promise<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Show or edit the metadata of a wallet item (by id or handle): with no
|
|
123
|
+
* `--handle` / `--description` edits, prints the current metadata; otherwise
|
|
124
|
+
* applies the set-or-clear edits, saves the sidecar, and prints the result.
|
|
125
|
+
* Shared by `vc meta` and `zcap meta`. (`key meta` keeps its own runner: it
|
|
126
|
+
* additionally backfills the created date and refreshes the cached DID
|
|
127
|
+
* associations.)
|
|
128
|
+
*
|
|
129
|
+
* @param options {object}
|
|
130
|
+
* @param options.collection {string}
|
|
131
|
+
* @param options.noun {string}
|
|
132
|
+
* @param options.resolve {(ref: string) => Promise<{storageId: string, meta?: ItemMetadata} | undefined>}
|
|
133
|
+
* @param options.ref {string}
|
|
134
|
+
* @param [options.handle] {string}
|
|
135
|
+
* @param [options.description] {string}
|
|
136
|
+
* @returns {Promise<number>} The process exit code.
|
|
137
|
+
*/
|
|
138
|
+
export declare function runMetaCollection({ collection, noun, resolve, ref, handle, description }: {
|
|
139
|
+
collection: string;
|
|
140
|
+
noun: string;
|
|
141
|
+
resolve: (ref: string) => Promise<{
|
|
142
|
+
storageId: string;
|
|
143
|
+
meta?: ItemMetadata;
|
|
144
|
+
} | undefined>;
|
|
145
|
+
ref: string;
|
|
146
|
+
handle?: string;
|
|
147
|
+
description?: string;
|
|
148
|
+
}): Promise<number>;
|
|
149
|
+
/**
|
|
150
|
+
* Resolve a wallet item by reference and remove it (and its metadata sidecar),
|
|
151
|
+
* printing each removed file path to stderr. Shared by `vc remove`,
|
|
152
|
+
* `key remove`, and `zcap remove`.
|
|
153
|
+
*
|
|
154
|
+
* @param options {object}
|
|
155
|
+
* @param options.collection {string}
|
|
156
|
+
* @param options.noun {string}
|
|
157
|
+
* @param options.resolve {(ref: string) => Promise<{storageId: string} | undefined>}
|
|
158
|
+
* @param options.ref {string}
|
|
159
|
+
* @returns {Promise<number>} The process exit code.
|
|
160
|
+
*/
|
|
161
|
+
export declare function runRemoveCollection({ collection, noun, resolve, ref }: {
|
|
162
|
+
collection: string;
|
|
163
|
+
noun: string;
|
|
164
|
+
resolve: (ref: string) => Promise<{
|
|
165
|
+
storageId: string;
|
|
166
|
+
} | undefined>;
|
|
167
|
+
ref: string;
|
|
168
|
+
}): Promise<number>;
|
|
169
|
+
//# sourceMappingURL=collection-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-command.d.ts","sourceRoot":"","sources":["../../src/commands/collection-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,WAAW,EACZ,EAAE;IACD,IAAI,CAAC,EAAE,OAAO,CA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GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;IACpE,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,OAAO,CAAC,MAAM,CAAC,CAalB"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the wallet "collection" command families (`vc`, `key`,
|
|
3
|
+
* and `zcap`), whose `list` / `show` / `meta` / `remove` subcommands and
|
|
4
|
+
* metadata handling are otherwise near-identical clones. Each command file
|
|
5
|
+
* declares its collection name and supplies the per-collection projection
|
|
6
|
+
* (how to load an item, turn it into a table row / JSON object, and resolve a
|
|
7
|
+
* reference); the control flow -- plain/json/empty/table listing, the
|
|
8
|
+
* set-or-clear metadata edits, and the resolve-then-validate preamble -- lives
|
|
9
|
+
* here once.
|
|
10
|
+
*/
|
|
11
|
+
import { listCollection, loadFromCollection, loadMetaFromCollection, removeFromCollection, saveMetaToCollection } from '../storage.js';
|
|
12
|
+
import { renderTable } from '../table.js';
|
|
13
|
+
/**
|
|
14
|
+
* Guards the `--handle` / `--description` metadata flags against being given
|
|
15
|
+
* without `--save`. Prints the standard message to stderr and returns false
|
|
16
|
+
* when the combination is invalid; the caller chooses the exit code.
|
|
17
|
+
*
|
|
18
|
+
* @param options {object}
|
|
19
|
+
* @param [options.save] {boolean}
|
|
20
|
+
* @param [options.handle] {string}
|
|
21
|
+
* @param [options.description] {string}
|
|
22
|
+
* @returns {boolean} true when the flags are valid.
|
|
23
|
+
*/
|
|
24
|
+
export function requireSaveForMetaFlags({ save, handle, description }) {
|
|
25
|
+
if ((handle !== undefined || description !== undefined) && !save) {
|
|
26
|
+
console.error('--handle and --description require --save');
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Apply the `--handle` / `--description` set-or-clear edits to a metadata
|
|
33
|
+
* object in place: a defined non-empty value sets the field, an empty string
|
|
34
|
+
* clears it, and an undefined value leaves it untouched.
|
|
35
|
+
*
|
|
36
|
+
* @param meta {ItemMetadata} The metadata object to mutate.
|
|
37
|
+
* @param edits {object}
|
|
38
|
+
* @param [edits.handle] {string}
|
|
39
|
+
* @param [edits.description] {string}
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
export function applyMetaEdits(meta, { handle, description }) {
|
|
43
|
+
if (handle !== undefined) {
|
|
44
|
+
if (handle === '') {
|
|
45
|
+
delete meta.handle;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
meta.handle = handle;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (description !== undefined) {
|
|
52
|
+
if (description === '') {
|
|
53
|
+
delete meta.description;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
meta.description = description;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Write the `.meta.json` metadata sidecar of a freshly saved wallet item: the
|
|
62
|
+
* creation timestamp plus the handle and description when given. When
|
|
63
|
+
* `mergeExisting` is set, any existing sidecar is loaded first and its fields
|
|
64
|
+
* take precedence over `created` (so re-saving an already-stored item keeps
|
|
65
|
+
* its original timestamp) -- used by `vc import` / `vc issue --save`, which may
|
|
66
|
+
* re-store a credential that is already in the wallet.
|
|
67
|
+
*
|
|
68
|
+
* @param options {object}
|
|
69
|
+
* @param options.collection {string}
|
|
70
|
+
* @param options.storageId {string}
|
|
71
|
+
* @param options.created {string}
|
|
72
|
+
* @param [options.handle] {string}
|
|
73
|
+
* @param [options.description] {string}
|
|
74
|
+
* @param [options.mergeExisting] {boolean}
|
|
75
|
+
* @returns {Promise<void>}
|
|
76
|
+
*/
|
|
77
|
+
export async function writeCreateMeta({ collection, storageId, created, handle, description, mergeExisting }) {
|
|
78
|
+
const existing = mergeExisting
|
|
79
|
+
? await loadMetaFromCollection({ collection, storageId })
|
|
80
|
+
: undefined;
|
|
81
|
+
const meta = { created, ...existing };
|
|
82
|
+
if (handle) {
|
|
83
|
+
meta.handle = handle;
|
|
84
|
+
}
|
|
85
|
+
if (description) {
|
|
86
|
+
meta.description = description;
|
|
87
|
+
}
|
|
88
|
+
await saveMetaToCollection({ collection, storageId, meta });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolve a wallet item reference, reporting failures to stderr and returning
|
|
92
|
+
* undefined: prints the thrown error message on an ambiguous handle, or the
|
|
93
|
+
* standard "No locally stored <noun> found for <ref>" message when nothing
|
|
94
|
+
* matches. Collapses the resolve-then-validate preamble shared by the
|
|
95
|
+
* `show` / `meta` / `remove` subcommands; callers do `if (!resolved) return 1`.
|
|
96
|
+
*
|
|
97
|
+
* @param options {object}
|
|
98
|
+
* @param options.resolve {(ref: string) => Promise<T | undefined>}
|
|
99
|
+
* @param options.ref {string}
|
|
100
|
+
* @param options.noun {string} The item noun for the not-found message.
|
|
101
|
+
* @returns {Promise<T | undefined>}
|
|
102
|
+
*/
|
|
103
|
+
export async function resolveRefOrReport({ resolve, ref, noun }) {
|
|
104
|
+
let resolved;
|
|
105
|
+
try {
|
|
106
|
+
resolved = await resolve(ref);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
console.error(err.message);
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
if (!resolved) {
|
|
113
|
+
console.error(`No locally stored ${noun} found for ${ref}`);
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return resolved;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Render a wallet collection listing: one id per line with `plain`, a JSON
|
|
120
|
+
* array with `json`, an empty result as no output, otherwise a column-aligned
|
|
121
|
+
* table. Shared by `vc list`, `key list`, and `zcap list`; each caller
|
|
122
|
+
* supplies how to load an item, project it to a row / JSON object, and the
|
|
123
|
+
* table columns. A `toEntry` returning undefined drops the item from the
|
|
124
|
+
* non-plain output (e.g. an id-less zcap).
|
|
125
|
+
*
|
|
126
|
+
* @param options {object}
|
|
127
|
+
* @param options.collection {string}
|
|
128
|
+
* @param [options.plain] {boolean}
|
|
129
|
+
* @param [options.json] {boolean}
|
|
130
|
+
* @param options.plainId {(item: Item, storageId: string) => string | undefined}
|
|
131
|
+
* The id to print in `--plain` mode; undefined skips the item.
|
|
132
|
+
* @param options.toEntry {(args: {storageId: string, item: Item, meta?: KeyMetadata}) => Entry | undefined | Promise<Entry | undefined>}
|
|
133
|
+
* @param options.toJson {(entry: Entry) => object}
|
|
134
|
+
* @param options.columns {Column[]}
|
|
135
|
+
* @param options.toRow {(entry: Entry) => string[]}
|
|
136
|
+
* @returns {Promise<number>} The process exit code.
|
|
137
|
+
*/
|
|
138
|
+
export async function runListCollection({ collection, plain, json, plainId, toEntry, toJson, columns, toRow }) {
|
|
139
|
+
const storageIds = await listCollection(collection);
|
|
140
|
+
if (plain) {
|
|
141
|
+
const ids = [];
|
|
142
|
+
for (const storageId of storageIds) {
|
|
143
|
+
const item = await loadFromCollection({ collection, storageId });
|
|
144
|
+
const id = plainId(item, storageId);
|
|
145
|
+
if (id !== undefined) {
|
|
146
|
+
ids.push(id);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
ids.sort();
|
|
150
|
+
for (const id of ids) {
|
|
151
|
+
console.log(id);
|
|
152
|
+
}
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
const entries = [];
|
|
156
|
+
for (const storageId of storageIds) {
|
|
157
|
+
const item = await loadFromCollection({ collection, storageId });
|
|
158
|
+
const meta = await loadMetaFromCollection({
|
|
159
|
+
collection,
|
|
160
|
+
storageId
|
|
161
|
+
});
|
|
162
|
+
const entry = await toEntry({ storageId, item, meta });
|
|
163
|
+
if (entry !== undefined) {
|
|
164
|
+
entries.push(entry);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (json) {
|
|
168
|
+
console.log(JSON.stringify(entries.map(toJson), null, 2));
|
|
169
|
+
return 0;
|
|
170
|
+
}
|
|
171
|
+
if (entries.length === 0) {
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
console.log(renderTable({ columns, rows: entries.map(toRow) }));
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Show or edit the metadata of a wallet item (by id or handle): with no
|
|
179
|
+
* `--handle` / `--description` edits, prints the current metadata; otherwise
|
|
180
|
+
* applies the set-or-clear edits, saves the sidecar, and prints the result.
|
|
181
|
+
* Shared by `vc meta` and `zcap meta`. (`key meta` keeps its own runner: it
|
|
182
|
+
* additionally backfills the created date and refreshes the cached DID
|
|
183
|
+
* associations.)
|
|
184
|
+
*
|
|
185
|
+
* @param options {object}
|
|
186
|
+
* @param options.collection {string}
|
|
187
|
+
* @param options.noun {string}
|
|
188
|
+
* @param options.resolve {(ref: string) => Promise<{storageId: string, meta?: ItemMetadata} | undefined>}
|
|
189
|
+
* @param options.ref {string}
|
|
190
|
+
* @param [options.handle] {string}
|
|
191
|
+
* @param [options.description] {string}
|
|
192
|
+
* @returns {Promise<number>} The process exit code.
|
|
193
|
+
*/
|
|
194
|
+
export async function runMetaCollection({ collection, noun, resolve, ref, handle, description }) {
|
|
195
|
+
const resolved = await resolveRefOrReport({ resolve, ref, noun });
|
|
196
|
+
if (!resolved) {
|
|
197
|
+
return 1;
|
|
198
|
+
}
|
|
199
|
+
const hasEdits = handle !== undefined || description !== undefined;
|
|
200
|
+
if (!hasEdits) {
|
|
201
|
+
console.log(JSON.stringify(resolved.meta ?? {}, null, 2));
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
const meta = { ...(resolved.meta ?? {}) };
|
|
205
|
+
applyMetaEdits(meta, { handle, description });
|
|
206
|
+
const filePath = await saveMetaToCollection({
|
|
207
|
+
collection,
|
|
208
|
+
storageId: resolved.storageId,
|
|
209
|
+
meta
|
|
210
|
+
});
|
|
211
|
+
console.error(`Metadata saved to ${filePath}`);
|
|
212
|
+
console.log(JSON.stringify(meta, null, 2));
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Resolve a wallet item by reference and remove it (and its metadata sidecar),
|
|
217
|
+
* printing each removed file path to stderr. Shared by `vc remove`,
|
|
218
|
+
* `key remove`, and `zcap remove`.
|
|
219
|
+
*
|
|
220
|
+
* @param options {object}
|
|
221
|
+
* @param options.collection {string}
|
|
222
|
+
* @param options.noun {string}
|
|
223
|
+
* @param options.resolve {(ref: string) => Promise<{storageId: string} | undefined>}
|
|
224
|
+
* @param options.ref {string}
|
|
225
|
+
* @returns {Promise<number>} The process exit code.
|
|
226
|
+
*/
|
|
227
|
+
export async function runRemoveCollection({ collection, noun, resolve, ref }) {
|
|
228
|
+
const resolved = await resolveRefOrReport({ resolve, ref, noun });
|
|
229
|
+
if (!resolved) {
|
|
230
|
+
return 1;
|
|
231
|
+
}
|
|
232
|
+
const removed = await removeFromCollection({
|
|
233
|
+
collection,
|
|
234
|
+
storageId: resolved.storageId
|
|
235
|
+
});
|
|
236
|
+
for (const filePath of removed) {
|
|
237
|
+
console.error(`Removed ${filePath}`);
|
|
238
|
+
}
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=collection-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-command.js","sourceRoot":"","sources":["../../src/commands/collection-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,IAAI,EACJ,MAAM,EACN,WAAW,EAKZ;IACC,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,CAAC,IAAI,CAAC,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EAAE,QAAQ,CAAC,SAAS;KAC9B,CAAC,CAAA;IACF,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verification relationships a newly created did:webvh document key is wired
|
|
3
|
+
* into -- everything but keyAgreement, which needs an X25519 key. Also the
|
|
4
|
+
* `add-key` default purpose set (described in its help text).
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_VERIFICATION_PURPOSES: readonly ["authentication", "assertionMethod", "capabilityDelegation", "capabilityInvocation"];
|
|
7
|
+
/**
|
|
8
|
+
* Create a new DID of the given method (key, web, or webvh), optionally saving
|
|
9
|
+
* its document, keys, and metadata to local storage, and print it to stdout.
|
|
10
|
+
*
|
|
11
|
+
* @param options {object}
|
|
12
|
+
* @param [options.method] {string} DID method: key (default), web, or webvh.
|
|
13
|
+
* @param options.type {string} Key type (ed25519 or ecdsa).
|
|
14
|
+
* @param options.curve {string} ECDSA curve, for --type ecdsa.
|
|
15
|
+
* @param [options.url] {string} HTTPS url (required for did:web/did:webvh).
|
|
16
|
+
* @param [options.prerotation] {boolean} Arm did:webvh key pre-rotation.
|
|
17
|
+
* @param [options.portable] {boolean} Create a portable did:webvh.
|
|
18
|
+
* @param [options.witness] {string[]} did:webvh witness did:key DIDs.
|
|
19
|
+
* @param [options.witnessThreshold] {string} Required witness approvals.
|
|
20
|
+
* @param [options.watcher] {string[]} did:webvh watcher URLs.
|
|
21
|
+
* @param [options.withSeed] {boolean} Include/derive the secret key seed.
|
|
22
|
+
* @param [options.save] {boolean} Save the DID to local storage.
|
|
23
|
+
* @param [options.handle] {string} Short tag stored in the metadata sidecar.
|
|
24
|
+
* @param [options.description] {string} Longer description for the sidecar.
|
|
25
|
+
* @returns {Promise<number>} The process exit code.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runCreate(options: {
|
|
28
|
+
method?: string;
|
|
29
|
+
type: string;
|
|
30
|
+
curve: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
prerotation?: boolean;
|
|
33
|
+
portable?: boolean;
|
|
34
|
+
witness?: string[];
|
|
35
|
+
witnessThreshold?: string;
|
|
36
|
+
watcher?: string[];
|
|
37
|
+
withSeed?: boolean;
|
|
38
|
+
save?: boolean;
|
|
39
|
+
handle?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Add a verification key to an existing (locally stored) did:web document,
|
|
44
|
+
* re-save the document and keys file, and print the updated document.
|
|
45
|
+
*
|
|
46
|
+
* @param options {object}
|
|
47
|
+
* @param options.did {string} The did:web DID to add a key to.
|
|
48
|
+
* @param options.type {string} Key type: ed25519, ecdsa, or x25519.
|
|
49
|
+
* @param options.curve {string} ECDSA curve, for --type ecdsa.
|
|
50
|
+
* @param [options.purpose] {string[]} Verification relationship(s) to wire
|
|
51
|
+
* the key into.
|
|
52
|
+
* @param [options.withSeed] {boolean} Include/derive the secret key seed
|
|
53
|
+
* (ed25519 only).
|
|
54
|
+
* @returns {Promise<number>} The process exit code.
|
|
55
|
+
*/
|
|
56
|
+
export declare function runAddKey(options: {
|
|
57
|
+
did: string;
|
|
58
|
+
type: string;
|
|
59
|
+
curve: string;
|
|
60
|
+
purpose?: string[];
|
|
61
|
+
withSeed?: boolean;
|
|
62
|
+
}): Promise<number>;
|
|
63
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/did/create.ts"],"names":[],"mappings":"AAsCA;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,gGAKhC,CAAA;AAuJV;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6XlB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsIlB"}
|