@interop/was-client 0.35.0 → 0.36.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 +22 -5
- package/dist/Collection.d.ts +5 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +37 -4
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +4 -3
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +31 -20
- package/dist/Resource.js.map +1 -1
- package/dist/codec.d.ts +91 -4
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +10 -1
- package/dist/codec.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts +33 -9
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +471 -52
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/WasTransport.d.ts +39 -2
- package/dist/edv/WasTransport.d.ts.map +1 -1
- package/dist/edv/WasTransport.js +82 -26
- package/dist/edv/WasTransport.js.map +1 -1
- package/dist/edv/docCipher.d.ts +59 -7
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +63 -13
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/index.d.ts +1 -1
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/errors.d.ts +31 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +35 -14
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/features.d.ts +44 -1
- package/dist/internal/features.d.ts.map +1 -1
- package/dist/internal/features.js +39 -0
- package/dist/internal/features.js.map +1 -1
- package/dist/internal/write.d.ts +65 -12
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +71 -9
- package/dist/internal/write.js.map +1 -1
- package/dist/sync/index.d.ts +9 -5
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -5
- package/dist/sync/index.js.map +1 -1
- package/package.json +1 -1
package/dist/internal/write.d.ts
CHANGED
|
@@ -12,11 +12,17 @@
|
|
|
12
12
|
* conditional-codec pre-read of the current document, the codec-vs-caller
|
|
13
13
|
* precondition selection, and the masked-404 policy for a document that exists
|
|
14
14
|
* but is not readable with the bound capability).
|
|
15
|
+
*
|
|
16
|
+
* A codec may also answer `encode` with a multi-request `ChunkedWrite` plan
|
|
17
|
+
* rather than an `EncodedWrite`. `insertResource` runs the plan over the
|
|
18
|
+
* signed-request context built here (`codecRequestContext`); `upsertResource`
|
|
19
|
+
* refuses one, since auto-routing is an insert-path affordance.
|
|
15
20
|
*/
|
|
16
21
|
import type { HttpResponse } from '@interop/http-client';
|
|
17
|
-
import type { EncodedWrite, ResourceCodec } from '../codec.js';
|
|
22
|
+
import type { CodecRequestContext, EncodedWrite, ResourceCodec } from '../codec.js';
|
|
18
23
|
import type { IZcap, ResourceData } from '../types.js';
|
|
19
24
|
import type { ClientContext } from './request.js';
|
|
25
|
+
import type { FeatureProbe } from './features.js';
|
|
20
26
|
import type { WritePrecondition } from './conditional.js';
|
|
21
27
|
/**
|
|
22
28
|
* Sends an encoded write (`PUT`/`POST`) to a resource path, applying the
|
|
@@ -40,11 +46,58 @@ export declare function sendEncodedWrite(context: ClientContext, { path, method,
|
|
|
40
46
|
capability?: IZcap;
|
|
41
47
|
precondition?: WritePrecondition;
|
|
42
48
|
}): Promise<HttpResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Builds the {@link CodecRequestContext} core hands a codec that drives its own
|
|
51
|
+
* I/O: the signed-request primitive bound to this handle's capability, plus the
|
|
52
|
+
* handle's memoized backend-feature probe. The codec never sees the zcap
|
|
53
|
+
* machinery, and the raw `HttpResponse` it gets back matches the
|
|
54
|
+
* `was.request()` escape hatch, which is what `WasTransport` consumes.
|
|
55
|
+
*
|
|
56
|
+
* Requests go through the same mapped `send` path the core write paths use, so
|
|
57
|
+
* a codec-driven write fails with the typed `WasError` subclasses the calling
|
|
58
|
+
* method documents (a document `PUT` that 404s is a `NotFoundError`, not a raw
|
|
59
|
+
* ky/ezcap error). The typed errors carry the HTTP `status`, so a consumer that
|
|
60
|
+
* dispatches on status keeps working.
|
|
61
|
+
*
|
|
62
|
+
* @param context {ClientContext}
|
|
63
|
+
* @param options {object}
|
|
64
|
+
* @param options.features {FeatureProbe} the handle's memoized backend-feature
|
|
65
|
+
* probe
|
|
66
|
+
* @param [options.capability] {IZcap} capability attached to each request
|
|
67
|
+
* @returns {CodecRequestContext}
|
|
68
|
+
*/
|
|
69
|
+
export declare function codecRequestContext(context: ClientContext, { features, capability }: {
|
|
70
|
+
features: FeatureProbe;
|
|
71
|
+
capability?: IZcap;
|
|
72
|
+
}): CodecRequestContext;
|
|
73
|
+
/**
|
|
74
|
+
* The outcome of {@link insertResource}: either the ordinary single-request
|
|
75
|
+
* write (the codec's encoding, the path written, and the response) or the
|
|
76
|
+
* result of a codec's multi-request {@link ChunkedWrite} plan, which has no one
|
|
77
|
+
* canonical response.
|
|
78
|
+
*/
|
|
79
|
+
export type InsertOutcome = {
|
|
80
|
+
chunked?: false;
|
|
81
|
+
encoded: EncodedWrite;
|
|
82
|
+
path: string;
|
|
83
|
+
response: HttpResponse;
|
|
84
|
+
} | {
|
|
85
|
+
chunked: true;
|
|
86
|
+
id: string;
|
|
87
|
+
path: string;
|
|
88
|
+
contentType?: string;
|
|
89
|
+
etag?: string;
|
|
90
|
+
};
|
|
43
91
|
/**
|
|
44
92
|
* Creates a resource with a codec-minted or server-minted id (insert) through
|
|
45
93
|
* its codec, owning the create orchestration in one place: the encode, the
|
|
46
94
|
* `PUT`-vs-`POST` branch, and the precondition selection.
|
|
47
95
|
*
|
|
96
|
+
* A codec may also answer the encode with a multi-request plan (the EDV codec's
|
|
97
|
+
* chunked blob write). The plan is then executed over the handle's signed
|
|
98
|
+
* request context instead of being sent as one request; it owns its own
|
|
99
|
+
* preconditions and feature gating.
|
|
100
|
+
*
|
|
48
101
|
* A codec that mints its own id (e.g. the encrypting codec's EDV id) writes it
|
|
49
102
|
* by `PUT` to that id's path; a codec that mints none (the identity codec)
|
|
50
103
|
* `POST`s to the items path and lets the server mint one. As in
|
|
@@ -64,25 +117,25 @@ export declare function sendEncodedWrite(context: ClientContext, { path, method,
|
|
|
64
117
|
* codec-minted id
|
|
65
118
|
* @param options.codec {ResourceCodec} the collection's resolved codec
|
|
66
119
|
* @param options.data {ResourceData} the plaintext value
|
|
120
|
+
* @param options.features {FeatureProbe} the handle's shared backend-feature
|
|
121
|
+
* probe, handed to a codec's multi-request plan so its affordance gate costs
|
|
122
|
+
* no extra round trip
|
|
67
123
|
* @param [options.contentType] {string} caller-supplied content type
|
|
68
124
|
* @param [options.capability] {IZcap}
|
|
69
125
|
* @param [options.precondition] {WritePrecondition} the caller's explicit
|
|
70
126
|
* precondition (used only for a non-conditional codec)
|
|
71
|
-
* @returns {Promise<
|
|
127
|
+
* @returns {Promise<InsertOutcome>}
|
|
72
128
|
*/
|
|
73
|
-
export declare function insertResource(context: ClientContext, { itemsPath, pathForId, codec, data, contentType, capability, precondition }: {
|
|
129
|
+
export declare function insertResource(context: ClientContext, { itemsPath, pathForId, codec, data, features, contentType, capability, precondition }: {
|
|
74
130
|
itemsPath: string;
|
|
75
131
|
pathForId: (id: string) => string;
|
|
76
132
|
codec: ResourceCodec;
|
|
77
133
|
data: ResourceData;
|
|
134
|
+
features: FeatureProbe;
|
|
78
135
|
contentType?: string;
|
|
79
136
|
capability?: IZcap;
|
|
80
137
|
precondition?: WritePrecondition;
|
|
81
|
-
}): Promise<
|
|
82
|
-
encoded: EncodedWrite;
|
|
83
|
-
path: string;
|
|
84
|
-
response: HttpResponse;
|
|
85
|
-
}>;
|
|
138
|
+
}): Promise<InsertOutcome>;
|
|
86
139
|
/**
|
|
87
140
|
* Creates or replaces a resource by id (upsert) through its codec, owning the
|
|
88
141
|
* conditional-write orchestration in one place:
|
|
@@ -111,9 +164,9 @@ export declare function insertResource(context: ClientContext, { itemsPath, path
|
|
|
111
164
|
* @param options.codec {ResourceCodec} the collection's resolved codec
|
|
112
165
|
* @param options.id {string} the resource id
|
|
113
166
|
* @param options.data {ResourceData} the plaintext value
|
|
114
|
-
* @param options.features {
|
|
115
|
-
*
|
|
116
|
-
*
|
|
167
|
+
* @param options.features {FeatureProbe} the handle's shared
|
|
168
|
+
* `BackendFeatures` probe; consulted only for a conditional codec's
|
|
169
|
+
* insert-after-null-pre-read
|
|
117
170
|
* @param [options.contentType] {string} caller-supplied content type
|
|
118
171
|
* @param [options.capability] {IZcap}
|
|
119
172
|
* @param [options.precondition] {WritePrecondition} the caller's explicit
|
|
@@ -125,7 +178,7 @@ export declare function upsertResource(context: ClientContext, { path, codec, id
|
|
|
125
178
|
codec: ResourceCodec;
|
|
126
179
|
id: string;
|
|
127
180
|
data: ResourceData;
|
|
128
|
-
features:
|
|
181
|
+
features: FeatureProbe;
|
|
129
182
|
contentType?: string;
|
|
130
183
|
capability?: IZcap;
|
|
131
184
|
precondition?: WritePrecondition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACd,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,iBAAiB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AM,CAAA;IACjC,KAAK,EAAE,aAAa,CAAA;IACpB,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,YAAY,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,GACA,OAAO,CAAC,aAAa,CAAC,CA2BxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,aAAa,EACtB,EACE,IAAI,EACJ,KAAK,EACL,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,YAAY,EACb,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,aAAa,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,YAAY,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC,GACA,OAAO,CAAC,YAAY,CAAC,CA2EvB"}
|
package/dist/internal/write.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isChunkedWrite } from '../codec.js';
|
|
1
2
|
import { PreconditionFailedError, ValidationError } from '../errors.js';
|
|
2
3
|
import { send } from './request.js';
|
|
3
4
|
import { encodedPrecondition, writeHeaders } from './conditional.js';
|
|
@@ -31,11 +32,47 @@ export async function sendEncodedWrite(context, { path, method, encoded, capabil
|
|
|
31
32
|
});
|
|
32
33
|
return response;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds the {@link CodecRequestContext} core hands a codec that drives its own
|
|
37
|
+
* I/O: the signed-request primitive bound to this handle's capability, plus the
|
|
38
|
+
* handle's memoized backend-feature probe. The codec never sees the zcap
|
|
39
|
+
* machinery, and the raw `HttpResponse` it gets back matches the
|
|
40
|
+
* `was.request()` escape hatch, which is what `WasTransport` consumes.
|
|
41
|
+
*
|
|
42
|
+
* Requests go through the same mapped `send` path the core write paths use, so
|
|
43
|
+
* a codec-driven write fails with the typed `WasError` subclasses the calling
|
|
44
|
+
* method documents (a document `PUT` that 404s is a `NotFoundError`, not a raw
|
|
45
|
+
* ky/ezcap error). The typed errors carry the HTTP `status`, so a consumer that
|
|
46
|
+
* dispatches on status keeps working.
|
|
47
|
+
*
|
|
48
|
+
* @param context {ClientContext}
|
|
49
|
+
* @param options {object}
|
|
50
|
+
* @param options.features {FeatureProbe} the handle's memoized backend-feature
|
|
51
|
+
* probe
|
|
52
|
+
* @param [options.capability] {IZcap} capability attached to each request
|
|
53
|
+
* @returns {CodecRequestContext}
|
|
54
|
+
*/
|
|
55
|
+
export function codecRequestContext(context, { features, capability }) {
|
|
56
|
+
return {
|
|
57
|
+
async request(input) {
|
|
58
|
+
// `send` only resolves `null` for the `read`/`idempotent` flags, which
|
|
59
|
+
// this surface never sets, so the response is always present.
|
|
60
|
+
const response = await send(context, { capability, ...input });
|
|
61
|
+
return response;
|
|
62
|
+
},
|
|
63
|
+
features
|
|
64
|
+
};
|
|
65
|
+
}
|
|
34
66
|
/**
|
|
35
67
|
* Creates a resource with a codec-minted or server-minted id (insert) through
|
|
36
68
|
* its codec, owning the create orchestration in one place: the encode, the
|
|
37
69
|
* `PUT`-vs-`POST` branch, and the precondition selection.
|
|
38
70
|
*
|
|
71
|
+
* A codec may also answer the encode with a multi-request plan (the EDV codec's
|
|
72
|
+
* chunked blob write). The plan is then executed over the handle's signed
|
|
73
|
+
* request context instead of being sent as one request; it owns its own
|
|
74
|
+
* preconditions and feature gating.
|
|
75
|
+
*
|
|
39
76
|
* A codec that mints its own id (e.g. the encrypting codec's EDV id) writes it
|
|
40
77
|
* by `PUT` to that id's path; a codec that mints none (the identity codec)
|
|
41
78
|
* `POST`s to the items path and lets the server mint one. As in
|
|
@@ -55,14 +92,28 @@ export async function sendEncodedWrite(context, { path, method, encoded, capabil
|
|
|
55
92
|
* codec-minted id
|
|
56
93
|
* @param options.codec {ResourceCodec} the collection's resolved codec
|
|
57
94
|
* @param options.data {ResourceData} the plaintext value
|
|
95
|
+
* @param options.features {FeatureProbe} the handle's shared backend-feature
|
|
96
|
+
* probe, handed to a codec's multi-request plan so its affordance gate costs
|
|
97
|
+
* no extra round trip
|
|
58
98
|
* @param [options.contentType] {string} caller-supplied content type
|
|
59
99
|
* @param [options.capability] {IZcap}
|
|
60
100
|
* @param [options.precondition] {WritePrecondition} the caller's explicit
|
|
61
101
|
* precondition (used only for a non-conditional codec)
|
|
62
|
-
* @returns {Promise<
|
|
102
|
+
* @returns {Promise<InsertOutcome>}
|
|
63
103
|
*/
|
|
64
|
-
export async function insertResource(context, { itemsPath, pathForId, codec, data, contentType, capability, precondition }) {
|
|
65
|
-
const
|
|
104
|
+
export async function insertResource(context, { itemsPath, pathForId, codec, data, features, contentType, capability, precondition }) {
|
|
105
|
+
const write = await codec.encode({ data, contentType });
|
|
106
|
+
if (isChunkedWrite(write)) {
|
|
107
|
+
const { id, etag } = await write.execute(codecRequestContext(context, { features, capability }));
|
|
108
|
+
return {
|
|
109
|
+
chunked: true,
|
|
110
|
+
id,
|
|
111
|
+
path: pathForId(id),
|
|
112
|
+
contentType: write.resourceContentType,
|
|
113
|
+
...(etag !== undefined && { etag })
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const encoded = write;
|
|
66
117
|
const chosen = codec.conditionalWrites
|
|
67
118
|
? encodedPrecondition(encoded)
|
|
68
119
|
: precondition;
|
|
@@ -104,9 +155,9 @@ export async function insertResource(context, { itemsPath, pathForId, codec, dat
|
|
|
104
155
|
* @param options.codec {ResourceCodec} the collection's resolved codec
|
|
105
156
|
* @param options.id {string} the resource id
|
|
106
157
|
* @param options.data {ResourceData} the plaintext value
|
|
107
|
-
* @param options.features {
|
|
108
|
-
*
|
|
109
|
-
*
|
|
158
|
+
* @param options.features {FeatureProbe} the handle's shared
|
|
159
|
+
* `BackendFeatures` probe; consulted only for a conditional codec's
|
|
160
|
+
* insert-after-null-pre-read
|
|
110
161
|
* @param [options.contentType] {string} caller-supplied content type
|
|
111
162
|
* @param [options.capability] {IZcap}
|
|
112
163
|
* @param [options.precondition] {WritePrecondition} the caller's explicit
|
|
@@ -122,8 +173,7 @@ export async function upsertResource(context, { path, codec, id, data, features,
|
|
|
122
173
|
capability,
|
|
123
174
|
read: true
|
|
124
175
|
});
|
|
125
|
-
if (current === null &&
|
|
126
|
-
!(await features()).includes('conditional-writes')) {
|
|
176
|
+
if (current === null && !(await features.has('conditional-writes'))) {
|
|
127
177
|
// The write would be encoded as a fresh insert guarded only by
|
|
128
178
|
// `If-None-Match: *`, which this backend ignores -- so if the document in
|
|
129
179
|
// fact exists but is unreadable with this capability (the masked-404
|
|
@@ -140,7 +190,19 @@ export async function upsertResource(context, { path, codec, id, data, features,
|
|
|
140
190
|
'descriptor, or add() to mint a fresh document id.');
|
|
141
191
|
}
|
|
142
192
|
}
|
|
143
|
-
const
|
|
193
|
+
const write = await codec.encode({ id, data, contentType, current });
|
|
194
|
+
if (isChunkedWrite(write)) {
|
|
195
|
+
// Auto-routing is an insert-path affordance: a write by id would have to
|
|
196
|
+
// reconcile the existing stored parts (and the codec's sequence) with the
|
|
197
|
+
// new payload, which this path does not do. Refuse instead of
|
|
198
|
+
// half-performing the update. The codec supplies the scheme-specific
|
|
199
|
+
// recovery advice; this layer knows nothing about how it stores things.
|
|
200
|
+
throw new ValidationError(`Cannot write this payload to "${path}": the collection's codec ` +
|
|
201
|
+
'answered with a multi-request write plan, which is only auto-routed ' +
|
|
202
|
+
'on the insert path (add()). Add it as a new resource' +
|
|
203
|
+
(write.guidance === undefined ? '.' : `. ${write.guidance}`));
|
|
204
|
+
}
|
|
205
|
+
const encoded = write;
|
|
144
206
|
// A conditional codec computes the precondition itself (from the sequence /
|
|
145
207
|
// ETag); a plaintext codec defers to the caller's explicit options.
|
|
146
208
|
const chosen = codec.conditionalWrites
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/internal/write.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGvE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAGpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAsB,EACtB,EACE,IAAI,EACJ,MAAM,EACN,OAAO,EACP,UAAU,EACV,YAAY,EAOb;IAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI;QACJ,MAAM;QACN,UAAU;QACV,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,YAAY,CAAC;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY;YACZ,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;KACH,CAAC,CAAA;IACF,OAAO,QAAwB,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAsB,EACtB,EAAE,QAAQ,EAAE,UAAU,EAAkD;IAExE,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,uEAAuE;YACvE,8DAA8D;YAC9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;YAC9D,OAAO,Q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AAI,4BAA4B;YAC/D,sEAAsE;YACtE,sDAAsD;YACtD,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC,CAC/D,CAAA;IACH,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAA;IACrB,4EAA4E;IAC5E,oEAAoE;IACpE,MAAM,MAAM,GAAG,KAAK,CAAC,iBAAiB;QACpC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC;QAC9B,CAAC,CAAC,YAAY,CAAA;IAChB,IAAI,CAAC;QACH,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE;YACrC,IAAI;YACJ,MAAM,EAAE,KAAK;YACb,UAAU;YACV,OAAO;YACP,YAAY,EAAE,MAAM;SACrB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IACE,GAAG,YAAY,uBAAuB;YACtC,KAAK,CAAC,iBAAiB;YACvB,OAAO,KAAK,IAAI,EAChB,CAAC;YACD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YACxD,MAAM,IAAI,uBAAuB,CAC/B,kCAAkC,IAAI,gCAAgC;gBACpE,0DAA0D;gBAC1D,kEAAkE;gBAClE,gEAAgE;gBAChE,+DAA+D;gBAC/D,WAAW,EACb,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CACzD,CAAA;QACH,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -18,16 +18,20 @@
|
|
|
18
18
|
* The 412 conflict / 404 not-found port signals (`WasSyncConflictError` /
|
|
19
19
|
* `WasSyncNotFoundError`), and the opt-in revoked-access signal
|
|
20
20
|
* (`WasSyncAuthError`, raised only under `mapAuthErrors`), live in the client's
|
|
21
|
-
* typed error hierarchy and are re-exported here for convenience -- as
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* typed error hierarchy and are re-exported here for convenience -- as are the
|
|
22
|
+
* two decrypt-routing signals, so a crypto-free sync consumer can
|
|
23
|
+
* `instanceof`-match them without importing the `/edv` entry that throws them:
|
|
24
|
+
* the stale-descriptor signal (`UnknownEpochError`: the envelope's epoch is not
|
|
25
|
+
* on the descriptor at all, so re-read it and rebuild the cipher) and the
|
|
26
|
+
* membership signal (`KeyUnwrapError`: the epoch is on the descriptor but this
|
|
27
|
+
* reader holds no key for it, so a refresh cannot help). `EncryptionError`, the
|
|
28
|
+
* fail-closed umbrella `KeyUnwrapError` falls under, rides along.
|
|
25
29
|
*/
|
|
26
30
|
export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus, errorMessage } from './port.js';
|
|
27
31
|
export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
28
32
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
29
33
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
|
30
34
|
export { ensureSpaceAndCollection } from './provisioning.js';
|
|
31
|
-
export { UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
35
|
+
export { EncryptionError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
32
36
|
export type { Json, SyncCheckpoint, WireDoc, SyncPage, MasterState, WasSyncPort, DocCipher } from './types.js';
|
|
33
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/sync/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA;AAErB,YAAY,EACV,IAAI,EACJ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA"}
|
package/dist/sync/index.js
CHANGED
|
@@ -18,15 +18,19 @@
|
|
|
18
18
|
* The 412 conflict / 404 not-found port signals (`WasSyncConflictError` /
|
|
19
19
|
* `WasSyncNotFoundError`), and the opt-in revoked-access signal
|
|
20
20
|
* (`WasSyncAuthError`, raised only under `mapAuthErrors`), live in the client's
|
|
21
|
-
* typed error hierarchy and are re-exported here for convenience -- as
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* typed error hierarchy and are re-exported here for convenience -- as are the
|
|
22
|
+
* two decrypt-routing signals, so a crypto-free sync consumer can
|
|
23
|
+
* `instanceof`-match them without importing the `/edv` entry that throws them:
|
|
24
|
+
* the stale-descriptor signal (`UnknownEpochError`: the envelope's epoch is not
|
|
25
|
+
* on the descriptor at all, so re-read it and rebuild the cipher) and the
|
|
26
|
+
* membership signal (`KeyUnwrapError`: the epoch is on the descriptor but this
|
|
27
|
+
* reader holds no key for it, so a refresh cannot help). `EncryptionError`, the
|
|
28
|
+
* fail-closed umbrella `KeyUnwrapError` falls under, rides along.
|
|
25
29
|
*/
|
|
26
30
|
export { createWasSyncPort, KEY_EPOCH_HEADER, formatEtag, parseEtag, errorStatus, errorMessage } from './port.js';
|
|
27
31
|
export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
28
32
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
29
33
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
|
30
34
|
export { ensureSpaceAndCollection } from './provisioning.js';
|
|
31
|
-
export { UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
35
|
+
export { EncryptionError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
32
36
|
//# sourceMappingURL=index.js.map
|
package/dist/sync/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED