@interop/was-react 0.9.0 → 0.11.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/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +9 -7
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/loginRequest.d.ts +38 -5
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +66 -5
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts +7 -4
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +19 -9
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/dev/provisionDevGrants.d.ts +13 -5
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +55 -23
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/identity/documentLoader.d.ts.map +1 -1
- package/dist/identity/documentLoader.js +9 -2
- package/dist/identity/documentLoader.js.map +1 -1
- package/dist/identity/seedStore.d.ts +15 -4
- package/dist/identity/seedStore.d.ts.map +1 -1
- package/dist/identity/seedStore.js +17 -5
- package/dist/identity/seedStore.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/session/authStore.d.ts.map +1 -1
- package/dist/session/authStore.js +147 -35
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/localStore.d.ts +12 -7
- package/dist/storage/localStore.d.ts.map +1 -1
- package/dist/storage/localStore.js +35 -20
- package/dist/storage/localStore.js.map +1 -1
- package/dist/storage/sharedCollectionReader.d.ts +6 -6
- package/dist/storage/sharedCollectionReader.d.ts.map +1 -1
- package/dist/storage/sharedCollectionReader.js +15 -13
- package/dist/storage/sharedCollectionReader.js.map +1 -1
- package/dist/storage/wasSync.d.ts +22 -1
- package/dist/storage/wasSync.d.ts.map +1 -1
- package/dist/storage/wasSync.js +45 -1
- package/dist/storage/wasSync.js.map +1 -1
- package/dist/sync/docCipher.d.ts +44 -17
- package/dist/sync/docCipher.d.ts.map +1 -1
- package/dist/sync/docCipher.js +60 -13
- package/dist/sync/docCipher.js.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +1 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/syncedDocSchema.js +1 -1
- package/dist/sync/syncedDocSchema.js.map +1 -1
- package/dist/sync/types.d.ts +2 -2
- package/dist/sync/wasSyncPort.js +1 -1
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginFlow.d.ts","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAEV,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAGL,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;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B;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
|
@@ -46,10 +46,13 @@ function appConnectFirstRun(presentation) {
|
|
|
46
46
|
* not a login failure, so such a login completes with no remote storage and
|
|
47
47
|
* the missing readers are warned about downstream.
|
|
48
48
|
*
|
|
49
|
-
* Only the app-owned collections are REQUIRED to be covered
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* Only the app-owned collections are REQUIRED to be covered, each at its own
|
|
50
|
+
* class ceiling: the collections are passed to `checkGrants` with their
|
|
51
|
+
* declared visibility, so a `visibility: 'public'` collection requires at most
|
|
52
|
+
* the add-only set a conformant wallet grants. A shared collection the wallet
|
|
53
|
+
* declined to grant is not a login failure -- the reader for it is simply not
|
|
54
|
+
* opened, with a warning -- so it is not passed to `checkGrants`; it still
|
|
55
|
+
* reaches the routing table through `parseGrants`.
|
|
53
56
|
*
|
|
54
57
|
* @param options {object}
|
|
55
58
|
* @param options.presentation {IVerifiablePresentation}
|
|
@@ -60,9 +63,8 @@ function appConnectFirstRun(presentation) {
|
|
|
60
63
|
* @returns {CheckedGrants}
|
|
61
64
|
*/
|
|
62
65
|
function checkGrantsForCollections({ presentation, controllerDid, collections, sharedCollections = [] }) {
|
|
63
|
-
const collectionIds = collections.map(collection => collection.id);
|
|
64
66
|
const grants = grantsOf(presentation);
|
|
65
|
-
if (
|
|
67
|
+
if (collections.length === 0 && grants.length === 0) {
|
|
66
68
|
if (sharedCollections.length > 0) {
|
|
67
69
|
console.warn('The wallet returned no storage grants; the requested shared ' +
|
|
68
70
|
`collection(s) [${sharedCollections.join(', ')}] were declined, so ` +
|
|
@@ -77,7 +79,7 @@ function checkGrantsForCollections({ presentation, controllerDid, collections, s
|
|
|
77
79
|
return checkGrants({
|
|
78
80
|
grants,
|
|
79
81
|
controllerDid,
|
|
80
|
-
collections
|
|
82
|
+
collections
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,kBAAkB,EAClB,YAAY,EAEb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,uBAAuB,EAExB,MAAM,qBAAqB,CAAA;AAgE5B;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,IAAY;QACtB,KAAK,CAAC,qCAAqC,IAAI,IAAI,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CACH,qEAAqE;YACnE,SAAS,CACZ,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,YAAqC;IAC/D,MAAM,UAAU,GAAI,YAAwD;SACzE,UAAU,CAAA;IACb,OAAO,UAAU,EAAE,QAAQ,KAAK,IAAI,CAAA;AACtC,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"loginFlow.js","sourceRoot":"","sources":["../../src/auth/loginFlow.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,kBAAkB,EAClB,YAAY,EAEb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,uBAAuB,EAExB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jE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAA;IAC1C,8EAA8E;IAC9E,+BAA+B;IAC/B,MAAM,OAAO,GAAG,yBAAyB,CAAC;QACxC,YAAY;QACZ,aAAa,EAAE,gBAAgB,CAAC,aAAa;QAC7C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI;YAC9B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC5C,CAAC;KACH,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"}
|
|
@@ -13,8 +13,16 @@
|
|
|
13
13
|
* delegated zcaps embedded in the response VP, so first-run and returning are a
|
|
14
14
|
* single request/response with no store popup and no separate grants popup.
|
|
15
15
|
*
|
|
16
|
-
* Only collection-scoped capabilities are requested (no whole-space grant)
|
|
17
|
-
*
|
|
16
|
+
* Only collection-scoped capabilities are requested (no whole-space grant),
|
|
17
|
+
* and each request stays within the ACTION CEILING of the descriptor class it
|
|
18
|
+
* uses (the App Connect spec's "Action ceilings" table): a private collection
|
|
19
|
+
* asks for the full vocabulary ({@link RW_ACTIONS}), a public collection at
|
|
20
|
+
* most the add-only set ({@link PUBLIC_ACTIONS}). A configured action set
|
|
21
|
+
* naming an action above a requested collection's ceiling is a configuration
|
|
22
|
+
* error thrown here, at build time -- a conformant wallet can never grant it,
|
|
23
|
+
* so letting it ride would surface later as a failed login instead.
|
|
24
|
+
*
|
|
25
|
+
* A `visibility: 'public'` collection is requested with the distinct descriptor
|
|
18
26
|
* type `https://w3id.org/byoe#public-collection` (the wallet provisions it plaintext with a
|
|
19
27
|
* collection-level public-read policy and renders a world-readable consent
|
|
20
28
|
* warning); wallets that predate the type render it UNSATISFIABLE, which is the
|
|
@@ -41,15 +49,37 @@
|
|
|
41
49
|
import type { SeedCredentialConfig } from '../identity/seedCredential.js';
|
|
42
50
|
import type { IVPRDetails } from './walletRequestTypes.js';
|
|
43
51
|
/**
|
|
44
|
-
* Default read/write actions requested on each app collection
|
|
52
|
+
* Default read/write actions requested on each private app collection -- also
|
|
53
|
+
* the `https://w3id.org/byoe#collection` class ceiling (the full WAS action
|
|
54
|
+
* vocabulary).
|
|
45
55
|
*/
|
|
46
56
|
export declare const RW_ACTIONS: string[];
|
|
57
|
+
/**
|
|
58
|
+
* The `https://w3id.org/byoe#public-collection` class ceiling: add-only, reads
|
|
59
|
+
* plus `POST`, never `PUT` or `DELETE`. A write to a plaintext world-readable
|
|
60
|
+
* collection is publication under the user's identity and irreversible in
|
|
61
|
+
* practice, so a conformant wallet caps a public grant here no matter what was
|
|
62
|
+
* asked -- and the App Connect spec forbids an application from requiring an
|
|
63
|
+
* action above it.
|
|
64
|
+
*/
|
|
65
|
+
export declare const PUBLIC_ACTIONS: string[];
|
|
47
66
|
/**
|
|
48
67
|
* The actions requested on a SHARED (wallet-owned) collection: read-only, and
|
|
49
68
|
* not configurable. A shared collection belongs to the wallet, so an app never
|
|
50
69
|
* asks to write it.
|
|
51
70
|
*/
|
|
52
71
|
export declare const SHARED_ACTIONS: string[];
|
|
72
|
+
/**
|
|
73
|
+
* The action ceiling of the descriptor class a collection is requested with
|
|
74
|
+
* (the App Connect spec's "Action ceilings" table): add-only for
|
|
75
|
+
* `visibility: 'public'` (`https://w3id.org/byoe#public-collection`), the full
|
|
76
|
+
* vocabulary otherwise (`https://w3id.org/byoe#collection`). Shares have their
|
|
77
|
+
* own fixed {@link SHARED_ACTIONS} and never consult a configured action set.
|
|
78
|
+
*
|
|
79
|
+
* @param [visibility] {'private' | 'public'}
|
|
80
|
+
* @returns {string[]}
|
|
81
|
+
*/
|
|
82
|
+
export declare function actionCeiling(visibility?: 'private' | 'public'): string[];
|
|
53
83
|
/**
|
|
54
84
|
* One collection to request a grant for: the WAS collection id plus its
|
|
55
85
|
* declared visibility (`'private'`, the default, or `'public'`).
|
|
@@ -95,8 +125,11 @@ export declare function newChallenge(): string;
|
|
|
95
125
|
* @param [options.sharedCollections] {string[]} WAS collection ids of
|
|
96
126
|
* wallet-owned collections to request read-and-decrypt access to; each gets a
|
|
97
127
|
* `https://w3id.org/byoe#shared-collection` descriptor with {@link SHARED_ACTIONS}
|
|
98
|
-
* @param [options.actions] {string[]} the
|
|
99
|
-
*
|
|
128
|
+
* @param [options.actions] {string[]} the action set to request on each app
|
|
129
|
+
* collection; when omitted each collection requests exactly its class
|
|
130
|
+
* ceiling ({@link actionCeiling}). An explicit set naming an action above a
|
|
131
|
+
* requested collection's ceiling throws (a configuration error, surfaced at
|
|
132
|
+
* build time rather than as a failed login)
|
|
100
133
|
* @returns {IVPRDetails}
|
|
101
134
|
*/
|
|
102
135
|
export declare function buildAppConnectVpr({ challenge, domain, appName, credential, collections, sharedCollections, actions }: {
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;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;;;;;;;;;GASG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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,19 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Default read/write actions requested on each app collection
|
|
2
|
+
* Default read/write actions requested on each private app collection -- also
|
|
3
|
+
* the `https://w3id.org/byoe#collection` class ceiling (the full WAS action
|
|
4
|
+
* vocabulary).
|
|
3
5
|
*/
|
|
4
6
|
export const RW_ACTIONS = ['GET', 'HEAD', 'PUT', 'POST', 'DELETE'];
|
|
7
|
+
/**
|
|
8
|
+
* The `https://w3id.org/byoe#public-collection` class ceiling: add-only, reads
|
|
9
|
+
* plus `POST`, never `PUT` or `DELETE`. A write to a plaintext world-readable
|
|
10
|
+
* collection is publication under the user's identity and irreversible in
|
|
11
|
+
* practice, so a conformant wallet caps a public grant here no matter what was
|
|
12
|
+
* asked -- and the App Connect spec forbids an application from requiring an
|
|
13
|
+
* action above it.
|
|
14
|
+
*/
|
|
15
|
+
export const PUBLIC_ACTIONS = ['GET', 'HEAD', 'POST'];
|
|
5
16
|
/**
|
|
6
17
|
* The actions requested on a SHARED (wallet-owned) collection: read-only, and
|
|
7
18
|
* not configurable. A shared collection belongs to the wallet, so an app never
|
|
8
19
|
* asks to write it.
|
|
9
20
|
*/
|
|
10
21
|
export const SHARED_ACTIONS = ['GET', 'HEAD'];
|
|
22
|
+
/**
|
|
23
|
+
* The action ceiling of the descriptor class a collection is requested with
|
|
24
|
+
* (the App Connect spec's "Action ceilings" table): add-only for
|
|
25
|
+
* `visibility: 'public'` (`https://w3id.org/byoe#public-collection`), the full
|
|
26
|
+
* vocabulary otherwise (`https://w3id.org/byoe#collection`). Shares have their
|
|
27
|
+
* own fixed {@link SHARED_ACTIONS} and never consult a configured action set.
|
|
28
|
+
*
|
|
29
|
+
* @param [visibility] {'private' | 'public'}
|
|
30
|
+
* @returns {string[]}
|
|
31
|
+
*/
|
|
32
|
+
export function actionCeiling(visibility) {
|
|
33
|
+
return visibility === 'public' ? PUBLIC_ACTIONS : RW_ACTIONS;
|
|
34
|
+
}
|
|
11
35
|
/**
|
|
12
36
|
* A fresh nonce for a VPR challenge.
|
|
13
37
|
*/
|
|
14
38
|
export function newChallenge() {
|
|
15
39
|
return crypto.randomUUID();
|
|
16
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* The actions to request for one collection: the configured set capped at the
|
|
43
|
+
* collection's class ceiling, kept in ceiling order. When no set is configured
|
|
44
|
+
* the whole ceiling is requested. An EXPLICIT set naming an action above the
|
|
45
|
+
* ceiling is a configuration error thrown here, at request build time: a
|
|
46
|
+
* conformant wallet can never grant it, so silently capping would leave the
|
|
47
|
+
* app believing it asked for more than any correct wallet returns, and the
|
|
48
|
+
* mismatch would surface later as a failed login instead of as the config bug
|
|
49
|
+
* it is.
|
|
50
|
+
*
|
|
51
|
+
* @param options {object}
|
|
52
|
+
* @param options.id {string} the WAS collection id (for error messages)
|
|
53
|
+
* @param [options.visibility] {'private' | 'public'}
|
|
54
|
+
* @param [options.actions] {string[]} the configured action set
|
|
55
|
+
* @returns {string[]}
|
|
56
|
+
*/
|
|
57
|
+
function requestedActions({ id, visibility, actions }) {
|
|
58
|
+
const ceiling = actionCeiling(visibility);
|
|
59
|
+
if (actions === undefined) {
|
|
60
|
+
return ceiling;
|
|
61
|
+
}
|
|
62
|
+
const excess = actions.filter(action => !ceiling.includes(action));
|
|
63
|
+
if (excess.length > 0) {
|
|
64
|
+
throw new Error(`Collection "${id}" cannot request action(s) above its class ceiling: ` +
|
|
65
|
+
`${excess.join(', ')} (the ceiling is ${ceiling.join(', ')}).`);
|
|
66
|
+
}
|
|
67
|
+
const capped = ceiling.filter(action => actions.includes(action));
|
|
68
|
+
if (capped.length === 0) {
|
|
69
|
+
// An empty allowedAction array means EVERY action in the zcap model, so an
|
|
70
|
+
// action-less request must never be built.
|
|
71
|
+
throw new Error(`Collection "${id}" requests no actions.`);
|
|
72
|
+
}
|
|
73
|
+
return capped;
|
|
74
|
+
}
|
|
17
75
|
/**
|
|
18
76
|
* The one-popup App Connect VPR: DIDAuthentication + a single `AppConnectQuery`.
|
|
19
77
|
*
|
|
@@ -39,14 +97,17 @@ export function newChallenge() {
|
|
|
39
97
|
* @param [options.sharedCollections] {string[]} WAS collection ids of
|
|
40
98
|
* wallet-owned collections to request read-and-decrypt access to; each gets a
|
|
41
99
|
* `https://w3id.org/byoe#shared-collection` descriptor with {@link SHARED_ACTIONS}
|
|
42
|
-
* @param [options.actions] {string[]} the
|
|
43
|
-
*
|
|
100
|
+
* @param [options.actions] {string[]} the action set to request on each app
|
|
101
|
+
* collection; when omitted each collection requests exactly its class
|
|
102
|
+
* ceiling ({@link actionCeiling}). An explicit set naming an action above a
|
|
103
|
+
* requested collection's ceiling throws (a configuration error, surfaced at
|
|
104
|
+
* build time rather than as a failed login)
|
|
44
105
|
* @returns {IVPRDetails}
|
|
45
106
|
*/
|
|
46
|
-
export function buildAppConnectVpr({ challenge, domain, appName, credential, collections, sharedCollections = [], actions
|
|
107
|
+
export function buildAppConnectVpr({ challenge, domain, appName, credential, collections, sharedCollections = [], actions }) {
|
|
47
108
|
const capabilityQuery = collections.map(({ id, visibility }) => ({
|
|
48
109
|
referenceId: id,
|
|
49
|
-
allowedAction: actions,
|
|
110
|
+
allowedAction: requestedActions({ id, visibility, actions }),
|
|
50
111
|
invocationTarget: {
|
|
51
112
|
type: visibility === 'public'
|
|
52
113
|
? 'https://w3id.org/byoe#public-collection'
|
|
@@ -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":"AAsDA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AAElE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAE7C;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,UAAiC;IAC7D,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAA;AAC9D,CAAC;AAmBD;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAS,gBAAgB,CAAC,EACxB,EAAE,EACF,UAAU,EACV,OAAO,EAKR;IACC,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;IACzC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;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ACT;KACF,CAAC,CACH,CAAA;IACD,KAAK,MAAM,EAAE,IAAI,iBAAiB,EAAE,CAAC;QACnC,eAAe,CAAC,IAAI,CAAC;YACnB,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,cAAc;YAC7B,gBAAgB,EAAE;gBAChB,IAAI,EAAE,yCAAyC;gBAC/C,IAAI,EAAE,EAAE;aACT;SACF,CAAC,CAAA;IACJ,CAAC;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,iBAAiB;gBACvB,GAAG,EAAE;oBACH,IAAI,EAAE,OAAO;oBACb,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,SAAS,EAAE,UAAU,CAAC,SAAS;iBAChC;gBACD,eAAe;aAChB;SACF;QACD,SAAS;QACT,MAAM;KACP,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IVerifiablePresentation, IZcap } from '@interop/data-integrity-core';
|
|
2
2
|
import type { DocumentLoader } from '../identity/documentLoader.js';
|
|
3
3
|
import { type ParsedGrants } from '../grants.js';
|
|
4
|
+
import { type GrantRequestCollection } from './loginRequest.js';
|
|
4
5
|
/**
|
|
5
6
|
* Verifies a login response VP cryptographically and structurally (steps 1-2
|
|
6
7
|
* above). Throws on any failure.
|
|
@@ -40,16 +41,18 @@ export interface CheckedGrants {
|
|
|
40
41
|
* @param options {object}
|
|
41
42
|
* @param options.grants {IZcap[]}
|
|
42
43
|
* @param options.controllerDid {string} this app's seed-derived DID
|
|
43
|
-
* @param options.collections {
|
|
44
|
-
* covered
|
|
44
|
+
* @param options.collections {GrantRequestCollection[]} the collections that
|
|
45
|
+
* must be covered (WAS collection id + visibility; the visibility selects
|
|
46
|
+
* the class ceiling the required actions are capped at)
|
|
45
47
|
* @param [options.requiredActions] {string[]} the actions each collection
|
|
46
|
-
* grant must allow (defaults to
|
|
48
|
+
* grant must allow, capped per collection at its class ceiling (defaults to
|
|
49
|
+
* `RW_ACTIONS`, so each collection requires exactly its ceiling)
|
|
47
50
|
* @returns {CheckedGrants}
|
|
48
51
|
*/
|
|
49
52
|
export declare function checkGrants({ grants, controllerDid, collections, requiredActions }: {
|
|
50
53
|
grants: IZcap[];
|
|
51
54
|
controllerDid: string;
|
|
52
|
-
collections:
|
|
55
|
+
collections: GrantRequestCollection[];
|
|
53
56
|
requiredActions?: string[];
|
|
54
57
|
}): CheckedGrants;
|
|
55
58
|
//# sourceMappingURL=verifyResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifyResponse.d.ts","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAgCA,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;AAG7D,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;;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,CA0EhB;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;AASD;;;;;;;;;;;;;;GAcG;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,sBAAsB,EAAE,CAAA;IACrC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,GAAG,aAAa,CA+ChB"}
|
|
@@ -15,9 +15,13 @@
|
|
|
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
17
|
* targets a single space on a single WAS host, is unexpired, and the
|
|
18
|
-
* collection set is fully covered with sufficient actions
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* collection set is fully covered with sufficient actions -- where
|
|
19
|
+
* "sufficient" is capped at each collection's class ceiling: a conformant
|
|
20
|
+
* wallet caps a public-collection grant add-only, so requiring `PUT` or
|
|
21
|
+
* `DELETE` there would reject every correct wallet (the App Connect spec
|
|
22
|
+
* forbids failing a connection over an action the class ceiling excludes).
|
|
23
|
+
* (Delegation-chain proofs are enforced server-side at invocation; the RP
|
|
24
|
+
* checks structure.)
|
|
21
25
|
*
|
|
22
26
|
* Note on holder binding: the wallet signs the VP as ITS holder DID (did:web
|
|
23
27
|
* or the wallet's did:key) -- not as this app's controller DID, which never
|
|
@@ -29,7 +33,7 @@ import { verifyPresentation } from '@interop/verifier-core';
|
|
|
29
33
|
import { parseGrants } from '../grants.js';
|
|
30
34
|
import { earliestExpiry, isExpired } from '../identity/appSession.js';
|
|
31
35
|
import { asArray } from '../jsonLd.js';
|
|
32
|
-
import { RW_ACTIONS } from './loginRequest.js';
|
|
36
|
+
import { actionCeiling, RW_ACTIONS } from './loginRequest.js';
|
|
33
37
|
/**
|
|
34
38
|
* Verifies a login response VP cryptographically and structurally (steps 1-2
|
|
35
39
|
* above). Throws on any failure.
|
|
@@ -123,10 +127,12 @@ function actionsOf(zcap) {
|
|
|
123
127
|
* @param options {object}
|
|
124
128
|
* @param options.grants {IZcap[]}
|
|
125
129
|
* @param options.controllerDid {string} this app's seed-derived DID
|
|
126
|
-
* @param options.collections {
|
|
127
|
-
* covered
|
|
130
|
+
* @param options.collections {GrantRequestCollection[]} the collections that
|
|
131
|
+
* must be covered (WAS collection id + visibility; the visibility selects
|
|
132
|
+
* the class ceiling the required actions are capped at)
|
|
128
133
|
* @param [options.requiredActions] {string[]} the actions each collection
|
|
129
|
-
* grant must allow (defaults to
|
|
134
|
+
* grant must allow, capped per collection at its class ceiling (defaults to
|
|
135
|
+
* `RW_ACTIONS`, so each collection requires exactly its ceiling)
|
|
130
136
|
* @returns {CheckedGrants}
|
|
131
137
|
*/
|
|
132
138
|
export function checkGrants({ grants, controllerDid, collections, requiredActions = RW_ACTIONS }) {
|
|
@@ -147,13 +153,17 @@ export function checkGrants({ grants, controllerDid, collections, requiredAction
|
|
|
147
153
|
// builds the per-collection routing table. The wallet decides where the
|
|
148
154
|
// user's Space lives; the sync layer derives its target from the grants.
|
|
149
155
|
const parsed = parseGrants(grants);
|
|
150
|
-
for (const id of collections) {
|
|
156
|
+
for (const { id, visibility } of collections) {
|
|
151
157
|
const grant = parsed.byCollectionId[id];
|
|
152
158
|
if (!grant) {
|
|
153
159
|
throw new Error(`No grant covers the "${id}" collection.`);
|
|
154
160
|
}
|
|
155
161
|
const actions = actionsOf(grant);
|
|
156
|
-
|
|
162
|
+
// The requirement is capped at the class ceiling: a conformant wallet caps
|
|
163
|
+
// a public grant add-only, so an above-ceiling requirement (explicit or
|
|
164
|
+
// the RW default) must cost the excess actions, never the login.
|
|
165
|
+
const required = actionCeiling(visibility).filter(action => requiredActions.includes(action));
|
|
166
|
+
const missing = required.filter(action => !actions.includes(action));
|
|
157
167
|
if (missing.length > 0) {
|
|
158
168
|
throw new Error(`The "${id}" grant lacks required actions: ${missing.join(', ')}.`);
|
|
159
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyResponse.js","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"verifyResponse.js","sourceRoot":"","sources":["../../src/auth/verifyResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;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,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EACL,aAAa,EACb,UAAU,EAEX,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAC5C,YAAY,EACZ,SAAS,EACT,MAAM,EACN,cAAc,EAMf;IACC,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC;QACtC,YAAY;QACZ,SAAS;QACT,UAAU,EAAE,EAAE;QACd,cAAc;KACf,CAAC,CAAA;IACF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,QAAQ,GAAG;YACf,GAAG,MAAM,CAAC,mBAAmB;YAC7B,GAAG,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;SACpD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAChB,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS;YAChC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC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E,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"}
|
|
@@ -34,7 +34,8 @@ export interface ProvisionDevGrantsResult {
|
|
|
34
34
|
provisionerDid: string;
|
|
35
35
|
/**
|
|
36
36
|
* Present only when `probe` was requested: the result of PUTting the
|
|
37
|
-
*
|
|
37
|
+
* collection description (read first, written back verbatim) with the app's
|
|
38
|
+
* delegated RW zcap.
|
|
38
39
|
*/
|
|
39
40
|
probe?: {
|
|
40
41
|
authorized: boolean;
|
|
@@ -50,8 +51,11 @@ export interface ProvisionDevGrantsResult {
|
|
|
50
51
|
* @param options.serverUrl {string} base URL of a running was-teaching-server
|
|
51
52
|
* @param options.seed {Uint8Array} the app (relying party) master seed; the
|
|
52
53
|
* app DID the grants are delegated to is derived from it
|
|
53
|
-
* @param options.collections {string
|
|
54
|
-
* grant (
|
|
54
|
+
* @param options.collections {Array<string | object>} the WAS collections to
|
|
55
|
+
* create and grant: a bare id string (private by default) or
|
|
56
|
+
* `{ id, visibility }`. A private collection is declared `edv` and gets its
|
|
57
|
+
* epoch[0] roster (sole recipient: the app's identity key-agreement key); a
|
|
58
|
+
* public one stays plaintext
|
|
55
59
|
* @param [options.spaceName] {string} human-readable Space name (defaults to
|
|
56
60
|
* `'Dev Space'`)
|
|
57
61
|
* @param [options.outFile] {string} when given, the `{ grants }` JSON is
|
|
@@ -63,7 +67,8 @@ export interface ProvisionDevGrantsResult {
|
|
|
63
67
|
* @param [options.actions] {ActionInput[]} the RW action set delegated per
|
|
64
68
|
* collection (defaults to the auth layer's `RW_ACTIONS`)
|
|
65
69
|
* @param [options.probe] {boolean} when true, probe whether the delegated RW
|
|
66
|
-
* zcap authorizes a PUT of the
|
|
70
|
+
* zcap authorizes a PUT of the collection description (read first and written
|
|
71
|
+
* back verbatim, so an installed epoch roster is never clobbered)
|
|
67
72
|
* @param [options.log] {(message: string) => void} progress sink (defaults to
|
|
68
73
|
* a no-op; the CLI passes `console.log`)
|
|
69
74
|
* @returns {Promise<ProvisionDevGrantsResult>}
|
|
@@ -71,7 +76,10 @@ export interface ProvisionDevGrantsResult {
|
|
|
71
76
|
export declare function provisionDevGrants({ serverUrl, seed, collections, spaceName, outFile, provisionerSeed, identityHandle, actions, probe, log }: {
|
|
72
77
|
serverUrl: string;
|
|
73
78
|
seed: Uint8Array;
|
|
74
|
-
collections: string
|
|
79
|
+
collections: Array<string | {
|
|
80
|
+
id: string;
|
|
81
|
+
visibility?: 'private' | 'public';
|
|
82
|
+
}>;
|
|
75
83
|
spaceName?: string;
|
|
76
84
|
outFile?: string;
|
|
77
85
|
provisionerSeed?: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionDevGrants.d.ts","sourceRoot":"","sources":["../../src/dev/provisionDevGrants.ts"],"names":[],"mappings":"
|
|
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;AAQlE;;;;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,CAiIpC"}
|
|
@@ -6,22 +6,25 @@
|
|
|
6
6
|
* this:
|
|
7
7
|
*
|
|
8
8
|
* 1. derives a throwaway "provisioner" identity (stands in for the wallet that
|
|
9
|
-
* owns the Space) and the app's own
|
|
9
|
+
* owns the Space) and the app's own identity from the supplied seed;
|
|
10
10
|
* 2. creates a Space (owned by the provisioner) and the requested collections,
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* mirroring what a wallet does when it provisions RP-requested collections:
|
|
12
|
+
* a PRIVATE collection is declared `edv` and gets its epoch[0] roster
|
|
13
|
+
* installed (`ensureFirstEpoch`) with the app's identity key-agreement key
|
|
14
|
+
* as the sole recipient -- epoch-from-birth, no plaintext interlude; a
|
|
15
|
+
* PUBLIC collection stays plaintext with no descriptor;
|
|
13
16
|
* 3. delegates a per-collection read/write zcap to the app's controller DID;
|
|
14
17
|
* 4. returns the signed grants and (optionally) writes them to a JSON file the
|
|
15
18
|
* app loads in dev-sync mode;
|
|
16
19
|
* 5. optionally probes the open question: does the delegated, collection-scoped
|
|
17
|
-
* RW zcap authorize an RP-side PUT of the collection description
|
|
18
|
-
* { encryption: { scheme: 'edv' } } descriptor?
|
|
20
|
+
* RW zcap authorize an RP-side PUT of the collection description?
|
|
19
21
|
*
|
|
20
22
|
* Node only (uses `fs`); consumed through the package `./dev` subpath.
|
|
21
23
|
*/
|
|
22
24
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
23
25
|
import { dirname } from 'node:path';
|
|
24
26
|
import { WasClient } from '@interop/was-client';
|
|
27
|
+
import { ensureFirstEpoch, ownerRecipient } from '@interop/was-client/edv';
|
|
25
28
|
import { CapabilityAgent } from '@interop/webkms-client';
|
|
26
29
|
import { agentsFromKeyAgent } from '@interop/wallet-core/identity';
|
|
27
30
|
import { deriveIdentity } from '../identity/agents.js';
|
|
@@ -63,8 +66,11 @@ async function provisionerClient({ serverUrl, seed }) {
|
|
|
63
66
|
* @param options.serverUrl {string} base URL of a running was-teaching-server
|
|
64
67
|
* @param options.seed {Uint8Array} the app (relying party) master seed; the
|
|
65
68
|
* app DID the grants are delegated to is derived from it
|
|
66
|
-
* @param options.collections {string
|
|
67
|
-
* grant (
|
|
69
|
+
* @param options.collections {Array<string | object>} the WAS collections to
|
|
70
|
+
* create and grant: a bare id string (private by default) or
|
|
71
|
+
* `{ id, visibility }`. A private collection is declared `edv` and gets its
|
|
72
|
+
* epoch[0] roster (sole recipient: the app's identity key-agreement key); a
|
|
73
|
+
* public one stays plaintext
|
|
68
74
|
* @param [options.spaceName] {string} human-readable Space name (defaults to
|
|
69
75
|
* `'Dev Space'`)
|
|
70
76
|
* @param [options.outFile] {string} when given, the `{ grants }` JSON is
|
|
@@ -76,7 +82,8 @@ async function provisionerClient({ serverUrl, seed }) {
|
|
|
76
82
|
* @param [options.actions] {ActionInput[]} the RW action set delegated per
|
|
77
83
|
* collection (defaults to the auth layer's `RW_ACTIONS`)
|
|
78
84
|
* @param [options.probe] {boolean} when true, probe whether the delegated RW
|
|
79
|
-
* zcap authorizes a PUT of the
|
|
85
|
+
* zcap authorizes a PUT of the collection description (read first and written
|
|
86
|
+
* back verbatim, so an installed epoch roster is never clobbered)
|
|
80
87
|
* @param [options.log] {(message: string) => void} progress sink (defaults to
|
|
81
88
|
* a no-op; the CLI passes `console.log`)
|
|
82
89
|
* @returns {Promise<ProvisionDevGrantsResult>}
|
|
@@ -85,7 +92,7 @@ export async function provisionDevGrants({ serverUrl, seed, collections, spaceNa
|
|
|
85
92
|
// The server accepts HEAD even though storage-core's ActionInput union omits
|
|
86
93
|
// it, hence the assertion.
|
|
87
94
|
actions = RW_ACTIONS, probe = false, log = () => { } }) {
|
|
88
|
-
const [{ controllerDid: appDid, zcapClient: appZcapClient }, { was: provisioner, did: provisionerDid }] = await Promise.all([
|
|
95
|
+
const [{ controllerDid: appDid, zcapClient: appZcapClient, keyAgreementKey }, { was: provisioner, did: provisionerDid }] = await Promise.all([
|
|
89
96
|
deriveIdentity({ seed, identityHandle }),
|
|
90
97
|
provisionerClient({ serverUrl, seed: provisionerSeed })
|
|
91
98
|
]);
|
|
@@ -113,17 +120,32 @@ actions = RW_ACTIONS, probe = false, log = () => { } }) {
|
|
|
113
120
|
};
|
|
114
121
|
// `Promise.all` preserves input order, so `grants[i]` still corresponds to
|
|
115
122
|
// `collections[i]` (the probe below relies on that for `[0]`).
|
|
116
|
-
const grants = await Promise.all(collections.map(async (
|
|
117
|
-
|
|
118
|
-
// provisioning
|
|
119
|
-
|
|
123
|
+
const grants = await Promise.all(collections.map(async (entry) => {
|
|
124
|
+
const { id, visibility = 'private' } = typeof entry === 'string' ? { id: entry } : entry;
|
|
125
|
+
// A private collection mirrors wallet provisioning: declared `edv` at
|
|
126
|
+
// creation, epoch[0] installed with the app's identity key-agreement
|
|
127
|
+
// key as the sole recipient (the roster entry a wallet would write for
|
|
128
|
+
// an app-owned collection). A public collection stays plaintext.
|
|
129
|
+
const collection = await space.createCollection({
|
|
130
|
+
id,
|
|
131
|
+
name: id,
|
|
132
|
+
...(visibility === 'private' && {
|
|
133
|
+
encryption: { scheme: 'edv' }
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
if (visibility === 'private') {
|
|
137
|
+
await ensureFirstEpoch({
|
|
138
|
+
collection,
|
|
139
|
+
recipients: [ownerRecipient({ keyAgreementKey })]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
120
142
|
const zcap = await provisioner.grant({
|
|
121
143
|
to: appDid,
|
|
122
144
|
actions,
|
|
123
145
|
target: `${spaceUrl}/${id}`,
|
|
124
146
|
capability: spaceRoot
|
|
125
147
|
});
|
|
126
|
-
log(` collection "${id}": created + delegated RW to app`);
|
|
148
|
+
log(` collection "${id}": created (${visibility}) + delegated RW to app`);
|
|
127
149
|
return zcap;
|
|
128
150
|
}));
|
|
129
151
|
if (outFile !== undefined) {
|
|
@@ -141,22 +163,32 @@ actions = RW_ACTIONS, probe = false, log = () => { } }) {
|
|
|
141
163
|
if (!probe) {
|
|
142
164
|
return result;
|
|
143
165
|
}
|
|
144
|
-
// ---
|
|
166
|
+
// --- Description-write probe --------------------------------------------------
|
|
145
167
|
// Using the app's OWN delegated RW zcap (not the provisioner root key),
|
|
146
|
-
// attempt to PUT the collection description
|
|
168
|
+
// attempt to PUT the collection description. The description is read first
|
|
169
|
+
// and written back verbatim: authorization is what is probed, and a blind
|
|
170
|
+
// descriptor PUT would try to clobber the installed epoch roster (which the
|
|
171
|
+
// server refuses -- epochs are append-only -- muddying the answer).
|
|
147
172
|
const appWas = new WasClient({ serverUrl, zcapClient: appZcapClient });
|
|
148
|
-
const
|
|
173
|
+
const firstEntry = collections[0];
|
|
174
|
+
const probeCollectionId = typeof firstEntry === 'string' ? firstEntry : firstEntry.id;
|
|
149
175
|
const probeCapability = grants[0];
|
|
150
|
-
|
|
176
|
+
const probePath = collectionPath({
|
|
177
|
+
spaceId: space.id,
|
|
178
|
+
collectionId: probeCollectionId
|
|
179
|
+
});
|
|
180
|
+
log(`\nDescription-write probe on "${probeCollectionId}" (delegated RW zcap):`);
|
|
151
181
|
try {
|
|
182
|
+
const current = await appWas.request({
|
|
183
|
+
capability: probeCapability,
|
|
184
|
+
path: probePath,
|
|
185
|
+
method: 'GET'
|
|
186
|
+
});
|
|
152
187
|
const response = await appWas.request({
|
|
153
188
|
capability: probeCapability,
|
|
154
|
-
path:
|
|
155
|
-
spaceId: space.id,
|
|
156
|
-
collectionId: probeCollectionId
|
|
157
|
-
}),
|
|
189
|
+
path: probePath,
|
|
158
190
|
method: 'PUT',
|
|
159
|
-
json: { id: probeCollectionId
|
|
191
|
+
json: (current.data ?? { id: probeCollectionId })
|
|
160
192
|
});
|
|
161
193
|
log(` AUTHORIZED -- server responded ${response.status}`);
|
|
162
194
|
result.probe = { authorized: true, status: response.status };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionDevGrants.js","sourceRoot":"","sources":["../../src/dev/provisionDevGrants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
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,qBAAqB,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAA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M,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACpC,UAAU,EAAE,eAAe;YAC3B,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,iBAAiB,EAAE,CAAW;SAC5D,CAAC,CAAA;QACF,GAAG,CAAC,oCAAoC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAC1D,MAAM,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAA;IAC9D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;QAC/B,MAAM,IAAI,GAAI,GAA0B,CAAC,IAAI,CAAA;QAC7C,GAAG,CAAC,8BAA8B,MAAM,IAAI,KAAK,EAAE,CAAC,CAAA;QACpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,GAAG,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,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"}
|
|
@@ -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":"AAuBA;;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;AAqBF;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|