@interop/was-client 0.64.0 → 0.66.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 +31 -23
- package/dist/Collection.d.ts +26 -2
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +49 -39
- package/dist/Collection.js.map +1 -1
- package/dist/Resource.d.ts +10 -4
- package/dist/Resource.d.ts.map +1 -1
- package/dist/Resource.js +21 -9
- package/dist/Resource.js.map +1 -1
- package/dist/Space.d.ts +32 -14
- package/dist/Space.d.ts.map +1 -1
- package/dist/Space.js +104 -42
- package/dist/Space.js.map +1 -1
- package/dist/WasClient.d.ts.map +1 -1
- package/dist/WasClient.js +5 -1
- package/dist/WasClient.js.map +1 -1
- package/dist/codec.d.ts +6 -5
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +1 -1
- package/dist/codec.js.map +1 -1
- package/dist/edv/EdvCodec.d.ts.map +1 -1
- package/dist/edv/EdvCodec.js +3 -2
- package/dist/edv/EdvCodec.js.map +1 -1
- package/dist/edv/descriptorStore.d.ts +14 -11
- package/dist/edv/descriptorStore.d.ts.map +1 -1
- package/dist/edv/descriptorStore.js +7 -5
- package/dist/edv/descriptorStore.js.map +1 -1
- package/dist/edv/docCipher.d.ts +11 -1
- package/dist/edv/docCipher.d.ts.map +1 -1
- package/dist/edv/docCipher.js +24 -6
- package/dist/edv/docCipher.js.map +1 -1
- package/dist/edv/epochRoster.d.ts +20 -11
- package/dist/edv/epochRoster.d.ts.map +1 -1
- package/dist/edv/epochRoster.js +29 -16
- package/dist/edv/epochRoster.js.map +1 -1
- package/dist/edv/index.d.ts +3 -1
- package/dist/edv/index.d.ts.map +1 -1
- package/dist/edv/index.js +3 -1
- package/dist/edv/index.js.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.d.ts.map +1 -1
- package/dist/edv/logGovernedDescriptorStore.js +5 -2
- package/dist/edv/logGovernedDescriptorStore.js.map +1 -1
- package/dist/edv/refreshingDocCipher.d.ts +4 -1
- package/dist/edv/refreshingDocCipher.d.ts.map +1 -1
- package/dist/edv/refreshingDocCipher.js +7 -4
- package/dist/edv/refreshingDocCipher.js.map +1 -1
- package/dist/errors.d.ts +17 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -1
- package/dist/errors.js.map +1 -1
- package/dist/internal/cas.d.ts +58 -1
- package/dist/internal/cas.d.ts.map +1 -1
- package/dist/internal/cas.js +79 -3
- package/dist/internal/cas.js.map +1 -1
- package/dist/internal/conditional.d.ts +85 -4
- package/dist/internal/conditional.d.ts.map +1 -1
- package/dist/internal/conditional.js +102 -2
- package/dist/internal/conditional.js.map +1 -1
- package/dist/internal/features.d.ts +9 -3
- package/dist/internal/features.d.ts.map +1 -1
- package/dist/internal/features.js +33 -4
- package/dist/internal/features.js.map +1 -1
- package/dist/internal/meta.d.ts +20 -2
- package/dist/internal/meta.d.ts.map +1 -1
- package/dist/internal/meta.js +30 -4
- package/dist/internal/meta.js.map +1 -1
- package/dist/internal/request.d.ts +10 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/write.d.ts +9 -2
- package/dist/internal/write.d.ts.map +1 -1
- package/dist/internal/write.js +18 -3
- package/dist/internal/write.js.map +1 -1
- package/dist/log/logStore.d.ts +11 -5
- package/dist/log/logStore.d.ts.map +1 -1
- package/dist/log/logStore.js +18 -5
- package/dist/log/logStore.js.map +1 -1
- package/dist/sync/index.d.ts +8 -5
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -5
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/plaintextCipher.d.ts +6 -4
- package/dist/sync/plaintextCipher.d.ts.map +1 -1
- package/dist/sync/plaintextCipher.js +19 -6
- package/dist/sync/plaintextCipher.js.map +1 -1
- package/dist/sync/port.d.ts +7 -1
- package/dist/sync/port.d.ts.map +1 -1
- package/dist/sync/port.js +18 -2
- package/dist/sync/port.js.map +1 -1
- package/dist/sync/predicates.d.ts +14 -3
- package/dist/sync/predicates.d.ts.map +1 -1
- package/dist/sync/predicates.js +16 -3
- package/dist/sync/predicates.js.map +1 -1
- package/dist/sync/types.d.ts +21 -1
- package/dist/sync/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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;AAG9C,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,CAgGlB"}
|
package/dist/log/logStore.js
CHANGED
|
@@ -19,11 +19,17 @@
|
|
|
19
19
|
* document under a human-readable id. A Collection's history log is never
|
|
20
20
|
* encrypted and runs no codec: the server reads its head itself.
|
|
21
21
|
*
|
|
22
|
-
* Both the append and the create
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* Both the append and the create depend on their precondition being enforced --
|
|
23
|
+
* the profile requires it (without it, concurrent appends silently overwrite
|
|
24
|
+
* one another instead of failing into the caller's rebase-and-retry loop). On
|
|
25
|
+
* a Resource host that is the backend's `conditional-writes` feature, and
|
|
26
|
+
* `Resource.put` refuses the write before it is sent when the backend was read
|
|
27
|
+
* and does not advertise it. A Collection's history log carries its own
|
|
28
|
+
* validator, which a server implementing the sub-resource honors whether or
|
|
29
|
+
* not the backend advertises the feature, so nothing gates that host. Either
|
|
30
|
+
* way an append is refused when the read it extends returned no validator.
|
|
31
|
+
* A lost race -- a stale `ifMatch`, or a guarded create against a log that
|
|
32
|
+
* already exists -- is rethrown as the library's
|
|
27
33
|
* `ResourceLogConflictError` with the transport's `PreconditionFailedError`
|
|
28
34
|
* as `cause`, which is the port's one conflict signal and what the library's
|
|
29
35
|
* rebase loop catches (by `name` rather than `instanceof`, since the error
|
|
@@ -31,6 +37,7 @@
|
|
|
31
37
|
*/
|
|
32
38
|
import { ResourceLogConflictError, parseResourceLog, serializeResourceLog, serializeResourceLogEntry } from '@interop/vh-resource-log';
|
|
33
39
|
import { PreconditionFailedError, ValidationError } from '../errors.js';
|
|
40
|
+
import { unenforcedPreconditionError } from '../internal/conditional.js';
|
|
34
41
|
import { ENCODER, LOG_CONTENT_TYPE } from '../internal/content.js';
|
|
35
42
|
export { LOG_CONTENT_TYPE };
|
|
36
43
|
/**
|
|
@@ -122,6 +129,12 @@ export function resourceLogStore(options) {
|
|
|
122
129
|
throw new ValidationError('Cannot append to resource log: append must follow a read on the ' +
|
|
123
130
|
'same store instance.');
|
|
124
131
|
}
|
|
132
|
+
if (ifMatch === undefined) {
|
|
133
|
+
throw unenforcedPreconditionError({
|
|
134
|
+
operation: 'Cannot append to the resource log',
|
|
135
|
+
reason: 'no-validator'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
125
138
|
const separator = lastReadBody.endsWith('\n') ? '' : '\n';
|
|
126
139
|
const extended = lastReadBody + separator + serializeResourceLogEntry(entry) + '\n';
|
|
127
140
|
await putOrConflict({
|
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
|
|
1
|
+
{"version":3,"file":"logStore.js","sourceRoot":"","sources":["../../src/log/logStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAElE,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAe3B;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,QAAkB;IACxC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;YAC1D,OAAO,OAAO,KAAK,IAAI;gBACrB,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAA;QAChD,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY;YAC1B,MAAM,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACvC,WAAW,EAAE,gBAAgB;gBAC7B,GAAG,YAAY;aAChB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,UAAsB;IAC9C,OAA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AO,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"}
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* Collection provisioning, and its Space half alone (ensure the Space once,
|
|
18
18
|
* then thread the returned description through every collection).
|
|
19
19
|
* - `isSyncConflictError` / `isSyncNotFoundError` / `isSyncAuthError` /
|
|
20
|
-
* `isUnknownEpochError`
|
|
20
|
+
* `isUnknownEpochError` / `isKeyUnwrapError` / `isIntegrityError` -- the
|
|
21
|
+
* classification contract for the signals
|
|
21
22
|
* below. A consumer matches by `err.name` and never with `instanceof`,
|
|
22
23
|
* because every one of these errors is raised inside a seam the app injects
|
|
23
24
|
* (the port, the caller's `DocCipher`) and that seam can resolve to a second
|
|
@@ -33,8 +34,10 @@
|
|
|
33
34
|
* signal (`UnknownEpochError`: the envelope's epoch is not on the descriptor at
|
|
34
35
|
* all, so re-read it and rebuild the cipher) and the membership signal
|
|
35
36
|
* (`KeyUnwrapError`: the epoch is on the descriptor but this reader holds no
|
|
36
|
-
* key for it, so a refresh cannot help).
|
|
37
|
-
*
|
|
37
|
+
* key for it, so a refresh cannot help). So is the tamper signal
|
|
38
|
+
* (`IntegrityError`: the stored body does not verify against the resource id
|
|
39
|
+
* it was read under). `EncryptionError`, the fail-closed umbrella both
|
|
40
|
+
* `KeyUnwrapError` and `IntegrityError` fall under, rides along. The classes are exported
|
|
38
41
|
* for construction and for a caller inside one resolved copy; across a package
|
|
39
42
|
* boundary the predicates are the contract
|
|
40
43
|
* (`decisions/0001-cross-package-errors-match-by-name.md`).
|
|
@@ -45,7 +48,7 @@ export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
|
45
48
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
46
49
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
|
47
50
|
export { ensureSpace, ensureSpaceAndCollection } from './provisioning.js';
|
|
48
|
-
export { isSyncAuthError, isSyncConflictError, isSyncNotFoundError, isKeyUnwrapError, isUnknownEpochError } from './predicates.js';
|
|
49
|
-
export { EncryptionError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
51
|
+
export { isSyncAuthError, isSyncConflictError, isSyncNotFoundError, isIntegrityError, isKeyUnwrapError, isUnknownEpochError } from './predicates.js';
|
|
52
|
+
export { EncryptionError, IntegrityError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
50
53
|
export type { Json, SyncCheckpoint, WireDoc, SyncPage, MasterState, WriteAck, SyncStatus, WasSyncPort, DocCipher } from './types.js';
|
|
51
54
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAI1E,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACtE,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,WAAW,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,eAAe,EACf,cAAc,EACd,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,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA"}
|
package/dist/sync/index.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
* Collection provisioning, and its Space half alone (ensure the Space once,
|
|
18
18
|
* then thread the returned description through every collection).
|
|
19
19
|
* - `isSyncConflictError` / `isSyncNotFoundError` / `isSyncAuthError` /
|
|
20
|
-
* `isUnknownEpochError`
|
|
20
|
+
* `isUnknownEpochError` / `isKeyUnwrapError` / `isIntegrityError` -- the
|
|
21
|
+
* classification contract for the signals
|
|
21
22
|
* below. A consumer matches by `err.name` and never with `instanceof`,
|
|
22
23
|
* because every one of these errors is raised inside a seam the app injects
|
|
23
24
|
* (the port, the caller's `DocCipher`) and that seam can resolve to a second
|
|
@@ -33,8 +34,10 @@
|
|
|
33
34
|
* signal (`UnknownEpochError`: the envelope's epoch is not on the descriptor at
|
|
34
35
|
* all, so re-read it and rebuild the cipher) and the membership signal
|
|
35
36
|
* (`KeyUnwrapError`: the epoch is on the descriptor but this reader holds no
|
|
36
|
-
* key for it, so a refresh cannot help).
|
|
37
|
-
*
|
|
37
|
+
* key for it, so a refresh cannot help). So is the tamper signal
|
|
38
|
+
* (`IntegrityError`: the stored body does not verify against the resource id
|
|
39
|
+
* it was read under). `EncryptionError`, the fail-closed umbrella both
|
|
40
|
+
* `KeyUnwrapError` and `IntegrityError` fall under, rides along. The classes are exported
|
|
38
41
|
* for construction and for a caller inside one resolved copy; across a package
|
|
39
42
|
* boundary the predicates are the contract
|
|
40
43
|
* (`decisions/0001-cross-package-errors-match-by-name.md`).
|
|
@@ -48,6 +51,6 @@ export { contentCid, cidFrom, deriveSpaceId } from './cid.js';
|
|
|
48
51
|
export { isEncryptedEnvelope } from './envelope.js';
|
|
49
52
|
export { createPlaintextDocCipher } from './plaintextCipher.js';
|
|
50
53
|
export { ensureSpace, ensureSpaceAndCollection } from './provisioning.js';
|
|
51
|
-
export { isSyncAuthError, isSyncConflictError, isSyncNotFoundError, isKeyUnwrapError, isUnknownEpochError } from './predicates.js';
|
|
52
|
-
export { EncryptionError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
54
|
+
export { isSyncAuthError, isSyncConflictError, isSyncNotFoundError, isIntegrityError, isKeyUnwrapError, isUnknownEpochError } from './predicates.js';
|
|
55
|
+
export { EncryptionError, IntegrityError, KeyUnwrapError, UnknownEpochError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError } from '../errors.js';
|
|
53
56
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,SAAS;AACT,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACtE,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,WAAW,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,cAAc,CAAA"}
|
|
@@ -2,12 +2,14 @@ import type { DocCipher } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Builds the identity {@link DocCipher} for a plaintext, content-addressed,
|
|
4
4
|
* insert-only collection. `encrypt` is the identity transform with a content-id
|
|
5
|
-
* key; `decrypt` returns the stored body unchanged
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* key; `decrypt` returns the stored body unchanged once its content id matches
|
|
6
|
+
* the resource id it was stored under, and throws {@link IntegrityError}
|
|
7
|
+
* otherwise (`ValidationError` when no id is passed); `encryptUpdate` throws -- a content-addressed document is never
|
|
8
|
+
* updated in place (a changed document is a different id).
|
|
8
9
|
*
|
|
9
10
|
* @param options {object}
|
|
10
|
-
* @param options.collectionId {string} labels the `encryptUpdate`
|
|
11
|
+
* @param options.collectionId {string} labels the `encryptUpdate` and
|
|
12
|
+
* `decrypt` errors
|
|
11
13
|
* @returns {DocCipher}
|
|
12
14
|
*/
|
|
13
15
|
export declare function createPlaintextDocCipher({ collectionId }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plaintextCipher.d.ts","sourceRoot":"","sources":["../../src/sync/plaintextCipher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plaintextCipher.d.ts","sourceRoot":"","sources":["../../src/sync/plaintextCipher.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,YAAY,CAAA;AAEjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,YAAY,EACb,EAAE;IACD,YAAY,EAAE,MAAM,CAAA;CACrB,GAAG,SAAS,CA2BZ"}
|
|
@@ -4,19 +4,24 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* The no-encryption (identity) {@link DocCipher} for a plaintext, content-
|
|
6
6
|
* addressed collection: the stored "envelope" IS the document, and the resource
|
|
7
|
-
* id is the document's content id
|
|
7
|
+
* id is the document's content id, so the content id is also the only
|
|
8
|
+
* integrity check a read has: `decrypt` recomputes it and refuses a document
|
|
9
|
+
* stored under an id it does not hash to. Kept free of the `@interop/was-client/edv`
|
|
8
10
|
* crypto graph so a plaintext-only consumer imports nothing it does not need.
|
|
9
11
|
*/
|
|
12
|
+
import { IntegrityError, requireResourceId } from '../errors.js';
|
|
10
13
|
import { contentCid } from './cid.js';
|
|
11
14
|
/**
|
|
12
15
|
* Builds the identity {@link DocCipher} for a plaintext, content-addressed,
|
|
13
16
|
* insert-only collection. `encrypt` is the identity transform with a content-id
|
|
14
|
-
* key; `decrypt` returns the stored body unchanged
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* key; `decrypt` returns the stored body unchanged once its content id matches
|
|
18
|
+
* the resource id it was stored under, and throws {@link IntegrityError}
|
|
19
|
+
* otherwise (`ValidationError` when no id is passed); `encryptUpdate` throws -- a content-addressed document is never
|
|
20
|
+
* updated in place (a changed document is a different id).
|
|
17
21
|
*
|
|
18
22
|
* @param options {object}
|
|
19
|
-
* @param options.collectionId {string} labels the `encryptUpdate`
|
|
23
|
+
* @param options.collectionId {string} labels the `encryptUpdate` and
|
|
24
|
+
* `decrypt` errors
|
|
20
25
|
* @returns {DocCipher}
|
|
21
26
|
*/
|
|
22
27
|
export function createPlaintextDocCipher({ collectionId }) {
|
|
@@ -28,7 +33,15 @@ export function createPlaintextDocCipher({ collectionId }) {
|
|
|
28
33
|
throw new Error(`Collection "${collectionId}" is content-addressed plaintext; ` +
|
|
29
34
|
'documents are never updated in place.');
|
|
30
35
|
},
|
|
31
|
-
async decrypt({ envelope }) {
|
|
36
|
+
async decrypt({ id, envelope }) {
|
|
37
|
+
requireResourceId({ id, collectionId });
|
|
38
|
+
const derived = contentCid(envelope);
|
|
39
|
+
if (derived !== id) {
|
|
40
|
+
throw new IntegrityError(`Cannot read resource "${id}" of collection "${collectionId}": its ` +
|
|
41
|
+
`content id is "${derived}", so the document was stored under an ` +
|
|
42
|
+
'id it was not written for. The server altered the document or ' +
|
|
43
|
+
'served it under another id.');
|
|
44
|
+
}
|
|
32
45
|
return envelope;
|
|
33
46
|
}
|
|
34
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plaintextCipher.js","sourceRoot":"","sources":["../../src/sync/plaintextCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"plaintextCipher.js","sourceRoot":"","sources":["../../src/sync/plaintextCipher.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGrC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CAAC,EACvC,YAAY,EAGb;IACC,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAkB;YACpC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACjD,CAAC;QAED,KAAK,CAAC,aAAa;YACjB,MAAM,IAAI,KAAK,CACb,eAAe,YAAY,oCAAoC;gBAC7D,uCAAuC,CAC1C,CAAA;QACH,CAAC;QAED,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAkC;YAC5D,iBAAiB,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,CAAA;YACvC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;YACpC,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;gBACnB,MAAM,IAAI,cAAc,CACtB,yBAAyB,EAAE,oBAAoB,YAAY,SAAS;oBAClE,kBAAkB,OAAO,yCAAyC;oBAClE,gEAAgE;oBAChE,6BAA6B,CAChC,CAAA;YACH,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/sync/port.d.ts
CHANGED
|
@@ -28,7 +28,13 @@
|
|
|
28
28
|
* WriteAck} -- the write's raw `etag` (re-read only if the backend sent
|
|
29
29
|
* none) plus its `version` parsed out of it -- so a caller can record acked
|
|
30
30
|
* revisions immediately and echo `etag` back verbatim as a later write's
|
|
31
|
-
* `ifMatch`.
|
|
31
|
+
* `ifMatch`. A write carrying `ifMatch` or `ifNoneMatch` is refused with
|
|
32
|
+
* `NotSupportedError` before it is sent when the collection's backend
|
|
33
|
+
* descriptor was read and advertises no `conditional-writes`, since a backend
|
|
34
|
+
* that ignores the header would turn a guarded push into a silent overwrite. A
|
|
35
|
+
* descriptor that could not be read is not evidence either way and the push
|
|
36
|
+
* goes out, so a collection that is briefly absent does not disable guarded
|
|
37
|
+
* pushes for the port's lifetime.
|
|
32
38
|
*
|
|
33
39
|
* Bypassing the codec is not bypassing the error mapper. Every failure caught
|
|
34
40
|
* here goes through the client's own `mapError` first, so the port's signals
|
package/dist/sync/port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EACL,gBAAgB,EAIjB,MAAM,4BAA4B,CAAA;AAYnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAIV,WAAW,EAEZ,MAAM,YAAY,CAAA;AAEnB;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAyG3B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW7E;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAqB,EACtB,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,GAAG,WAAW,CA4Pd"}
|
package/dist/sync/port.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KEY_EPOCH_HEADER, readEtag, writeHeaders } from '../internal/conditional.js';
|
|
1
|
+
import { KEY_EPOCH_HEADER, assertPreconditionEnforced, readEtag, writeHeaders } from '../internal/conditional.js';
|
|
2
2
|
import { resourceMeta, resourcePath } from '../internal/paths.js';
|
|
3
3
|
import { mapError, NotFoundError, PreconditionFailedError, WasSyncAuthError, WasSyncConflictError, WasSyncNotFoundError, WasServerError } from '../errors.js';
|
|
4
4
|
/**
|
|
@@ -187,7 +187,8 @@ export function createWasSyncPort({ was, spaceId, collectionId, capability, mapA
|
|
|
187
187
|
const metaPath = (id) => resourceMeta(spaceId, collectionId, id);
|
|
188
188
|
// Construction is I/O-free (the codec/feature probes are lazy thunks) and
|
|
189
189
|
// `changes()` never resolves the codec, so it ships the stored bodies
|
|
190
|
-
// verbatim -- what this codec-bypassing port requires.
|
|
190
|
+
// verbatim -- what this codec-bypassing port requires. Its feature probe
|
|
191
|
+
// also gates the port's precondition-bearing writes.
|
|
191
192
|
const changesCollection = was
|
|
192
193
|
.space(spaceId)
|
|
193
194
|
.collection(collectionId, { capability });
|
|
@@ -273,6 +274,11 @@ export function createWasSyncPort({ was, spaceId, collectionId, capability, mapA
|
|
|
273
274
|
},
|
|
274
275
|
async putContent({ id, data, ifMatch, ifNoneMatch, epoch }) {
|
|
275
276
|
try {
|
|
277
|
+
await assertPreconditionEnforced({
|
|
278
|
+
features: changesCollection.features,
|
|
279
|
+
precondition: { ifMatch, ifNoneMatch },
|
|
280
|
+
operation: `Cannot write the resource "${id}"`
|
|
281
|
+
});
|
|
276
282
|
const response = await was.request({
|
|
277
283
|
capability,
|
|
278
284
|
path: contentPath(id),
|
|
@@ -291,6 +297,11 @@ export function createWasSyncPort({ was, spaceId, collectionId, capability, mapA
|
|
|
291
297
|
},
|
|
292
298
|
async deleteContent({ id, ifMatch }) {
|
|
293
299
|
try {
|
|
300
|
+
await assertPreconditionEnforced({
|
|
301
|
+
features: changesCollection.features,
|
|
302
|
+
precondition: { ifMatch },
|
|
303
|
+
operation: `Cannot delete the resource "${id}"`
|
|
304
|
+
});
|
|
294
305
|
const response = await was.request({
|
|
295
306
|
capability,
|
|
296
307
|
path: contentPath(id),
|
|
@@ -315,6 +326,11 @@ export function createWasSyncPort({ was, spaceId, collectionId, capability, mapA
|
|
|
315
326
|
},
|
|
316
327
|
async putMeta({ id, custom, ifMatch, ifNoneMatch }) {
|
|
317
328
|
try {
|
|
329
|
+
await assertPreconditionEnforced({
|
|
330
|
+
features: changesCollection.features,
|
|
331
|
+
precondition: { ifMatch, ifNoneMatch },
|
|
332
|
+
operation: `Cannot write the metadata of resource "${id}"`
|
|
333
|
+
});
|
|
318
334
|
const response = await was.request({
|
|
319
335
|
capability,
|
|
320
336
|
path: metaPath(id),
|
package/dist/sync/port.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../src/sync/port.ts"],"names":[],"mappings":"AA6CA,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,QAAQ,EACR,YAAY,EACb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EACL,QAAQ,EACR,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACf,MAAM,cAAc,CAAA;AAWrB;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AAEpD;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAA;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,MAAgB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,KAAK,EAAE,MAAM,CAAC,K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AAM,CAAA;YACd,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAOlB,CAAA;YACb,IAAI,QAAQ,EAAE,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;YACvC,CAAC;YACD,IAAI,QAAQ,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;YACvC,CAAC;YACD,IAAI,QAAQ,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;gBAClC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAA;YAC/B,CAAC;YACD,IAAI,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;YACjC,CAAC;YACD,iEAAiE;YACjE,yEAAyE;YACzE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,aAAa,CAC5D,IAAI,CAAC,QAAQ,CACd,CAAA;YACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAC5B,CAAC;YACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;YAClC,CAAC;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* The `err.name` predicates that classify the errors a replication path can
|
|
6
6
|
* meet: the port's two wire signals (`WasSyncConflictError` /
|
|
7
7
|
* `WasSyncNotFoundError`), its opt-in revoked-access signal
|
|
8
|
-
* (`WasSyncAuthError`),
|
|
9
|
-
*
|
|
10
|
-
* (`
|
|
8
|
+
* (`WasSyncAuthError`), the cipher's two no-key signals (the stale-descriptor
|
|
9
|
+
* `UnknownEpochError` and the not-a-recipient `KeyUnwrapError`), and its
|
|
10
|
+
* tamper signal (`IntegrityError`).
|
|
11
11
|
*
|
|
12
12
|
* They live beside the classes that assign the names they match (`errors.ts`)
|
|
13
13
|
* because every one of those errors is raised inside a seam the consuming app
|
|
@@ -81,4 +81,15 @@ export declare function isUnknownEpochError(err: unknown): boolean;
|
|
|
81
81
|
* @returns {boolean}
|
|
82
82
|
*/
|
|
83
83
|
export declare function isKeyUnwrapError(err: unknown): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether an error is the cipher's tamper signal (`IntegrityError`): a stored
|
|
86
|
+
* body failed verification against the resource id it was read under, or an
|
|
87
|
+
* envelope this reader holds a key for failed to authenticate. The server
|
|
88
|
+
* altered the data or served it under another id. Retrying the read or
|
|
89
|
+
* refreshing the descriptor cannot fix it, and the row must not be applied.
|
|
90
|
+
*
|
|
91
|
+
* @param err {unknown} the caught error
|
|
92
|
+
* @returns {boolean}
|
|
93
|
+
*/
|
|
94
|
+
export declare function isIntegrityError(err: unknown): boolean;
|
|
84
95
|
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/sync/predicates.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEtD"}
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/sync/predicates.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEtD"}
|
package/dist/sync/predicates.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* The `err.name` predicates that classify the errors a replication path can
|
|
6
6
|
* meet: the port's two wire signals (`WasSyncConflictError` /
|
|
7
7
|
* `WasSyncNotFoundError`), its opt-in revoked-access signal
|
|
8
|
-
* (`WasSyncAuthError`),
|
|
9
|
-
*
|
|
10
|
-
* (`
|
|
8
|
+
* (`WasSyncAuthError`), the cipher's two no-key signals (the stale-descriptor
|
|
9
|
+
* `UnknownEpochError` and the not-a-recipient `KeyUnwrapError`), and its
|
|
10
|
+
* tamper signal (`IntegrityError`).
|
|
11
11
|
*
|
|
12
12
|
* They live beside the classes that assign the names they match (`errors.ts`)
|
|
13
13
|
* because every one of those errors is raised inside a seam the consuming app
|
|
@@ -101,4 +101,17 @@ export function isUnknownEpochError(err) {
|
|
|
101
101
|
export function isKeyUnwrapError(err) {
|
|
102
102
|
return nameOf(err) === 'KeyUnwrapError';
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether an error is the cipher's tamper signal (`IntegrityError`): a stored
|
|
106
|
+
* body failed verification against the resource id it was read under, or an
|
|
107
|
+
* envelope this reader holds a key for failed to authenticate. The server
|
|
108
|
+
* altered the data or served it under another id. Retrying the read or
|
|
109
|
+
* refreshing the descriptor cannot fix it, and the row must not be applied.
|
|
110
|
+
*
|
|
111
|
+
* @param err {unknown} the caught error
|
|
112
|
+
* @returns {boolean}
|
|
113
|
+
*/
|
|
114
|
+
export function isIntegrityError(err) {
|
|
115
|
+
return nameOf(err) === 'IntegrityError';
|
|
116
|
+
}
|
|
104
117
|
//# sourceMappingURL=predicates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/sync/predicates.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,GAAY;IAC1B,OAAQ,GAAiC,EAAE,IAAI,CAAA;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,sBAAsB,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,sBAAsB,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAA;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,mBAAmB,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAA;AACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/sync/predicates.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,GAAY;IAC1B,OAAQ,GAAiC,EAAE,IAAI,CAAA;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,sBAAsB,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,sBAAsB,CAAA;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAA;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,mBAAmB,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAA;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAA;AACzC,CAAC"}
|
package/dist/sync/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* every replication driver reports one feed's state through.
|
|
14
14
|
*/
|
|
15
15
|
import type { ChangeDocument, ChangesCheckpoint, ChangesPage } from '@interop/storage-core';
|
|
16
|
+
import type { CodecRequestContext } from '../codec.js';
|
|
16
17
|
import type { Json } from '../types.js';
|
|
17
18
|
export type { Json };
|
|
18
19
|
/**
|
|
@@ -184,6 +185,23 @@ export interface WasSyncPort {
|
|
|
184
185
|
* (advancing the envelope `sequence`). A content-addressed cipher (plaintext
|
|
185
186
|
* or `idDerivation: 'content'`) either omits it or throws: a changed document
|
|
186
187
|
* is a different id, never an in-place update.
|
|
188
|
+
* - `decrypt` takes the resource id the envelope was stored under (the feed
|
|
189
|
+
* row's `id`, or the id a {@link WasSyncPort.get} addressed) and verifies the
|
|
190
|
+
* envelope against it, throwing `IntegrityError` when the envelope was
|
|
191
|
+
* written for a different id. A missing id throws `ValidationError` rather
|
|
192
|
+
* than skipping the check. An EDV cipher checks the AEAD-bound
|
|
193
|
+
* `was.resource` binding, or re-derives a content-derived id from the
|
|
194
|
+
* ciphertext. The plaintext cipher recomputes the content id. Pass the id
|
|
195
|
+
* the replica addressed, never the envelope's own cleartext `id`, which the
|
|
196
|
+
* server controls.
|
|
197
|
+
* - `decrypt` also takes an optional `context`, the signed-request surface a
|
|
198
|
+
* codec reads a multi-resource document through. With it, an EDV cipher
|
|
199
|
+
* reassembles a chunked envelope from its chunk resources. Without it, such
|
|
200
|
+
* an envelope throws `EncryptionError`. A cipher built without a `spaceId`,
|
|
201
|
+
* or a backend that does not advertise `chunked-streams`, throws
|
|
202
|
+
* `NotSupportedError`. A replica gets one from its
|
|
203
|
+
* Collection handle (`collection.codecContext()`). A binary document
|
|
204
|
+
* decrypts to a `Blob`, and everything else to `Json`.
|
|
187
205
|
*/
|
|
188
206
|
export interface DocCipher {
|
|
189
207
|
encrypt(options: {
|
|
@@ -203,8 +221,10 @@ export interface DocCipher {
|
|
|
203
221
|
epoch?: string;
|
|
204
222
|
}>;
|
|
205
223
|
decrypt(options: {
|
|
224
|
+
id: string;
|
|
206
225
|
envelope: Json;
|
|
207
|
-
|
|
226
|
+
context?: CodecRequestContext;
|
|
227
|
+
}): Promise<Json | Blob>;
|
|
208
228
|
}
|
|
209
229
|
/**
|
|
210
230
|
* Per-feed replication status, surfaced to the app's state layer. The
|
package/dist/sync/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAEvC,YAAY,EAAE,IAAI,EAAE,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,OAAQ,SAAQ,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAC;IACtE,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,MAAM,CAAC,EAAE,IAAI,CAAA;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAC9D,SAAS,EAAE,OAAO,EAAE,CAAA;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;A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