@interop/was-client 0.51.0 → 0.53.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 +46 -2
- package/dist/Collection.d.ts +30 -9
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +110 -76
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +15 -0
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +6 -17
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +54 -0
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +104 -18
- package/dist/Space.js.map +1 -1
- package/dist/codec.d.ts +54 -12
- package/dist/codec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.d.ts +9 -8
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +65 -33
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/descriptorStore.d.ts.map +1 -1
- package/dist/edv/descriptorStore.js +2 -0
- package/dist/edv/descriptorStore.js.map +1 -1
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +1 -1
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/index.d.ts +2 -0
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +1 -0
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.d.ts +164 -0
- package/dist/edv/logGovernedDescriptorStore.d.ts.map +1 -0
- package/dist/edv/logGovernedDescriptorStore.js +477 -0
- package/dist/edv/logGovernedDescriptorStore.js.map +1 -0
- package/dist/edv/recipients.d.ts.map +1 -1
- package/dist/edv/recipients.js +25 -82
- package/dist/edv/recipients.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/cas.d.ts +95 -0
- package/dist/internal/cas.d.ts.map +1 -0
- package/dist/internal/cas.js +116 -0
- package/dist/internal/cas.js.map +1 -0
- package/dist/internal/codec.d.ts.map +1 -1
- package/dist/internal/codec.js +6 -6
- package/dist/internal/codec.js.map +1 -1
- package/dist/internal/content.d.ts +13 -0
- package/dist/internal/content.d.ts.map +1 -1
- package/dist/internal/content.js +16 -0
- package/dist/internal/content.js.map +1 -1
- package/dist/internal/describe.d.ts +16 -21
- package/dist/internal/describe.d.ts.map +1 -1
- package/dist/internal/describe.js +17 -25
- package/dist/internal/describe.js.map +1 -1
- package/dist/internal/meta.d.ts +9 -9
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +13 -14
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/request.d.ts +19 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js +26 -0
- package/dist/internal/request.js.map +1 -1
- package/dist/log/logStore.d.ts +8 -5
- package/dist/log/logStore.d.ts.map +1 -1
- package/dist/log/logStore.js +30 -30
- package/dist/log/logStore.js.map +1 -1
- package/dist/sync/provisioning.d.ts +43 -15
- package/dist/sync/provisioning.d.ts.map +1 -1
- package/dist/sync/provisioning.js +147 -38
- package/dist/sync/provisioning.js.map +1 -1
- package/dist/types.d.ts +11 -12
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/internal/meta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResourceCodec } from '../codec.js';
|
|
1
|
+
import type { MetaReadSlot, MetaWriteSlot, ResourceCodec } from '../codec.js';
|
|
2
2
|
import type { ClientContext } from './request.js';
|
|
3
3
|
import type { IZcap, ResourceMetadataCustom, ResourceMetadataCustomInput } from '../types.js';
|
|
4
4
|
/**
|
|
@@ -13,18 +13,18 @@ import type { IZcap, ResourceMetadataCustom, ResourceMetadataCustomInput } from
|
|
|
13
13
|
* concurrently with the read
|
|
14
14
|
* @param options.subject {string} the metadata's owner as it reads in the
|
|
15
15
|
* malformed-response error message
|
|
16
|
-
* @param
|
|
17
|
-
*
|
|
16
|
+
* @param options.slot {MetaReadSlot} the `/meta` slot being read, for an
|
|
17
|
+
* encrypting codec's envelope-binding check
|
|
18
18
|
* @param [options.capability] {IZcap}
|
|
19
19
|
* @returns {Promise<(Metadata & { etag?: string }) | null>}
|
|
20
20
|
*/
|
|
21
21
|
export declare function readMeta<Metadata extends {
|
|
22
22
|
custom?: ResourceMetadataCustom;
|
|
23
|
-
}>(context: ClientContext, { metaPath, codec: codecPromise, subject,
|
|
23
|
+
}>(context: ClientContext, { metaPath, codec: codecPromise, subject, slot, capability }: {
|
|
24
24
|
metaPath: string;
|
|
25
25
|
codec: Promise<ResourceCodec>;
|
|
26
26
|
subject: string;
|
|
27
|
-
|
|
27
|
+
slot: MetaReadSlot;
|
|
28
28
|
capability?: IZcap;
|
|
29
29
|
}): Promise<(Metadata & {
|
|
30
30
|
etag?: string;
|
|
@@ -45,19 +45,19 @@ export declare function readMeta<Metadata extends {
|
|
|
45
45
|
* stamp describes the `custom` envelope itself; false at Resource level,
|
|
46
46
|
* where a Resource's epoch instead stamps its content write via the
|
|
47
47
|
* `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
|
|
48
|
-
* @param
|
|
49
|
-
*
|
|
48
|
+
* @param options.slot {MetaWriteSlot} the `/meta` slot being written, which
|
|
49
|
+
* an encrypting codec binds into the envelope
|
|
50
50
|
* @param [options.ifMatch] {string} update only if the `/meta` ETag matches
|
|
51
51
|
* @param [options.ifNoneMatch] {boolean} write only if no metadata is set
|
|
52
52
|
* @param [options.capability] {IZcap}
|
|
53
53
|
* @returns {Promise<{ etag?: string }>} the metadata's new ETag
|
|
54
54
|
*/
|
|
55
|
-
export declare function writeMeta(context: ClientContext, { metaPath, codec: codecPromise, custom, sendEpoch,
|
|
55
|
+
export declare function writeMeta(context: ClientContext, { metaPath, codec: codecPromise, custom, sendEpoch, slot, ifMatch, ifNoneMatch, capability }: {
|
|
56
56
|
metaPath: string;
|
|
57
57
|
codec: Promise<ResourceCodec>;
|
|
58
58
|
custom: ResourceMetadataCustomInput;
|
|
59
59
|
sendEpoch: boolean;
|
|
60
|
-
|
|
60
|
+
slot: MetaWriteSlot;
|
|
61
61
|
ifMatch?: string;
|
|
62
62
|
ifNoneMatch?: boolean;
|
|
63
63
|
capability?: IZcap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,OAAO,KAAK,EACV,KAAK,EACL,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,SAAS;IAAE,MAAM,CAAC,EAAE,sBAAsB,CAAA;CAAE,EAEpD,OAAO,EAAE,aAAa,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,OAAO,EACP,IAAI,EACJ,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,YAAY,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GACA,OAAO,CAAC,CAAC,QAAQ,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,IAAI,CAAC,CAsChD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,aAAa,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,MAAM,EACN,SAAS,EACT,IAAI,EACJ,OAAO,EACP,WAAW,EACX,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC7B,MAAM,EAAE,2BAA2B,CAAA;IACnC,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GACA,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAoB5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,IAAI,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,sBAAsB,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAA;IAC1E,OAAO,CACL,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,sBAAsB,CAAA;KAAE,EACzC,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5B,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9B,EACD,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
package/dist/internal/meta.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Shared `/meta` I/O for the Collection and Resource handles. The two read and
|
|
6
6
|
* write the same metadata document shape and differ only in the metadata type,
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* the `/meta` slot the `custom` envelope is bound to, and whether the codec's
|
|
8
|
+
* key epoch travels in the PUT body. Each handle wraps these with its
|
|
9
9
|
* own JSDoc.
|
|
10
10
|
*/
|
|
11
11
|
import { WasServerError } from '../errors.js';
|
|
@@ -24,12 +24,12 @@ import { withCodec } from './withCodec.js';
|
|
|
24
24
|
* concurrently with the read
|
|
25
25
|
* @param options.subject {string} the metadata's owner as it reads in the
|
|
26
26
|
* malformed-response error message
|
|
27
|
-
* @param
|
|
28
|
-
*
|
|
27
|
+
* @param options.slot {MetaReadSlot} the `/meta` slot being read, for an
|
|
28
|
+
* encrypting codec's envelope-binding check
|
|
29
29
|
* @param [options.capability] {IZcap}
|
|
30
30
|
* @returns {Promise<(Metadata & { etag?: string }) | null>}
|
|
31
31
|
*/
|
|
32
|
-
export async function readMeta(context, { metaPath, codec: codecPromise, subject,
|
|
32
|
+
export async function readMeta(context, { metaPath, codec: codecPromise, subject, slot, capability }) {
|
|
33
33
|
// The metadata GET does not depend on the codec (only its `custom` decode
|
|
34
34
|
// below does), so the two overlap.
|
|
35
35
|
const [codec, response] = await withCodec(codecPromise, send(context, {
|
|
@@ -55,11 +55,10 @@ export async function readMeta(context, { metaPath, codec: codecPromise, subject
|
|
|
55
55
|
}
|
|
56
56
|
const metadata = response.data;
|
|
57
57
|
// Decode the user-writable `custom` (decrypting it on an encrypted
|
|
58
|
-
// collection) so callers uniformly see plaintext `{ name, tags }`.
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
const custom = await codec.decodeMeta({ custom: metadata.custom }, id);
|
|
58
|
+
// collection) so callers uniformly see plaintext `{ name, tags }`. The
|
|
59
|
+
// stated slot drives the encrypting codec's binding check: in the
|
|
60
|
+
// Collection slot it refuses a resource-bound envelope served there.
|
|
61
|
+
const custom = await codec.decodeMeta({ custom: metadata.custom }, slot);
|
|
63
62
|
const decoded = { ...metadata, custom };
|
|
64
63
|
const etag = readEtag(response);
|
|
65
64
|
return etag !== undefined ? { ...decoded, etag } : decoded;
|
|
@@ -80,16 +79,16 @@ export async function readMeta(context, { metaPath, codec: codecPromise, subject
|
|
|
80
79
|
* stamp describes the `custom` envelope itself; false at Resource level,
|
|
81
80
|
* where a Resource's epoch instead stamps its content write via the
|
|
82
81
|
* `Key-Epoch` header, so an epoch surfaced here is deliberately dropped.
|
|
83
|
-
* @param
|
|
84
|
-
*
|
|
82
|
+
* @param options.slot {MetaWriteSlot} the `/meta` slot being written, which
|
|
83
|
+
* an encrypting codec binds into the envelope
|
|
85
84
|
* @param [options.ifMatch] {string} update only if the `/meta` ETag matches
|
|
86
85
|
* @param [options.ifNoneMatch] {boolean} write only if no metadata is set
|
|
87
86
|
* @param [options.capability] {IZcap}
|
|
88
87
|
* @returns {Promise<{ etag?: string }>} the metadata's new ETag
|
|
89
88
|
*/
|
|
90
|
-
export async function writeMeta(context, { metaPath, codec: codecPromise, custom, sendEpoch,
|
|
89
|
+
export async function writeMeta(context, { metaPath, codec: codecPromise, custom, sendEpoch, slot, ifMatch, ifNoneMatch, capability }) {
|
|
91
90
|
const codec = await codecPromise;
|
|
92
|
-
const { custom: encoded, epoch } = await codec.encodeMeta(
|
|
91
|
+
const { custom: encoded, epoch } = await codec.encodeMeta({ custom, slot });
|
|
93
92
|
const response = await send(context, {
|
|
94
93
|
path: metaPath,
|
|
95
94
|
method: 'PUT',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/internal/meta.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAG5B,OAAsB,EACtB,EACE,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,OAAO,EACP,
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","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C,EAAE,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAMC,EACD,KAA6B;IAE7B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;IACnC,MAAM,MAAM,CAAC,OAAO,CAClB,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,EAC5C,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAC3B,CAAA;AACH,CAAC"}
|
|
@@ -96,4 +96,23 @@ export declare function readData<T>(context: ClientContext, { path, capability }
|
|
|
96
96
|
path: string;
|
|
97
97
|
capability?: IZcap;
|
|
98
98
|
}): Promise<T | null>;
|
|
99
|
+
/**
|
|
100
|
+
* {@link readData} keeping the response's `ETag` validator beside the body:
|
|
101
|
+
* the read-with-validator shape a description compare-and-swap starts from.
|
|
102
|
+
* `null` on the same conditions as `readData`; `etag` is absent against a
|
|
103
|
+
* server that does not version the target.
|
|
104
|
+
*
|
|
105
|
+
* @param context {ClientContext}
|
|
106
|
+
* @param options {object}
|
|
107
|
+
* @param options.path {string} the path to read
|
|
108
|
+
* @param [options.capability] {IZcap} capability attached to the request
|
|
109
|
+
* @returns {Promise<{ data: T; etag?: string } | null>}
|
|
110
|
+
*/
|
|
111
|
+
export declare function readDataWithEtag<T>(context: ClientContext, { path, capability }: {
|
|
112
|
+
path: string;
|
|
113
|
+
capability?: IZcap;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
data: T;
|
|
116
|
+
etag?: string;
|
|
117
|
+
} | null>;
|
|
99
118
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,C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GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAS9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,OAAO,EAAE,aAAa,EACtB,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAQnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,OAAO,EAAE,aAAa,EACtB,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzD,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAY5C"}
|
package/dist/internal/request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mapError, httpStatus } from '../errors.js';
|
|
2
2
|
import { toUrl } from './paths.js';
|
|
3
3
|
import { dataOrNull } from './content.js';
|
|
4
|
+
import { readEtag } from './conditional.js';
|
|
4
5
|
function resolveRequestUrl(context, input) {
|
|
5
6
|
if (input.url !== undefined) {
|
|
6
7
|
return input.url;
|
|
@@ -122,4 +123,29 @@ export async function readData(context, { path, capability }) {
|
|
|
122
123
|
});
|
|
123
124
|
return dataOrNull(response);
|
|
124
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* {@link readData} keeping the response's `ETag` validator beside the body:
|
|
128
|
+
* the read-with-validator shape a description compare-and-swap starts from.
|
|
129
|
+
* `null` on the same conditions as `readData`; `etag` is absent against a
|
|
130
|
+
* server that does not version the target.
|
|
131
|
+
*
|
|
132
|
+
* @param context {ClientContext}
|
|
133
|
+
* @param options {object}
|
|
134
|
+
* @param options.path {string} the path to read
|
|
135
|
+
* @param [options.capability] {IZcap} capability attached to the request
|
|
136
|
+
* @returns {Promise<{ data: T; etag?: string } | null>}
|
|
137
|
+
*/
|
|
138
|
+
export async function readDataWithEtag(context, { path, capability }) {
|
|
139
|
+
const response = await send(context, {
|
|
140
|
+
path,
|
|
141
|
+
method: 'GET',
|
|
142
|
+
capability,
|
|
143
|
+
read: true
|
|
144
|
+
});
|
|
145
|
+
const data = dataOrNull(response);
|
|
146
|
+
if (data === null) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return { data, etag: readEtag(response) };
|
|
150
|
+
}
|
|
125
151
|
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/internal/request.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAkC3C,SAAS,iBAAiB,CAAC,OAAsB,EAAE,KAAgB;IACjE,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,GAAG,CAAA;IAClB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC,EAAE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,EAAE,IAAI,EAAE,UAAU,EAAwC;IAE1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QACnC,IAAI;QACJ,MAAM,EAAE,KAAK;QACb,UAAU;QACV,IAAI,EAAE,IAAI;KACX,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,UAAU,CAAI,QAAQ,CAAC,CAAA;IACpC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3C,CAAC"}
|
package/dist/log/logStore.d.ts
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* create against a log that already exists -- is rethrown as the library's
|
|
27
27
|
* `ResourceLogConflictError` with the transport's `PreconditionFailedError`
|
|
28
28
|
* as `cause`, which is the port's one conflict signal and what the library's
|
|
29
|
-
* rebase loop catches (by `name
|
|
30
|
-
* adapter-to-library package boundary).
|
|
29
|
+
* rebase loop catches (by `name` rather than `instanceof`, since the error
|
|
30
|
+
* crosses the adapter-to-library package boundary).
|
|
31
31
|
*/
|
|
32
32
|
import { type ResourceLogStore } from '@interop/vh-resource-log';
|
|
33
33
|
import type { Collection } from '../Collection.js';
|
|
@@ -39,13 +39,16 @@ export { LOG_CONTENT_TYPE };
|
|
|
39
39
|
* one of two hosts: `resource`, a WAS Resource whose whole body is the log,
|
|
40
40
|
* or `collection`, whose governing history log at `/meta/log` is the log.
|
|
41
41
|
* `append` carries the prior entries' bytes forward verbatim from the most
|
|
42
|
-
* recent read (an append
|
|
43
|
-
* `create` translate the transport's 412 into the library's conflict
|
|
42
|
+
* recent read (an append does not re-serialize history), and both `append`
|
|
43
|
+
* and `create` translate the transport's 412 into the library's conflict
|
|
44
|
+
* error. A served log with an empty body reads as absent (the pre-genesis
|
|
45
|
+
* `null`), the state a host that has no log for the slot should report as
|
|
46
|
+
* 404; under a held pin the library still refuses it as a rollback.
|
|
44
47
|
*
|
|
45
48
|
* @param options {object}
|
|
46
49
|
* @param [options.resource] {Resource} the Resource holding the log
|
|
47
50
|
* @param [options.collection] {Collection} the Collection whose history log
|
|
48
|
-
* is the log; exactly one of the two is given
|
|
51
|
+
* is the log; exactly one of the two is given, or `ValidationError`
|
|
49
52
|
* @returns {ResourceLogStore}
|
|
50
53
|
*/
|
|
51
54
|
export declare function resourceLogStore(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAW,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAwD3B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EACH;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAA;CAAE,GAC9C;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GACnD,gBAAgB,CA0FlB"}
|
package/dist/log/logStore.js
CHANGED
|
@@ -26,19 +26,17 @@
|
|
|
26
26
|
* create against a log that already exists -- is rethrown as the library's
|
|
27
27
|
* `ResourceLogConflictError` with the transport's `PreconditionFailedError`
|
|
28
28
|
* as `cause`, which is the port's one conflict signal and what the library's
|
|
29
|
-
* rebase loop catches (by `name
|
|
30
|
-
* adapter-to-library package boundary).
|
|
29
|
+
* rebase loop catches (by `name` rather than `instanceof`, since the error
|
|
30
|
+
* crosses the adapter-to-library package boundary).
|
|
31
31
|
*/
|
|
32
32
|
import { ResourceLogConflictError, parseResourceLog, serializeResourceLog, serializeResourceLogEntry } from '@interop/vh-resource-log';
|
|
33
33
|
import { PreconditionFailedError, ValidationError } from '../errors.js';
|
|
34
|
-
import {
|
|
35
|
-
import { ENCODER, LOG_CONTENT_TYPE, isBlob } from '../internal/content.js';
|
|
34
|
+
import { ENCODER, LOG_CONTENT_TYPE } from '../internal/content.js';
|
|
36
35
|
export { LOG_CONTENT_TYPE };
|
|
37
36
|
/**
|
|
38
|
-
* The Resource host: `getWithEtag` (so the codec runs and
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `text()`; `blobText` falls back to `FileReader`).
|
|
37
|
+
* The Resource host: `getWithEtag({ as: 'text' })` (so the codec runs and
|
|
38
|
+
* the content layer projects the decoded body to text) and `put` with the
|
|
39
|
+
* log content type.
|
|
42
40
|
*
|
|
43
41
|
* @param resource {Resource}
|
|
44
42
|
* @returns {LogTarget}
|
|
@@ -46,20 +44,10 @@ export { LOG_CONTENT_TYPE };
|
|
|
46
44
|
function resourceTarget(resource) {
|
|
47
45
|
return {
|
|
48
46
|
async read() {
|
|
49
|
-
const current = await resource.getWithEtag();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const body = isBlob(current.data)
|
|
54
|
-
? await blobText(current.data)
|
|
55
|
-
: typeof current.data === 'string'
|
|
56
|
-
? current.data
|
|
57
|
-
: undefined;
|
|
58
|
-
if (body === undefined) {
|
|
59
|
-
throw new ValidationError(`Cannot read resource log: the resource "${resource.id}" does not ` +
|
|
60
|
-
'hold a text body (is it stored as JSON instead of JSON Lines?).');
|
|
61
|
-
}
|
|
62
|
-
return { body, etag: current.etag };
|
|
47
|
+
const current = await resource.getWithEtag({ as: 'text' });
|
|
48
|
+
return current === null
|
|
49
|
+
? null
|
|
50
|
+
: { body: current.data, etag: current.etag };
|
|
63
51
|
},
|
|
64
52
|
async put(body, precondition) {
|
|
65
53
|
await resource.put(ENCODER.encode(body), {
|
|
@@ -89,28 +77,40 @@ function collectionTarget(collection) {
|
|
|
89
77
|
* one of two hosts: `resource`, a WAS Resource whose whole body is the log,
|
|
90
78
|
* or `collection`, whose governing history log at `/meta/log` is the log.
|
|
91
79
|
* `append` carries the prior entries' bytes forward verbatim from the most
|
|
92
|
-
* recent read (an append
|
|
93
|
-
* `create` translate the transport's 412 into the library's conflict
|
|
80
|
+
* recent read (an append does not re-serialize history), and both `append`
|
|
81
|
+
* and `create` translate the transport's 412 into the library's conflict
|
|
82
|
+
* error. A served log with an empty body reads as absent (the pre-genesis
|
|
83
|
+
* `null`), the state a host that has no log for the slot should report as
|
|
84
|
+
* 404; under a held pin the library still refuses it as a rollback.
|
|
94
85
|
*
|
|
95
86
|
* @param options {object}
|
|
96
87
|
* @param [options.resource] {Resource} the Resource holding the log
|
|
97
88
|
* @param [options.collection] {Collection} the Collection whose history log
|
|
98
|
-
* is the log; exactly one of the two is given
|
|
89
|
+
* is the log; exactly one of the two is given, or `ValidationError`
|
|
99
90
|
* @returns {ResourceLogStore}
|
|
100
91
|
*/
|
|
101
92
|
export function resourceLogStore(options) {
|
|
93
|
+
if (options.resource !== undefined && options.collection !== undefined) {
|
|
94
|
+
throw new ValidationError('Pass either `resource` (the Resource holding the log) or ' +
|
|
95
|
+
'`collection` (the Collection whose history log is the log), not both.');
|
|
96
|
+
}
|
|
97
|
+
if (options.resource === undefined && options.collection === undefined) {
|
|
98
|
+
throw new ValidationError('A resource log store needs its host: pass `resource` or `collection`.');
|
|
99
|
+
}
|
|
102
100
|
const target = options.resource !== undefined
|
|
103
101
|
? resourceTarget(options.resource)
|
|
104
102
|
: collectionTarget(options.collection);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
/**
|
|
104
|
+
* The raw body observed by the most recent read; an append extends these
|
|
105
|
+
* bytes verbatim instead of re-serializing the parsed entries. Safe to carry
|
|
106
|
+
* even if stale: the append is pinned to the same read's ETag, so a
|
|
107
|
+
* concurrent append fails the CAS instead.
|
|
108
|
+
*/
|
|
109
109
|
let lastReadBody;
|
|
110
110
|
return {
|
|
111
111
|
async read() {
|
|
112
112
|
const current = await target.read();
|
|
113
|
-
if (current === null) {
|
|
113
|
+
if (current === null || current.body === '') {
|
|
114
114
|
return null;
|
|
115
115
|
}
|
|
116
116
|
const entries = parseResourceLog(current.body);
|
package/dist/log/logStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logStore.js","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAE1B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"logStore.js","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EAE1B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;A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+D;oBAC/D,WAAW;aACd,CAAC,CAAA;YACF,YAAY,GAAG,QAAQ,CAAA;QACzB,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,KAAK;YAChB,MAAM,UAAU,GAAG,oBAAoB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;YAChD,MAAM,aAAa,CAAC;gBAClB,IAAI,EAAE,UAAU;gBAChB,YAAY,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;gBACnC,QAAQ,EACN,4DAA4D;oBAC5D,iBAAiB;aACpB,CAAC,CAAA;YACF,YAAY,GAAG,UAAU,CAAA;QAC3B,CAAC;KACF,CAAA;IAED;;;;;;OAMG;IACH,KAAK,UAAU,aAAa,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,QAAQ,EAKT;QACC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,uBAAuB,EAAE,CAAC;gBAC3C,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;YAC9D,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -15,13 +15,19 @@
|
|
|
15
15
|
* every encrypted collection must carry before any read or write routes
|
|
16
16
|
* (epoch-from-birth) -- is installed by the EDV-bearing second step,
|
|
17
17
|
* `ensureFirstEpoch` in `@interop/was-client/edv`.
|
|
18
|
+
*
|
|
19
|
+
* Three collection modes: `'edv'` (the client-written encryption descriptor),
|
|
20
|
+
* `'plaintext'` (no descriptor), and `'governed'` (a Collection whose
|
|
21
|
+
* `encryption` member the server derives from its history log). A `'governed'`
|
|
22
|
+
* collection is created descriptor-less here and declared governed afterwards,
|
|
23
|
+
* by the caller's guarded create of the log.
|
|
18
24
|
*/
|
|
19
25
|
import type { SpaceDescription } from '../types.js';
|
|
20
26
|
import type { WasClient } from '../WasClient.js';
|
|
21
27
|
/**
|
|
22
28
|
* Ensures the controller's Space exists and one synced collection is
|
|
23
29
|
* configured, without overwriting anything already there. The Space is
|
|
24
|
-
* described first and
|
|
30
|
+
* described first and created only when absent -- an existing Space keeps
|
|
25
31
|
* its name AND its controller, so `controllerDid` is used only at creation
|
|
26
32
|
* (a joined client re-running this never rewrites the description). The
|
|
27
33
|
* collection likewise: when absent, an `'edv'` collection is created with the
|
|
@@ -29,16 +35,29 @@ import type { WasClient } from '../WasClient.js';
|
|
|
29
35
|
* the server stores only ciphertext it can never decrypt and validates every
|
|
30
36
|
* write against the declared envelope wire format -- the same version the
|
|
31
37
|
* cipher binds into each envelope's AEAD-protected header, so descriptor and
|
|
32
|
-
* envelopes cannot drift; a `'plaintext'` collection is created
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* envelopes cannot drift; a `'plaintext'` or `'governed'` collection is created
|
|
39
|
+
* without one. Both creates are guarded (`If-None-Match: *`), so two clients
|
|
40
|
+
* booting at once cannot both create, and the loser adopts the winner's
|
|
41
|
+
* description instead of failing. Against a server that ignores the
|
|
42
|
+
* precondition the create is an unconditional upsert, and the loser of a race
|
|
43
|
+
* can overwrite the winner's display name; the server merges the rest of the
|
|
44
|
+
* winner's description forward.
|
|
45
|
+
*
|
|
46
|
+
* An existing collection that lacks the descriptor an `'edv'` spec calls for
|
|
36
47
|
* gets the late in-place declaration (set-once on the server); one that
|
|
37
48
|
* already carries a descriptor -- possibly with appended key epochs -- is
|
|
38
|
-
* left untouched, epochs and display name included.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
49
|
+
* left untouched, epochs and display name included. An existing `'governed'`
|
|
50
|
+
* collection is never written to: the server refuses to govern a Description
|
|
51
|
+
* that carries a client-written descriptor (`encryption-immutable`), and a
|
|
52
|
+
* governed Collection's served `encryption` is the derived member, which a
|
|
53
|
+
* Description PUT may not carry (`encryption-history-log-governed`). So an
|
|
54
|
+
* existing collection whose descriptor is client-written (no `history`
|
|
55
|
+
* member) cannot become governed, and a `'governed'` spec over it throws
|
|
56
|
+
* `ValidationError` here rather than letting the caller's log create fail
|
|
57
|
+
* with the server's 409. A public collection gets the collection-level
|
|
58
|
+
* world-read grant (`setPublic`, what makes a resource URL in it resolve for
|
|
59
|
+
* anyone) only when its policy does not already say so. Runs full-tier -- the
|
|
60
|
+
* client invokes its own root authority.
|
|
42
61
|
*
|
|
43
62
|
* @param options {object}
|
|
44
63
|
* @param options.was {WasClient}
|
|
@@ -46,7 +65,14 @@ import type { WasClient } from '../WasClient.js';
|
|
|
46
65
|
* @param options.controllerDid {string} the Space controller (e.g. `did:key`);
|
|
47
66
|
* used only when the Space does not exist yet
|
|
48
67
|
* @param options.collectionId {string} the WAS collection id
|
|
49
|
-
* @param [options.encryption] {'edv' | 'plaintext'
|
|
68
|
+
* @param [options.encryption] {'edv' | 'plaintext' | 'governed'} how the
|
|
69
|
+
* collection's `encryption` member is settled; defaults to `'edv'`.
|
|
70
|
+
* `'edv'` declares the descriptor here, `'plaintext'` declares none, and
|
|
71
|
+
* `'governed'` leaves the member to the server, which derives it from the
|
|
72
|
+
* collection's history log. Declaring that governance is the caller's next
|
|
73
|
+
* step, through the log's guarded create --
|
|
74
|
+
* `logGovernedDescriptorStore(...).create` or
|
|
75
|
+
* `resourceLogStore({ collection }).create`
|
|
50
76
|
* @param [options.isPublic] {boolean} grant collection-level world read
|
|
51
77
|
* @param [options.spaceName] {string} the Space display name, applied only at
|
|
52
78
|
* Space creation; defaults to `'WAS Space'`
|
|
@@ -67,7 +93,7 @@ export declare function ensureSpaceAndCollection({ was, spaceId, controllerDid,
|
|
|
67
93
|
spaceId: string;
|
|
68
94
|
controllerDid: string;
|
|
69
95
|
collectionId: string;
|
|
70
|
-
encryption?: 'edv' | 'plaintext';
|
|
96
|
+
encryption?: 'edv' | 'plaintext' | 'governed';
|
|
71
97
|
isPublic?: boolean;
|
|
72
98
|
spaceName?: string;
|
|
73
99
|
collectionName?: string;
|
|
@@ -78,11 +104,13 @@ export declare function ensureSpaceAndCollection({ was, spaceId, controllerDid,
|
|
|
78
104
|
* there -- the Space half of {@link ensureSpaceAndCollection}, split out so a
|
|
79
105
|
* caller provisioning SEVERAL collections into one Space pays for it once
|
|
80
106
|
* rather than once per collection. An existing Space keeps its name AND its
|
|
81
|
-
* controller, so `controllerDid` is used only at creation.
|
|
107
|
+
* controller, so `controllerDid` is used only at creation. The create is
|
|
108
|
+
* guarded (`If-None-Match: *`), so a Space created concurrently keeps its
|
|
109
|
+
* `type` array (accepted at creation only) and is adopted by the loser.
|
|
82
110
|
*
|
|
83
|
-
* Costs one `GET` on a settled Space, and one `GET` plus one `PUT`
|
|
84
|
-
*
|
|
85
|
-
*
|
|
111
|
+
* Costs one `GET` on a settled Space, and one `GET` plus one guarded `PUT`
|
|
112
|
+
* (`If-None-Match: *`) on a fresh one; a lost create race costs one more `GET`
|
|
113
|
+
* to adopt the winner.
|
|
86
114
|
*
|
|
87
115
|
* @param options {object}
|
|
88
116
|
* @param options.was {WasClient}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisioning.d.ts","sourceRoot":"","sources":["../../src/sync/provisioning.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"provisioning.d.ts","sourceRoot":"","sources":["../../src/sync/provisioning.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAkGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,GAAG,EACH,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAkB,EAClB,QAAgB,EAChB,SAA8B,EAC9B,cAA6B,EAC7B,gBAAgB,EACjB,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,UAAU,CAAA;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGhB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,OAAO,EACP,aAAa,EACb,SAA8B,EAC/B,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB5B"}
|