@interop/did-cli 0.7.1 → 0.9.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/CHANGELOG.md +130 -0
- package/README.md +335 -6
- package/dist/commands/did.d.ts.map +1 -1
- package/dist/commands/did.js +66 -18
- package/dist/commands/did.js.map +1 -1
- package/dist/commands/edv.d.ts +63 -0
- package/dist/commands/edv.d.ts.map +1 -0
- package/dist/commands/edv.js +627 -0
- package/dist/commands/edv.js.map +1 -0
- package/dist/commands/key.d.ts.map +1 -1
- package/dist/commands/key.js +87 -13
- package/dist/commands/key.js.map +1 -1
- package/dist/commands/was/collection.d.ts +121 -0
- package/dist/commands/was/collection.d.ts.map +1 -0
- package/dist/commands/was/collection.js +316 -0
- package/dist/commands/was/collection.js.map +1 -0
- package/dist/commands/was/policy.d.ts +50 -0
- package/dist/commands/was/policy.d.ts.map +1 -0
- package/dist/commands/was/policy.js +133 -0
- package/dist/commands/was/policy.js.map +1 -0
- package/dist/commands/was/publish.d.ts +67 -0
- package/dist/commands/was/publish.d.ts.map +1 -0
- package/dist/commands/was/publish.js +151 -0
- package/dist/commands/was/publish.js.map +1 -0
- package/dist/commands/was/resource.d.ts +148 -0
- package/dist/commands/was/resource.d.ts.map +1 -0
- package/dist/commands/was/resource.js +402 -0
- package/dist/commands/was/resource.js.map +1 -0
- package/dist/commands/was/shared.d.ts +156 -0
- package/dist/commands/was/shared.d.ts.map +1 -0
- package/dist/commands/was/shared.js +237 -0
- package/dist/commands/was/shared.js.map +1 -0
- package/dist/commands/was/space.d.ts +196 -0
- package/dist/commands/was/space.d.ts.map +1 -0
- package/dist/commands/was/space.js +516 -0
- package/dist/commands/was/space.js.map +1 -0
- package/dist/commands/was/tree.d.ts +44 -0
- package/dist/commands/was/tree.d.ts.map +1 -0
- package/dist/commands/was/tree.js +135 -0
- package/dist/commands/was/tree.js.map +1 -0
- package/dist/commands/was.d.ts +29 -496
- package/dist/commands/was.d.ts.map +1 -1
- package/dist/commands/was.js +84 -1473
- package/dist/commands/was.js.map +1 -1
- package/dist/commands/zcap.d.ts +22 -2
- package/dist/commands/zcap.d.ts.map +1 -1
- package/dist/commands/zcap.js +6 -20
- package/dist/commands/zcap.js.map +1 -1
- package/dist/edv/core.d.ts +60 -0
- package/dist/edv/core.d.ts.map +1 -0
- package/dist/edv/core.js +75 -0
- package/dist/edv/core.js.map +1 -0
- package/dist/edv/document.d.ts +25 -0
- package/dist/edv/document.d.ts.map +1 -0
- package/dist/edv/document.js +19 -0
- package/dist/edv/document.js.map +1 -0
- package/dist/edv/hmac.d.ts +26 -0
- package/dist/edv/hmac.d.ts.map +1 -0
- package/dist/edv/hmac.js +67 -0
- package/dist/edv/hmac.js.map +1 -0
- package/dist/edv/recipients.d.ts +65 -0
- package/dist/edv/recipients.d.ts.map +1 -0
- package/dist/edv/recipients.js +253 -0
- package/dist/edv/recipients.js.map +1 -0
- package/dist/edv/stream.d.ts +69 -0
- package/dist/edv/stream.d.ts.map +1 -0
- package/dist/edv/stream.js +169 -0
- package/dist/edv/stream.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/meta.d.ts +1 -0
- package/dist/meta.d.ts.map +1 -1
- package/dist/meta.js +1 -1
- package/dist/meta.js.map +1 -1
- package/dist/storage.d.ts +6 -4
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -5
- package/dist/storage.js.map +1 -1
- package/dist/was/capability.d.ts +10 -13
- package/dist/was/capability.d.ts.map +1 -1
- package/dist/was/capability.js +1 -59
- package/dist/was/capability.js.map +1 -1
- package/dist/was/io.d.ts +14 -0
- package/dist/was/io.d.ts.map +1 -1
- package/dist/was/io.js +20 -7
- package/dist/was/io.js.map +1 -1
- package/dist/zcap/delegate.d.ts +2 -2
- package/dist/zcap/delegate.js +2 -2
- package/dist/zcap/resolve.d.ts +15 -0
- package/dist/zcap/resolve.d.ts.map +1 -0
- package/dist/zcap/resolve.js +55 -0
- package/dist/zcap/resolve.js.map +1 -0
- package/package.json +17 -14
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `was collection` run functions: create, list, show, update, delete, and the
|
|
3
|
+
* read-only `backend` (the storage backend the collection is stored on) and
|
|
4
|
+
* `quota` (the collection's storage usage, scoped to that backend) for a
|
|
5
|
+
* collection within a space.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveWasTarget } from '../../was/client.js';
|
|
8
|
+
import { renderTable } from '../../table.js';
|
|
9
|
+
import { parseSpaceAddress, printCollectionListing, reportError, requireCollectionTarget, wasUrl } from './shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a collection within a space and prints `{ id, url, name? }`.
|
|
12
|
+
*
|
|
13
|
+
* @param options {object}
|
|
14
|
+
* @param options.address {string} The space address.
|
|
15
|
+
* @param [options.name] {string} The collection's display name.
|
|
16
|
+
* @param [options.id] {string} A caller-chosen collection id.
|
|
17
|
+
* @param [options.server] {string} The server base URL.
|
|
18
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
19
|
+
* @returns {Promise<number>} The process exit code.
|
|
20
|
+
*/
|
|
21
|
+
export async function runCollectionCreate(options) {
|
|
22
|
+
try {
|
|
23
|
+
parseSpaceAddress(options.address);
|
|
24
|
+
const target = await resolveWasTarget({
|
|
25
|
+
address: options.address,
|
|
26
|
+
server: options.server,
|
|
27
|
+
did: options.did
|
|
28
|
+
});
|
|
29
|
+
const collection = await target.client
|
|
30
|
+
.space(target.spaceId)
|
|
31
|
+
.createCollection({
|
|
32
|
+
...(options.name !== undefined && { name: options.name }),
|
|
33
|
+
...(options.id !== undefined && { id: options.id })
|
|
34
|
+
});
|
|
35
|
+
const url = wasUrl({
|
|
36
|
+
server: target.server,
|
|
37
|
+
spaceId: target.spaceId,
|
|
38
|
+
collectionId: collection.id
|
|
39
|
+
});
|
|
40
|
+
console.log(JSON.stringify({
|
|
41
|
+
id: collection.id,
|
|
42
|
+
url,
|
|
43
|
+
...(options.name !== undefined && { name: options.name })
|
|
44
|
+
}, null, 2));
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return reportError({ action: 'create the collection', err });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Lists the collections in a space.
|
|
53
|
+
*
|
|
54
|
+
* @param options {object}
|
|
55
|
+
* @param options.address {string} The space address.
|
|
56
|
+
* @param [options.json] {boolean} Output the raw listing JSON.
|
|
57
|
+
* @param [options.plain] {boolean} Output one collection id per line.
|
|
58
|
+
* @param [options.server] {string} The server base URL.
|
|
59
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
60
|
+
* @returns {Promise<number>} The process exit code.
|
|
61
|
+
*/
|
|
62
|
+
export async function runCollectionList(options) {
|
|
63
|
+
try {
|
|
64
|
+
parseSpaceAddress(options.address);
|
|
65
|
+
const target = await resolveWasTarget({
|
|
66
|
+
address: options.address,
|
|
67
|
+
server: options.server,
|
|
68
|
+
did: options.did
|
|
69
|
+
});
|
|
70
|
+
const listing = await target.client.space(target.spaceId).collections();
|
|
71
|
+
if (listing === null) {
|
|
72
|
+
console.error('Not found (or not visible to you): ' +
|
|
73
|
+
wasUrl({ server: target.server, spaceId: target.spaceId }));
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
printCollectionListing({
|
|
77
|
+
listing,
|
|
78
|
+
json: options.json,
|
|
79
|
+
plain: options.plain
|
|
80
|
+
});
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return reportError({ action: 'list collections', err });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Shows a collection's description from the server.
|
|
89
|
+
*
|
|
90
|
+
* @param options {object}
|
|
91
|
+
* @param options.address {string} The collection address.
|
|
92
|
+
* @param [options.server] {string} The server base URL.
|
|
93
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
94
|
+
* @returns {Promise<number>} The process exit code.
|
|
95
|
+
*/
|
|
96
|
+
export async function runCollectionShow(options) {
|
|
97
|
+
try {
|
|
98
|
+
const target = requireCollectionTarget({
|
|
99
|
+
target: await resolveWasTarget({
|
|
100
|
+
address: options.address,
|
|
101
|
+
server: options.server,
|
|
102
|
+
did: options.did
|
|
103
|
+
}),
|
|
104
|
+
address: options.address
|
|
105
|
+
});
|
|
106
|
+
const description = await target.client
|
|
107
|
+
.space(target.spaceId)
|
|
108
|
+
.collection(target.collectionId)
|
|
109
|
+
.describe();
|
|
110
|
+
if (description === null) {
|
|
111
|
+
console.error('Not found (or not visible to you): ' +
|
|
112
|
+
wasUrl({
|
|
113
|
+
server: target.server,
|
|
114
|
+
spaceId: target.spaceId,
|
|
115
|
+
collectionId: target.collectionId
|
|
116
|
+
}));
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
console.log(JSON.stringify(description, null, 2));
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return reportError({ action: 'show the collection', err });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Updates a collection's description fields on the server (upsert via
|
|
128
|
+
* `configure()`).
|
|
129
|
+
*
|
|
130
|
+
* @param options {object}
|
|
131
|
+
* @param options.address {string} The collection address.
|
|
132
|
+
* @param options.name {string} The collection's new display name.
|
|
133
|
+
* @param [options.server] {string} The server base URL.
|
|
134
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
135
|
+
* @returns {Promise<number>} The process exit code.
|
|
136
|
+
*/
|
|
137
|
+
export async function runCollectionUpdate(options) {
|
|
138
|
+
try {
|
|
139
|
+
const target = requireCollectionTarget({
|
|
140
|
+
target: await resolveWasTarget({
|
|
141
|
+
address: options.address,
|
|
142
|
+
server: options.server,
|
|
143
|
+
did: options.did
|
|
144
|
+
}),
|
|
145
|
+
address: options.address
|
|
146
|
+
});
|
|
147
|
+
const description = await target.client
|
|
148
|
+
.space(target.spaceId)
|
|
149
|
+
.collection(target.collectionId)
|
|
150
|
+
.configure({ name: options.name });
|
|
151
|
+
console.log(JSON.stringify(description, null, 2));
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
return reportError({ action: 'update the collection', err });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deletes a whole collection and its contents on the server. Idempotent.
|
|
160
|
+
*
|
|
161
|
+
* @param options {object}
|
|
162
|
+
* @param options.address {string} The collection address.
|
|
163
|
+
* @param [options.server] {string} The server base URL.
|
|
164
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
165
|
+
* @returns {Promise<number>} The process exit code.
|
|
166
|
+
*/
|
|
167
|
+
export async function runCollectionDelete(options) {
|
|
168
|
+
try {
|
|
169
|
+
const target = requireCollectionTarget({
|
|
170
|
+
target: await resolveWasTarget({
|
|
171
|
+
address: options.address,
|
|
172
|
+
server: options.server,
|
|
173
|
+
did: options.did
|
|
174
|
+
}),
|
|
175
|
+
address: options.address
|
|
176
|
+
});
|
|
177
|
+
await target.client
|
|
178
|
+
.space(target.spaceId)
|
|
179
|
+
.collection(target.collectionId)
|
|
180
|
+
.delete();
|
|
181
|
+
console.error('Deleted ' +
|
|
182
|
+
wasUrl({
|
|
183
|
+
server: target.server,
|
|
184
|
+
spaceId: target.spaceId,
|
|
185
|
+
collectionId: target.collectionId
|
|
186
|
+
}) +
|
|
187
|
+
' on the server.');
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
return reportError({ action: 'delete the collection', err });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Shows the storage backend a collection is stored on (its "Collection Backend
|
|
196
|
+
* Selected" descriptor). A missing/not-visible collection returns `null` (a
|
|
197
|
+
* 404), reported as not-found; a server without backend support surfaces its
|
|
198
|
+
* 501 as a typed error.
|
|
199
|
+
*
|
|
200
|
+
* @param options {object}
|
|
201
|
+
* @param options.address {string} The collection address.
|
|
202
|
+
* @param [options.json] {boolean} Output the raw backend JSON.
|
|
203
|
+
* @param [options.server] {string} The server base URL.
|
|
204
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
205
|
+
* @returns {Promise<number>} The process exit code.
|
|
206
|
+
*/
|
|
207
|
+
export async function runCollectionBackend(options) {
|
|
208
|
+
try {
|
|
209
|
+
const target = requireCollectionTarget({
|
|
210
|
+
target: await resolveWasTarget({
|
|
211
|
+
address: options.address,
|
|
212
|
+
server: options.server,
|
|
213
|
+
did: options.did
|
|
214
|
+
}),
|
|
215
|
+
address: options.address
|
|
216
|
+
});
|
|
217
|
+
const backend = await target.client
|
|
218
|
+
.space(target.spaceId)
|
|
219
|
+
.collection(target.collectionId)
|
|
220
|
+
.backend();
|
|
221
|
+
if (backend === null) {
|
|
222
|
+
console.error('Not found (or not visible to you): ' +
|
|
223
|
+
wasUrl({
|
|
224
|
+
server: target.server,
|
|
225
|
+
spaceId: target.spaceId,
|
|
226
|
+
collectionId: target.collectionId
|
|
227
|
+
}));
|
|
228
|
+
return 1;
|
|
229
|
+
}
|
|
230
|
+
if (options.json) {
|
|
231
|
+
console.log(JSON.stringify(backend, null, 2));
|
|
232
|
+
return 0;
|
|
233
|
+
}
|
|
234
|
+
const rows = [
|
|
235
|
+
['ID', backend.id],
|
|
236
|
+
['Name', backend.name ?? ''],
|
|
237
|
+
['Managed By', backend.managedBy ?? ''],
|
|
238
|
+
['Storage Mode', backend.storageMode?.join(', ') ?? ''],
|
|
239
|
+
['Persistence', backend.persistence ?? '']
|
|
240
|
+
];
|
|
241
|
+
console.log(renderTable({
|
|
242
|
+
columns: [{ header: 'FIELD' }, { header: 'VALUE' }],
|
|
243
|
+
rows
|
|
244
|
+
}));
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
return reportError({ action: 'show the collection backend', err });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Shows a collection's storage usage report, scoped to its backend (one
|
|
253
|
+
* `BackendUsage` entry: state, usage, limit, and any restricted actions). A
|
|
254
|
+
* missing/not-visible collection returns `null` (a 404), reported as
|
|
255
|
+
* not-found; a backend that cannot account per-collection surfaces its 501 as
|
|
256
|
+
* a typed error.
|
|
257
|
+
*
|
|
258
|
+
* @param options {object}
|
|
259
|
+
* @param options.address {string} The collection address.
|
|
260
|
+
* @param [options.json] {boolean} Output the raw usage JSON.
|
|
261
|
+
* @param [options.server] {string} The server base URL.
|
|
262
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
263
|
+
* @returns {Promise<number>} The process exit code.
|
|
264
|
+
*/
|
|
265
|
+
export async function runCollectionQuota(options) {
|
|
266
|
+
try {
|
|
267
|
+
const target = requireCollectionTarget({
|
|
268
|
+
target: await resolveWasTarget({
|
|
269
|
+
address: options.address,
|
|
270
|
+
server: options.server,
|
|
271
|
+
did: options.did
|
|
272
|
+
}),
|
|
273
|
+
address: options.address
|
|
274
|
+
});
|
|
275
|
+
const usage = await target.client
|
|
276
|
+
.space(target.spaceId)
|
|
277
|
+
.collection(target.collectionId)
|
|
278
|
+
.quota();
|
|
279
|
+
if (usage === null) {
|
|
280
|
+
console.error('Not found (or not visible to you): ' +
|
|
281
|
+
wasUrl({
|
|
282
|
+
server: target.server,
|
|
283
|
+
spaceId: target.spaceId,
|
|
284
|
+
collectionId: target.collectionId
|
|
285
|
+
}));
|
|
286
|
+
return 1;
|
|
287
|
+
}
|
|
288
|
+
if (options.json) {
|
|
289
|
+
console.log(JSON.stringify(usage, null, 2));
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
292
|
+
const rows = [
|
|
293
|
+
['Backend', usage.name ? `${usage.id} (${usage.name})` : usage.id],
|
|
294
|
+
['Managed By', usage.managedBy],
|
|
295
|
+
['State', usage.state],
|
|
296
|
+
['Usage (B)', String(usage.usageBytes)],
|
|
297
|
+
[
|
|
298
|
+
'Limit (B)',
|
|
299
|
+
usage.limit.isUnlimited
|
|
300
|
+
? 'unlimited'
|
|
301
|
+
: String(usage.limit.capacityBytes ?? '')
|
|
302
|
+
],
|
|
303
|
+
['Restricted', usage.restrictedActions.join(', ')],
|
|
304
|
+
['Measured At', usage.measuredAt]
|
|
305
|
+
];
|
|
306
|
+
console.log(renderTable({
|
|
307
|
+
columns: [{ header: 'FIELD' }, { header: 'VALUE' }],
|
|
308
|
+
rows
|
|
309
|
+
}));
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
catch (err) {
|
|
313
|
+
return reportError({ action: 'get the collection quota', err });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/commands/was/collection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,uBAAuB,EACvB,MAAM,EACP,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAMzC;IACC,IAAI,CAAC;QACH,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAClC,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAA;QACF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM;aACnC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;aACrB,gBAAgB,CAAC;YAChB,GAAG,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CAAC,WAAW;oBACrB,CAAC,CAAC,WAAW;oBACb,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC;aAC5C;YACD,CAAC,YAAY,EAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC;SAClC,CAAA;QACD,OAAO,CAAC,GAAG,CACT,WAAW,CAAC;YACV,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YACnD,IAAI;SACL,CAAC,CACH,CAAA;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shows the access-control policy of a space, collection, or resource.
|
|
3
|
+
*
|
|
4
|
+
* @param options {object}
|
|
5
|
+
* @param options.address {string} A space/collection/resource address.
|
|
6
|
+
* @param [options.server] {string} The server base URL.
|
|
7
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
8
|
+
* @returns {Promise<number>} The process exit code.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runPolicyShow(options: {
|
|
11
|
+
address: string;
|
|
12
|
+
server?: string;
|
|
13
|
+
did?: string;
|
|
14
|
+
}): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Sets (creates or replaces) the access-control policy of a space,
|
|
17
|
+
* collection, or resource, and prints the policy document that was set.
|
|
18
|
+
*
|
|
19
|
+
* @param options {object}
|
|
20
|
+
* @param options.address {string} A space/collection/resource address.
|
|
21
|
+
* @param [options.file] {string} A policy JSON file.
|
|
22
|
+
* @param [options.type] {string} A simple type-only policy (e.g.
|
|
23
|
+
* PublicCanRead).
|
|
24
|
+
* @param [options.server] {string} The server base URL.
|
|
25
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
26
|
+
* @returns {Promise<number>} The process exit code.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runPolicySet(options: {
|
|
29
|
+
address: string;
|
|
30
|
+
file?: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
server?: string;
|
|
33
|
+
did?: string;
|
|
34
|
+
}): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Removes the access-control policy of a space, collection, or resource,
|
|
37
|
+
* reverting it to capability-only access. Idempotent.
|
|
38
|
+
*
|
|
39
|
+
* @param options {object}
|
|
40
|
+
* @param options.address {string} A space/collection/resource address.
|
|
41
|
+
* @param [options.server] {string} The server base URL.
|
|
42
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
43
|
+
* @returns {Promise<number>} The process exit code.
|
|
44
|
+
*/
|
|
45
|
+
export declare function runPolicyClear(options: {
|
|
46
|
+
address: string;
|
|
47
|
+
server?: string;
|
|
48
|
+
did?: string;
|
|
49
|
+
}): Promise<number>;
|
|
50
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/commands/was/policy.ts"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBlB;AAiDD;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAclB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `was policy` run functions: show, set (from `--type` or a JSON file), and
|
|
3
|
+
* clear the access-control policy of a space, collection, or resource.
|
|
4
|
+
*/
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { resolveWasTarget } from '../../was/client.js';
|
|
7
|
+
import { handleForTarget, reportError } from './shared.js';
|
|
8
|
+
/**
|
|
9
|
+
* Shows the access-control policy of a space, collection, or resource.
|
|
10
|
+
*
|
|
11
|
+
* @param options {object}
|
|
12
|
+
* @param options.address {string} A space/collection/resource address.
|
|
13
|
+
* @param [options.server] {string} The server base URL.
|
|
14
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
15
|
+
* @returns {Promise<number>} The process exit code.
|
|
16
|
+
*/
|
|
17
|
+
export async function runPolicyShow(options) {
|
|
18
|
+
try {
|
|
19
|
+
const target = await resolveWasTarget({
|
|
20
|
+
address: options.address,
|
|
21
|
+
server: options.server,
|
|
22
|
+
did: options.did
|
|
23
|
+
});
|
|
24
|
+
const { handle, url } = handleForTarget(target);
|
|
25
|
+
const policy = await handle.getPolicy();
|
|
26
|
+
if (policy === null) {
|
|
27
|
+
console.error(`No policy set (or not visible to you): ${url}`);
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
return reportError({ action: 'show the policy', err });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parses the `policy set` arguments -- `--type <type>` for a simple
|
|
39
|
+
* type-only policy, or a JSON file for richer ones -- into a policy
|
|
40
|
+
* document.
|
|
41
|
+
*
|
|
42
|
+
* @param options {object}
|
|
43
|
+
* @param [options.type] {string}
|
|
44
|
+
* @param [options.file] {string}
|
|
45
|
+
* @returns {Promise<PolicyDocument>}
|
|
46
|
+
*/
|
|
47
|
+
async function resolvePolicyInput({ type, file }) {
|
|
48
|
+
if (type && file) {
|
|
49
|
+
throw new Error('Provide either --type or a policy file, not both.');
|
|
50
|
+
}
|
|
51
|
+
if (type) {
|
|
52
|
+
return { type };
|
|
53
|
+
}
|
|
54
|
+
if (!file) {
|
|
55
|
+
throw new Error('Provide --type <type> or a policy JSON file.');
|
|
56
|
+
}
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = JSON.parse(await readFile(file, 'utf8'));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
throw new Error(`${file} does not contain policy JSON: ` +
|
|
63
|
+
`${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
64
|
+
}
|
|
65
|
+
if (parsed === null ||
|
|
66
|
+
typeof parsed !== 'object' ||
|
|
67
|
+
Array.isArray(parsed) ||
|
|
68
|
+
typeof parsed.type !== 'string') {
|
|
69
|
+
throw new Error(`${file} must hold a policy object with a "type" field.`);
|
|
70
|
+
}
|
|
71
|
+
return parsed;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Sets (creates or replaces) the access-control policy of a space,
|
|
75
|
+
* collection, or resource, and prints the policy document that was set.
|
|
76
|
+
*
|
|
77
|
+
* @param options {object}
|
|
78
|
+
* @param options.address {string} A space/collection/resource address.
|
|
79
|
+
* @param [options.file] {string} A policy JSON file.
|
|
80
|
+
* @param [options.type] {string} A simple type-only policy (e.g.
|
|
81
|
+
* PublicCanRead).
|
|
82
|
+
* @param [options.server] {string} The server base URL.
|
|
83
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
84
|
+
* @returns {Promise<number>} The process exit code.
|
|
85
|
+
*/
|
|
86
|
+
export async function runPolicySet(options) {
|
|
87
|
+
try {
|
|
88
|
+
const policy = await resolvePolicyInput({
|
|
89
|
+
type: options.type,
|
|
90
|
+
file: options.file
|
|
91
|
+
});
|
|
92
|
+
const target = await resolveWasTarget({
|
|
93
|
+
address: options.address,
|
|
94
|
+
server: options.server,
|
|
95
|
+
did: options.did
|
|
96
|
+
});
|
|
97
|
+
const { handle, url } = handleForTarget(target);
|
|
98
|
+
await handle.setPolicy(policy);
|
|
99
|
+
console.error(`Policy set on ${url}`);
|
|
100
|
+
console.log(JSON.stringify(policy, null, 2));
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return reportError({ action: 'set the policy', err });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Removes the access-control policy of a space, collection, or resource,
|
|
109
|
+
* reverting it to capability-only access. Idempotent.
|
|
110
|
+
*
|
|
111
|
+
* @param options {object}
|
|
112
|
+
* @param options.address {string} A space/collection/resource address.
|
|
113
|
+
* @param [options.server] {string} The server base URL.
|
|
114
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
115
|
+
* @returns {Promise<number>} The process exit code.
|
|
116
|
+
*/
|
|
117
|
+
export async function runPolicyClear(options) {
|
|
118
|
+
try {
|
|
119
|
+
const target = await resolveWasTarget({
|
|
120
|
+
address: options.address,
|
|
121
|
+
server: options.server,
|
|
122
|
+
did: options.did
|
|
123
|
+
});
|
|
124
|
+
const { handle, url } = handleForTarget(target);
|
|
125
|
+
await handle.clearPolicy();
|
|
126
|
+
console.error(`Cleared the policy on ${url} (capability-only access).`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
return reportError({ action: 'clear the policy', err });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/commands/was/policy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE1D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAInC;IACC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAA;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;QACvC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,0CAA0C,GAAG,EAAE,CAAC,CAAA;YAC9D,OAAO,CAAC,CAAA;QACV,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QAC5C,OAAO,CAAC,CAAA;IACV,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAA;IACxD,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,KAAK,UAAU,kBAAkB,CAAC,EAChC,IAAI,EACJ,IAAI,EAIL;IACC,IAAI,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, collection, or resource world-readable (the
|
|
3
|
+
* `PublicCanRead` policy) and prints its public URL -- the "share via
|
|
4
|
+
* public link" case.
|
|
5
|
+
*
|
|
6
|
+
* @param options {object}
|
|
7
|
+
* @param options.address {string} A space/collection/resource address.
|
|
8
|
+
* @param [options.server] {string} The server base URL.
|
|
9
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
10
|
+
* @returns {Promise<number>} The process exit code.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runPublish(options: {
|
|
13
|
+
address: string;
|
|
14
|
+
server?: string;
|
|
15
|
+
did?: string;
|
|
16
|
+
}): Promise<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Reverts a published space, collection, or resource to capability-only
|
|
19
|
+
* access (clears its policy). Idempotent.
|
|
20
|
+
*
|
|
21
|
+
* @param options {object}
|
|
22
|
+
* @param options.address {string} A space/collection/resource address.
|
|
23
|
+
* @param [options.server] {string} The server base URL.
|
|
24
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
25
|
+
* @returns {Promise<number>} The process exit code.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runUnpublish(options: {
|
|
28
|
+
address: string;
|
|
29
|
+
server?: string;
|
|
30
|
+
did?: string;
|
|
31
|
+
}): Promise<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Delegates access to a space, collection, or resource: signs a capability
|
|
34
|
+
* for the `--to` DID with the given actions and expiration, and prints
|
|
35
|
+
* `{ delegatedCapability, encoded }` (the same shape as `zcap delegate`).
|
|
36
|
+
* `--save` stores the capability in the local zcap store
|
|
37
|
+
* (`~/.config/did-cli-wallet/zcaps/`).
|
|
38
|
+
*
|
|
39
|
+
* @param options {object}
|
|
40
|
+
* @param options.address {string} The space/collection/resource address.
|
|
41
|
+
* @param options.to {string} The delegatee DID (or stored-DID handle).
|
|
42
|
+
* @param options.action {string[]} Allowed actions (HTTP verbs; lowercase
|
|
43
|
+
* accepted).
|
|
44
|
+
* @param [options.ttl] {string} Time-to-live for expiration (default 1y).
|
|
45
|
+
* @param [options.expires] {string} Explicit ISO 8601 expiration
|
|
46
|
+
* (overrides --ttl).
|
|
47
|
+
* @param [options.save] {boolean} Save the capability to the zcap store.
|
|
48
|
+
* @param [options.handle] {string} Short tag for the saved zcap.
|
|
49
|
+
* @param [options.description] {string} Longer description for the saved
|
|
50
|
+
* zcap.
|
|
51
|
+
* @param [options.server] {string} The server base URL.
|
|
52
|
+
* @param [options.did] {string} The signing DID or stored-DID handle.
|
|
53
|
+
* @returns {Promise<number>} The process exit code.
|
|
54
|
+
*/
|
|
55
|
+
export declare function runGrant(options: {
|
|
56
|
+
address: string;
|
|
57
|
+
to: string;
|
|
58
|
+
action: string[];
|
|
59
|
+
ttl?: string;
|
|
60
|
+
expires?: string;
|
|
61
|
+
save?: boolean;
|
|
62
|
+
handle?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
server?: string;
|
|
65
|
+
did?: string;
|
|
66
|
+
}): Promise<number>;
|
|
67
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/was/publish.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAelB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAclB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ClB"}
|