@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
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* An `@interop/edv-client` `Transport` that maps Encrypted Data Vault (EDV)
|
|
6
|
+
* document operations onto ordinary WAS Resource CRUD -- the "EDV-over-WAS"
|
|
7
|
+
* layout profile (Layer 1). It is paired with `EdvClientCore`, which does all
|
|
8
|
+
* encryption, decryption, and index blinding client-side; this transport only
|
|
9
|
+
* moves opaque JWE documents to and from a WAS server, reusing the client's
|
|
10
|
+
* zcap-signed request layer (`WasClient.request()`). Keys never reach the
|
|
11
|
+
* server.
|
|
12
|
+
*
|
|
13
|
+
* Profile decisions encoded here:
|
|
14
|
+
*
|
|
15
|
+
* - **Vault per Collection.** The WAS Collection is the EDV vault; each
|
|
16
|
+
* encrypted document is one WAS Resource.
|
|
17
|
+
* - **Restrict-mode ids.** The WAS resource id IS the EDV document id (the
|
|
18
|
+
* 128-bit multibase value `EdvClientCore.generateId()` produces), which is
|
|
19
|
+
* URL-safe and never a reserved segment.
|
|
20
|
+
* - **Encrypted content type.** Documents are stored as `application/json` by
|
|
21
|
+
* default, so the profile works against an unmodified WAS server. The
|
|
22
|
+
* preferred marker is `application/edv+json` (exported as `EDV_CONTENT_TYPE`),
|
|
23
|
+
* which distinguishes EDV envelopes from plaintext application JSON in
|
|
24
|
+
* listings and metadata -- but the server must register an `application/*+json`
|
|
25
|
+
* content-type parser to accept it (the reference was-teaching-server does; a
|
|
26
|
+
* server that does not will reject it with 415). Pass `contentType:
|
|
27
|
+
* EDV_CONTENT_TYPE` to opt into it where the server supports it.
|
|
28
|
+
*
|
|
29
|
+
* Scope: documents only (`insert` / `update` / `get`). Blinded `find` / `count`
|
|
30
|
+
* / `updateIndex` and chunked streams (`storeChunk` / `getChunk`) require
|
|
31
|
+
* server-side EDV affordances (blinded `/query`, the `/{id}/chunks/{n}`
|
|
32
|
+
* sub-segment, conditional writes) that a plaintext WAS server does not yet
|
|
33
|
+
* provide, so they throw here. Because there are no conditional writes, the EDV
|
|
34
|
+
* `sequence` is advisory (last-writer-wins on `update`).
|
|
35
|
+
*/
|
|
36
|
+
import { Transport } from '@interop/edv-client';
|
|
37
|
+
import { httpStatus } from '../errors.js';
|
|
38
|
+
import { readJsonData } from '../internal/content.js';
|
|
39
|
+
import { resourcePath } from '../internal/paths.js';
|
|
40
|
+
/**
|
|
41
|
+
* The preferred content type marking a stored EDV-encrypted document (a JSON
|
|
42
|
+
* envelope whose `jwe` property carries the ciphertext). Requires the server to
|
|
43
|
+
* register an `application/*+json` content-type parser; otherwise use the
|
|
44
|
+
* default `application/json` (see `WasTransport`'s `contentType` option).
|
|
45
|
+
*/
|
|
46
|
+
export const EDV_CONTENT_TYPE = 'application/edv+json';
|
|
47
|
+
/**
|
|
48
|
+
* The content type used by default: plain JSON, which an unmodified WAS server
|
|
49
|
+
* accepts. The stored envelope is still self-identifying by its `jwe` field.
|
|
50
|
+
*/
|
|
51
|
+
const DEFAULT_CONTENT_TYPE = 'application/json';
|
|
52
|
+
/**
|
|
53
|
+
* A shared `TextEncoder` for serializing envelope bytes (stateless, so one
|
|
54
|
+
* instance is reused across every `_put`).
|
|
55
|
+
*/
|
|
56
|
+
const ENCODER = new TextEncoder();
|
|
57
|
+
/**
|
|
58
|
+
* Builds an `Error` carrying the `name` that `EdvClientCore` (and the reference
|
|
59
|
+
* `HttpsTransport`) dispatch on -- `DuplicateError`, `InvalidStateError`,
|
|
60
|
+
* `NotFoundError`.
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param options.name {string} the error name to set
|
|
64
|
+
* @param options.message {string} the human-readable message
|
|
65
|
+
* @param [options.cause] {unknown} the underlying error, if any
|
|
66
|
+
* @returns {Error}
|
|
67
|
+
*/
|
|
68
|
+
function namedError({ name, message, cause }) {
|
|
69
|
+
const err = new Error(message);
|
|
70
|
+
err.name = name;
|
|
71
|
+
if (cause !== undefined) {
|
|
72
|
+
err.cause = cause;
|
|
73
|
+
}
|
|
74
|
+
return err;
|
|
75
|
+
}
|
|
76
|
+
export class WasTransport extends Transport {
|
|
77
|
+
spaceId;
|
|
78
|
+
collectionId;
|
|
79
|
+
contentType;
|
|
80
|
+
_was;
|
|
81
|
+
/**
|
|
82
|
+
* @param options {object}
|
|
83
|
+
* @param options.was {WasClient} a WAS client holding the signer
|
|
84
|
+
* @param options.spaceId {string} the vault's Space id
|
|
85
|
+
* @param options.collectionId {string} the vault Collection id
|
|
86
|
+
* @param [options.contentType] {string} content type for stored envelopes;
|
|
87
|
+
* defaults to `application/json` (accepted by an unmodified server). Pass
|
|
88
|
+
* `EDV_CONTENT_TYPE` against a server that registers an `application/*+json`
|
|
89
|
+
* parser.
|
|
90
|
+
*/
|
|
91
|
+
constructor({ was, spaceId, collectionId, contentType = DEFAULT_CONTENT_TYPE }) {
|
|
92
|
+
super();
|
|
93
|
+
this._was = was;
|
|
94
|
+
this.spaceId = spaceId;
|
|
95
|
+
this.collectionId = collectionId;
|
|
96
|
+
this.contentType = contentType;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The WAS resource path for a document id, delegating to was-client's
|
|
100
|
+
* internal `resourcePath` builder so the percent-encoding and trailing-slash
|
|
101
|
+
* rules stay defined in one place (no trailing slash -- get/put/delete by
|
|
102
|
+
* id).
|
|
103
|
+
*
|
|
104
|
+
* @param id {string} the EDV document id (= WAS resource id)
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
_resourcePath(id) {
|
|
108
|
+
return resourcePath(this.spaceId, this.collectionId, id);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Writes an encrypted document to its WAS resource path as
|
|
112
|
+
* `application/edv+json` (the envelope serialized to bytes so the stored
|
|
113
|
+
* content type is exact).
|
|
114
|
+
*
|
|
115
|
+
* @param id {string}
|
|
116
|
+
* @param encrypted {IEncryptedDocument}
|
|
117
|
+
* @returns {Promise<HttpResponse>}
|
|
118
|
+
*/
|
|
119
|
+
async _put(id, encrypted) {
|
|
120
|
+
const body = ENCODER.encode(JSON.stringify(encrypted));
|
|
121
|
+
return this._was.request({
|
|
122
|
+
path: this._resourcePath(id),
|
|
123
|
+
method: 'PUT',
|
|
124
|
+
body,
|
|
125
|
+
headers: { 'content-type': this.contentType }
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*
|
|
131
|
+
* Inserts a new encrypted document. WAS `PUT` is an upsert, so to preserve
|
|
132
|
+
* EDV insert semantics (`DuplicateError` if the id already exists) this first
|
|
133
|
+
* checks for an existing resource. The check + write is not atomic -- with no
|
|
134
|
+
* server-side conditional writes yet, this is an advisory, single-writer
|
|
135
|
+
* guard.
|
|
136
|
+
*
|
|
137
|
+
* @param options {object}
|
|
138
|
+
* @param options.encrypted {IEncryptedDocument} the document to insert
|
|
139
|
+
* @returns {Promise<void>}
|
|
140
|
+
*/
|
|
141
|
+
async insert({ encrypted } = {}) {
|
|
142
|
+
if (!encrypted) {
|
|
143
|
+
throw new TypeError('"encrypted" is required.');
|
|
144
|
+
}
|
|
145
|
+
if (await this._exists(encrypted.id)) {
|
|
146
|
+
throw namedError({
|
|
147
|
+
name: 'DuplicateError',
|
|
148
|
+
message: `A document with id "${encrypted.id}" already exists.`
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
await this._put(encrypted.id, encrypted);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* @inheritdoc
|
|
155
|
+
*
|
|
156
|
+
* Updates (upserts) an encrypted document. The EDV `sequence` is advisory
|
|
157
|
+
* here -- without server-side conditional writes, a stale write is not
|
|
158
|
+
* rejected (last-writer-wins).
|
|
159
|
+
*
|
|
160
|
+
* @param options {object}
|
|
161
|
+
* @param options.encrypted {IEncryptedDocument} the document to update
|
|
162
|
+
* @returns {Promise<void>}
|
|
163
|
+
*/
|
|
164
|
+
async update({ encrypted } = {}) {
|
|
165
|
+
if (!encrypted) {
|
|
166
|
+
throw new TypeError('"encrypted" is required.');
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
await this._put(encrypted.id, encrypted);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
// A server that DOES enforce conditional writes signals a stale update
|
|
173
|
+
// with 409; surface it the way `EdvClientCore` expects.
|
|
174
|
+
if (httpStatus(err) === 409) {
|
|
175
|
+
throw namedError({
|
|
176
|
+
name: 'InvalidStateError',
|
|
177
|
+
message: 'Conflict error.',
|
|
178
|
+
cause: err
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* @inheritdoc
|
|
186
|
+
*
|
|
187
|
+
* Reads an encrypted document by id. Throws a `NotFoundError` (the name
|
|
188
|
+
* `EdvClientCore` expects) when the resource is missing or not visible.
|
|
189
|
+
*
|
|
190
|
+
* @param options {object}
|
|
191
|
+
* @param options.id {string} the document id to read
|
|
192
|
+
* @returns {Promise<IEncryptedDocument>}
|
|
193
|
+
*/
|
|
194
|
+
async get({ id } = {}) {
|
|
195
|
+
if (!id) {
|
|
196
|
+
throw new TypeError('"id" is required.');
|
|
197
|
+
}
|
|
198
|
+
let response;
|
|
199
|
+
try {
|
|
200
|
+
response = await this._was.request({
|
|
201
|
+
path: this._resourcePath(id),
|
|
202
|
+
method: 'GET'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
if (httpStatus(err) === 404) {
|
|
207
|
+
throw namedError({
|
|
208
|
+
name: 'NotFoundError',
|
|
209
|
+
message: 'Document not found.',
|
|
210
|
+
cause: err
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
return (await readJsonData(response));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Resolves to `true` if a resource exists at the document's path. A 404
|
|
219
|
+
* resolves to `false`; any other error propagates.
|
|
220
|
+
*
|
|
221
|
+
* @param id {string}
|
|
222
|
+
* @returns {Promise<boolean>}
|
|
223
|
+
*/
|
|
224
|
+
async _exists(id) {
|
|
225
|
+
try {
|
|
226
|
+
await this._was.request({ path: this._resourcePath(id), method: 'GET' });
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (httpStatus(err) === 404) {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
throw err;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* @inheritdoc
|
|
238
|
+
*
|
|
239
|
+
* Blinded-index query is not part of the documents-only EDV-over-WAS profile;
|
|
240
|
+
* it needs the server's `/query` affordance.
|
|
241
|
+
*/
|
|
242
|
+
async find() {
|
|
243
|
+
return this._unsupported('find (blinded-index query)');
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @inheritdoc
|
|
247
|
+
*
|
|
248
|
+
* Index updates need the server's `/{id}/index` affordance.
|
|
249
|
+
*/
|
|
250
|
+
async updateIndex() {
|
|
251
|
+
return this._unsupported('updateIndex');
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @inheritdoc
|
|
255
|
+
*
|
|
256
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
257
|
+
*/
|
|
258
|
+
async storeChunk() {
|
|
259
|
+
return this._unsupported('storeChunk (chunked streams)');
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @inheritdoc
|
|
263
|
+
*
|
|
264
|
+
* Chunked streams need the reserved `/{id}/chunks/{n}` sub-segment.
|
|
265
|
+
*/
|
|
266
|
+
async getChunk() {
|
|
267
|
+
return this._unsupported('getChunk (chunked streams)');
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Throws a uniform "not supported in this profile" error for EDV operations
|
|
271
|
+
* that depend on server-side affordances absent from a plaintext WAS server.
|
|
272
|
+
*
|
|
273
|
+
* @param operation {string}
|
|
274
|
+
* @returns {never}
|
|
275
|
+
*/
|
|
276
|
+
_unsupported(operation) {
|
|
277
|
+
throw namedError({
|
|
278
|
+
name: 'NotSupportedError',
|
|
279
|
+
message: `"${operation}" is not supported by the documents-only ` +
|
|
280
|
+
'EDV-over-WAS profile (requires server-side EDV affordances).'
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=WasTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WasTransport.js","sourceRoot":"","sources":["../../src/edv/WasTransport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAI/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAA;AAEtD;;;GAGG;AACH,MAAM,oBAAoB,GAAG,kBAAkB,CAAA;AAQ/C;;;GAGG;AACH,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC;;;;;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AAU;QACvB,OAAO,IAAI,CAAC,YAAY,CAAC,8BAA8B,CAAC,CAAA;IAC1D,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,QAAQ;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAA;IACxD,CAAC;IAED;;;;;;OAMG;IACK,YAAY,CAAC,SAAiB;QACpC,MAAM,UAAU,CAAC;YACf,IAAI,EAAE,mBAAmB;YACzB,OAAO,EACL,IAAI,SAAS,2CAA2C;gBACxD,8DAA8D;SACjE,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `@interop/was-client/edv` subpath entry: encrypted (EDV-over-WAS) storage
|
|
6
|
+
* support. Kept off the core `@interop/was-client` entry so plaintext consumers
|
|
7
|
+
* do not pull the `@interop/edv-client` / `@interop/minimal-cipher` crypto graph
|
|
8
|
+
* unless they opt in by importing this subpath.
|
|
9
|
+
*
|
|
10
|
+
* Two integration levels:
|
|
11
|
+
*
|
|
12
|
+
* - `createEdvEncryption` -- the encrypting codec for the handle
|
|
13
|
+
* seam. Pass its result as `WasClient`'s `encryption` option to make
|
|
14
|
+
* `collection.put`/`get` transparently encrypt the collections the client
|
|
15
|
+
* holds keys for.
|
|
16
|
+
* - `WasTransport` -- the standalone `@interop/edv-client`
|
|
17
|
+
* transport, for driving an `EdvClient` directly against WAS.
|
|
18
|
+
*/
|
|
19
|
+
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
20
|
+
export { WasTransport, EDV_CONTENT_TYPE } from './WasTransport.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The `@interop/was-client/edv` subpath entry: encrypted (EDV-over-WAS) storage
|
|
6
|
+
* support. Kept off the core `@interop/was-client` entry so plaintext consumers
|
|
7
|
+
* do not pull the `@interop/edv-client` / `@interop/minimal-cipher` crypto graph
|
|
8
|
+
* unless they opt in by importing this subpath.
|
|
9
|
+
*
|
|
10
|
+
* Two integration levels:
|
|
11
|
+
*
|
|
12
|
+
* - `createEdvEncryption` -- the encrypting codec for the handle
|
|
13
|
+
* seam. Pass its result as `WasClient`'s `encryption` option to make
|
|
14
|
+
* `collection.put`/`get` transparently encrypt the collections the client
|
|
15
|
+
* holds keys for.
|
|
16
|
+
* - `WasTransport` -- the standalone `@interop/edv-client`
|
|
17
|
+
* transport, for driving an `EdvClient` directly against WAS.
|
|
18
|
+
*/
|
|
19
|
+
export { createEdvEncryption, EdvCodec } from './EdvCodec.js';
|
|
20
|
+
export { WasTransport, EDV_CONTENT_TYPE } from './WasTransport.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edv/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -61,6 +61,17 @@ export declare class NotImplementedError extends WasError {
|
|
|
61
61
|
export declare class ConflictError extends WasError {
|
|
62
62
|
constructor(message: string, options?: WasErrorOptions);
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* A conditional write's precondition evaluated false (HTTP 412): an `ifMatch`
|
|
66
|
+
* ETag did not match the Resource's current version (a lost-update conflict), or
|
|
67
|
+
* an `ifNoneMatch` create-if-absent target already exists. Recover by re-reading
|
|
68
|
+
* the current Resource (its new `etag`), re-applying the change, and retrying.
|
|
69
|
+
* Distinct from `ConflictError` (409), which is the header-less id/backend
|
|
70
|
+
* conflict family.
|
|
71
|
+
*/
|
|
72
|
+
export declare class PreconditionFailedError extends WasError {
|
|
73
|
+
constructor(message: string, options?: WasErrorOptions);
|
|
74
|
+
}
|
|
64
75
|
/**
|
|
65
76
|
* A single upload exceeded the target backend's `maxUploadBytes` constraint
|
|
66
77
|
* (HTTP 413). Unlike `QuotaExceededError`, this is per-request -- a smaller
|
|
@@ -83,6 +94,14 @@ export declare class QuotaExceededError extends WasError {
|
|
|
83
94
|
export declare class WasServerError extends WasError {
|
|
84
95
|
constructor(message: string, options?: WasErrorOptions);
|
|
85
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Reads the HTTP status from a raw ky/ezcap error, checking both the flat
|
|
99
|
+
* `status` and the nested `response.status` shapes.
|
|
100
|
+
*
|
|
101
|
+
* @param err {unknown} the caught error
|
|
102
|
+
* @returns {number | undefined}
|
|
103
|
+
*/
|
|
104
|
+
export declare function httpStatus(err: unknown): number | undefined;
|
|
86
105
|
/**
|
|
87
106
|
* Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
|
|
88
107
|
* carrying through the server's `problem+json` fields. Dispatches on the
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,C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AAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ;gBACvC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAI3D;AA8ED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CA+C/C"}
|
package/dist/errors.js
CHANGED
|
@@ -79,6 +79,20 @@ export class ConflictError extends WasError {
|
|
|
79
79
|
this.name = 'ConflictError';
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* A conditional write's precondition evaluated false (HTTP 412): an `ifMatch`
|
|
84
|
+
* ETag did not match the Resource's current version (a lost-update conflict), or
|
|
85
|
+
* an `ifNoneMatch` create-if-absent target already exists. Recover by re-reading
|
|
86
|
+
* the current Resource (its new `etag`), re-applying the change, and retrying.
|
|
87
|
+
* Distinct from `ConflictError` (409), which is the header-less id/backend
|
|
88
|
+
* conflict family.
|
|
89
|
+
*/
|
|
90
|
+
export class PreconditionFailedError extends WasError {
|
|
91
|
+
constructor(message, options = {}) {
|
|
92
|
+
super(message, options);
|
|
93
|
+
this.name = 'PreconditionFailedError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
82
96
|
/**
|
|
83
97
|
* A single upload exceeded the target backend's `maxUploadBytes` constraint
|
|
84
98
|
* (HTTP 413). Unlike `QuotaExceededError`, this is per-request -- a smaller
|
|
@@ -137,6 +151,7 @@ const ERROR_CLASS_BY_KIND = {
|
|
|
137
151
|
[problemFragment(ProblemTypes.RESERVED_ID)]: ConflictError,
|
|
138
152
|
[problemFragment(ProblemTypes.ID_CONFLICT)]: ConflictError,
|
|
139
153
|
[problemFragment(ProblemTypes.UNSUPPORTED_BACKEND)]: ConflictError,
|
|
154
|
+
[problemFragment(ProblemTypes.PRECONDITION_FAILED)]: PreconditionFailedError,
|
|
140
155
|
[problemFragment(ProblemTypes.PAYLOAD_TOO_LARGE)]: PayloadTooLargeError,
|
|
141
156
|
[problemFragment(ProblemTypes.QUOTA_EXCEEDED)]: QuotaExceededError,
|
|
142
157
|
[problemFragment(ProblemTypes.UNSUPPORTED_OPERATION)]: NotImplementedError,
|
|
@@ -157,6 +172,17 @@ function errorForKind(kind, message, options) {
|
|
|
157
172
|
const ErrorClass = kind === undefined ? undefined : ERROR_CLASS_BY_KIND[kind];
|
|
158
173
|
return ErrorClass ? new ErrorClass(message, options) : null;
|
|
159
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Reads the HTTP status from a raw ky/ezcap error, checking both the flat
|
|
177
|
+
* `status` and the nested `response.status` shapes.
|
|
178
|
+
*
|
|
179
|
+
* @param err {unknown} the caught error
|
|
180
|
+
* @returns {number | undefined}
|
|
181
|
+
*/
|
|
182
|
+
export function httpStatus(err) {
|
|
183
|
+
const raw = err;
|
|
184
|
+
return raw?.status ?? raw?.response?.status;
|
|
185
|
+
}
|
|
160
186
|
/**
|
|
161
187
|
* Translates a thrown ky/ezcap error into the appropriate `WasError` subclass,
|
|
162
188
|
* carrying through the server's `problem+json` fields. Dispatches on the
|
|
@@ -171,7 +197,7 @@ export function mapError(err) {
|
|
|
171
197
|
return err;
|
|
172
198
|
}
|
|
173
199
|
const httpError = (err ?? {});
|
|
174
|
-
const status = httpError
|
|
200
|
+
const status = httpStatus(httpError);
|
|
175
201
|
const data = httpError.data;
|
|
176
202
|
const type = data?.type;
|
|
177
203
|
const title = data?.title;
|
|
@@ -195,6 +221,8 @@ export function mapError(err) {
|
|
|
195
221
|
return new NotFoundError(message, options);
|
|
196
222
|
case 409:
|
|
197
223
|
return new ConflictError(message, options);
|
|
224
|
+
case 412:
|
|
225
|
+
return new PreconditionFailedError(message, options);
|
|
198
226
|
case 413:
|
|
199
227
|
return new PayloadTooLargeError(message, options);
|
|
200
228
|
case 501:
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAmBpD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,IAAI,CAAS;IACb,KAAK,CAAS;IACd,OAAO,CAAW;IAClB,UAAU,CAAS;IAEnB,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC3D,IAAI,CAAC,IAAI,GAAG,UAAU,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,Q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AQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { WasClient } from './WasClient.js';
|
|
|
9
9
|
export { Space } from './Space.js';
|
|
10
10
|
export { Collection } from './Collection.js';
|
|
11
11
|
export { Resource } from './Resource.js';
|
|
12
|
-
export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, ConflictError, PayloadTooLargeError, QuotaExceededError, WasServerError, mapError } from './errors.js';
|
|
12
|
+
export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, ConflictError, PreconditionFailedError, PayloadTooLargeError, QuotaExceededError, WasServerError, mapError } from './errors.js';
|
|
13
|
+
export type { ResourceCodec, EncryptionProvider, EncodedWrite } from './codec.js';
|
|
13
14
|
export type { Json, JsonPrimitive, JsonObject, JsonArray, Action, ActionInput, SpaceDescription, CollectionDescription, CollectionSummary, CollectionsList, SpaceSummary, SpaceListing, ResourceSummary, CollectionResourcesList, ResourceMetadata, ResourceMetadataCustom, AddResult, ImportStats, PolicyDocument, LinkSet, LinkSetEntry, HandleOptions, BackendReference, BackendDescriptor, StorageLimit, CollectionUsage, BackendUsage, SpaceQuotaReport, GrantOptions, RequestInput, IZcap, IDelegatedZcap, ISigner } from './types.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACR,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,WAAW,EACX,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACR,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,5 @@ export { WasClient } from './WasClient.js';
|
|
|
9
9
|
export { Space } from './Space.js';
|
|
10
10
|
export { Collection } from './Collection.js';
|
|
11
11
|
export { Resource } from './Resource.js';
|
|
12
|
-
export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, ConflictError, PayloadTooLargeError, QuotaExceededError, WasServerError, mapError } from './errors.js';
|
|
12
|
+
export { WasError, NotFoundError, ValidationError, AuthRequiredError, NotImplementedError, ConflictError, PreconditionFailedError, PayloadTooLargeError, QuotaExceededError, WasServerError, mapError } from './errors.js';
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ResourceCodec } from '../codec.js';
|
|
2
|
+
import type { ClientContext } from './request.js';
|
|
3
|
+
/**
|
|
4
|
+
* The default codec: passes plaintext through unchanged. `encode` echoes the
|
|
5
|
+
* caller's `id` (so `put(id, ...)` is a `PUT` and `add(...)`, with no id, stays
|
|
6
|
+
* a server-minting `POST`) and reuses `prepareBody` -- including the
|
|
7
|
+
* filename-extension content-type guess when an id is present. `decode` reuses
|
|
8
|
+
* `parseResource`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const identityCodec: ResourceCodec;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the codec for a collection. Returns {@link identityCodec} unless an
|
|
13
|
+
* {@link EncryptionProvider} is injected and returns a codec for the collection
|
|
14
|
+
* (i.e. the client holds keys for it). No backend round-trip: whether a
|
|
15
|
+
* collection is encrypted is a client/key concern, not a backend capability.
|
|
16
|
+
*
|
|
17
|
+
* @param context {ClientContext}
|
|
18
|
+
* @param options {object}
|
|
19
|
+
* @param options.spaceId {string}
|
|
20
|
+
* @param options.collectionId {string}
|
|
21
|
+
* @returns {Promise<ResourceCodec>}
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCodec(context: ClientContext, { spaceId, collectionId }: {
|
|
24
|
+
spaceId: string;
|
|
25
|
+
collectionId: string;
|
|
26
|
+
}): Promise<ResourceCodec>;
|
|
27
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,aAwB3B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC,aAAa,CAAC,CAOxB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { prepareBody, parseResource } from './content.js';
|
|
2
|
+
/**
|
|
3
|
+
* The default codec: passes plaintext through unchanged. `encode` echoes the
|
|
4
|
+
* caller's `id` (so `put(id, ...)` is a `PUT` and `add(...)`, with no id, stays
|
|
5
|
+
* a server-minting `POST`) and reuses `prepareBody` -- including the
|
|
6
|
+
* filename-extension content-type guess when an id is present. `decode` reuses
|
|
7
|
+
* `parseResource`.
|
|
8
|
+
*/
|
|
9
|
+
export const identityCodec = {
|
|
10
|
+
allowsServerMetadata: true,
|
|
11
|
+
async encode({ id, data, contentType }) {
|
|
12
|
+
const prepared = prepareBody(data, { contentType, filename: id });
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
json: prepared.json,
|
|
16
|
+
body: prepared.body,
|
|
17
|
+
contentType: prepared.contentType
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
async decode(response) {
|
|
21
|
+
return (await parseResource(response));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the codec for a collection. Returns {@link identityCodec} unless an
|
|
26
|
+
* {@link EncryptionProvider} is injected and returns a codec for the collection
|
|
27
|
+
* (i.e. the client holds keys for it). No backend round-trip: whether a
|
|
28
|
+
* collection is encrypted is a client/key concern, not a backend capability.
|
|
29
|
+
*
|
|
30
|
+
* @param context {ClientContext}
|
|
31
|
+
* @param options {object}
|
|
32
|
+
* @param options.spaceId {string}
|
|
33
|
+
* @param options.collectionId {string}
|
|
34
|
+
* @returns {Promise<ResourceCodec>}
|
|
35
|
+
*/
|
|
36
|
+
export async function resolveCodec(context, { spaceId, collectionId }) {
|
|
37
|
+
const provider = context.encryption;
|
|
38
|
+
if (!provider) {
|
|
39
|
+
return identityCodec;
|
|
40
|
+
}
|
|
41
|
+
const codec = await provider.resolveCodec({ spaceId, collectionId });
|
|
42
|
+
return codec ?? identityCodec;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/internal/codec.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,oBAAoB,EAAE,IAAI;IAE1B,KAAK,CAAC,MAAM,CAAC,EACX,EAAE,EACF,IAAI,EACJ,WAAW,EAKZ;QACC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;QACjE,OAAO;YACL,EAAE;YACF,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;SAClC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAsB;QACjC,OAAO,CAAC,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAgB,CAAA;IACvD,CAAC;CACF,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAsB,EACtB,EAAE,OAAO,EAAE,YAAY,EAA6C;IAEpE,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAA;IACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,aAAa,CAAA;IACtB,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;IACpE,OAAO,KAAK,IAAI,aAAa,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Helpers for conditional writes (the server's `conditional-writes` feature):
|
|
6
|
+
* assembling a write's request headers from an optional content-type plus the
|
|
7
|
+
* `If-Match` / `If-None-Match: *` preconditions, and reading the `ETag` a write
|
|
8
|
+
* response returns.
|
|
9
|
+
*/
|
|
10
|
+
import type { HttpResponse } from '@interop/http-client';
|
|
11
|
+
/**
|
|
12
|
+
* A conditional-write precondition: `ifMatch` is the quoted ETag an
|
|
13
|
+
* update-if-unchanged write must match; `ifNoneMatch` requests a create-if-absent
|
|
14
|
+
* (`If-None-Match: *`). At most one is normally set.
|
|
15
|
+
*/
|
|
16
|
+
export interface WritePrecondition {
|
|
17
|
+
ifMatch?: string;
|
|
18
|
+
ifNoneMatch?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds the headers for a write request: the content-type (when present) and
|
|
22
|
+
* the conditional-write precondition headers (`If-Match` / `If-None-Match: *`).
|
|
23
|
+
* Returns `undefined` when no header is needed, matching the request layer's
|
|
24
|
+
* optional `headers`.
|
|
25
|
+
*
|
|
26
|
+
* @param contentType {string | undefined} the body content-type, if any
|
|
27
|
+
* @param [precondition] {WritePrecondition} the conditional-write precondition
|
|
28
|
+
* @returns {Record<string, string> | undefined}
|
|
29
|
+
*/
|
|
30
|
+
export declare function writeHeaders(contentType: string | undefined, precondition?: WritePrecondition): Record<string, string> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Reads the strong `ETag` validator a write/read response returned, or
|
|
33
|
+
* `undefined` when the backend sent none (it does not advertise the
|
|
34
|
+
* `conditional-writes` feature).
|
|
35
|
+
*
|
|
36
|
+
* @param response {HttpResponse | null}
|
|
37
|
+
* @returns {string | undefined}
|
|
38
|
+
*/
|
|
39
|
+
export declare function readEtag(response: HttpResponse | null): string | undefined;
|
|
40
|
+
//# sourceMappingURL=conditional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../src/internal/conditional.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,YAAY,GAAE,iBAAsB,GACnC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAYpC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE1E"}
|