@interop/was-client 0.5.0 → 0.7.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/README.md +166 -0
- package/dist/Collection.d.ts +28 -3
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +74 -13
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +64 -9
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +110 -26
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +4 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +4 -0
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts +10 -2
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +13 -6
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +127 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +2 -0
- package/dist/codec.js.map +1 -0
- package/dist/edv/EdvCodec.d.ts +148 -0
- package/dist/edv/EdvCodec.d.ts.map +1 -0
- package/dist/edv/EdvCodec.js +284 -0
- package/dist/edv/EdvCodec.js.map +1 -0
- package/dist/edv/WasTransport.d.ts +178 -0
- package/dist/edv/WasTransport.d.ts.map +1 -0
- package/dist/edv/WasTransport.js +284 -0
- package/dist/edv/WasTransport.js.map +1 -0
- package/dist/edv/index.d.ts +21 -0
- package/dist/edv/index.d.ts.map +1 -0
- package/dist/edv/index.js +21 -0
- package/dist/edv/index.js.map +1 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codec.d.ts +27 -0
- package/dist/internal/codec.d.ts.map +1 -0
- package/dist/internal/codec.js +44 -0
- package/dist/internal/codec.js.map +1 -0
- package/dist/internal/conditional.d.ts +40 -0
- package/dist/internal/conditional.d.ts.map +1 -0
- package/dist/internal/conditional.js +35 -0
- package/dist/internal/conditional.js.map +1 -0
- package/dist/internal/content.d.ts +30 -1
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +68 -3
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/request.d.ts +5 -1
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +2 -7
- package/dist/internal/request.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -3
package/dist/Resource.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* A navigational handle to a single Resource (a JSON object or binary blob
|
|
6
|
-
* keyed by id within a Collection). Sugar over the Collection item operations,
|
|
7
|
-
* with explicit `getText()` / `getBytes()` escape hatches.
|
|
8
|
-
*/
|
|
9
1
|
import { resourcePath, resourcePolicy, resourceMeta } from './internal/paths.js';
|
|
10
|
-
import { prepareBody, parseResource } from './internal/content.js';
|
|
11
2
|
import { assertNotReserved } from './internal/reserved.js';
|
|
12
3
|
import { send } from './internal/request.js';
|
|
4
|
+
import { resolveCodec } from './internal/codec.js';
|
|
5
|
+
import { writeHeaders, readEtag } from './internal/conditional.js';
|
|
6
|
+
import { ValidationError } from './errors.js';
|
|
13
7
|
export class Resource {
|
|
14
8
|
spaceId;
|
|
15
9
|
collectionId;
|
|
16
10
|
id;
|
|
17
11
|
_context;
|
|
18
12
|
_capability;
|
|
13
|
+
_codecThunk;
|
|
14
|
+
_codecPromise;
|
|
19
15
|
/**
|
|
20
16
|
* @param options {object}
|
|
21
17
|
* @param options.context {ClientContext}
|
|
@@ -23,17 +19,37 @@ export class Resource {
|
|
|
23
19
|
* @param options.collectionId {string}
|
|
24
20
|
* @param options.resourceId {string}
|
|
25
21
|
* @param [options.capability] {IZcap} capability attached to every request
|
|
22
|
+
* @param [options.codec] {function} resolver sharing the parent collection's
|
|
23
|
+
* codec, so a resource handle obtained via `collection.resource(id)` does
|
|
24
|
+
* not repeat the backend() round-trip. A standalone resource resolves its
|
|
25
|
+
* own.
|
|
26
26
|
*/
|
|
27
|
-
constructor({ context, spaceId, collectionId, resourceId, capability }) {
|
|
27
|
+
constructor({ context, spaceId, collectionId, resourceId, capability, codec }) {
|
|
28
28
|
this._context = context;
|
|
29
29
|
this.spaceId = spaceId;
|
|
30
30
|
this.collectionId = collectionId;
|
|
31
31
|
this.id = resourceId;
|
|
32
32
|
this._capability = capability;
|
|
33
|
+
this._codecThunk = codec;
|
|
33
34
|
}
|
|
34
35
|
get _path() {
|
|
35
36
|
return resourcePath(this.spaceId, this.collectionId, this.id);
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolves (once, then caches) the codec for this resource: the parent
|
|
40
|
+
* collection's shared codec when this handle came from
|
|
41
|
+
* `collection.resource(id)`, otherwise one resolved for its own collection.
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<ResourceCodec>}
|
|
44
|
+
*/
|
|
45
|
+
_codec() {
|
|
46
|
+
return (this._codecPromise ??= this._codecThunk
|
|
47
|
+
? this._codecThunk()
|
|
48
|
+
: resolveCodec(this._context, {
|
|
49
|
+
spaceId: this.spaceId,
|
|
50
|
+
collectionId: this.collectionId
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
37
53
|
/**
|
|
38
54
|
* Reads the resource, auto-parsing JSON to an object and returning binary as
|
|
39
55
|
* a `Blob`. Returns `null` if the resource is missing or not visible to you
|
|
@@ -42,17 +58,20 @@ export class Resource {
|
|
|
42
58
|
* @returns {Promise<Json | Blob | null>}
|
|
43
59
|
*/
|
|
44
60
|
async get() {
|
|
61
|
+
const codec = await this._codec();
|
|
45
62
|
const response = await send(this._context, {
|
|
46
63
|
path: this._path,
|
|
47
64
|
method: 'GET',
|
|
48
65
|
capability: this._capability,
|
|
49
66
|
read: true
|
|
50
67
|
});
|
|
51
|
-
return
|
|
68
|
+
return response === null ? null : codec.decode(response);
|
|
52
69
|
}
|
|
53
70
|
/**
|
|
54
71
|
* Reads the resource body as text. Returns `null` on a missing/unauthorized
|
|
55
|
-
* resource (404 conflation caveat).
|
|
72
|
+
* resource (404 conflation caveat). A raw escape hatch: it does NOT run the
|
|
73
|
+
* codec, so on an encrypted collection it never decrypts -- use `get()` to
|
|
74
|
+
* decrypt.
|
|
56
75
|
*
|
|
57
76
|
* @returns {Promise<string | null>}
|
|
58
77
|
*/
|
|
@@ -67,7 +86,9 @@ export class Resource {
|
|
|
67
86
|
}
|
|
68
87
|
/**
|
|
69
88
|
* Reads the resource body as raw bytes. Returns `null` on a
|
|
70
|
-
* missing/unauthorized resource (404 conflation caveat).
|
|
89
|
+
* missing/unauthorized resource (404 conflation caveat). A raw escape hatch:
|
|
90
|
+
* it does NOT run the codec, so on an encrypted collection it never decrypts
|
|
91
|
+
* -- use `get()` to decrypt.
|
|
71
92
|
*
|
|
72
93
|
* @returns {Promise<Uint8Array | null>}
|
|
73
94
|
*/
|
|
@@ -88,36 +109,80 @@ export class Resource {
|
|
|
88
109
|
* objects/arrays, binary for `Blob`/`Uint8Array`. Throws `NotFoundError` if
|
|
89
110
|
* the parent collection does not exist (WAS does not auto-create parents).
|
|
90
111
|
*
|
|
112
|
+
* For binary data with no explicit `contentType` (and no `Blob.type`), the
|
|
113
|
+
* content-type is guessed from the resource id's file extension for common
|
|
114
|
+
* static-web types -- so `resource('index.html').put(bytes)` is sent as
|
|
115
|
+
* `text/html`. An unrecognized/absent extension sends no content-type, and the
|
|
116
|
+
* server applies its own required-`Content-Type` rule.
|
|
117
|
+
*
|
|
118
|
+
* Conditional writes (the backend's `conditional-writes` feature): pass
|
|
119
|
+
* `ifMatch` (the ETag from a prior read/write) for an update-if-unchanged, or
|
|
120
|
+
* `ifNoneMatch: true` for a create-if-absent. A failed precondition throws
|
|
121
|
+
* `PreconditionFailedError` (412). On an encrypted collection these are managed
|
|
122
|
+
* automatically by the codec (the EDV `sequence` becomes the enforced ETag), so
|
|
123
|
+
* the explicit options are for plaintext collections. Returns the new `etag`.
|
|
124
|
+
*
|
|
91
125
|
* @param data {Json | Blob | Uint8Array}
|
|
92
126
|
* @param options {object}
|
|
93
127
|
* @param [options.contentType] {string} content-type for binary data
|
|
94
|
-
* @
|
|
128
|
+
* @param [options.ifMatch] {string} update only if the ETag matches
|
|
129
|
+
* @param [options.ifNoneMatch] {boolean} create only if absent
|
|
130
|
+
* @returns {Promise<{ etag?: string }>} the stored resource's new ETag
|
|
95
131
|
*/
|
|
96
132
|
async put(data, options = {}) {
|
|
97
133
|
assertNotReserved(this.id, 'resource');
|
|
98
|
-
const
|
|
99
|
-
|
|
134
|
+
const codec = await this._codec();
|
|
135
|
+
// A conditional codec (e.g. the EDV codec) needs the current stored envelope
|
|
136
|
+
// to advance its sequence and pin the write to the current ETag, so pre-read
|
|
137
|
+
// it. A plaintext codec needs no pre-read.
|
|
138
|
+
let current;
|
|
139
|
+
if (codec.conditionalWrites) {
|
|
140
|
+
current = await send(this._context, {
|
|
141
|
+
path: this._path,
|
|
142
|
+
method: 'GET',
|
|
143
|
+
capability: this._capability,
|
|
144
|
+
read: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const encoded = await codec.encode({
|
|
148
|
+
id: this.id,
|
|
149
|
+
data,
|
|
150
|
+
contentType: options.contentType,
|
|
151
|
+
current
|
|
152
|
+
});
|
|
153
|
+
// A conditional codec computes the precondition itself (from the sequence /
|
|
154
|
+
// ETag); a plaintext codec defers to the caller's explicit options.
|
|
155
|
+
const precondition = codec.conditionalWrites
|
|
156
|
+
? { ifMatch: encoded.ifMatch, ifNoneMatch: encoded.ifNoneMatch }
|
|
157
|
+
: { ifMatch: options.ifMatch, ifNoneMatch: options.ifNoneMatch };
|
|
158
|
+
const response = await send(this._context, {
|
|
100
159
|
path: this._path,
|
|
101
160
|
method: 'PUT',
|
|
102
161
|
capability: this._capability,
|
|
103
|
-
json:
|
|
104
|
-
body:
|
|
105
|
-
headers:
|
|
106
|
-
? { 'content-type': prepared.contentType }
|
|
107
|
-
: undefined
|
|
162
|
+
json: encoded.json,
|
|
163
|
+
body: encoded.body,
|
|
164
|
+
headers: writeHeaders(encoded.contentType, precondition)
|
|
108
165
|
});
|
|
166
|
+
return { etag: readEtag(response) };
|
|
109
167
|
}
|
|
110
168
|
/**
|
|
111
|
-
* Deletes the resource. Idempotent.
|
|
169
|
+
* Deletes the resource. Idempotent. Pass `ifMatch` (the backend's
|
|
170
|
+
* `conditional-writes` feature) to delete only if the resource's current ETag
|
|
171
|
+
* matches; a stale validator throws `PreconditionFailedError` (412).
|
|
112
172
|
*
|
|
173
|
+
* @param options {object}
|
|
174
|
+
* @param [options.ifMatch] {string} delete only if the ETag matches
|
|
113
175
|
* @returns {Promise<void>}
|
|
114
176
|
*/
|
|
115
|
-
async delete() {
|
|
177
|
+
async delete(options = {}) {
|
|
116
178
|
await send(this._context, {
|
|
117
179
|
path: this._path,
|
|
118
180
|
method: 'DELETE',
|
|
119
181
|
capability: this._capability,
|
|
120
|
-
idempotent:
|
|
182
|
+
// A conditional delete is not idempotent: a stale `If-Match` must surface
|
|
183
|
+
// as a 412 rather than being swallowed as an absent-target success.
|
|
184
|
+
idempotent: options.ifMatch === undefined,
|
|
185
|
+
headers: writeHeaders(undefined, { ifMatch: options.ifMatch })
|
|
121
186
|
});
|
|
122
187
|
}
|
|
123
188
|
get _metaPath() {
|
|
@@ -129,7 +194,11 @@ export class Resource {
|
|
|
129
194
|
* resource is missing or not visible to you (404 conflation caveat). A server
|
|
130
195
|
* without metadata support surfaces its 501 as `NotImplementedError`.
|
|
131
196
|
*
|
|
132
|
-
*
|
|
197
|
+
* Against a backend with the `conditional-writes` feature the result also
|
|
198
|
+
* carries the resource's current `etag` (the strong validator) -- pass it as
|
|
199
|
+
* `put(data, { ifMatch })` for a lost-update-safe update.
|
|
200
|
+
*
|
|
201
|
+
* @returns {Promise<(ResourceMetadata & { etag?: string }) | null>}
|
|
133
202
|
*/
|
|
134
203
|
async meta() {
|
|
135
204
|
const response = await send(this._context, {
|
|
@@ -138,7 +207,12 @@ export class Resource {
|
|
|
138
207
|
capability: this._capability,
|
|
139
208
|
read: true
|
|
140
209
|
});
|
|
141
|
-
|
|
210
|
+
if (response === null) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const metadata = response.data;
|
|
214
|
+
const etag = readEtag(response);
|
|
215
|
+
return etag !== undefined ? { ...metadata, etag } : metadata;
|
|
142
216
|
}
|
|
143
217
|
/**
|
|
144
218
|
* Replaces the resource's user-writable metadata (`custom`). This is a full
|
|
@@ -147,11 +221,21 @@ export class Resource {
|
|
|
147
221
|
* metadata of a nonexistent resource throws `NotFoundError`. Servers without
|
|
148
222
|
* metadata support surface their 501 as `NotImplementedError`.
|
|
149
223
|
*
|
|
224
|
+
* On an encrypted collection this throws a `ValidationError`: `custom`
|
|
225
|
+
* (`name` / `tags`) would be stored as server-visible plaintext, defeating the
|
|
226
|
+
* encryption. Carry those values inside the encrypted content instead.
|
|
227
|
+
*
|
|
150
228
|
* @param meta {object}
|
|
151
229
|
* @param [meta.custom] {ResourceMetadataCustom} the user-writable properties
|
|
152
230
|
* @returns {Promise<void>}
|
|
153
231
|
*/
|
|
154
232
|
async setMeta(meta = {}) {
|
|
233
|
+
const codec = await this._codec();
|
|
234
|
+
if (!codec.allowsServerMetadata) {
|
|
235
|
+
throw new ValidationError('Cannot set server-visible metadata (name/tags) on an encrypted ' +
|
|
236
|
+
'collection -- it would be stored as plaintext. Carry these values ' +
|
|
237
|
+
'inside the encrypted content instead.');
|
|
238
|
+
}
|
|
155
239
|
await send(this._context, {
|
|
156
240
|
path: this._metaPath,
|
|
157
241
|
method: 'PUT',
|
package/dist/Resource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"
|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79,6 +79,10 @@ export declare class Space {
|
|
|
79
79
|
* the space is missing or not visible to you (404 conflation caveat). A
|
|
80
80
|
* server without backend support surfaces its 501 as `NotImplementedError`.
|
|
81
81
|
*
|
|
82
|
+
* Each descriptor's optional `features` array advertises optional server
|
|
83
|
+
* affordances (e.g. `conditional-writes`). See {@link Collection.backend} for
|
|
84
|
+
* the full note.
|
|
85
|
+
*
|
|
82
86
|
* @returns {Promise<BackendDescriptor[] | null>}
|
|
83
87
|
*/
|
|
84
88
|
backends(): Promise<BackendDescriptor[] | null>;
|
package/dist/Space.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Space.d.ts","sourceRoot":"","sources":["../src/Space.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,cAAc,EACd,KAAK,EACL,WAAW,EACX,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,qBAAa,KAAK;IAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAO;IAEpC;;;;;OAKG;gBACS,EACV,OAAO,EACP,OAAO,EACP,UAAU,EACX,EAAE;QACD,OAAO,EAAE,aAAa,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,UAAU,CAAC,EAAE,KAAK,CAAA;KACnB;IAMD,OAAO,KAAK,KAAK,GAEhB;IAED;;;;;OAKG;IACG,QAAQ,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUlD;;;;;;;;OAQG;IACG,SAAS,CAAC,IA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AAO,CAAC,IAAI,CAAC;IAStD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAKlC;;;;;;OAMG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IASlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;CASzC"}
|
package/dist/Space.js
CHANGED
|
@@ -156,6 +156,10 @@ export class Space {
|
|
|
156
156
|
* the space is missing or not visible to you (404 conflation caveat). A
|
|
157
157
|
* server without backend support surfaces its 501 as `NotImplementedError`.
|
|
158
158
|
*
|
|
159
|
+
* Each descriptor's optional `features` array advertises optional server
|
|
160
|
+
* affordances (e.g. `conditional-writes`). See {@link Collection.backend} for
|
|
161
|
+
* the full note.
|
|
162
|
+
*
|
|
159
163
|
* @returns {Promise<BackendDescriptor[] | null>}
|
|
160
164
|
*/
|
|
161
165
|
async backends() {
|
package/dist/Space.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Space.js","sourceRoot":"","sources":["../src/Space.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,KAAK,EACN,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAiB5C,MAAM,OAAO,KAAK;IACP,EAAE,CAAQ;IAEF,QAAQ,CAAe;IACvB,WAAW,CAAQ;IAEpC;;;;;OAKG;IACH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ACZ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QACrC,OAAO,MAAM,EAAE,IAAI,KAAK,eAAe,CAAA;IACzC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACxB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,EAAE,QAAQ;YAChB,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACzC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;QACF,OAAO,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,QAAQ,CAAC,IAAgB,CAAA;IAC9D,CAAC;CACF"}
|
package/dist/WasClient.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { ZcapClient } from '@interop/ezcap';
|
|
13
13
|
import type { HttpResponse } from '@interop/http-client';
|
|
14
|
+
import type { EncryptionProvider } from './codec.js';
|
|
14
15
|
import { Space } from './Space.js';
|
|
15
16
|
import { Collection } from './Collection.js';
|
|
16
17
|
import { Resource } from './Resource.js';
|
|
@@ -18,15 +19,20 @@ import type { GrantOptions, HandleOptions, IDelegatedZcap, ISigner, IZcap, Json,
|
|
|
18
19
|
export declare class WasClient {
|
|
19
20
|
readonly serverUrl: string;
|
|
20
21
|
readonly zcapClient: ZcapClient;
|
|
22
|
+
readonly encryption?: EncryptionProvider;
|
|
21
23
|
/**
|
|
22
24
|
* @param options {object}
|
|
23
25
|
* @param options.serverUrl {string} base URL for both URL building and
|
|
24
26
|
* zcap `invocationTarget`s
|
|
25
27
|
* @param options.zcapClient {ZcapClient} an ezcap client holding the signer
|
|
28
|
+
* @param [options.encryption] {EncryptionProvider} supplies the encrypting
|
|
29
|
+
* codec for the collections the client holds keys for (built by the
|
|
30
|
+
* `@interop/was-client/edv` subpath); omit for plaintext-only clients
|
|
26
31
|
*/
|
|
27
|
-
constructor({ serverUrl, zcapClient }: {
|
|
32
|
+
constructor({ serverUrl, zcapClient, encryption }: {
|
|
28
33
|
serverUrl: string;
|
|
29
34
|
zcapClient: ZcapClient;
|
|
35
|
+
encryption?: EncryptionProvider;
|
|
30
36
|
});
|
|
31
37
|
/**
|
|
32
38
|
* Convenience constructor that builds the ezcap `ZcapClient` internally from
|
|
@@ -35,11 +41,13 @@ export declare class WasClient {
|
|
|
35
41
|
* @param options {object}
|
|
36
42
|
* @param options.serverUrl {string}
|
|
37
43
|
* @param options.signer {ISigner}
|
|
44
|
+
* @param [options.encryption] {EncryptionProvider} see the constructor
|
|
38
45
|
* @returns {WasClient}
|
|
39
46
|
*/
|
|
40
|
-
static fromSigner({ serverUrl, signer }: {
|
|
47
|
+
static fromSigner({ serverUrl, signer, encryption }: {
|
|
41
48
|
serverUrl: string;
|
|
42
49
|
signer: ISigner;
|
|
50
|
+
encryption?: EncryptionProvider;
|
|
43
51
|
}): WasClient;
|
|
44
52
|
/**
|
|
45
53
|
* The DID controlling the wrapped signer (`signer.id` without the key
|
package/dist/WasClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasClient.d.ts","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;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D;;;;;;;;OAQG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAI3D;;;;;;;;OAQG;IACG,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;CAG5D"}
|
package/dist/WasClient.js
CHANGED
|
@@ -13,7 +13,7 @@ import { ZcapClient } from '@interop/ezcap';
|
|
|
13
13
|
import { Ed25519Signature2020 } from '@interop/ed25519-signature';
|
|
14
14
|
import { spacesRoot } from './internal/paths.js';
|
|
15
15
|
import { send, rawRequest, unsignedRequest } from './internal/request.js';
|
|
16
|
-
import { parseResource } from './internal/content.js';
|
|
16
|
+
import { parseResource, readJsonData } from './internal/content.js';
|
|
17
17
|
import { delegateGrant } from './internal/grant.js';
|
|
18
18
|
import { ValidationError } from './errors.js';
|
|
19
19
|
import { Space } from './Space.js';
|
|
@@ -22,15 +22,20 @@ import { Resource } from './Resource.js';
|
|
|
22
22
|
export class WasClient {
|
|
23
23
|
serverUrl;
|
|
24
24
|
zcapClient;
|
|
25
|
+
encryption;
|
|
25
26
|
/**
|
|
26
27
|
* @param options {object}
|
|
27
28
|
* @param options.serverUrl {string} base URL for both URL building and
|
|
28
29
|
* zcap `invocationTarget`s
|
|
29
30
|
* @param options.zcapClient {ZcapClient} an ezcap client holding the signer
|
|
31
|
+
* @param [options.encryption] {EncryptionProvider} supplies the encrypting
|
|
32
|
+
* codec for the collections the client holds keys for (built by the
|
|
33
|
+
* `@interop/was-client/edv` subpath); omit for plaintext-only clients
|
|
30
34
|
*/
|
|
31
|
-
constructor({ serverUrl, zcapClient }) {
|
|
35
|
+
constructor({ serverUrl, zcapClient, encryption }) {
|
|
32
36
|
this.serverUrl = serverUrl;
|
|
33
37
|
this.zcapClient = zcapClient;
|
|
38
|
+
this.encryption = encryption;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* Convenience constructor that builds the ezcap `ZcapClient` internally from
|
|
@@ -39,15 +44,16 @@ export class WasClient {
|
|
|
39
44
|
* @param options {object}
|
|
40
45
|
* @param options.serverUrl {string}
|
|
41
46
|
* @param options.signer {ISigner}
|
|
47
|
+
* @param [options.encryption] {EncryptionProvider} see the constructor
|
|
42
48
|
* @returns {WasClient}
|
|
43
49
|
*/
|
|
44
|
-
static fromSigner({ serverUrl, signer }) {
|
|
50
|
+
static fromSigner({ serverUrl, signer, encryption }) {
|
|
45
51
|
const zcapClient = new ZcapClient({
|
|
46
52
|
SuiteClass: Ed25519Signature2020,
|
|
47
53
|
invocationSigner: signer,
|
|
48
54
|
delegationSigner: signer
|
|
49
55
|
});
|
|
50
|
-
return new WasClient({ serverUrl, zcapClient });
|
|
56
|
+
return new WasClient({ serverUrl, zcapClient, encryption });
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* The DID controlling the wrapped signer (`signer.id` without the key
|
|
@@ -66,7 +72,8 @@ export class WasClient {
|
|
|
66
72
|
return {
|
|
67
73
|
serverUrl: this.serverUrl,
|
|
68
74
|
zcapClient: this.zcapClient,
|
|
69
|
-
controllerDid: this.controllerDid
|
|
75
|
+
controllerDid: this.controllerDid,
|
|
76
|
+
encryption: this.encryption
|
|
70
77
|
};
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
@@ -166,7 +173,7 @@ export class WasClient {
|
|
|
166
173
|
if (response === null) {
|
|
167
174
|
return null;
|
|
168
175
|
}
|
|
169
|
-
return (
|
|
176
|
+
return (await readJsonData(response));
|
|
170
177
|
}
|
|
171
178
|
/**
|
|
172
179
|
* Rebuilds an access handle from a received capability, returning a handle at
|
package/dist/WasClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasClient.js","sourceRoot":"","sources":["../src/WasClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA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K,CAAC,KAAK,CAAC,OAAqB;QAC/B,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqB;QACjC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;CACF"}
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The resource codec seam: a pluggable transform sitting between a caller's
|
|
6
|
+
* plaintext value and the bytes a Resource actually stores. The default
|
|
7
|
+
* identity codec preserves today's plaintext behavior byte-for-byte; the opt-in
|
|
8
|
+
* EDV codec (in the `@interop/was-client/edv` subpath) encrypts on write and
|
|
9
|
+
* decrypts on read, so `collection.put(id, obj)` transparently round-trips
|
|
10
|
+
* ciphertext.
|
|
11
|
+
*
|
|
12
|
+
* Core defines only these interfaces and the identity default -- the crypto
|
|
13
|
+
* implementation lives in the subpath so the `@interop/edv-client` /
|
|
14
|
+
* `@interop/minimal-cipher` graph stays out of core was-client. An app wires the
|
|
15
|
+
* two together by passing an `EncryptionProvider` (built by the subpath) to
|
|
16
|
+
* `WasClient`; core holds it as an opaque interface and never imports the
|
|
17
|
+
* subpath.
|
|
18
|
+
*
|
|
19
|
+
* Whether a collection is encrypted is a per-collection client concern (does the
|
|
20
|
+
* client hold keys for it?), not a backend capability -- an encrypted document
|
|
21
|
+
* is opaque JSON any document backend stores faithfully. So the switch is keys
|
|
22
|
+
* alone: the encrypting codec binds iff the provider returns one for the
|
|
23
|
+
* collection.
|
|
24
|
+
*/
|
|
25
|
+
import type { HttpResponse } from '@interop/http-client';
|
|
26
|
+
import type { Json } from './types.js';
|
|
27
|
+
/**
|
|
28
|
+
* The result of {@link ResourceCodec.encode}: the stored representation of a
|
|
29
|
+
* write, plus the id to store it under.
|
|
30
|
+
*
|
|
31
|
+
* - `id` -- when present, the write is a `PUT` to this resource id (the codec
|
|
32
|
+
* either echoes the caller's id or, for `add()`, mints one). When absent, the
|
|
33
|
+
* write is a `POST` and the server mints the id (the identity codec's `add()`
|
|
34
|
+
* path).
|
|
35
|
+
* - `json` / `body` -- mutually exclusive payloads, mirroring the request
|
|
36
|
+
* layer: `json` for a structured body, `body` for raw bytes.
|
|
37
|
+
* - `contentType` -- the content type to send for a `body` write (e.g.
|
|
38
|
+
* `application/edv+json` for an encrypted envelope).
|
|
39
|
+
* - `ifMatch` / `ifNoneMatch` -- an optional conditional-write precondition the
|
|
40
|
+
* codec computed (e.g. the EDV codec maps its `sequence` onto an `If-Match`
|
|
41
|
+
* ETag for lost-update-safe updates, or `If-None-Match: *` for a fresh
|
|
42
|
+
* insert). The write path forwards these as the request's conditional headers.
|
|
43
|
+
* Only honored for a codec that sets {@link ResourceCodec.conditionalWrites}.
|
|
44
|
+
*/
|
|
45
|
+
export interface EncodedWrite {
|
|
46
|
+
id?: string;
|
|
47
|
+
json?: object;
|
|
48
|
+
body?: Uint8Array | Blob;
|
|
49
|
+
contentType?: string;
|
|
50
|
+
ifMatch?: string;
|
|
51
|
+
ifNoneMatch?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A pluggable encode/decode transform bound to a single collection handle.
|
|
55
|
+
* Implementations must be stateless with respect to a given call (a resolved
|
|
56
|
+
* codec is reused across every read/write on the handle).
|
|
57
|
+
*/
|
|
58
|
+
export interface ResourceCodec {
|
|
59
|
+
/**
|
|
60
|
+
* Whether server-visible custom metadata (`resource.setName` / `setTags` /
|
|
61
|
+
* `setMeta`) is permitted. The identity codec allows it; an encrypting codec
|
|
62
|
+
* forbids it (the values would be stored as server-visible plaintext -- a
|
|
63
|
+
* leak), so those methods throw on an encrypted collection.
|
|
64
|
+
*/
|
|
65
|
+
readonly allowsServerMetadata: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether this codec drives optimistic-concurrency (conditional) writes. When
|
|
68
|
+
* `true`, the write path pre-reads the current stored resource and passes it
|
|
69
|
+
* to {@link encode} as `current`, then forwards the precondition `encode`
|
|
70
|
+
* returns ({@link EncodedWrite.ifMatch} / `ifNoneMatch`). The EDV codec sets
|
|
71
|
+
* this so its `sequence` is enforced (lost-update-safe) rather than advisory;
|
|
72
|
+
* the identity codec leaves it unset (plaintext writes carry only the caller's
|
|
73
|
+
* explicit precondition).
|
|
74
|
+
*/
|
|
75
|
+
readonly conditionalWrites?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Transforms a caller's write value into its stored representation. `id` is
|
|
78
|
+
* present for `put(id, ...)` (and absent for `add(...)`, where the codec may
|
|
79
|
+
* mint one by returning {@link EncodedWrite.id}).
|
|
80
|
+
*
|
|
81
|
+
* @param input {object}
|
|
82
|
+
* @param [input.id] {string} resource id (absent on add)
|
|
83
|
+
* @param input.data {Json | Blob | Uint8Array} the plaintext value
|
|
84
|
+
* @param [input.contentType] {string} caller-supplied content type
|
|
85
|
+
* @param [input.current] {HttpResponse | null} the current stored response
|
|
86
|
+
* (or `null` if absent), supplied only when {@link conditionalWrites} is set,
|
|
87
|
+
* so the codec can derive the next `sequence` and the `If-Match` ETag.
|
|
88
|
+
* @returns {Promise<EncodedWrite>}
|
|
89
|
+
*/
|
|
90
|
+
encode(input: {
|
|
91
|
+
id?: string;
|
|
92
|
+
data: Json | Blob | Uint8Array;
|
|
93
|
+
contentType?: string;
|
|
94
|
+
current?: HttpResponse | null;
|
|
95
|
+
}): Promise<EncodedWrite>;
|
|
96
|
+
/**
|
|
97
|
+
* Transforms a stored (non-null) read response back into a caller value: a
|
|
98
|
+
* parsed object for JSON, a `Blob` for binary, decrypting first when the
|
|
99
|
+
* codec encrypts.
|
|
100
|
+
*
|
|
101
|
+
* @param response {HttpResponse}
|
|
102
|
+
* @returns {Promise<Json | Blob>}
|
|
103
|
+
*/
|
|
104
|
+
decode(response: HttpResponse): Promise<Json | Blob>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Supplies the encrypting {@link ResourceCodec} for a collection, if the client
|
|
108
|
+
* holds keys for it. Injected into {@link WasClient} by an app that imports the
|
|
109
|
+
* `@interop/was-client/edv` subpath; core only ever holds this interface.
|
|
110
|
+
*
|
|
111
|
+
* `resolveCodec` returns `null` when this client has no keys for the collection,
|
|
112
|
+
* so it should be read/written in plaintext. This is the whole switch: a
|
|
113
|
+
* collection is encrypted iff the provider returns a codec for it.
|
|
114
|
+
*/
|
|
115
|
+
export interface EncryptionProvider {
|
|
116
|
+
/**
|
|
117
|
+
* @param input {object}
|
|
118
|
+
* @param input.spaceId {string}
|
|
119
|
+
* @param input.collectionId {string}
|
|
120
|
+
* @returns {Promise<ResourceCodec | null>}
|
|
121
|
+
*/
|
|
122
|
+
resolveCodec(input: {
|
|
123
|
+
spaceId: string;
|
|
124
|
+
collectionId: string;
|
|
125
|
+
}): Promise<ResourceCodec | null>;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;A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