@interop/was-react 0.1.9 → 0.1.11
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 +83 -3
- package/dist/auth/loginFlow.d.ts +4 -7
- package/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +1 -4
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/loginRequest.d.ts +29 -3
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +12 -4
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts +1 -4
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +4 -9
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/config.d.ts +15 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -0
- package/dist/config.js.map +1 -1
- package/dist/identity/documentLoader.d.ts +2 -8
- package/dist/identity/documentLoader.d.ts.map +1 -1
- package/dist/identity/documentLoader.js +7 -88
- package/dist/identity/documentLoader.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react/documentApp.d.ts +8 -5
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +1 -3
- package/dist/react/documentApp.js.map +1 -1
- package/dist/react/hooks.d.ts +3 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js.map +1 -1
- package/dist/session/authStore.d.ts +10 -2
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +35 -24
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/entityStore.d.ts +20 -0
- package/dist/storage/entityStore.d.ts.map +1 -1
- package/dist/storage/entityStore.js +24 -1
- package/dist/storage/entityStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +10 -0
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +24 -2
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/publicUrl.d.ts +20 -0
- package/dist/storage/publicUrl.d.ts.map +1 -0
- package/dist/storage/publicUrl.js +33 -0
- package/dist/storage/publicUrl.js.map +1 -0
- package/dist/storage/storageManager.d.ts +28 -0
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +42 -2
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +91 -2
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +159 -9
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/storage/wasSync.d.ts +2 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +13 -6
- package/dist/storage/wasSync.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -83,7 +83,6 @@ import type { WasAppConfig } from '@interop/was-react'
|
|
|
83
83
|
export const config: WasAppConfig = {
|
|
84
84
|
appName: 'Notes',
|
|
85
85
|
appOrigin: 'https://notes.example',
|
|
86
|
-
wasServerUrl: 'https://was.example',
|
|
87
86
|
collections: [{ key: 'notes', id: 'notes' }],
|
|
88
87
|
credential: {
|
|
89
88
|
credentialType: 'NotesAppKey',
|
|
@@ -116,6 +115,17 @@ recognize a stray encrypted envelope and refuses the row), and payloads should
|
|
|
116
115
|
carry the `updatedAt` / `deviceId` LWW fields like any other collection --
|
|
117
116
|
without them a concurrent multi-device edit falls back to server-wins.
|
|
118
117
|
|
|
118
|
+
At login, a public collection is requested from the wallet with the distinct
|
|
119
|
+
`urn:was:public-collection` descriptor type (private collections use
|
|
120
|
+
`urn:was:collection`): the wallet provisions it plaintext with a public-read
|
|
121
|
+
policy, shows a world-readable consent warning, and delegates the usual
|
|
122
|
+
read/write capability (public covers only unauthenticated reads; writes stay
|
|
123
|
+
capability-only). A wallet that predates the descriptor reports the request
|
|
124
|
+
unsatisfiable rather than silently provisioning a private collection, so the
|
|
125
|
+
feature fails closed with older wallets. Publicness is granted at consent time
|
|
126
|
+
by the wallet -- the app itself can never escalate an existing private
|
|
127
|
+
collection to public.
|
|
128
|
+
|
|
119
129
|
### 2. Entity stores and the registry
|
|
120
130
|
|
|
121
131
|
```ts
|
|
@@ -228,6 +238,75 @@ stamped on EVERY insert and update: they are the last-write-wins pair that
|
|
|
228
238
|
settles concurrent multi-device edits of the same entity. A payload without them
|
|
229
239
|
loses every sync conflict.
|
|
230
240
|
|
|
241
|
+
A public collection can additionally answer server-side equality queries.
|
|
242
|
+
Declare the queryable content attributes in the collection config:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
{ key: 'posts', id: 'microblog-posts', visibility: 'public',
|
|
246
|
+
indexes: ['author', 'inReplyTo'] }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
The sync bootstrap announces the declaration in the collection description (the
|
|
250
|
+
server rejects filters on undeclared attributes fail-closed), and the entity
|
|
251
|
+
store's `query` verb runs the query:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
const page = await usePosts.getState().query({
|
|
255
|
+
equals: { author: 'did:key:z6Mk...' }
|
|
256
|
+
})
|
|
257
|
+
// page.docs: the matching payloads
|
|
258
|
+
// page.hasMore / page.cursor: pass cursor back in to fetch the next page
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`query` is a read verb against the server (signed with the granted collection
|
|
262
|
+
capability, so it needs a wallet-connected session), not a sync path: it never
|
|
263
|
+
touches the in-memory Map. Multiple `equals` attributes AND together; values are
|
|
264
|
+
string equality only. On the wire it is the collection list endpoint's cacheable
|
|
265
|
+
`filter[attr]=value` GET form, with filter attributes emitted in sorted order so
|
|
266
|
+
identical queries produce identical URLs; on a public collection the same URL
|
|
267
|
+
also answers anonymously for non-app consumers. Declaring `indexes` on a private
|
|
268
|
+
collection is rejected at config validation -- the encrypted (blinded-index)
|
|
269
|
+
query path is not yet supported.
|
|
270
|
+
|
|
271
|
+
### Share links (publish-copy)
|
|
272
|
+
|
|
273
|
+
A public collection also gives every document a stable, world-readable resource
|
|
274
|
+
URL, which is the basis for share links. The pattern is publish-copy: declare
|
|
275
|
+
one public collection for shared documents,
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
{ key: 'sharedNotes', id: 'shared-notes', visibility: 'public' }
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
to share a document, copy it into that store, and the share URL is that copy's
|
|
282
|
+
resource URL:
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { publicUrlFor } from '@interop/was-react'
|
|
286
|
+
import { useSharedNotes } from './stores.js'
|
|
287
|
+
|
|
288
|
+
// Share: copy the doc into the public collection.
|
|
289
|
+
await useSharedNotes.getState().insert(doc)
|
|
290
|
+
const url = publicUrlFor({ collectionKey: 'sharedNotes', id: doc.id })
|
|
291
|
+
|
|
292
|
+
// Unshare: remove the copy; replication pushes the delete and the URL stops
|
|
293
|
+
// resolving.
|
|
294
|
+
await useSharedNotes.getState().remove(doc.id)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The URL is stable across edits because a public collection stores the payload
|
|
298
|
+
under its own logical uuid. Whether a share is a copy (which survives later
|
|
299
|
+
unsharing edits of the original) or a move is an app product decision;
|
|
300
|
+
content-addressed ids (hashing immutable content so identical content shares one
|
|
301
|
+
URL) are likewise an app-level choice.
|
|
302
|
+
|
|
303
|
+
Anyone on the web can read the URL -- there is no auth. A consumer can fetch it
|
|
304
|
+
with `WasClient.publicRead` from `@interop/was-client` or a plain GET. The URL
|
|
305
|
+
resolves only after the document has synced to the server (a locally-inserted
|
|
306
|
+
doc shares after the next sync push). Expiring or time-boxed share links are not
|
|
307
|
+
supported: sharing IS public-collection membership, so a share lasts until the
|
|
308
|
+
copy is removed.
|
|
309
|
+
|
|
231
310
|
The MUI entry supplies a router gate and status UI on top of this; see
|
|
232
311
|
[Entry points](#entry-points).
|
|
233
312
|
|
|
@@ -261,8 +340,9 @@ Login is driven by CHAPI Verifiable Presentation Requests (VPRs). The
|
|
|
261
340
|
wallet provisions the collections and returns a signed presentation.
|
|
262
341
|
7. **Verify the response.** `verifyLoginPresentation` checks the VP and embedded
|
|
263
342
|
proofs (purpose `authentication`, matching domain and challenge), and
|
|
264
|
-
`checkGrants` asserts every zcap is controlled by the app DID,
|
|
265
|
-
|
|
343
|
+
`checkGrants` asserts every zcap is controlled by the app DID, shares one
|
|
344
|
+
space on a single WAS host, and is unexpired. The wallet decides where the
|
|
345
|
+
user's Space lives; the sync layer derives its target from the grants.
|
|
266
346
|
8. **Activate.** The session (seed, grants, earliest expiry) is persisted to
|
|
267
347
|
IndexedDB, the encrypted local store is opened, the entity stores hydrate,
|
|
268
348
|
and background WAS sync starts.
|
package/dist/auth/loginFlow.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type { IZcap } from '@interop/data-integrity-core';
|
|
|
19
19
|
import type { DocumentLoader } from '../identity/documentLoader.js';
|
|
20
20
|
import { type SeedCredentialConfig } from '../identity/seedCredential.js';
|
|
21
21
|
import type { IdentityAgents } from '../identity/agents.js';
|
|
22
|
+
import { type GrantRequestCollection } from './loginRequest.js';
|
|
22
23
|
import { type CheckedGrants } from './verifyResponse.js';
|
|
23
24
|
import type { ParsedGrants } from '../grants.js';
|
|
24
25
|
/**
|
|
@@ -36,9 +37,10 @@ export interface LoginConfig {
|
|
|
36
37
|
*/
|
|
37
38
|
appName: string;
|
|
38
39
|
/**
|
|
39
|
-
* The
|
|
40
|
+
* The collections to request read/write grants for (WAS collection id +
|
|
41
|
+
* visibility; `'public'` selects the `urn:was:public-collection` descriptor).
|
|
40
42
|
*/
|
|
41
|
-
collections:
|
|
43
|
+
collections: GrantRequestCollection[];
|
|
42
44
|
/**
|
|
43
45
|
* The seed-credential type name + vocabulary namespace.
|
|
44
46
|
*/
|
|
@@ -47,11 +49,6 @@ export interface LoginConfig {
|
|
|
47
49
|
* The JSON-LD document loader (see `createDocumentLoader`).
|
|
48
50
|
*/
|
|
49
51
|
documentLoader: DocumentLoader;
|
|
50
|
-
/**
|
|
51
|
-
* The expected WAS server URL. When set, every granted zcap must target it;
|
|
52
|
-
* grants pointing anywhere else are rejected at login.
|
|
53
|
-
*/
|
|
54
|
-
wasServerUrl?: string;
|
|
55
52
|
/**
|
|
56
53
|
* The CHAPI mediator base URL (defaults to `DEFAULT_MEDIATOR_BASE`).
|
|
57
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginFlow.d.ts","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"loginFlow.d.ts","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,WAAW,EAAE,sBAAsB,EAAE,CAAA;IACrC;;OAEG;IACH,UAAU,EAAE,oBAAoB,CAAA;IAChC;;OAEG;IACH,cAAc,EAAE,cAAc,CAAA;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GACpB,SAAS,GAAG,aAAa,GAAG,mBAAmB,GAAG,WAAW,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,EAAE,YAAY,CAAA;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,IAAI,EAAE,MAAM;CAIzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,MAAM,EACN,OAAO,EACR,EAAE;IACD,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACtC,GAAG,OAAO,CAAC,aAAa,CAAC,CA+BzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,OAAO,EACR,EAAE;IACD,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACtC,GAAG,OAAO,CAAC,YAAY,CAAC,CAiFxB"}
|
package/dist/auth/loginFlow.js
CHANGED
|
@@ -51,10 +51,7 @@ export async function requestGrants({ identity, config, onPhase }) {
|
|
|
51
51
|
return checkGrants({
|
|
52
52
|
grants: grantsOf(presentation),
|
|
53
53
|
controllerDid: identity.controllerDid,
|
|
54
|
-
collections: config.collections
|
|
55
|
-
...(config.wasServerUrl !== undefined && {
|
|
56
|
-
expectedServerUrl: config.wasServerUrl
|
|
57
|
-
})
|
|
54
|
+
collections: config.collections.map(collection => collection.id)
|
|
58
55
|
});
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EAEvB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,
|
|
1
|
+
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EAEvB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EAEb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,uBAAuB,EAExB,MAAM,qBAAqB,CAAA;AAyD5B;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,IAAY;QACtB,KAAK,CAAC,qCAAqC,IAAI,IAAI,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAA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,CAAC;SAAM,CAAC;QACN,sEAAsE;QACtE,qEAAqE;QACrE,+BAA+B;QAC/B,IAAI,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAA;QACjD,QAAQ,GAAG,IAAI,CAAA;QACf,OAAO,EAAE,CAAC,aAAa,CAAC,CAAA;QACxB,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC;YACvC,IAAI;YACJ,MAAM,EAAE,MAAM,CAAC,SAAS;YACxB,MAAM,EAAE,MAAM,CAAC,UAAU;YACzB,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC;YAC9B,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI;gBACvC,YAAY,EAAE,MAAM,CAAC,YAAY;aAClC,CAAC;SACH,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,CAAC,CAAA;QACpE,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,sEAAsE;IACtE,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,QAAQ;QACR,MAAM;QACN,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC;KAC5B,CAAC,CAAA;IACF,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
* one capabilityQuery per collection (descriptor-object targets, which the
|
|
12
12
|
* wallet resolves against the user's one Space and auto-provisions). Only
|
|
13
13
|
* collection-scoped capabilities are requested -- no whole-space grant.
|
|
14
|
+
* A `visibility: 'public'` collection is requested with the distinct
|
|
15
|
+
* descriptor type `urn:was:public-collection` (the wallet provisions it
|
|
16
|
+
* plaintext with a collection-level public-read policy and renders a
|
|
17
|
+
* world-readable consent warning); wallets that predate the type render it
|
|
18
|
+
* UNSATISFIABLE, which is the intended fail-closed behavior -- an older
|
|
19
|
+
* wallet must not silently provision a private collection the app believes
|
|
20
|
+
* is public.
|
|
14
21
|
*
|
|
15
22
|
* `domain` must host-match the CHAPI requesting origin or the wallet refuses
|
|
16
23
|
* to sign; `challenge` must be fresh per request (echoed into the DIDAuth
|
|
@@ -21,6 +28,22 @@ import type { IVPRDetails } from './walletRequestTypes.js';
|
|
|
21
28
|
* Default read/write actions requested on each app collection.
|
|
22
29
|
*/
|
|
23
30
|
export declare const RW_ACTIONS: string[];
|
|
31
|
+
/**
|
|
32
|
+
* One collection to request a grant for: the WAS collection id plus its
|
|
33
|
+
* declared visibility (`'private'`, the default, or `'public'`).
|
|
34
|
+
*/
|
|
35
|
+
export interface GrantRequestCollection {
|
|
36
|
+
/**
|
|
37
|
+
* WAS collection id (the unprefixed, cross-app generic name).
|
|
38
|
+
*/
|
|
39
|
+
id: string;
|
|
40
|
+
/**
|
|
41
|
+
* Who can read the collection; selects the descriptor type
|
|
42
|
+
* (`urn:was:collection` for `'private'`/unset, `urn:was:public-collection`
|
|
43
|
+
* for `'public'`).
|
|
44
|
+
*/
|
|
45
|
+
visibility?: 'private' | 'public';
|
|
46
|
+
}
|
|
24
47
|
/**
|
|
25
48
|
* A fresh nonce for a VPR challenge.
|
|
26
49
|
*/
|
|
@@ -44,13 +67,16 @@ export declare function buildSeedProbeVpr({ challenge, domain, credentialType, a
|
|
|
44
67
|
/**
|
|
45
68
|
* VPR #2: DIDAuthentication + AuthorizationCapabilityQuery -- one read/write
|
|
46
69
|
* capabilityQuery per app collection (delegated to `controllerDid`). Only
|
|
47
|
-
* collection-scoped capabilities are requested.
|
|
70
|
+
* collection-scoped capabilities are requested. A `visibility: 'public'`
|
|
71
|
+
* collection uses the `urn:was:public-collection` descriptor type; everything
|
|
72
|
+
* else uses `urn:was:collection`.
|
|
48
73
|
*
|
|
49
74
|
* @param options {object}
|
|
50
75
|
* @param options.challenge {string}
|
|
51
76
|
* @param options.domain {string}
|
|
52
77
|
* @param options.controllerDid {string}
|
|
53
|
-
* @param options.collections {
|
|
78
|
+
* @param options.collections {GrantRequestCollection[]} the collections to
|
|
79
|
+
* request (WAS collection id + visibility)
|
|
54
80
|
* @param options.appName {string} human-readable app name for the reason line
|
|
55
81
|
* @param [options.actions] {string[]} the RW action set (defaults to
|
|
56
82
|
* `RW_ACTIONS`)
|
|
@@ -60,7 +86,7 @@ export declare function buildGrantsVpr({ challenge, domain, controllerDid, colle
|
|
|
60
86
|
challenge: string;
|
|
61
87
|
domain: string;
|
|
62
88
|
controllerDid: string;
|
|
63
|
-
collections:
|
|
89
|
+
collections: GrantRequestCollection[];
|
|
64
90
|
appName: string;
|
|
65
91
|
actions?: string[];
|
|
66
92
|
}): IVPRDetails;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,yBAAyB,CAAA;AAEhC;;GAEG;AACH,eAAO,MAAM,UAAU,UAA2C,CAAA;AAElE;;;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;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,MAAM,EACN,cAAc,EACd,OAAO,EACR,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,WAAW,CAkBd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,aAAa,EACb,WAAW,EACX,OAAO,EACP,OAAoB,EACrB,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,sBAAsB,EAAE,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,GAAG,WAAW,CA8Bd"}
|
|
@@ -40,25 +40,33 @@ export function buildSeedProbeVpr({ challenge, domain, credentialType, appName }
|
|
|
40
40
|
/**
|
|
41
41
|
* VPR #2: DIDAuthentication + AuthorizationCapabilityQuery -- one read/write
|
|
42
42
|
* capabilityQuery per app collection (delegated to `controllerDid`). Only
|
|
43
|
-
* collection-scoped capabilities are requested.
|
|
43
|
+
* collection-scoped capabilities are requested. A `visibility: 'public'`
|
|
44
|
+
* collection uses the `urn:was:public-collection` descriptor type; everything
|
|
45
|
+
* else uses `urn:was:collection`.
|
|
44
46
|
*
|
|
45
47
|
* @param options {object}
|
|
46
48
|
* @param options.challenge {string}
|
|
47
49
|
* @param options.domain {string}
|
|
48
50
|
* @param options.controllerDid {string}
|
|
49
|
-
* @param options.collections {
|
|
51
|
+
* @param options.collections {GrantRequestCollection[]} the collections to
|
|
52
|
+
* request (WAS collection id + visibility)
|
|
50
53
|
* @param options.appName {string} human-readable app name for the reason line
|
|
51
54
|
* @param [options.actions] {string[]} the RW action set (defaults to
|
|
52
55
|
* `RW_ACTIONS`)
|
|
53
56
|
* @returns {IVPRDetails}
|
|
54
57
|
*/
|
|
55
58
|
export function buildGrantsVpr({ challenge, domain, controllerDid, collections, appName, actions = RW_ACTIONS }) {
|
|
56
|
-
const capabilityQuery = collections.map(id => ({
|
|
59
|
+
const capabilityQuery = collections.map(({ id, visibility }) => ({
|
|
57
60
|
referenceId: id,
|
|
58
61
|
reason: `Store your ${appName} data in the "${id}" collection.`,
|
|
59
62
|
controller: controllerDid,
|
|
60
63
|
allowedAction: actions,
|
|
61
|
-
invocationTarget: {
|
|
64
|
+
invocationTarget: {
|
|
65
|
+
type: visibility === 'public'
|
|
66
|
+
? 'urn:was:public-collection'
|
|
67
|
+
: 'urn:was:collection',
|
|
68
|
+
name: id
|
|
69
|
+
}
|
|
62
70
|
}));
|
|
63
71
|
return {
|
|
64
72
|
query: [
|
|
@@ -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"],"names":[],"mappings":"AA8BA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AAmBlE;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,MAAM,EACN,cAAc,EACd,OAAO,EAMR;IACC,OAAO;QACL,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,mBAAmB;gBACzB,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;aACrC;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,eAAe,EAAE;oBACf,MAAM,EAAE,eAAe,OAAO,iCAAiC;oBAC/D,OAAO,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;iBAClC;aACF;SACF;QACD,SAAS;QACT,MAAM;KACP,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,aAAa,EACb,WAAW,EACX,OAAO,EACP,OAAO,GAAG,UAAU,EAQrB;IACC,MAAM,eAAe,GAA6B,WAAW,CAAC,GAAG,CAC/D,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QACvB,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,cAAc,OAAO,iBAAiB,EAAE,eAAe;QAC/D,UAAU,EAAE,aAAa;QACzB,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE;YAChB,IAAI,EACF,UAAU,KAAK,QAAQ;gBACrB,CAAC,CAAC,2BAA2B;gBAC7B,CAAC,CAAC,oBAAoB;YAC1B,IAAI,EAAE,EAAE;SACT;KACF,CAAC,CACH,CAAA;IACD,OAAO;QACL,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,mBAAmB;gBACzB,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;aACrC;YACD;gBACE,IAAI,EAAE,8BAA8B;gBACpC,eAAe;aAChB;SACF;QACD,SAAS;QACT,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -44,15 +44,12 @@ export interface CheckedGrants {
|
|
|
44
44
|
* covered
|
|
45
45
|
* @param [options.requiredActions] {string[]} the actions each collection
|
|
46
46
|
* grant must allow (defaults to `RW_ACTIONS`)
|
|
47
|
-
* @param [options.expectedServerUrl] {string} the configured WAS host; when
|
|
48
|
-
* set, every grant must target it
|
|
49
47
|
* @returns {CheckedGrants}
|
|
50
48
|
*/
|
|
51
|
-
export declare function checkGrants({ grants, controllerDid, collections, requiredActions
|
|
49
|
+
export declare function checkGrants({ grants, controllerDid, collections, requiredActions }: {
|
|
52
50
|
grants: IZcap[];
|
|
53
51
|
controllerDid: string;
|
|
54
52
|
collections: string[];
|
|
55
53
|
requiredActions?: string[];
|
|
56
|
-
expectedServerUrl?: string;
|
|
57
54
|
}): CheckedGrants;
|
|
58
55
|
//# sourceMappingURL=verifyResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAc7D;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,SAAS,EACT,MAAM,EACN,cAAc,EACf,EAAE;IACD,YAAY,EAAE,uBAAuB,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,cAAc,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,GAAG,KAAK,EAAE,CAMvE;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAUD
|
|
1
|
+
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAc7D;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,SAAS,EACT,MAAM,EACN,cAAc,EACf,EAAE;IACD,YAAY,EAAE,uBAAuB,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,cAAc,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,GAAG,KAAK,EAAE,CAMvE;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAUD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,aAAa,EACb,WAAW,EACX,eAA4B,EAC7B,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,GAAG,aAAa,CAyChB"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* `authentication`, `domain` equals what this app sent (its origin), and
|
|
15
15
|
* the `challenge` echoes this request's fresh nonce.
|
|
16
16
|
* 3. Grant structure: every zcap is controlled by OUR seed-derived DID,
|
|
17
|
-
* targets a single space on
|
|
17
|
+
* targets a single space on a single WAS host, is unexpired, and the
|
|
18
18
|
* collection set is fully covered with sufficient actions. (Delegation-
|
|
19
19
|
* chain proofs are enforced server-side at invocation; the RP checks
|
|
20
20
|
* structure.)
|
|
@@ -97,11 +97,9 @@ function actionsOf(zcap) {
|
|
|
97
97
|
* covered
|
|
98
98
|
* @param [options.requiredActions] {string[]} the actions each collection
|
|
99
99
|
* grant must allow (defaults to `RW_ACTIONS`)
|
|
100
|
-
* @param [options.expectedServerUrl] {string} the configured WAS host; when
|
|
101
|
-
* set, every grant must target it
|
|
102
100
|
* @returns {CheckedGrants}
|
|
103
101
|
*/
|
|
104
|
-
export function checkGrants({ grants, controllerDid, collections, requiredActions = RW_ACTIONS
|
|
102
|
+
export function checkGrants({ grants, controllerDid, collections, requiredActions = RW_ACTIONS }) {
|
|
105
103
|
if (grants.length === 0) {
|
|
106
104
|
throw new Error('The wallet returned no storage grants.');
|
|
107
105
|
}
|
|
@@ -116,12 +114,9 @@ export function checkGrants({ grants, controllerDid, collections, requiredAction
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
// Asserts a single server origin + single space across all grants and
|
|
119
|
-
// builds the per-collection routing table.
|
|
117
|
+
// builds the per-collection routing table. The wallet decides where the
|
|
118
|
+
// user's Space lives; the sync layer derives its target from the grants.
|
|
120
119
|
const parsed = parseGrants(grants);
|
|
121
|
-
if (expectedServerUrl !== undefined &&
|
|
122
|
-
parsed.serverUrl !== expectedServerUrl) {
|
|
123
|
-
throw new Error(`Grants target "${parsed.serverUrl}", expected "${expectedServerUrl}".`);
|
|
124
|
-
}
|
|
125
120
|
for (const id of collections) {
|
|
126
121
|
const grant = parsed.byCollectionId[id];
|
|
127
122
|
if (!grant) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.js","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAM3D,OAAO,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrE,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ACtD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAElC,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAA;QAC5D,CAAC;QACD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QAChC,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;QAC3E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,QAAQ,EAAE,mCAAmC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnE,CAAA;QACH,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AACpC,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -48,6 +48,15 @@ export interface WasCollectionConfig {
|
|
|
48
48
|
* their stored form and stop being readable by the other mode.
|
|
49
49
|
*/
|
|
50
50
|
visibility?: 'private' | 'public';
|
|
51
|
+
/**
|
|
52
|
+
* The content attributes the server indexes for equality queries
|
|
53
|
+
* (`store.query({ equals })`), e.g. `['author', 'inReplyTo']`. Declared here
|
|
54
|
+
* so the sync bootstrap can announce them in the collection description
|
|
55
|
+
* (undeclared attributes are rejected fail-closed by the server). Only valid
|
|
56
|
+
* on `visibility: 'public'` (plaintext) collections for now: the encrypted
|
|
57
|
+
* `blinded-index` query path is not yet supported.
|
|
58
|
+
*/
|
|
59
|
+
indexes?: string[];
|
|
51
60
|
}
|
|
52
61
|
/**
|
|
53
62
|
* Optional replication tuning; each field falls back to a documented default.
|
|
@@ -96,11 +105,6 @@ export interface WasAppConfig {
|
|
|
96
105
|
* This app's own web origin (the anti-phishing bind on the app key).
|
|
97
106
|
*/
|
|
98
107
|
appOrigin: string;
|
|
99
|
-
/**
|
|
100
|
-
* The expected WAS server URL. When set, every granted zcap must target it;
|
|
101
|
-
* grants pointing anywhere else are rejected at login.
|
|
102
|
-
*/
|
|
103
|
-
wasServerUrl?: string;
|
|
104
108
|
/**
|
|
105
109
|
* The CHAPI mediator base URL (the requesting origin is appended).
|
|
106
110
|
*/
|
|
@@ -213,10 +217,14 @@ export declare const DEFAULT_EXPIRY_WATCH_MS: number;
|
|
|
213
217
|
/**
|
|
214
218
|
* Validates a collection registry, fail-closed. Rejects an unknown `visibility`
|
|
215
219
|
* value (a config written against a future library version must not silently
|
|
216
|
-
* fall back to either mode)
|
|
220
|
+
* fall back to either mode), the encrypted-but-public combination: the same
|
|
217
221
|
* WAS collection id registered under conflicting visibilities, which would
|
|
218
222
|
* treat one server-side collection as both encrypted (private) and plaintext
|
|
219
|
-
* (public)
|
|
223
|
+
* (public), and malformed `indexes` declarations (indexes on a private
|
|
224
|
+
* collection -- the encrypted query path is not yet supported -- plus empty or
|
|
225
|
+
* duplicate attribute names, and the same WAS collection id declared with
|
|
226
|
+
* diverging index sets). Called by the storage layer before any replica is
|
|
227
|
+
* opened.
|
|
220
228
|
*
|
|
221
229
|
* @param collections {WasCollectionConfig[]} the collection registry
|
|
222
230
|
* @returns {void}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IACjC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,SAAS,EAAE,M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B,QAAY,CAAA;AAEhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,IAAI,CAyD5E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,EAAE,EACH,EAAE;IACD,WAAW,EAAE,mBAAmB,EAAE,CAAA;IAClC,EAAE,EAAE,MAAM,CAAA;CACX,GAAG,MAAM,GAAG,SAAS,CAErB"}
|
package/dist/config.js
CHANGED
|
Binary file
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAiMA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAA;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,YAAY,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAA;AAEhD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAkC;IACpE,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgC,CAAA;IAC9D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC7C,KAAK,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,WAAW,EAAE,CAAC;QAC3D,MAAM,SAAS,GAAG,UAAU,IAA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AAM,SAAS,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvD,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACxC,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,kBAAkB,EAAE,uCAAuC;gBACzD,oEAAoE;gBACpE,eAAe,CAClB,CAAA;QACH,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;IAChC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,EACX,EAAE,EAIH;IACC,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAA;AACxD,CAAC"}
|
|
@@ -8,15 +8,9 @@ export type DocumentLoader = (url: string) => Promise<{
|
|
|
8
8
|
}>;
|
|
9
9
|
/**
|
|
10
10
|
* Builds the JSON-LD document loader handed to `@interop/vc` issuance and
|
|
11
|
-
* verifier-core verification.
|
|
12
|
-
* did:web dev shim activates only when `wasServerUrl` is an http URL.
|
|
11
|
+
* verifier-core verification.
|
|
13
12
|
*
|
|
14
|
-
* @param [options] {object}
|
|
15
|
-
* @param [options.wasServerUrl] {string} the configured WAS server URL; when
|
|
16
|
-
* it is an http URL, did:web DIDs on that exact host are resolved over http
|
|
17
13
|
* @returns {DocumentLoader}
|
|
18
14
|
*/
|
|
19
|
-
export declare function createDocumentLoader(
|
|
20
|
-
wasServerUrl?: string;
|
|
21
|
-
}): DocumentLoader;
|
|
15
|
+
export declare function createDocumentLoader(): DocumentLoader;
|
|
22
16
|
//# sourceMappingURL=documentLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../../src/identity/documentLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../../src/identity/documentLoader.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAC,CAAA;AAIF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
|
@@ -3,101 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* The app's one JSON-LD document loader: static security contexts plus did:key
|
|
6
|
-
* / did:web resolution (`@interop/security-document-loader`).
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* configured WAS server URL is http, DIDs on exactly that host are resolved over
|
|
11
|
-
* it; everything else falls through to the standard loader. In production
|
|
12
|
-
* (https server, or no server URL) the shim never engages.
|
|
6
|
+
* / did:web resolution (`@interop/security-document-loader`). did:web DIDs on
|
|
7
|
+
* loopback hosts (a local dev WAS server on `localhost` or `127.0.0.1`)
|
|
8
|
+
* resolve over plain http; the resolver handles that natively, so no dev shim
|
|
9
|
+
* is needed here.
|
|
13
10
|
*/
|
|
14
11
|
import { securityLoader } from '@interop/security-document-loader';
|
|
15
12
|
const baseLoader = securityLoader({ fetchRemoteContexts: true }).build();
|
|
16
|
-
/**
|
|
17
|
-
* Per-suite context for a dereferenced verification-method node.
|
|
18
|
-
*/
|
|
19
|
-
const CONTEXT_BY_KEY_TYPE = {
|
|
20
|
-
Ed25519VerificationKey2020: 'https://w3id.org/security/suites/ed25519-2020/v1',
|
|
21
|
-
X25519KeyAgreementKey2020: 'https://w3id.org/security/suites/x25519-2020/v1',
|
|
22
|
-
Multikey: 'https://w3id.org/security/multikey/v1'
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Dereferences a `#fragment` subnode the way did-web-resolver's getNode does.
|
|
26
|
-
*/
|
|
27
|
-
function nodeOf(didDocument, id) {
|
|
28
|
-
const methods = (didDocument.verificationMethod ?? []);
|
|
29
|
-
let match = methods.find(vm => vm?.id === id);
|
|
30
|
-
if (!match) {
|
|
31
|
-
for (const [key, value] of Object.entries(didDocument)) {
|
|
32
|
-
if (key === '@context' || key === 'verificationMethod') {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
match = value.find(entry => entry?.id === id);
|
|
37
|
-
}
|
|
38
|
-
else if (value?.id === id) {
|
|
39
|
-
match = value;
|
|
40
|
-
}
|
|
41
|
-
if (match) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (!match) {
|
|
47
|
-
throw new Error(`DID document entity with id "${id}" not found.`);
|
|
48
|
-
}
|
|
49
|
-
const context = (match.type && CONTEXT_BY_KEY_TYPE[match.type]) ?? didDocument['@context'];
|
|
50
|
-
return { '@context': context, ...match };
|
|
51
|
-
}
|
|
52
13
|
/**
|
|
53
14
|
* Builds the JSON-LD document loader handed to `@interop/vc` issuance and
|
|
54
|
-
* verifier-core verification.
|
|
55
|
-
* did:web dev shim activates only when `wasServerUrl` is an http URL.
|
|
15
|
+
* verifier-core verification.
|
|
56
16
|
*
|
|
57
|
-
* @param [options] {object}
|
|
58
|
-
* @param [options.wasServerUrl] {string} the configured WAS server URL; when
|
|
59
|
-
* it is an http URL, did:web DIDs on that exact host are resolved over http
|
|
60
17
|
* @returns {DocumentLoader}
|
|
61
18
|
*/
|
|
62
|
-
export function createDocumentLoader(
|
|
63
|
-
|
|
64
|
-
* Maps a did:web DID onto the local http WAS server's URL, or `null` when the
|
|
65
|
-
* DID does not live on that host (or the shim is not applicable).
|
|
66
|
-
*/
|
|
67
|
-
function insecureDidWebUrl(didAuthority) {
|
|
68
|
-
if (!wasServerUrl || !wasServerUrl.startsWith('http://')) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const server = new URL(wasServerUrl);
|
|
72
|
-
const segments = didAuthority.split(':');
|
|
73
|
-
// ['did', 'web', '<encoded host>', ...path]
|
|
74
|
-
const host = segments[2] ? decodeURIComponent(segments[2]) : '';
|
|
75
|
-
if (host !== server.host) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
const path = segments.slice(3).map(decodeURIComponent).join('/');
|
|
79
|
-
return `http://${host}/${path ? `${path}/did.json` : '.well-known/did.json'}`;
|
|
80
|
-
}
|
|
81
|
-
return async function documentLoader(url) {
|
|
82
|
-
if (url.startsWith('did:web:')) {
|
|
83
|
-
const [didAuthority = ''] = url.split(/[#?]/);
|
|
84
|
-
const fetchUrl = insecureDidWebUrl(didAuthority);
|
|
85
|
-
if (fetchUrl) {
|
|
86
|
-
const response = await fetch(fetchUrl);
|
|
87
|
-
if (!response.ok) {
|
|
88
|
-
throw new Error(`Could not fetch the DID document at "${fetchUrl}" (status ${response.status}).`);
|
|
89
|
-
}
|
|
90
|
-
const didDocument = (await response.json());
|
|
91
|
-
if (didDocument.id !== didAuthority) {
|
|
92
|
-
throw new Error(`DID document for "${didAuthority}" not found.`);
|
|
93
|
-
}
|
|
94
|
-
const document = url.includes('#')
|
|
95
|
-
? nodeOf(didDocument, url)
|
|
96
|
-
: didDocument;
|
|
97
|
-
return { contextUrl: null, document, documentUrl: url };
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return (await baseLoader(url));
|
|
101
|
-
};
|
|
19
|
+
export function createDocumentLoader() {
|
|
20
|
+
return baseLoader;
|
|
102
21
|
}
|
|
103
22
|
//# sourceMappingURL=documentLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../../src/identity/documentLoader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../../src/identity/documentLoader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAWlE,MAAM,UAAU,GAAG,cAAc,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;AAExE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,UAA4B,CAAA;AACrC,CAAC"}
|