@interop/was-react 0.11.0 → 0.12.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 +17 -17
- package/dist/auth/loginFlow.d.ts +2 -2
- package/dist/auth/loginRequest.d.ts +15 -12
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +12 -10
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +3 -2
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +7 -12
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/grants.d.ts +0 -14
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +0 -13
- package/dist/grants.js.map +1 -1
- package/dist/storage/sharedCollectionReader.js +4 -4
- package/dist/storage/wasRemoteStore.d.ts +1 -1
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +8 -8
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -2
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/types.d.ts +28 -45
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +17 -35
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts +14 -31
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +27 -169
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -125,14 +125,14 @@ without them a concurrent multi-device edit falls back to server-wins.
|
|
|
125
125
|
|
|
126
126
|
At login, a public collection is requested from the wallet with the distinct
|
|
127
127
|
`https://w3id.org/byoe#public-collection` descriptor type (private collections
|
|
128
|
-
use `https://w3id.org/byoe#collection`): the wallet provisions it
|
|
129
|
-
a public-read policy, shows a world-readable consent warning, and
|
|
130
|
-
usual read/write capability (public covers only unauthenticated
|
|
131
|
-
stay capability-only). A wallet that predates the descriptor
|
|
132
|
-
unsatisfiable rather than silently provisioning a private
|
|
133
|
-
feature fails closed with older wallets. Publicness is
|
|
134
|
-
by the wallet -- the app itself can never escalate an
|
|
135
|
-
collection to public.
|
|
128
|
+
use `https://w3id.org/byoe#private-collection`): the wallet provisions it
|
|
129
|
+
plaintext with a public-read policy, shows a world-readable consent warning, and
|
|
130
|
+
delegates the usual read/write capability (public covers only unauthenticated
|
|
131
|
+
reads; writes stay capability-only). A wallet that predates the descriptor
|
|
132
|
+
reports the request unsatisfiable rather than silently provisioning a private
|
|
133
|
+
collection, so the feature fails closed with older wallets. Publicness is
|
|
134
|
+
granted at consent time by the wallet -- the app itself can never escalate an
|
|
135
|
+
existing private collection to public.
|
|
136
136
|
|
|
137
137
|
#### Shared (wallet-owned) collections
|
|
138
138
|
|
|
@@ -173,13 +173,13 @@ the same `key` or `id` in each is rejected at store open
|
|
|
173
173
|
(`validateSharedCollections`).
|
|
174
174
|
|
|
175
175
|
At login each shared collection is requested with the distinct
|
|
176
|
-
`https://w3id.org/byoe#shared-collection` descriptor type and the
|
|
177
|
-
action set `SHARED_ACTIONS` (`GET`/`HEAD`) -- an app never asks to
|
|
178
|
-
wallet collection. As with `https://w3id.org/byoe#public-collection`, a
|
|
179
|
-
that predates the type reports the request unsatisfiable and the feature
|
|
180
|
-
closed, which is the point: a share fuses two axes -- the read zcap AND an
|
|
181
|
-
in the collection's key-epoch roster -- and a wallet that granted only the
|
|
182
|
-
would hand the app ciphertext it cannot decrypt, surfacing as corrupt data
|
|
176
|
+
`https://w3id.org/byoe#shared-wallet-collection` descriptor type and the
|
|
177
|
+
read-only action set `SHARED_ACTIONS` (`GET`/`HEAD`) -- an app never asks to
|
|
178
|
+
write a wallet collection. As with `https://w3id.org/byoe#public-collection`, a
|
|
179
|
+
wallet that predates the type reports the request unsatisfiable and the feature
|
|
180
|
+
fails closed, which is the point: a share fuses two axes -- the read zcap AND an
|
|
181
|
+
entry in the collection's key-epoch roster -- and a wallet that granted only the
|
|
182
|
+
zcap would hand the app ciphertext it cannot decrypt, surfacing as corrupt data
|
|
183
183
|
rather than as a wallet that needs updating.
|
|
184
184
|
|
|
185
185
|
Decryption uses the app's **identity** key-agreement key: the X25519 twin of its
|
|
@@ -395,8 +395,8 @@ a progress line (`connecting` to `verifying`):
|
|
|
395
395
|
2. **One popup.** A VPR carrying a `DIDAuthentication` query plus one
|
|
396
396
|
`AppConnectQuery` -- the app's display name, `credentialType`, and
|
|
397
397
|
`vocabBase`, a `capabilityQuery` entry per configured collection, and a
|
|
398
|
-
`https://w3id.org/byoe#shared-collection` entry per shared collection
|
|
399
|
-
sent via `navigator.credentials.get` (`buildAppConnectVpr`). A `null`
|
|
398
|
+
`https://w3id.org/byoe#shared-wallet-collection` entry per shared collection
|
|
399
|
+
-- is sent via `navigator.credentials.get` (`buildAppConnectVpr`). A `null`
|
|
400
400
|
response is a user cancel (`LoginCancelledError`), not an error.
|
|
401
401
|
3. **The wallet matches or mints.** On a first run the wallet generates the
|
|
402
402
|
32-byte seed itself, self-issues the origin-bound app-key credential, and
|
package/dist/auth/loginFlow.d.ts
CHANGED
|
@@ -50,8 +50,8 @@ export interface LoginConfig {
|
|
|
50
50
|
collections: GrantRequestCollection[];
|
|
51
51
|
/**
|
|
52
52
|
* WAS collection ids of wallet-owned collections to request read-and-decrypt
|
|
53
|
-
* access to (the `https://w3id.org/byoe#shared-collection` grant).
|
|
54
|
-
* replicated.
|
|
53
|
+
* access to (the `https://w3id.org/byoe#shared-wallet-collection` grant).
|
|
54
|
+
* Read-only; never replicated.
|
|
55
55
|
*/
|
|
56
56
|
sharedCollections?: string[];
|
|
57
57
|
/**
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
* fails closed rather than degrading into a partial generic flow.
|
|
33
33
|
*
|
|
34
34
|
* A SHARED collection -- one the wallet already owns and encrypts, which the app
|
|
35
|
-
* asks to read and decrypt -- uses the
|
|
36
|
-
* type, and the
|
|
35
|
+
* asks to read and decrypt -- uses the
|
|
36
|
+
* `https://w3id.org/byoe#shared-wallet-collection` descriptor type, and the
|
|
37
|
+
* actions are read-only by construction ({@link SHARED_ACTIONS}):
|
|
37
38
|
* the app never requests writes on a wallet collection. Exactly like
|
|
38
39
|
* `https://w3id.org/byoe#public-collection`, a wallet that predates the type resolves the
|
|
39
40
|
* descriptor UNSATISFIABLE and fails closed -- which is the point here. A share
|
|
@@ -50,8 +51,8 @@ import type { SeedCredentialConfig } from '../identity/seedCredential.js';
|
|
|
50
51
|
import type { IVPRDetails } from './walletRequestTypes.js';
|
|
51
52
|
/**
|
|
52
53
|
* Default read/write actions requested on each private app collection -- also
|
|
53
|
-
* the `https://w3id.org/byoe#collection` class ceiling (the full WAS
|
|
54
|
-
* vocabulary).
|
|
54
|
+
* the `https://w3id.org/byoe#private-collection` class ceiling (the full WAS
|
|
55
|
+
* action vocabulary).
|
|
55
56
|
*/
|
|
56
57
|
export declare const RW_ACTIONS: string[];
|
|
57
58
|
/**
|
|
@@ -73,8 +74,9 @@ export declare const SHARED_ACTIONS: string[];
|
|
|
73
74
|
* The action ceiling of the descriptor class a collection is requested with
|
|
74
75
|
* (the App Connect spec's "Action ceilings" table): add-only for
|
|
75
76
|
* `visibility: 'public'` (`https://w3id.org/byoe#public-collection`), the full
|
|
76
|
-
* vocabulary otherwise (`https://w3id.org/byoe#collection`). Shares
|
|
77
|
-
* own fixed {@link SHARED_ACTIONS} and never consult a configured
|
|
77
|
+
* vocabulary otherwise (`https://w3id.org/byoe#private-collection`). Shares
|
|
78
|
+
* have their own fixed {@link SHARED_ACTIONS} and never consult a configured
|
|
79
|
+
* action set.
|
|
78
80
|
*
|
|
79
81
|
* @param [visibility] {'private' | 'public'}
|
|
80
82
|
* @returns {string[]}
|
|
@@ -91,8 +93,8 @@ export interface GrantRequestCollection {
|
|
|
91
93
|
id: string;
|
|
92
94
|
/**
|
|
93
95
|
* Who can read the collection; selects the descriptor type
|
|
94
|
-
* (`https://w3id.org/byoe#collection` for `'private'`/unset,
|
|
95
|
-
* for `'public'`).
|
|
96
|
+
* (`https://w3id.org/byoe#private-collection` for `'private'`/unset,
|
|
97
|
+
* `https://w3id.org/byoe#public-collection` for `'public'`).
|
|
96
98
|
*/
|
|
97
99
|
visibility?: 'private' | 'public';
|
|
98
100
|
}
|
|
@@ -110,8 +112,8 @@ export declare function newChallenge(): string;
|
|
|
110
112
|
* shape MINUS `controller` (the wallet fills it with the app-key subject DID)
|
|
111
113
|
* and MINUS `reason` (the App Connect consent screen supersedes per-grant
|
|
112
114
|
* reasons). A `visibility: 'public'` collection uses the
|
|
113
|
-
* `https://w3id.org/byoe#public-collection` descriptor type; everything else
|
|
114
|
-
* `https://w3id.org/byoe#collection`.
|
|
115
|
+
* `https://w3id.org/byoe#public-collection` descriptor type; everything else
|
|
116
|
+
* uses `https://w3id.org/byoe#private-collection`.
|
|
115
117
|
*
|
|
116
118
|
* @param options {object}
|
|
117
119
|
* @param options.challenge {string}
|
|
@@ -123,8 +125,9 @@ export declare function newChallenge(): string;
|
|
|
123
125
|
* @param options.collections {GrantRequestCollection[]} the collections to
|
|
124
126
|
* request (WAS collection id + visibility)
|
|
125
127
|
* @param [options.sharedCollections] {string[]} WAS collection ids of
|
|
126
|
-
* wallet-owned collections to request read-and-decrypt access to; each gets
|
|
127
|
-
* `https://w3id.org/byoe#shared-collection` descriptor with
|
|
128
|
+
* wallet-owned collections to request read-and-decrypt access to; each gets
|
|
129
|
+
* a `https://w3id.org/byoe#shared-wallet-collection` descriptor with
|
|
130
|
+
* {@link SHARED_ACTIONS}
|
|
128
131
|
* @param [options.actions] {string[]} the action set to request on each app
|
|
129
132
|
* collection; when omitted each collection requests exactly its class
|
|
130
133
|
* ceiling ({@link actionCeiling}). An explicit set naming an action above a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginRequest.d.ts","sourceRoot":"","sources":["../../src/auth/loginRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"loginRequest.d.ts","sourceRoot":"","sources":["../../src/auth/loginRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACzE,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,yBAAyB,CAAA;AAEhC;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAA2C,CAAA;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,UAA0B,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAkB,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,EAAE,CAEzE;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAClC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AA+CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,iBAAsB,EACtB,OAAO,EACR,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,oBAAoB,CAAA;IAChC,WAAW,EAAE,sBAAsB,EAAE,CAAA;IACrC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,GAAG,WAAW,CA2Cd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Default read/write actions requested on each private app collection -- also
|
|
3
|
-
* the `https://w3id.org/byoe#collection` class ceiling (the full WAS
|
|
4
|
-
* vocabulary).
|
|
3
|
+
* the `https://w3id.org/byoe#private-collection` class ceiling (the full WAS
|
|
4
|
+
* action vocabulary).
|
|
5
5
|
*/
|
|
6
6
|
export const RW_ACTIONS = ['GET', 'HEAD', 'PUT', 'POST', 'DELETE'];
|
|
7
7
|
/**
|
|
@@ -23,8 +23,9 @@ export const SHARED_ACTIONS = ['GET', 'HEAD'];
|
|
|
23
23
|
* The action ceiling of the descriptor class a collection is requested with
|
|
24
24
|
* (the App Connect spec's "Action ceilings" table): add-only for
|
|
25
25
|
* `visibility: 'public'` (`https://w3id.org/byoe#public-collection`), the full
|
|
26
|
-
* vocabulary otherwise (`https://w3id.org/byoe#collection`). Shares
|
|
27
|
-
* own fixed {@link SHARED_ACTIONS} and never consult a configured
|
|
26
|
+
* vocabulary otherwise (`https://w3id.org/byoe#private-collection`). Shares
|
|
27
|
+
* have their own fixed {@link SHARED_ACTIONS} and never consult a configured
|
|
28
|
+
* action set.
|
|
28
29
|
*
|
|
29
30
|
* @param [visibility] {'private' | 'public'}
|
|
30
31
|
* @returns {string[]}
|
|
@@ -82,8 +83,8 @@ function requestedActions({ id, visibility, actions }) {
|
|
|
82
83
|
* shape MINUS `controller` (the wallet fills it with the app-key subject DID)
|
|
83
84
|
* and MINUS `reason` (the App Connect consent screen supersedes per-grant
|
|
84
85
|
* reasons). A `visibility: 'public'` collection uses the
|
|
85
|
-
* `https://w3id.org/byoe#public-collection` descriptor type; everything else
|
|
86
|
-
* `https://w3id.org/byoe#collection`.
|
|
86
|
+
* `https://w3id.org/byoe#public-collection` descriptor type; everything else
|
|
87
|
+
* uses `https://w3id.org/byoe#private-collection`.
|
|
87
88
|
*
|
|
88
89
|
* @param options {object}
|
|
89
90
|
* @param options.challenge {string}
|
|
@@ -95,8 +96,9 @@ function requestedActions({ id, visibility, actions }) {
|
|
|
95
96
|
* @param options.collections {GrantRequestCollection[]} the collections to
|
|
96
97
|
* request (WAS collection id + visibility)
|
|
97
98
|
* @param [options.sharedCollections] {string[]} WAS collection ids of
|
|
98
|
-
* wallet-owned collections to request read-and-decrypt access to; each gets
|
|
99
|
-
* `https://w3id.org/byoe#shared-collection` descriptor with
|
|
99
|
+
* wallet-owned collections to request read-and-decrypt access to; each gets
|
|
100
|
+
* a `https://w3id.org/byoe#shared-wallet-collection` descriptor with
|
|
101
|
+
* {@link SHARED_ACTIONS}
|
|
100
102
|
* @param [options.actions] {string[]} the action set to request on each app
|
|
101
103
|
* collection; when omitted each collection requests exactly its class
|
|
102
104
|
* ceiling ({@link actionCeiling}). An explicit set naming an action above a
|
|
@@ -111,7 +113,7 @@ export function buildAppConnectVpr({ challenge, domain, appName, credential, col
|
|
|
111
113
|
invocationTarget: {
|
|
112
114
|
type: visibility === 'public'
|
|
113
115
|
? 'https://w3id.org/byoe#public-collection'
|
|
114
|
-
: 'https://w3id.org/byoe#collection',
|
|
116
|
+
: 'https://w3id.org/byoe#private-collection',
|
|
115
117
|
name: id
|
|
116
118
|
}
|
|
117
119
|
}));
|
|
@@ -120,7 +122,7 @@ export function buildAppConnectVpr({ challenge, domain, appName, credential, col
|
|
|
120
122
|
referenceId: id,
|
|
121
123
|
allowedAction: SHARED_ACTIONS,
|
|
122
124
|
invocationTarget: {
|
|
123
|
-
type: 'https://w3id.org/byoe#shared-collection',
|
|
125
|
+
type: 'https://w3id.org/byoe#shared-wallet-collection',
|
|
124
126
|
name: id
|
|
125
127
|
}
|
|
126
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginRequest.js","sourceRoot":"","sources":["../../src/auth/loginRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loginRequest.js","sourceRoot":"","sources":["../../src/auth/loginRequest.ts"],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BACb,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,SAAS,EAAE,UAAU,CAAC,SAAS;iBAChC;gBACD,eAAe;aAChB;SACF;QACD,SAAS;QACT,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -45,8 +45,9 @@ export type IDIDAuthenticationQuery = {
|
|
|
45
45
|
* (`controller`) wants on which storage target (`invocationTarget`), with an
|
|
46
46
|
* optional human-readable `reason` and RP-chosen `referenceId`. The
|
|
47
47
|
* `invocationTarget` is either a plain URL (satisfied only under the user's own
|
|
48
|
-
* Space) or a wallet-defined descriptor object
|
|
49
|
-
*
|
|
48
|
+
* Space) or a wallet-defined descriptor object
|
|
49
|
+
* (`https://w3id.org/byoe#private-collection`), resolved by
|
|
50
|
+
* `resolveInvocationTarget`. Login requests only ever ask for
|
|
50
51
|
* collection-scoped capabilities.
|
|
51
52
|
*/
|
|
52
53
|
export type ICapabilityQueryDetail = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletRequestTypes.d.ts","sourceRoot":"","sources":["../../src/auth/walletRequestTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,uBAAuB,GAAG,gBAAgB,CAAA;AAElE;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,mBAAmB,CAAA;IACzB,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3C,oBAAoB,CAAC,EA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;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,iBAAiB,CAAA;IACvB,GAAG,EAAE;QACH,IAAI,EAAE,MAAM,CAAA;QACZ,cAAc,EAAE,MAAM,CAAA;QACtB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,eAAe,EAAE,0BAA0B,GAAG,0BAA0B,EAAE,CAAA;CAC3E,CAAA;AAED,YAAY,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionDevGrants.d.ts","sourceRoot":"","sources":["../../src/dev/provisionDevGrants.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"provisionDevGrants.d.ts","sourceRoot":"","sources":["../../src/dev/provisionDevGrants.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAalE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,UAIrC,CAAA;AAEF;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QACN,UAAU,EAAE,OAAO,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;CACF;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,IAAI,EACJ,WAAW,EACX,SAAuB,EACvB,OAAO,EACP,eAA0C,EAC1C,cAAc,EAGd,OAAqC,EACrC,KAAa,EACb,GAAc,EACf,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;IAChB,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;KAAE,CAAC,CAAA;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,UAAU,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA4HpC"}
|
|
@@ -27,8 +27,8 @@ import { WasClient } from '@interop/was-client';
|
|
|
27
27
|
import { ensureFirstEpoch, ownerRecipient } from '@interop/was-client/edv';
|
|
28
28
|
import { CapabilityAgent } from '@interop/webkms-client';
|
|
29
29
|
import { agentsFromKeyAgent } from '@interop/wallet-core/identity';
|
|
30
|
+
import { collectionPath, rootCapability, spacePath, toUrl } from '@interop/was-client/paths';
|
|
30
31
|
import { deriveIdentity } from '../identity/agents.js';
|
|
31
|
-
import { collectionPath } from '../grants.js';
|
|
32
32
|
import { RW_ACTIONS } from '../auth/loginRequest.js';
|
|
33
33
|
import { errorStatus } from '../sync/index.js';
|
|
34
34
|
/**
|
|
@@ -111,13 +111,11 @@ actions = RW_ACTIONS, probe = false, log = () => { } }) {
|
|
|
111
111
|
// of every `/<collection>/<resource>` and `/<collection>/query` request. A
|
|
112
112
|
// grant rooted at the collection's own root authorizes only the exact
|
|
113
113
|
// collection-description URL, not its resources or the changes feed.
|
|
114
|
-
const spaceUrl =
|
|
115
|
-
const spaceRoot = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
invocationTarget: spaceUrl
|
|
120
|
-
};
|
|
114
|
+
const spaceUrl = toUrl({ serverUrl, path: spacePath(space.id) });
|
|
115
|
+
const spaceRoot = rootCapability({
|
|
116
|
+
target: spaceUrl,
|
|
117
|
+
controller: provisionerDid
|
|
118
|
+
});
|
|
121
119
|
// `Promise.all` preserves input order, so `grants[i]` still corresponds to
|
|
122
120
|
// `collections[i]` (the probe below relies on that for `[0]`).
|
|
123
121
|
const grants = await Promise.all(collections.map(async (entry) => {
|
|
@@ -173,10 +171,7 @@ actions = RW_ACTIONS, probe = false, log = () => { } }) {
|
|
|
173
171
|
const firstEntry = collections[0];
|
|
174
172
|
const probeCollectionId = typeof firstEntry === 'string' ? firstEntry : firstEntry.id;
|
|
175
173
|
const probeCapability = grants[0];
|
|
176
|
-
const probePath = collectionPath(
|
|
177
|
-
spaceId: space.id,
|
|
178
|
-
collectionId: probeCollectionId
|
|
179
|
-
});
|
|
174
|
+
const probePath = collectionPath(space.id, probeCollectionId);
|
|
180
175
|
log(`\nDescription-write probe on "${probeCollectionId}" (delegated RW zcap):`);
|
|
181
176
|
try {
|
|
182
177
|
const current = await appWas.request({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionDevGrants.js","sourceRoot":"","sources":["../../src/dev/provisionDevGrants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAoB,MAAM,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AAE,CAAC,CAAA;QAC/C,CAAC;QACD,MAAM,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC1D,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/grants.d.ts
CHANGED
|
@@ -12,20 +12,6 @@ export interface ParsedGrants {
|
|
|
12
12
|
*/
|
|
13
13
|
byCollectionId: Record<string, IZcap>;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Builds the server path of a collection, the inverse of the grammar
|
|
17
|
-
* `parseInvocationTarget` reads. Callers append a trailing slash or query
|
|
18
|
-
* string for resource-listing and query endpoints.
|
|
19
|
-
*
|
|
20
|
-
* @param options {object}
|
|
21
|
-
* @param options.spaceId {string}
|
|
22
|
-
* @param options.collectionId {string}
|
|
23
|
-
* @returns {string}
|
|
24
|
-
*/
|
|
25
|
-
export declare function collectionPath({ spaceId, collectionId }: {
|
|
26
|
-
spaceId: string;
|
|
27
|
-
collectionId: string;
|
|
28
|
-
}): string;
|
|
29
15
|
/**
|
|
30
16
|
* Parses a single `invocationTarget` URL into its WAS components: the server
|
|
31
17
|
* origin, the space id, and the collection (every routed grant is
|
package/dist/grants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEzD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CACtC;AAED
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEzD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG;IACrD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACrB,CA0BA;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,CAgCxD"}
|
package/dist/grants.js
CHANGED
|
@@ -16,19 +16,6 @@
|
|
|
16
16
|
* silently split writes).
|
|
17
17
|
*/
|
|
18
18
|
import { parseSpaceTarget } from '@interop/was-client';
|
|
19
|
-
/**
|
|
20
|
-
* Builds the server path of a collection, the inverse of the grammar
|
|
21
|
-
* `parseInvocationTarget` reads. Callers append a trailing slash or query
|
|
22
|
-
* string for resource-listing and query endpoints.
|
|
23
|
-
*
|
|
24
|
-
* @param options {object}
|
|
25
|
-
* @param options.spaceId {string}
|
|
26
|
-
* @param options.collectionId {string}
|
|
27
|
-
* @returns {string}
|
|
28
|
-
*/
|
|
29
|
-
export function collectionPath({ spaceId, collectionId }) {
|
|
30
|
-
return `/space/${spaceId}/${collectionId}`;
|
|
31
|
-
}
|
|
32
19
|
/**
|
|
33
20
|
* Parses a single `invocationTarget` URL into its WAS components: the server
|
|
34
21
|
* origin, the space id, and the collection (every routed grant is
|
package/dist/grants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE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;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;IACD,IAAI,SAA6B,CAAA;IACjC,IAAI,OAA2B,CAAA;IAC/B,MAAM,cAAc,GAA0B,EAAE,CAAA;IAEhD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAC9B,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,SAAS,MAAM,CAAC,SAAS,IAAI,CACpE,CAAA;QACH,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,4BAA4B,OAAO,SAAS,MAAM,CAAC,OAAO,IAAI,CAC/D,CAAA;QACH,CAAC;QACD,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;IAC5C,CAAC;IAED,OAAO;QACL,SAAS,EAAE,SAAmB;QAC9B,OAAO,EAAE,OAAiB;QAC1B,cAAc;KACf,CAAA;AACH,CAAC"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* SharedCollectionReader: a READ-ONLY view over one wallet-owned encrypted
|
|
6
6
|
* collection the wallet has shared with this app (the
|
|
7
|
-
* `https://w3id.org/byoe#shared-collection` grant). It is the app-side
|
|
8
|
-
* wallet's share flow, and it is read-only BY CONSTRUCTION --
|
|
9
|
-
* verb on this class, the collection is never replicated
|
|
10
|
-
* sync bootstrap never PUTs a description onto it.
|
|
7
|
+
* `https://w3id.org/byoe#shared-wallet-collection` grant). It is the app-side
|
|
8
|
+
* other half of the wallet's share flow, and it is read-only BY CONSTRUCTION --
|
|
9
|
+
* there is no write verb on this class, the collection is never replicated
|
|
10
|
+
* into RxDB, and the sync bootstrap never PUTs a description onto it.
|
|
11
11
|
*
|
|
12
12
|
* A share fuses two axes, and both are needed here:
|
|
13
13
|
*
|
|
@@ -29,7 +29,7 @@ import { WasClient } from '@interop/was-client';
|
|
|
29
29
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
30
30
|
import type { EncryptionDescriptorSource } from '@interop/wallet-core/descriptors';
|
|
31
31
|
import type { WasCollectionConfig } from '../config.js';
|
|
32
|
-
import {
|
|
32
|
+
import type { ParsedGrants } from '../grants.js';
|
|
33
33
|
/**
|
|
34
34
|
* The outcome of a best-effort encryption-descriptor PUT, for diagnostics.
|
|
35
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasRemoteStore.d.ts","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"wasRemoteStore.d.ts","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"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{ WasClient } from '@interop/was-client';
|
|
2
2
|
import { createEdvEncryption } from '@interop/was-client/edv';
|
|
3
|
+
import { collectionItems, collectionPath, resourcePath, toUrl } from '@interop/was-client/paths';
|
|
3
4
|
import { errorStatus, errorMessage } from '../sync/index.js';
|
|
4
|
-
import { collectionPath } from '../grants.js';
|
|
5
5
|
export class WasRemoteStore {
|
|
6
6
|
was;
|
|
7
7
|
serverUrl;
|
|
@@ -76,7 +76,7 @@ export class WasRemoteStore {
|
|
|
76
76
|
try {
|
|
77
77
|
const response = await this.was.request({
|
|
78
78
|
capability,
|
|
79
|
-
path: collectionPath(
|
|
79
|
+
path: collectionPath(this.spaceId, collectionId),
|
|
80
80
|
method: 'GET'
|
|
81
81
|
});
|
|
82
82
|
const description = response.data;
|
|
@@ -209,8 +209,7 @@ export class WasRemoteStore {
|
|
|
209
209
|
// The list endpoint is the trailing-slash collection items URL.
|
|
210
210
|
const response = await this.was.request({
|
|
211
211
|
capability,
|
|
212
|
-
path:
|
|
213
|
-
`?${params.join('&')}`,
|
|
212
|
+
path: collectionItems(this.spaceId, collectionId) + `?${params.join('&')}`,
|
|
214
213
|
method: 'GET'
|
|
215
214
|
});
|
|
216
215
|
const page = response.data;
|
|
@@ -257,9 +256,10 @@ export class WasRemoteStore {
|
|
|
257
256
|
if (!capability) {
|
|
258
257
|
throw new Error(`No delegated capability covers collection "${collectionId}".`);
|
|
259
258
|
}
|
|
260
|
-
return (
|
|
261
|
-
|
|
262
|
-
|
|
259
|
+
return toUrl({
|
|
260
|
+
serverUrl: this.serverUrl,
|
|
261
|
+
path: resourcePath(this.spaceId, collectionId, id)
|
|
262
|
+
});
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* The shared best-effort collection-description PUT behind the encryption
|
|
@@ -274,7 +274,7 @@ export class WasRemoteStore {
|
|
|
274
274
|
try {
|
|
275
275
|
const response = await this.was.request({
|
|
276
276
|
capability,
|
|
277
|
-
path: collectionPath(
|
|
277
|
+
path: collectionPath(this.spaceId, collectionId),
|
|
278
278
|
method: 'PUT',
|
|
279
279
|
json: description
|
|
280
280
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasRemoteStore.js","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,
|
|
1
|
+
{"version":3,"file":"wasRemoteStore.js","sourceRoot":"","sources":["../../src/storage/wasRemoteStore.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,EACZ,KAAK,EACN,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA2C5D,MAAM,OAAO,cAAc;IACT,GAAG,CAAW;IACd,SAAS,CAAQ;IACjB,OAAO,CAAQ;IACtB,eAAe,CAAuB;IAC/C,sEAAsE;IACtE,4DAA4D;IACnD,WAAW,CAAgC;IAEpD,YAAoB,EAClB,GAAG,EACH,MAAM,EACN,UAAU,EAKX;QACC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,UAAU,CAAC,EAChB,MAAM,EACN,UAAU,EACV,WAAW,GAAG,EAAE,EAKjB;QACC,MAAM,GAAG,GAAG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QAAQ,CAAC,MAAM,EAAE,CAAA;QAC5D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;YAC/B,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;YACjC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;QAC5D,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,WAAW,EAGZ;IACC,OAAO;QACL,KAAK,CAAC,oBAAoB,CAAC,EAAE,YAAY,EAA4B;YACnE,OAAO,MAAM,WAAW,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAA;QACjE,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/sync/index.d.ts
CHANGED
|
@@ -13,10 +13,10 @@ export { syncedDocSchema } from './syncedDocSchema.js';
|
|
|
13
13
|
export { createPullHandler, wireDocToRxDoc } from './changesQuery.js';
|
|
14
14
|
export { createPushHandler, type PushWriteAck } from './pushWrites.js';
|
|
15
15
|
export { WasSyncConflictError, WasSyncAuthError, type Json, type SyncCheckpoint, type WireDoc, type SyncedDoc, type MasterState, type MasterReadCache, type WasSyncBasePort, type WasSyncPort } from './types.js';
|
|
16
|
-
export { createWasSyncPort
|
|
16
|
+
export { createWasSyncPort } from './wasSyncPort.js';
|
|
17
17
|
export { withFeedMasterRead } from './feedMasterPort.js';
|
|
18
18
|
export { createDocCipher, createPlaintextDocCodec, createUnprovisionedDocCipher, hasKeyEpochs, isUnknownEpochError, type DocCipher } from './docCipher.js';
|
|
19
19
|
export { makeLwwConflictHandler } from './lwwConflictHandler.js';
|
|
20
20
|
export { lwwFields, remotePayloadWins, type LwwFields } from './lww.js';
|
|
21
|
-
export { errorStatus, formatEtag, isEncryptedEnvelope } from '@interop/was-client/sync';
|
|
21
|
+
export { errorStatus, errorMessage, formatEtag, isEncryptedEnvelope } from '@interop/was-client/sync';
|
|
22
22
|
//# 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;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,4BAA4B,EAC5B,YAAY,EACZ,mBAAmB,EACnB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAGvE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,mBAAmB,EACpB,MAAM,0BAA0B,CAAA"}
|
package/dist/sync/index.js
CHANGED
|
@@ -13,12 +13,12 @@ export { syncedDocSchema } from './syncedDocSchema.js';
|
|
|
13
13
|
export { createPullHandler, wireDocToRxDoc } from './changesQuery.js';
|
|
14
14
|
export { createPushHandler } from './pushWrites.js';
|
|
15
15
|
export { WasSyncConflictError, WasSyncAuthError } from './types.js';
|
|
16
|
-
export { createWasSyncPort
|
|
16
|
+
export { createWasSyncPort } from './wasSyncPort.js';
|
|
17
17
|
export { withFeedMasterRead } from './feedMasterPort.js';
|
|
18
18
|
export { createDocCipher, createPlaintextDocCodec, createUnprovisionedDocCipher, hasKeyEpochs, isUnknownEpochError } from './docCipher.js';
|
|
19
19
|
export { makeLwwConflictHandler } from './lwwConflictHandler.js';
|
|
20
20
|
export { lwwFields, remotePayloadWins } from './lww.js';
|
|
21
21
|
// Owned by the client's sync subpath and re-exported verbatim, so the names this
|
|
22
22
|
// package's consumers already import stay put.
|
|
23
|
-
export { errorStatus, formatEtag, isEncryptedEnvelope } from '@interop/was-client/sync';
|
|
23
|
+
export { errorStatus, errorMessage, formatEtag, isEncryptedEnvelope } from '@interop/was-client/sync';
|
|
24
24
|
//# 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;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,iBAAiB,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EASjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,iBAAiB,CAAA;AACtE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EASjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,4BAA4B,EAC5B,YAAY,EACZ,mBAAmB,EAEpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAkB,MAAM,UAAU,CAAA;AACvE,iFAAiF;AACjF,+CAA+C;AAC/C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,mBAAmB,EACpB,MAAM,0BAA0B,CAAA"}
|
package/dist/sync/types.d.ts
CHANGED
|
@@ -25,6 +25,24 @@
|
|
|
25
25
|
* copy every wire-to-local mapping runs.
|
|
26
26
|
*/
|
|
27
27
|
import type { Json } from '@interop/was-client';
|
|
28
|
+
import type { MasterState as ClientMasterState, SyncCheckpoint as ClientSyncCheckpoint } from '@interop/was-client/sync';
|
|
29
|
+
/**
|
|
30
|
+
* The typed port signals, owned by `@interop/was-client` (its sync port raises
|
|
31
|
+
* them) and re-exported here so the names this package's consumers already
|
|
32
|
+
* import stay put -- and so an `instanceof` check anywhere in this package
|
|
33
|
+
* matches the very class the port throws.
|
|
34
|
+
*
|
|
35
|
+
* `WasSyncConflictError` marks a conditional write rejected with `412
|
|
36
|
+
* precondition-failed` (a lost-update conflict, or a create-if-absent whose
|
|
37
|
+
* target already exists); the push handler catches exactly it to trigger the
|
|
38
|
+
* re-read-and-report-conflict path. `WasSyncAuthError` marks a request refused
|
|
39
|
+
* on authorization grounds -- `401`, `403`, or the `404` a WAS server masks a
|
|
40
|
+
* failed capability invocation as, which on the sync paths (where the invoked
|
|
41
|
+
* collection is known to exist) means the invocation was rejected. It keeps the
|
|
42
|
+
* offending HTTP status on `status`, which the `/meta` push path reads to tell
|
|
43
|
+
* a masked denial from an ordinary delete race.
|
|
44
|
+
*/
|
|
45
|
+
export { WasSyncAuthError, WasSyncConflictError } from '@interop/was-client/sync';
|
|
28
46
|
/**
|
|
29
47
|
* A JSON value -- the opaque stored resource body the sync layer moves verbatim.
|
|
30
48
|
* For a plaintext collection this is the user document; for an encrypted one it
|
|
@@ -80,12 +98,10 @@ export declare function copyOptionalBodyFields({ source, target }: {
|
|
|
80
98
|
* The keyset position in the change feed: the `{ id, updatedAt }` of the last
|
|
81
99
|
* document a pull returned. Passed back verbatim to resume, and used as the
|
|
82
100
|
* RxDB replication checkpoint. `id` is the total-order tiebreaker within a
|
|
83
|
-
* single `updatedAt`.
|
|
101
|
+
* single `updatedAt`. The client's own checkpoint type, aliased here so the
|
|
102
|
+
* replication layer and the port agree by construction.
|
|
84
103
|
*/
|
|
85
|
-
export
|
|
86
|
-
id: string;
|
|
87
|
-
updatedAt: string;
|
|
88
|
-
}
|
|
104
|
+
export type SyncCheckpoint = ClientSyncCheckpoint;
|
|
89
105
|
/**
|
|
90
106
|
* One document as it travels on the `changes` feed wire
|
|
91
107
|
* (`POST /space/:s/:c/query`, profile `changes`). `id` is the WAS resourceId,
|
|
@@ -136,20 +152,15 @@ export interface SyncedDoc {
|
|
|
136
152
|
}
|
|
137
153
|
/**
|
|
138
154
|
* The current master state of a single resource, as read back for the 412
|
|
139
|
-
* conflict path
|
|
140
|
-
* `metaVersion` / `
|
|
155
|
+
* conflict path: the client's own `MasterState` (content `version` /
|
|
156
|
+
* `updatedAt`, plus the optional `metaVersion` / `data` / `custom` /
|
|
157
|
+
* `createdBy` / `epoch`) plus the `deleted` flag that distinguishes a tombstone
|
|
158
|
+
* from a live resource. The flag is required here because this package resolves
|
|
159
|
+
* the master from the changes feed, where a tombstone travels as a document
|
|
160
|
+
* rather than as an absent read.
|
|
141
161
|
*/
|
|
142
|
-
export interface MasterState {
|
|
143
|
-
version: number;
|
|
144
|
-
updatedAt: string;
|
|
162
|
+
export interface MasterState extends ClientMasterState {
|
|
145
163
|
deleted: boolean;
|
|
146
|
-
metaVersion?: number;
|
|
147
|
-
data?: Json;
|
|
148
|
-
custom?: Json;
|
|
149
|
-
/**
|
|
150
|
-
* The key-epoch stamp of the master's content body, when the feed carries one.
|
|
151
|
-
*/
|
|
152
|
-
epoch?: string;
|
|
153
164
|
}
|
|
154
165
|
/**
|
|
155
166
|
* The short-lived master-read memo the rows of ONE push batch share. A
|
|
@@ -305,32 +316,4 @@ export interface WasSyncPort extends WasSyncBasePort {
|
|
|
305
316
|
cache?: MasterReadCache;
|
|
306
317
|
}): Promise<MasterState | null>;
|
|
307
318
|
}
|
|
308
|
-
/**
|
|
309
|
-
* Thrown by a {@link WasSyncPort} implementation when a conditional write is
|
|
310
|
-
* rejected with `412 precondition-failed` (a lost-update conflict, or a
|
|
311
|
-
* create-if-absent whose target already exists). The core push handler catches
|
|
312
|
-
* exactly this type to trigger the re-read-and-report-conflict path; any other
|
|
313
|
-
* error propagates to RxDB for retry.
|
|
314
|
-
*/
|
|
315
|
-
export declare class WasSyncConflictError extends Error {
|
|
316
|
-
constructor(message?: string);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Thrown by a {@link WasSyncPort} implementation when a request is rejected with
|
|
320
|
-
* `401 unauthorized`, `403 forbidden`, or `404 not found` -- the
|
|
321
|
-
* storage-access-expired/revoked signal. `404` qualifies because a WAS server
|
|
322
|
-
* masks a failed capability invocation as `404` (never confirming to an
|
|
323
|
-
* unauthorized caller whether the resource exists); on the sync paths the
|
|
324
|
-
* invoked collection is known to exist, so a `404` means the invocation was
|
|
325
|
-
* rejected. Mapping the raw HTTP status to a typed error at the port boundary
|
|
326
|
-
* (the same way `412` becomes {@link WasSyncConflictError}) lets the sync
|
|
327
|
-
* controller recognise expired access with an `instanceof` check rather than
|
|
328
|
-
* re-extracting status codes from a wrapped RxDB error graph. The offending
|
|
329
|
-
* HTTP status is kept on `status` -- diagnostics, plus the delete path's
|
|
330
|
-
* already-absent-404 check.
|
|
331
|
-
*/
|
|
332
|
-
export declare class WasSyncAuthError extends Error {
|
|
333
|
-
readonly status: number;
|
|
334
|
-
constructor(status: number);
|
|
335
|
-
}
|
|
336
319
|
//# sourceMappingURL=types.d.ts.map
|
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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.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ACH,aAAa,CAAC,OAAO,EAAE;QACrB,EAAE,EAAE,MAAM,CAAA;QACV,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAE/B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,OAAO,EAAE;QACf,EAAE,EAAE,MAAM,CAAA;QACV,MAAM,CAAC,EAAE,IAAI,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,WAAW,CAAC,EAAE,OAAO,CAAA;KACtB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;;;;;;;;;;;;;;;;OAiBG;IACH,GAAG,CAAC,OAAO,EAAE;QACX,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,CAAC,EAAE,eAAe,CAAA;KACxB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CAChC"}
|
package/dist/sync/types.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed port signals, owned by `@interop/was-client` (its sync port raises
|
|
3
|
+
* them) and re-exported here so the names this package's consumers already
|
|
4
|
+
* import stay put -- and so an `instanceof` check anywhere in this package
|
|
5
|
+
* matches the very class the port throws.
|
|
6
|
+
*
|
|
7
|
+
* `WasSyncConflictError` marks a conditional write rejected with `412
|
|
8
|
+
* precondition-failed` (a lost-update conflict, or a create-if-absent whose
|
|
9
|
+
* target already exists); the push handler catches exactly it to trigger the
|
|
10
|
+
* re-read-and-report-conflict path. `WasSyncAuthError` marks a request refused
|
|
11
|
+
* on authorization grounds -- `401`, `403`, or the `404` a WAS server masks a
|
|
12
|
+
* failed capability invocation as, which on the sync paths (where the invoked
|
|
13
|
+
* collection is known to exist) means the invocation was rejected. It keeps the
|
|
14
|
+
* offending HTTP status on `status`, which the `/meta` push path reads to tell
|
|
15
|
+
* a masked denial from an ordinary delete race.
|
|
16
|
+
*/
|
|
17
|
+
export { WasSyncAuthError, WasSyncConflictError } from '@interop/was-client/sync';
|
|
1
18
|
/**
|
|
2
19
|
* Structural equality over two opaque bodies, by canonical-free JSON string.
|
|
3
20
|
* Decides whether the content or the metadata half changed -- which endpoint(s)
|
|
@@ -38,39 +55,4 @@ export function copyOptionalBodyFields({ source, target }) {
|
|
|
38
55
|
target.epoch = source.epoch;
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Thrown by a {@link WasSyncPort} implementation when a conditional write is
|
|
43
|
-
* rejected with `412 precondition-failed` (a lost-update conflict, or a
|
|
44
|
-
* create-if-absent whose target already exists). The core push handler catches
|
|
45
|
-
* exactly this type to trigger the re-read-and-report-conflict path; any other
|
|
46
|
-
* error propagates to RxDB for retry.
|
|
47
|
-
*/
|
|
48
|
-
export class WasSyncConflictError extends Error {
|
|
49
|
-
constructor(message = 'WAS conditional write precondition failed.') {
|
|
50
|
-
super(message);
|
|
51
|
-
this.name = 'WasSyncConflictError';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Thrown by a {@link WasSyncPort} implementation when a request is rejected with
|
|
56
|
-
* `401 unauthorized`, `403 forbidden`, or `404 not found` -- the
|
|
57
|
-
* storage-access-expired/revoked signal. `404` qualifies because a WAS server
|
|
58
|
-
* masks a failed capability invocation as `404` (never confirming to an
|
|
59
|
-
* unauthorized caller whether the resource exists); on the sync paths the
|
|
60
|
-
* invoked collection is known to exist, so a `404` means the invocation was
|
|
61
|
-
* rejected. Mapping the raw HTTP status to a typed error at the port boundary
|
|
62
|
-
* (the same way `412` becomes {@link WasSyncConflictError}) lets the sync
|
|
63
|
-
* controller recognise expired access with an `instanceof` check rather than
|
|
64
|
-
* re-extracting status codes from a wrapped RxDB error graph. The offending
|
|
65
|
-
* HTTP status is kept on `status` -- diagnostics, plus the delete path's
|
|
66
|
-
* already-absent-404 check.
|
|
67
|
-
*/
|
|
68
|
-
export class WasSyncAuthError extends Error {
|
|
69
|
-
status;
|
|
70
|
-
constructor(status) {
|
|
71
|
-
super(`WAS storage access denied (HTTP ${status}).`);
|
|
72
|
-
this.name = 'WasSyncAuthError';
|
|
73
|
-
this.status = status;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
58
|
//# sourceMappingURL=types.js.map
|
package/dist/sync/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AA2BjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACzB,IAAsB,EACtB,KAAuB;IAEvB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAA;AACvE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,MAAM,EACN,MAAM,EAIP;IACC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IAC3B,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;IACzC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC/B,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -3,41 +3,24 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* The app-side seam between the generic sync adapter and `@interop/was-client`.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* Delegates to the client's own `createWasSyncPort` -- which owns the WAS URL
|
|
7
|
+
* grammar, the verbatim (codec-bypassing) `was.request()` writes, the `changes`
|
|
8
|
+
* feed pull, the key-epoch header, and the conditional-write ETag handling --
|
|
9
|
+
* and pins the two options this package needs: the collection's delegated
|
|
10
|
+
* capability, and `mapAuthErrors` so a `401` / `403` / the server's masked `404`
|
|
11
|
+
* arrive as a `WasSyncAuthError` the sync controller can `instanceof`-match.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* side must write those same bytes back unchanged -- running them through
|
|
17
|
-
* `resource.put()` would re-encrypt an already-encrypted envelope. Encrypt /
|
|
18
|
-
* decrypt stays a read/write-time concern above this layer; this port is
|
|
19
|
-
* collection-agnostic and never touches keys.
|
|
20
|
-
*
|
|
21
|
-
* Conditional writes ride the server's monotonic `version` (content) and
|
|
22
|
-
* `metaVersion` (metadata) ETags, which the reference server enforces uniformly
|
|
23
|
-
* for plaintext and encrypted resources alike -- so there is no plaintext-vs-
|
|
24
|
-
* encrypted fork here.
|
|
13
|
+
* What stays here is the narrowing to a {@link WasSyncBasePort}: the 412
|
|
14
|
+
* conflict re-read (`get`) is supplied separately by `withFeedMasterRead`, which
|
|
15
|
+
* resolves the master state from the changes-feed BODY -- origin-independent,
|
|
16
|
+
* unlike a cross-origin `GET` whose ETag header CORS hides.
|
|
25
17
|
*/
|
|
26
|
-
import {
|
|
18
|
+
import type { WasClient } from '@interop/was-client';
|
|
27
19
|
import type { IZcap } from '@interop/data-integrity-core';
|
|
28
|
-
import {
|
|
29
|
-
/**
|
|
30
|
-
* Normalizes an unknown caught error into a display string: the `Error`'s
|
|
31
|
-
* `message` when it is one, else its `String(...)` coercion. Shared by the
|
|
32
|
-
* remote store's descriptor PUT and the session activation error path.
|
|
33
|
-
*
|
|
34
|
-
* @param err {unknown}
|
|
35
|
-
* @returns {string}
|
|
36
|
-
*/
|
|
37
|
-
export declare function errorMessage(err: unknown): string;
|
|
20
|
+
import type { WasSyncBasePort } from './types.js';
|
|
38
21
|
/**
|
|
39
|
-
* Builds a `
|
|
40
|
-
* server, backed by the session's signed `WasClient`.
|
|
22
|
+
* Builds a `WasSyncBasePort` bound to a single Space + Collection on the remote
|
|
23
|
+
* WAS server, backed by the session's signed `WasClient`.
|
|
41
24
|
*
|
|
42
25
|
* @param options {object}
|
|
43
26
|
* @param options.was {WasClient} the session client (holds the signer)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasSyncPort.d.ts","sourceRoot":"","sources":["../../src/sync/wasSyncPort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"wasSyncPort.d.ts","sourceRoot":"","sources":["../../src/sync/wasSyncPort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAkB,eAAe,EAAW,MAAM,YAAY,CAAA;AAE1E;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GAAG,eAAe,CAqClB"}
|
package/dist/sync/wasSyncPort.js
CHANGED
|
@@ -1,75 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The app-side seam between the generic sync adapter and `@interop/was-client`.
|
|
6
|
-
* Implements the `WasSyncBasePort` interface (query + conditional writes) for one
|
|
7
|
-
* remote WAS Collection using the raw, signed `was.request()` escape hatch. The
|
|
8
|
-
* 412 conflict re-read (`get`) is supplied separately by `withFeedMasterRead`,
|
|
9
|
-
* which resolves the master state from the changes-feed body -- origin-
|
|
10
|
-
* independent, unlike a cross-origin `GET` ETag header.
|
|
11
|
-
*
|
|
12
|
-
* Using `request()` (rather than the `Resource` / `Collection` handles) is
|
|
13
|
-
* deliberate: it moves the stored body VERBATIM, bypassing the encryption codec.
|
|
14
|
-
* The `changes` feed already ships opaque stored bodies (plaintext for a
|
|
15
|
-
* plaintext collection, the EDV envelope for an encrypted one), and the push
|
|
16
|
-
* side must write those same bytes back unchanged -- running them through
|
|
17
|
-
* `resource.put()` would re-encrypt an already-encrypted envelope. Encrypt /
|
|
18
|
-
* decrypt stays a read/write-time concern above this layer; this port is
|
|
19
|
-
* collection-agnostic and never touches keys.
|
|
20
|
-
*
|
|
21
|
-
* Conditional writes ride the server's monotonic `version` (content) and
|
|
22
|
-
* `metaVersion` (metadata) ETags, which the reference server enforces uniformly
|
|
23
|
-
* for plaintext and encrypted resources alike -- so there is no plaintext-vs-
|
|
24
|
-
* encrypted fork here.
|
|
25
|
-
*/
|
|
26
|
-
import { readEtag, writeHeaders } from '@interop/was-client';
|
|
27
|
-
import { errorStatus, parseEtag } from '@interop/was-client/sync';
|
|
28
|
-
import { collectionPath } from '../grants.js';
|
|
29
|
-
import { WasSyncAuthError, WasSyncConflictError } from './types.js';
|
|
30
|
-
/**
|
|
31
|
-
* Normalizes an unknown caught error into a display string: the `Error`'s
|
|
32
|
-
* `message` when it is one, else its `String(...)` coercion. Shared by the
|
|
33
|
-
* remote store's descriptor PUT and the session activation error path.
|
|
34
|
-
*
|
|
35
|
-
* @param err {unknown}
|
|
36
|
-
* @returns {string}
|
|
37
|
-
*/
|
|
38
|
-
export function errorMessage(err) {
|
|
39
|
-
return err instanceof Error ? err.message : String(err);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Maps a raw `was.request()` rejection to the sync layer's typed errors: `412`
|
|
43
|
-
* to {@link WasSyncConflictError} (a lost-update conflict) and `401` / `403` /
|
|
44
|
-
* `404` to {@link WasSyncAuthError} (expired/revoked storage access). Every
|
|
45
|
-
* other error is returned unchanged so RxDB's retry/backoff handles it. Returns
|
|
46
|
-
* the error to throw (the caller re-throws) rather than throwing itself.
|
|
47
|
-
*
|
|
48
|
-
* `404` counts as access denied because a WAS server masks a failed capability
|
|
49
|
-
* invocation as `404` ("URL not found or invalid authorization") rather than
|
|
50
|
-
* `403`, so an unauthorized caller cannot probe which resources exist. On the
|
|
51
|
-
* sync paths the invoked space and collection are known to exist (the session
|
|
52
|
-
* synced them), so a `404` means the invocation itself was rejected -- the
|
|
53
|
-
* revoked/expired-grant signal. The one route where `404` is routine --
|
|
54
|
-
* deleting an already-absent resource -- inspects the preserved `status` on the
|
|
55
|
-
* mapped error and stays a success (see `deleteContent`).
|
|
56
|
-
*
|
|
57
|
-
* @param err {unknown}
|
|
58
|
-
* @returns {unknown}
|
|
59
|
-
*/
|
|
60
|
-
function toPortError(err) {
|
|
61
|
-
const status = errorStatus(err);
|
|
62
|
-
if (status === 412) {
|
|
63
|
-
return new WasSyncConflictError();
|
|
64
|
-
}
|
|
65
|
-
if (status === 401 || status === 403 || status === 404) {
|
|
66
|
-
return new WasSyncAuthError(status);
|
|
67
|
-
}
|
|
68
|
-
return err;
|
|
69
|
-
}
|
|
1
|
+
import { createWasSyncPort as createClientSyncPort } from '@interop/was-client/sync';
|
|
70
2
|
/**
|
|
71
|
-
* Builds a `
|
|
72
|
-
* server, backed by the session's signed `WasClient`.
|
|
3
|
+
* Builds a `WasSyncBasePort` bound to a single Space + Collection on the remote
|
|
4
|
+
* WAS server, backed by the session's signed `WasClient`.
|
|
73
5
|
*
|
|
74
6
|
* @param options {object}
|
|
75
7
|
* @param options.was {WasClient} the session client (holds the signer)
|
|
@@ -81,106 +13,32 @@ function toPortError(err) {
|
|
|
81
13
|
* @returns {WasSyncBasePort}
|
|
82
14
|
*/
|
|
83
15
|
export function createWasSyncPort({ was, spaceId, collectionId, capability }) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const response = await run();
|
|
101
|
-
// `readEtag` reports an absent header as `undefined`; `parseEtag` reads
|
|
102
|
-
// the `null` spelling of the same thing.
|
|
103
|
-
return parseEtag(readEtag(response) ?? null);
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
throw toPortError(err);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
16
|
+
const port = createClientSyncPort({
|
|
17
|
+
was,
|
|
18
|
+
spaceId,
|
|
19
|
+
collectionId,
|
|
20
|
+
...(capability !== undefined && { capability }),
|
|
21
|
+
mapAuthErrors: true
|
|
22
|
+
});
|
|
23
|
+
// The client types `putMeta` as optional (a port may replicate content only);
|
|
24
|
+
// its own implementation always supplies it, and this package's replication
|
|
25
|
+
// always writes the `/meta` half, so require it at the boundary rather than
|
|
26
|
+
// guarding at every call site.
|
|
27
|
+
const { putMeta } = port;
|
|
28
|
+
if (putMeta === undefined) {
|
|
29
|
+
throw new Error('The WAS sync port does not implement `putMeta`, which this ' +
|
|
30
|
+
"package's replication requires.");
|
|
31
|
+
}
|
|
109
32
|
return {
|
|
110
|
-
async query(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
method: 'POST',
|
|
116
|
-
json: {
|
|
117
|
-
profile: 'changes',
|
|
118
|
-
...(checkpoint !== undefined && { checkpoint }),
|
|
119
|
-
limit
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return response.data;
|
|
123
|
-
}
|
|
124
|
-
catch (err) {
|
|
125
|
-
// Map a pull-path auth rejection (401/403, or the masked 404) to
|
|
126
|
-
// WasSyncAuthError too, so expired/revoked access is recognised
|
|
127
|
-
// whether it surfaces on the pull or the push side.
|
|
128
|
-
throw toPortError(err);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
async putContent({ id, data, ifMatch, ifNoneMatch, epoch }) {
|
|
132
|
-
return conditionalWrite(() => was.request({
|
|
133
|
-
capability,
|
|
134
|
-
path: resourcePath(id),
|
|
135
|
-
method: 'PUT',
|
|
136
|
-
json: data,
|
|
137
|
-
// `epoch` rides as the `Key-Epoch` header so the server's stamp
|
|
138
|
-
// stays in step with the envelope (an absent epoch clears any prior
|
|
139
|
-
// stamp, per the `key-epochs` feature).
|
|
140
|
-
headers: writeHeaders({
|
|
141
|
-
precondition: { ifMatch, ifNoneMatch },
|
|
142
|
-
epoch
|
|
143
|
-
})
|
|
144
|
-
}));
|
|
145
|
-
},
|
|
146
|
-
async deleteContent({ id, ifMatch }) {
|
|
147
|
-
try {
|
|
148
|
-
return await conditionalWrite(() => was.request({
|
|
149
|
-
capability,
|
|
150
|
-
path: resourcePath(id),
|
|
151
|
-
method: 'DELETE',
|
|
152
|
-
headers: writeHeaders({ precondition: { ifMatch } })
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
catch (err) {
|
|
156
|
-
// A 404 means the resource is already absent -- the row was created
|
|
157
|
-
// and deleted locally before ever being pushed, or another device
|
|
158
|
-
// deleted it first. Either way the tombstone's goal state holds, so
|
|
159
|
-
// report success (no acked revision) instead of rejecting the batch,
|
|
160
|
-
// which RxDB would otherwise retry forever. (A masked auth-failure 404
|
|
161
|
-
// is swallowed here too -- indistinguishable by design -- but revoked
|
|
162
|
-
// access still surfaces within one pull-poll interval, where 404 maps
|
|
163
|
-
// to WasSyncAuthError.) The mapped error keeps the raw `status`, so
|
|
164
|
-
// this check works on the WasSyncAuthError conditionalWrite now throws
|
|
165
|
-
// for a 404.
|
|
166
|
-
if (errorStatus(err) === 404) {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
throw err;
|
|
170
|
-
}
|
|
33
|
+
async query(options) {
|
|
34
|
+
// The feed page's bodies are `unknown` upstream (a stored body is any
|
|
35
|
+
// JSON, and a future encryption scheme's envelope need not be an EDV
|
|
36
|
+
// document); this layer moves them verbatim as `Json`.
|
|
37
|
+
return (await port.query(options));
|
|
171
38
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
path: `${resourcePath(id)}/meta`,
|
|
176
|
-
method: 'PUT',
|
|
177
|
-
// The `/meta` PUT is a full replacement of `custom`: a body with no
|
|
178
|
-
// `custom` member writes the CLEARED state (the server clears every
|
|
179
|
-
// property the body omits), which is how a metadata clear replicates.
|
|
180
|
-
json: custom === undefined ? {} : { custom },
|
|
181
|
-
headers: writeHeaders({ precondition: { ifMatch, ifNoneMatch } })
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
39
|
+
putContent: options => port.putContent(options),
|
|
40
|
+
deleteContent: options => port.deleteContent(options),
|
|
41
|
+
putMeta: options => putMeta(options)
|
|
184
42
|
};
|
|
185
43
|
}
|
|
186
44
|
//# sourceMappingURL=wasSyncPort.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasSyncPort.js","sourceRoot":"","sources":["../../src/sync/wasSyncPort.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wasSyncPort.js","sourceRoot":"","sources":["../../src/sync/wasSyncPort.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAIpF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,UAAU,EAMX;IACC,MAAM,IAAI,GAAG,oBAAoB,CAAC;QAChC,GAAG;QACH,OAAO;QACP,YAAY;QACZ,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;QAC/C,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IACF,8EAA8E;IAC9E,4EAA4E;IAC5E,4EAA4E;IAC5E,+BAA+B;IAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IACxB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,6DAA6D;YAC3D,iCAAiC,CACpC,CAAA;IACH,CAAC;IAED,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,OAAO;YACjB,sEAAsE;YACtE,qEAAqE;YACrE,uDAAuD;YACvD,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAGhC,CAAA;QACH,CAAC;QAED,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAE/C,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAErD,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;KACrC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/was-react",
|
|
3
3
|
"description": "React library for building 'Bring Your Own Everything' (BYOE) apps on Wallet Attached Storage: DID Auth login via CHAPI wallet, local-first encrypted storage, and background sync to a WAS server.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@interop/security-document-loader": "^10.0.0",
|
|
54
54
|
"@interop/vc": "^11.0.6",
|
|
55
55
|
"@interop/verifier-core": "^3.5.4",
|
|
56
|
-
"@interop/wallet-core": "^0.
|
|
57
|
-
"@interop/was-client": "^0.
|
|
56
|
+
"@interop/wallet-core": "^0.30.1",
|
|
57
|
+
"@interop/was-client": "^0.34.0",
|
|
58
58
|
"@interop/webkms-client": "^14.7.1",
|
|
59
59
|
"@scure/base": "^2.2.0",
|
|
60
60
|
"byoe-context": "^0.3.0",
|