@interop/wallet-core 0.16.0 → 0.17.1
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/clients/revocation.d.ts +5 -2
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +27 -11
- package/dist/clients/revocation.js.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +26 -5
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.js +93 -35
- package/dist/clients/rosterPolicy.js.map +1 -1
- package/dist/descriptors/refresh.d.ts +3 -1
- package/dist/descriptors/refresh.d.ts.map +1 -1
- package/dist/descriptors/refresh.js +3 -1
- package/dist/descriptors/refresh.js.map +1 -1
- package/dist/display/alignment.d.ts +8 -2
- package/dist/display/alignment.d.ts.map +1 -1
- package/dist/display/alignment.js +11 -8
- package/dist/display/alignment.js.map +1 -1
- package/dist/display/displayFields.d.ts +6 -2
- package/dist/display/displayFields.d.ts.map +1 -1
- package/dist/display/displayFields.js.map +1 -1
- package/dist/display/evidence.d.ts +9 -3
- package/dist/display/evidence.d.ts.map +1 -1
- package/dist/display/evidence.js +3 -1
- package/dist/display/evidence.js.map +1 -1
- package/dist/display/index.d.ts +1 -1
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +1 -1
- package/dist/display/index.js.map +1 -1
- package/dist/display/issuer.d.ts +12 -4
- package/dist/display/issuer.d.ts.map +1 -1
- package/dist/display/issuer.js.map +1 -1
- package/dist/display/obv3.d.ts +7 -2
- package/dist/display/obv3.d.ts.map +1 -1
- package/dist/display/obv3.js +14 -24
- package/dist/display/obv3.js.map +1 -1
- package/dist/display/parse.d.ts +6 -2
- package/dist/display/parse.d.ts.map +1 -1
- package/dist/display/parse.js +6 -2
- package/dist/display/parse.js.map +1 -1
- package/dist/display/subject.d.ts +4 -0
- package/dist/display/subject.d.ts.map +1 -1
- package/dist/display/subject.js +12 -10
- package/dist/display/subject.js.map +1 -1
- package/dist/display/text.d.ts +11 -0
- package/dist/display/text.d.ts.map +1 -1
- package/dist/display/text.js +20 -4
- package/dist/display/text.js.map +1 -1
- package/dist/display/types.js +1 -1
- package/dist/display/types.js.map +1 -1
- package/dist/display/validity.js +4 -4
- package/dist/display/validity.js.map +1 -1
- package/dist/display/verificationView.d.ts +21 -7
- package/dist/display/verificationView.d.ts.map +1 -1
- package/dist/display/verificationView.js.map +1 -1
- package/dist/enrollment/enrollment.d.ts +5 -3
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +79 -15
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/keys/clientKeyRecord.d.ts +3 -1
- package/dist/keys/clientKeyRecord.d.ts.map +1 -1
- package/dist/keys/clientKeyRecord.js +42 -10
- package/dist/keys/clientKeyRecord.js.map +1 -1
- package/dist/keys/index.d.ts +1 -1
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -1
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/pukCascade.d.ts.map +1 -1
- package/dist/keys/pukCascade.js +13 -14
- package/dist/keys/pukCascade.js.map +1 -1
- package/dist/keys/pukRoster.d.ts +85 -7
- package/dist/keys/pukRoster.d.ts.map +1 -1
- package/dist/keys/pukRoster.js +136 -11
- package/dist/keys/pukRoster.js.map +1 -1
- package/dist/request/classify.d.ts +15 -1
- package/dist/request/classify.d.ts.map +1 -1
- package/dist/request/classify.js +38 -14
- package/dist/request/classify.js.map +1 -1
- package/dist/request/composeVp.d.ts.map +1 -1
- package/dist/request/composeVp.js +10 -3
- package/dist/request/composeVp.js.map +1 -1
- package/dist/request/matching.d.ts +6 -0
- package/dist/request/matching.d.ts.map +1 -1
- package/dist/request/matching.js +33 -8
- package/dist/request/matching.js.map +1 -1
- package/dist/request/parse.d.ts +5 -2
- package/dist/request/parse.d.ts.map +1 -1
- package/dist/request/parse.js +30 -5
- package/dist/request/parse.js.map +1 -1
- package/dist/request/presentationSuite.d.ts.map +1 -1
- package/dist/request/presentationSuite.js +6 -2
- package/dist/request/presentationSuite.js.map +1 -1
- package/dist/request/processRequest.js +1 -1
- package/dist/request/processRequest.js.map +1 -1
- package/dist/space/activity.d.ts +21 -7
- package/dist/space/activity.d.ts.map +1 -1
- package/dist/space/activity.js +18 -6
- package/dist/space/activity.js.map +1 -1
- package/dist/space/collections.d.ts +18 -6
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +18 -6
- package/dist/space/collections.js.map +1 -1
- package/dist/space/wasLink.d.ts +6 -2
- package/dist/space/wasLink.d.ts.map +1 -1
- package/dist/space/wasLink.js +5 -2
- package/dist/space/wasLink.js.map +1 -1
- package/dist/sync/contactsConflict.d.ts +1 -1
- package/dist/sync/contactsConflict.js +1 -1
- package/dist/sync/engine.d.ts +33 -11
- package/dist/sync/engine.d.ts.map +1 -1
- package/dist/sync/engine.js +4 -3
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/pull.d.ts +5 -3
- package/dist/sync/pull.d.ts.map +1 -1
- package/dist/sync/pull.js +34 -10
- package/dist/sync/pull.js.map +1 -1
- package/dist/sync/push.d.ts.map +1 -1
- package/dist/sync/push.js +24 -8
- package/dist/sync/push.js.map +1 -1
- package/dist/sync/types.d.ts +30 -6
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/webvh/didWebvh.d.ts +28 -0
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +40 -5
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/index.d.ts +1 -1
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +1 -1
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/listClients.d.ts +19 -0
- package/dist/webvh/listClients.d.ts.map +1 -1
- package/dist/webvh/listClients.js +37 -1
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/revokeClient.d.ts +11 -3
- package/dist/webvh/revokeClient.d.ts.map +1 -1
- package/dist/webvh/revokeClient.js +83 -14
- package/dist/webvh/revokeClient.js.map +1 -1
- package/package.json +3 -3
package/dist/keys/pukRoster.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* A resource-hosted descriptor gets NONE of the server-side epoch invariants a
|
|
20
20
|
* Collection Description enforces (append-only epochs, monotone
|
|
21
|
-
* `currentEpoch`), so
|
|
21
|
+
* `currentEpoch`), so four client-side compensations are load-bearing alone
|
|
22
22
|
* against a tampering host:
|
|
23
23
|
*
|
|
24
24
|
* - **`epochsMac`** -- the epoch configuration is authenticated under the
|
|
@@ -38,10 +38,22 @@
|
|
|
38
38
|
* verification method is dropped and never receives a wrap, so a
|
|
39
39
|
* server-injected entry sits ignored. Wraps are minted only by enrolled
|
|
40
40
|
* clients, against log-verified keys.
|
|
41
|
+
* - **`epochsSig`** -- the epoch configuration is additionally SIGNED by the
|
|
42
|
+
* writing client's enrolled Ed25519 key (`pukRosterEpochsSigner`), and a
|
|
43
|
+
* read that adopts an epoch this client has not vouched for itself (a
|
|
44
|
+
* rotated read, or a freshly enrolled client's first read) verifies that
|
|
45
|
+
* signature against the locally verified did:webvh document
|
|
46
|
+
* (`verifyPukRosterEpochsSig`). This is the check the `epochsMac` alone
|
|
47
|
+
* cannot make on those paths: the MAC is keyed by a secret unwrapped from
|
|
48
|
+
* the served descriptor itself, so a host that mints its own epoch, wraps
|
|
49
|
+
* it to this client's world-readable key-agreement key, and MACs the
|
|
50
|
+
* fabricated configuration under the same minted secret passes the MAC --
|
|
51
|
+
* but it cannot produce a signature by a key the document backs.
|
|
41
52
|
*/
|
|
42
53
|
import type { IKeyAgreementKey } from '@interop/data-integrity-core';
|
|
43
54
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
44
|
-
import { type EncryptionDescriptorStore, type RecipientPublicKey } from '@interop/was-client/edv';
|
|
55
|
+
import { type EncryptionDescriptorStore, type EpochsSigner, type RecipientPublicKey } from '@interop/was-client/edv';
|
|
56
|
+
import { type ICapabilityAgent } from '../webvh/zcap.js';
|
|
45
57
|
import type { Puk } from './puk.js';
|
|
46
58
|
/**
|
|
47
59
|
* Thrown when a served roster fails its client-side authentication: a
|
|
@@ -89,6 +101,41 @@ export interface RosterRecipientDocument {
|
|
|
89
101
|
publicKeyMultibase?: string;
|
|
90
102
|
}>;
|
|
91
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* The roster's epoch-configuration signer: signs each roster write's epoch
|
|
106
|
+
* configuration with this client's own Ed25519 signing key, under a `kid`
|
|
107
|
+
* that is the key's public multibase -- exactly the string enrolled as this
|
|
108
|
+
* client's verification method in the did:webvh document, so a reader
|
|
109
|
+
* resolves the signature against the document rather than anything the
|
|
110
|
+
* roster (or the server) supplies.
|
|
111
|
+
*
|
|
112
|
+
* @param options {object}
|
|
113
|
+
* @param options.keyAgent {ICapabilityAgent} this client's signing key
|
|
114
|
+
* agent (the `keyAgent` of `agentsFromSeed`)
|
|
115
|
+
* @returns {EpochsSigner} the `signEpochs` hook for roster writes
|
|
116
|
+
*/
|
|
117
|
+
export declare function pukRosterEpochsSigner({ keyAgent }: {
|
|
118
|
+
keyAgent: ICapabilityAgent;
|
|
119
|
+
}): EpochsSigner;
|
|
120
|
+
/**
|
|
121
|
+
* Verifies a served roster's `epochsSig` against the locally verified
|
|
122
|
+
* did:webvh document -- the root of trust the server cannot mint. The
|
|
123
|
+
* signature must be present and supported, its `kid` must be the public
|
|
124
|
+
* multibase of one of the document's verification methods (an enrolled
|
|
125
|
+
* client's signing key), and it must verify over the canonical
|
|
126
|
+
* epoch-configuration payload. Throws {@link PukRosterIntegrityError}
|
|
127
|
+
* otherwise: a configuration no enrolled client signed.
|
|
128
|
+
*
|
|
129
|
+
* @param options {object}
|
|
130
|
+
* @param options.descriptor {CollectionEncryption} the served roster
|
|
131
|
+
* @param options.document {RosterRecipientDocument} the locally verified
|
|
132
|
+
* did:webvh document (never a server-supplied roster field)
|
|
133
|
+
* @returns {Promise<void>}
|
|
134
|
+
*/
|
|
135
|
+
export declare function verifyPukRosterEpochsSig({ descriptor, document }: {
|
|
136
|
+
descriptor: CollectionEncryption;
|
|
137
|
+
document: RosterRecipientDocument;
|
|
138
|
+
}): Promise<void>;
|
|
92
139
|
/**
|
|
93
140
|
* A wallet client's roster kid: its key-agreement key's id exactly as
|
|
94
141
|
* `agentsFromSeed` derives it at the client's own logins
|
|
@@ -139,12 +186,16 @@ export declare function pukRosterRecipientResolver({ document }: {
|
|
|
139
186
|
* @param options.puk {Puk} the account's per-user key
|
|
140
187
|
* @param options.clientKeyAgreementKey {IKeyAgreementKey} this client's own
|
|
141
188
|
* (identity) key-agreement key -- the roster recipient
|
|
189
|
+
* @param options.signEpochs {EpochsSigner} this client's epoch-configuration
|
|
190
|
+
* signer ({@link pukRosterEpochsSigner}), so the first configuration is
|
|
191
|
+
* vouched for by an enrollable key rather than only its own MAC
|
|
142
192
|
* @returns {Promise<CollectionEncryption>} the roster descriptor
|
|
143
193
|
*/
|
|
144
|
-
export declare function ensurePukRoster({ store, puk, clientKeyAgreementKey }: {
|
|
194
|
+
export declare function ensurePukRoster({ store, puk, clientKeyAgreementKey, signEpochs }: {
|
|
145
195
|
store: EncryptionDescriptorStore;
|
|
146
196
|
puk: Puk;
|
|
147
197
|
clientKeyAgreementKey: IKeyAgreementKey;
|
|
198
|
+
signEpochs: EpochsSigner;
|
|
148
199
|
}): Promise<CollectionEncryption>;
|
|
149
200
|
/**
|
|
150
201
|
* Wraps the PUK to a client being enrolled -- the roster half of the
|
|
@@ -196,12 +247,16 @@ export declare function addPukRosterRecipient({ store, recipient, ownerKeyAgreem
|
|
|
196
247
|
* did:webvh document, AFTER the removal edit
|
|
197
248
|
* @param options.retireRecipientId {string} the removed recipient's roster
|
|
198
249
|
* kid
|
|
250
|
+
* @param options.signEpochs {EpochsSigner} the rotating client's
|
|
251
|
+
* epoch-configuration signer ({@link pukRosterEpochsSigner}), vouching for
|
|
252
|
+
* the fresh epoch so other clients' rotated reads accept it
|
|
199
253
|
* @returns {Promise<CollectionEncryption>} the rotated roster descriptor
|
|
200
254
|
*/
|
|
201
|
-
export declare function rotatePukRoster({ store, document, retireRecipientId }: {
|
|
255
|
+
export declare function rotatePukRoster({ store, document, retireRecipientId, signEpochs }: {
|
|
202
256
|
store: EncryptionDescriptorStore;
|
|
203
257
|
document: RosterRecipientDocument;
|
|
204
258
|
retireRecipientId: string;
|
|
259
|
+
signEpochs: EpochsSigner;
|
|
205
260
|
}): Promise<CollectionEncryption>;
|
|
206
261
|
/**
|
|
207
262
|
* Converges the roster onto the account document: the standing detector for a
|
|
@@ -237,14 +292,18 @@ export declare function rotatePukRoster({ store, document, retireRecipientId }:
|
|
|
237
292
|
* @param [options.descriptor] {CollectionEncryption} a descriptor the caller
|
|
238
293
|
* has just read (a login-time roster read), to save a re-read; omitted, the
|
|
239
294
|
* roster is read fresh
|
|
295
|
+
* @param options.signEpochs {EpochsSigner} the converging client's
|
|
296
|
+
* epoch-configuration signer ({@link pukRosterEpochsSigner}), for the
|
|
297
|
+
* rotation this call may perform
|
|
240
298
|
* @returns {Promise<object>} whether the roster rotated on this call, the
|
|
241
299
|
* stale recipient kids found, and the roster descriptor as it now stands
|
|
242
300
|
* (`null` when the account has no roster yet)
|
|
243
301
|
*/
|
|
244
|
-
export declare function convergePukRosterToDocument({ store, document, descriptor }: {
|
|
302
|
+
export declare function convergePukRosterToDocument({ store, document, descriptor, signEpochs }: {
|
|
245
303
|
store: EncryptionDescriptorStore;
|
|
246
304
|
document: RosterRecipientDocument;
|
|
247
305
|
descriptor?: CollectionEncryption;
|
|
306
|
+
signEpochs: EpochsSigner;
|
|
248
307
|
}): Promise<{
|
|
249
308
|
rotated: boolean;
|
|
250
309
|
staleRecipientIds: string[];
|
|
@@ -274,7 +333,15 @@ export interface PukRosterReadResult {
|
|
|
274
333
|
* current; otherwise the current epoch was rotated by another client and
|
|
275
334
|
* this client's wrap is unwrapped with its own key-agreement key
|
|
276
335
|
* (`PukRosterUnwrapError` when it holds none).
|
|
277
|
-
* 3. **
|
|
336
|
+
* 3. **Provenance** (the rotated/first-read path only): the epoch
|
|
337
|
+
* configuration's `epochsSig` is verified against the locally verified
|
|
338
|
+
* did:webvh document ({@link verifyPukRosterEpochsSig}) BEFORE the epoch
|
|
339
|
+
* it delivers is adopted. On this path the `epochsMac` alone proves
|
|
340
|
+
* nothing against the host -- its key is unwrapped from the served
|
|
341
|
+
* descriptor itself -- so an epoch no enrolled client signed is refused
|
|
342
|
+
* (`PukRosterIntegrityError`). The cached-current path needs no signature:
|
|
343
|
+
* there the MAC is keyed by a secret this client already trusts.
|
|
344
|
+
* 4. **Authentication**: the descriptor's `epochsMac` is verified under the
|
|
278
345
|
* current epoch's secret (`PukRosterIntegrityError` on any mismatch -- a
|
|
279
346
|
* fabricated configuration).
|
|
280
347
|
*
|
|
@@ -285,6 +352,10 @@ export interface PukRosterReadResult {
|
|
|
285
352
|
* A caller with no cached PUK at all -- a freshly enrolled client making its
|
|
286
353
|
* first post-enrollment read -- omits `puk` and always takes the unwrap path;
|
|
287
354
|
* the result's `rotated` is then true (the PUK was adopted from the roster).
|
|
355
|
+
* Every unwrap-path caller must therefore supply the account document (or a
|
|
356
|
+
* way to resolve it): `document` when it already holds a verified copy, or
|
|
357
|
+
* `resolveDocument` to fetch-and-verify lazily, only when the read actually
|
|
358
|
+
* rotates.
|
|
288
359
|
*
|
|
289
360
|
* @param options {object}
|
|
290
361
|
* @param options.store {EncryptionDescriptorStore} the roster's descriptor
|
|
@@ -294,12 +365,19 @@ export interface PukRosterReadResult {
|
|
|
294
365
|
* (identity) key-agreement key, unwrapping a rotated epoch
|
|
295
366
|
* @param [options.pinnedEpochId] {string} the locally pinned latest-seen
|
|
296
367
|
* roster epoch, when this client has seen the roster before
|
|
368
|
+
* @param [options.document] {RosterRecipientDocument} the locally verified
|
|
369
|
+
* did:webvh document, when the caller already holds one
|
|
370
|
+
* @param [options.resolveDocument] {function} resolves the locally verified
|
|
371
|
+
* did:webvh document on demand; called only when the read takes the
|
|
372
|
+
* rotated/first-read path
|
|
297
373
|
* @returns {Promise<PukRosterReadResult | null>}
|
|
298
374
|
*/
|
|
299
|
-
export declare function readPukRoster({ store, puk, clientKeyAgreementKey, pinnedEpochId }: {
|
|
375
|
+
export declare function readPukRoster({ store, puk, clientKeyAgreementKey, pinnedEpochId, document, resolveDocument }: {
|
|
300
376
|
store: EncryptionDescriptorStore;
|
|
301
377
|
puk?: Puk;
|
|
302
378
|
clientKeyAgreementKey: IKeyAgreementKey;
|
|
303
379
|
pinnedEpochId?: string | null;
|
|
380
|
+
document?: RosterRecipientDocument;
|
|
381
|
+
resolveDocument?: () => Promise<RosterRecipientDocument>;
|
|
304
382
|
}): Promise<PukRosterReadResult | null>;
|
|
305
383
|
//# sourceMappingURL=pukRoster.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pukRoster.d.ts","sourceRoot":"","sources":["../../src/keys/pukRoster.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"pukRoster.d.ts","sourceRoot":"","sources":["../../src/keys/pukRoster.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAQL,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAA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AAE,oBAAoB,GAAG,IAAI,CAAA;CACxC,CAAC,CAiDD;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,oBAAoB,CAAA;IAChC,GAAG,EAAE,GAAG,CAAA;IACR,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,GAAG,EACH,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACR,eAAe,EAChB,EAAE;IACD,KAAK,EAAE,yBAAyB,CAAA;IAChC,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,qBAAqB,EAAE,gBAAgB,CAAA;IACvC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACzD,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CA2FtC"}
|
package/dist/keys/pukRoster.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { addRecipient, initRecipients, ownerRecipient, removeRecipient, unwrapEpochSecret, verifyEpochsMac } from '@interop/was-client/edv';
|
|
1
|
+
import { addRecipient, epochsSigPayload, initRecipients, ownerRecipient, removeRecipient, unwrapEpochSecret, verifyEpochsMac } from '@interop/was-client/edv';
|
|
2
|
+
import { Ed25519VerificationKey } from '@interop/ed25519-verification-key';
|
|
3
|
+
import { base64urlnopad } from '@scure/base';
|
|
4
|
+
import { clientSigningKeyMultibase } from '../webvh/zcap.js';
|
|
2
5
|
/**
|
|
3
6
|
* Thrown when a served roster fails its client-side authentication: a
|
|
4
7
|
* missing/unsupported/invalid `epochsMac`, or a descriptor whose `currentEpoch`
|
|
@@ -39,6 +42,86 @@ export class PukRosterUnwrapError extends Error {
|
|
|
39
42
|
this.name = 'PukRosterUnwrapError';
|
|
40
43
|
}
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The `epochsSig` construction this module mints and accepts: version 1,
|
|
47
|
+
* Ed25519 (`EdDSA`), `kid` the signer's public-key multibase (`z6Mk...`) --
|
|
48
|
+
* the same string that names the client's verification method in the
|
|
49
|
+
* did:webvh document.
|
|
50
|
+
*/
|
|
51
|
+
const EPOCHS_SIG_V = 1;
|
|
52
|
+
const EPOCHS_SIG_ALG = 'EdDSA';
|
|
53
|
+
/**
|
|
54
|
+
* The roster's epoch-configuration signer: signs each roster write's epoch
|
|
55
|
+
* configuration with this client's own Ed25519 signing key, under a `kid`
|
|
56
|
+
* that is the key's public multibase -- exactly the string enrolled as this
|
|
57
|
+
* client's verification method in the did:webvh document, so a reader
|
|
58
|
+
* resolves the signature against the document rather than anything the
|
|
59
|
+
* roster (or the server) supplies.
|
|
60
|
+
*
|
|
61
|
+
* @param options {object}
|
|
62
|
+
* @param options.keyAgent {ICapabilityAgent} this client's signing key
|
|
63
|
+
* agent (the `keyAgent` of `agentsFromSeed`)
|
|
64
|
+
* @returns {EpochsSigner} the `signEpochs` hook for roster writes
|
|
65
|
+
*/
|
|
66
|
+
export function pukRosterEpochsSigner({ keyAgent }) {
|
|
67
|
+
const kid = clientSigningKeyMultibase({ keyAgent });
|
|
68
|
+
const signer = keyAgent.getSigner();
|
|
69
|
+
return async function signEpochs({ payload }) {
|
|
70
|
+
const signature = await signer.sign({ data: payload });
|
|
71
|
+
return {
|
|
72
|
+
v: EPOCHS_SIG_V,
|
|
73
|
+
alg: EPOCHS_SIG_ALG,
|
|
74
|
+
kid,
|
|
75
|
+
sig: base64urlnopad.encode(signature)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Verifies a served roster's `epochsSig` against the locally verified
|
|
81
|
+
* did:webvh document -- the root of trust the server cannot mint. The
|
|
82
|
+
* signature must be present and supported, its `kid` must be the public
|
|
83
|
+
* multibase of one of the document's verification methods (an enrolled
|
|
84
|
+
* client's signing key), and it must verify over the canonical
|
|
85
|
+
* epoch-configuration payload. Throws {@link PukRosterIntegrityError}
|
|
86
|
+
* otherwise: a configuration no enrolled client signed.
|
|
87
|
+
*
|
|
88
|
+
* @param options {object}
|
|
89
|
+
* @param options.descriptor {CollectionEncryption} the served roster
|
|
90
|
+
* @param options.document {RosterRecipientDocument} the locally verified
|
|
91
|
+
* did:webvh document (never a server-supplied roster field)
|
|
92
|
+
* @returns {Promise<void>}
|
|
93
|
+
*/
|
|
94
|
+
export async function verifyPukRosterEpochsSig({ descriptor, document }) {
|
|
95
|
+
const epochsSig = descriptor.epochsSig;
|
|
96
|
+
if (!epochsSig ||
|
|
97
|
+
epochsSig.v !== EPOCHS_SIG_V ||
|
|
98
|
+
epochsSig.alg !== EPOCHS_SIG_ALG) {
|
|
99
|
+
throw new PukRosterIntegrityError('The PUK roster carries no supported epoch-configuration signature.');
|
|
100
|
+
}
|
|
101
|
+
const backed = (document.verificationMethod ?? []).some(method => method.publicKeyMultibase === epochsSig.kid);
|
|
102
|
+
if (!backed) {
|
|
103
|
+
throw new PukRosterIntegrityError('The PUK roster epoch configuration is signed by a key the account ' +
|
|
104
|
+
'document does not back.');
|
|
105
|
+
}
|
|
106
|
+
let signature;
|
|
107
|
+
try {
|
|
108
|
+
signature = base64urlnopad.decode(epochsSig.sig);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
throw new PukRosterIntegrityError('The PUK roster epoch-configuration signature is malformed.');
|
|
112
|
+
}
|
|
113
|
+
const verifier = new Ed25519VerificationKey({
|
|
114
|
+
controller: `did:key:${epochsSig.kid}`,
|
|
115
|
+
publicKeyMultibase: epochsSig.kid
|
|
116
|
+
}).verifier();
|
|
117
|
+
const verified = await verifier.verify({
|
|
118
|
+
data: epochsSigPayload(descriptor),
|
|
119
|
+
signature
|
|
120
|
+
});
|
|
121
|
+
if (!verified) {
|
|
122
|
+
throw new PukRosterIntegrityError('The PUK roster epoch-configuration signature failed verification.');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
42
125
|
/**
|
|
43
126
|
* A wallet client's roster kid: its key-agreement key's id exactly as
|
|
44
127
|
* `agentsFromSeed` derives it at the client's own logins
|
|
@@ -129,9 +212,12 @@ export function pukRosterRecipientResolver({ document }) {
|
|
|
129
212
|
* @param options.puk {Puk} the account's per-user key
|
|
130
213
|
* @param options.clientKeyAgreementKey {IKeyAgreementKey} this client's own
|
|
131
214
|
* (identity) key-agreement key -- the roster recipient
|
|
215
|
+
* @param options.signEpochs {EpochsSigner} this client's epoch-configuration
|
|
216
|
+
* signer ({@link pukRosterEpochsSigner}), so the first configuration is
|
|
217
|
+
* vouched for by an enrollable key rather than only its own MAC
|
|
132
218
|
* @returns {Promise<CollectionEncryption>} the roster descriptor
|
|
133
219
|
*/
|
|
134
|
-
export async function ensurePukRoster({ store, puk, clientKeyAgreementKey }) {
|
|
220
|
+
export async function ensurePukRoster({ store, puk, clientKeyAgreementKey, signEpochs }) {
|
|
135
221
|
const current = await store.read();
|
|
136
222
|
if (current !== null) {
|
|
137
223
|
return current.descriptor;
|
|
@@ -139,7 +225,8 @@ export async function ensurePukRoster({ store, puk, clientKeyAgreementKey }) {
|
|
|
139
225
|
return initRecipients({
|
|
140
226
|
store,
|
|
141
227
|
recipients: [ownerRecipient({ keyAgreementKey: clientKeyAgreementKey })],
|
|
142
|
-
epoch: { epochId: puk.id, secret: puk.secret }
|
|
228
|
+
epoch: { epochId: puk.id, secret: puk.secret },
|
|
229
|
+
signEpochs
|
|
143
230
|
});
|
|
144
231
|
}
|
|
145
232
|
/**
|
|
@@ -208,14 +295,18 @@ export async function addPukRosterRecipient({ store, recipient, ownerKeyAgreemen
|
|
|
208
295
|
* did:webvh document, AFTER the removal edit
|
|
209
296
|
* @param options.retireRecipientId {string} the removed recipient's roster
|
|
210
297
|
* kid
|
|
298
|
+
* @param options.signEpochs {EpochsSigner} the rotating client's
|
|
299
|
+
* epoch-configuration signer ({@link pukRosterEpochsSigner}), vouching for
|
|
300
|
+
* the fresh epoch so other clients' rotated reads accept it
|
|
211
301
|
* @returns {Promise<CollectionEncryption>} the rotated roster descriptor
|
|
212
302
|
*/
|
|
213
|
-
export async function rotatePukRoster({ store, document, retireRecipientId }) {
|
|
303
|
+
export async function rotatePukRoster({ store, document, retireRecipientId, signEpochs }) {
|
|
214
304
|
return removeRecipient({
|
|
215
305
|
store,
|
|
216
306
|
recipientId: retireRecipientId,
|
|
217
307
|
resolveRecipientKey: pukRosterRecipientResolver({ document }),
|
|
218
|
-
pull: async () => { }
|
|
308
|
+
pull: async () => { },
|
|
309
|
+
signEpochs
|
|
219
310
|
});
|
|
220
311
|
}
|
|
221
312
|
/**
|
|
@@ -252,11 +343,14 @@ export async function rotatePukRoster({ store, document, retireRecipientId }) {
|
|
|
252
343
|
* @param [options.descriptor] {CollectionEncryption} a descriptor the caller
|
|
253
344
|
* has just read (a login-time roster read), to save a re-read; omitted, the
|
|
254
345
|
* roster is read fresh
|
|
346
|
+
* @param options.signEpochs {EpochsSigner} the converging client's
|
|
347
|
+
* epoch-configuration signer ({@link pukRosterEpochsSigner}), for the
|
|
348
|
+
* rotation this call may perform
|
|
255
349
|
* @returns {Promise<object>} whether the roster rotated on this call, the
|
|
256
350
|
* stale recipient kids found, and the roster descriptor as it now stands
|
|
257
351
|
* (`null` when the account has no roster yet)
|
|
258
352
|
*/
|
|
259
|
-
export async function convergePukRosterToDocument({ store, document, descriptor }) {
|
|
353
|
+
export async function convergePukRosterToDocument({ store, document, descriptor, signEpochs }) {
|
|
260
354
|
let roster = descriptor;
|
|
261
355
|
if (!roster) {
|
|
262
356
|
const read = await store.read();
|
|
@@ -294,7 +388,8 @@ export async function convergePukRosterToDocument({ store, document, descriptor
|
|
|
294
388
|
const rotated = await rotatePukRoster({
|
|
295
389
|
store,
|
|
296
390
|
document,
|
|
297
|
-
retireRecipientId: staleRecipientIds[0]
|
|
391
|
+
retireRecipientId: staleRecipientIds[0],
|
|
392
|
+
signEpochs
|
|
298
393
|
});
|
|
299
394
|
return { rotated: true, staleRecipientIds, descriptor: rotated };
|
|
300
395
|
}
|
|
@@ -310,7 +405,15 @@ export async function convergePukRosterToDocument({ store, document, descriptor
|
|
|
310
405
|
* current; otherwise the current epoch was rotated by another client and
|
|
311
406
|
* this client's wrap is unwrapped with its own key-agreement key
|
|
312
407
|
* (`PukRosterUnwrapError` when it holds none).
|
|
313
|
-
* 3. **
|
|
408
|
+
* 3. **Provenance** (the rotated/first-read path only): the epoch
|
|
409
|
+
* configuration's `epochsSig` is verified against the locally verified
|
|
410
|
+
* did:webvh document ({@link verifyPukRosterEpochsSig}) BEFORE the epoch
|
|
411
|
+
* it delivers is adopted. On this path the `epochsMac` alone proves
|
|
412
|
+
* nothing against the host -- its key is unwrapped from the served
|
|
413
|
+
* descriptor itself -- so an epoch no enrolled client signed is refused
|
|
414
|
+
* (`PukRosterIntegrityError`). The cached-current path needs no signature:
|
|
415
|
+
* there the MAC is keyed by a secret this client already trusts.
|
|
416
|
+
* 4. **Authentication**: the descriptor's `epochsMac` is verified under the
|
|
314
417
|
* current epoch's secret (`PukRosterIntegrityError` on any mismatch -- a
|
|
315
418
|
* fabricated configuration).
|
|
316
419
|
*
|
|
@@ -321,6 +424,10 @@ export async function convergePukRosterToDocument({ store, document, descriptor
|
|
|
321
424
|
* A caller with no cached PUK at all -- a freshly enrolled client making its
|
|
322
425
|
* first post-enrollment read -- omits `puk` and always takes the unwrap path;
|
|
323
426
|
* the result's `rotated` is then true (the PUK was adopted from the roster).
|
|
427
|
+
* Every unwrap-path caller must therefore supply the account document (or a
|
|
428
|
+
* way to resolve it): `document` when it already holds a verified copy, or
|
|
429
|
+
* `resolveDocument` to fetch-and-verify lazily, only when the read actually
|
|
430
|
+
* rotates.
|
|
324
431
|
*
|
|
325
432
|
* @param options {object}
|
|
326
433
|
* @param options.store {EncryptionDescriptorStore} the roster's descriptor
|
|
@@ -330,9 +437,14 @@ export async function convergePukRosterToDocument({ store, document, descriptor
|
|
|
330
437
|
* (identity) key-agreement key, unwrapping a rotated epoch
|
|
331
438
|
* @param [options.pinnedEpochId] {string} the locally pinned latest-seen
|
|
332
439
|
* roster epoch, when this client has seen the roster before
|
|
440
|
+
* @param [options.document] {RosterRecipientDocument} the locally verified
|
|
441
|
+
* did:webvh document, when the caller already holds one
|
|
442
|
+
* @param [options.resolveDocument] {function} resolves the locally verified
|
|
443
|
+
* did:webvh document on demand; called only when the read takes the
|
|
444
|
+
* rotated/first-read path
|
|
333
445
|
* @returns {Promise<PukRosterReadResult | null>}
|
|
334
446
|
*/
|
|
335
|
-
export async function readPukRoster({ store, puk, clientKeyAgreementKey, pinnedEpochId }) {
|
|
447
|
+
export async function readPukRoster({ store, puk, clientKeyAgreementKey, pinnedEpochId, document, resolveDocument }) {
|
|
336
448
|
const current = await store.read();
|
|
337
449
|
if (current === null) {
|
|
338
450
|
return null;
|
|
@@ -363,8 +475,21 @@ export async function readPukRoster({ store, puk, clientKeyAgreementKey, pinnedE
|
|
|
363
475
|
rotated = false;
|
|
364
476
|
}
|
|
365
477
|
else {
|
|
366
|
-
// Rotated by another client
|
|
367
|
-
// epoch
|
|
478
|
+
// Rotated by another client (or this client's first read): before
|
|
479
|
+
// adopting the delivered epoch, trace it to a root of trust the server
|
|
480
|
+
// cannot mint -- the epoch configuration must be signed by a key the
|
|
481
|
+
// locally verified account document backs. The epochsMac below cannot
|
|
482
|
+
// carry this: on this path its key comes out of the served descriptor
|
|
483
|
+
// itself.
|
|
484
|
+
const accountDocument = document ?? (resolveDocument ? await resolveDocument() : undefined);
|
|
485
|
+
if (!accountDocument) {
|
|
486
|
+
throw new Error('A PUK roster read that adopts an epoch from the roster needs the ' +
|
|
487
|
+
'account document (pass `document` or `resolveDocument`) to verify ' +
|
|
488
|
+
'the epoch configuration signature.');
|
|
489
|
+
}
|
|
490
|
+
await verifyPukRosterEpochsSig({ descriptor, document: accountDocument });
|
|
491
|
+
// Unwrap this client's entry in the current epoch with its own
|
|
492
|
+
// key-agreement key (rotation delivery).
|
|
368
493
|
const entry = descriptor.epochs[currentIndex].recipients.find(recipient => recipient.header.kid === clientKeyAgreementKey.id);
|
|
369
494
|
if (!entry) {
|
|
370
495
|
throw new PukRosterUnwrapError('The PUK roster current epoch carries no wrap for this client.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pukRoster.js","sourceRoot":"","sources":["../../src/keys/pukRoster.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pukRoster.js","sourceRoot":"","sources":["../../src/keys/pukRoster.ts"],"names":[],"mappings":"AAyDA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,EAIhB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EACL,yBAAyB,EAE1B,MAAM,kBAAkB,CAAA;AAGzB;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,aAAa,CAAQ;IACrB,YAAY,EAAE,aAAa,EAA6B;QACtD,KAAK,CACH,uEAAuE;YACrE,mCAAmC,CACtC,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,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E,WAAW,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,EACxE,CAAC;QACD,MAAM,IAAI,uBAAuB,CAC/B,2DAA2D,CAC5D,CAAA;IACH,CAAC;IAED,OAAO;QACL,UAAU;QACV,GAAG,EAAE,UAAU;QACf,OAAO;QACP,aAAa,EAAE,UAAU,CAAC,YAAa;KACxC,CAAA;AACH,CAAC"}
|
|
@@ -14,6 +14,17 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { CHAPIStoreEvent, ICapabilityQueryDetail, ICredentialQuery, IQueryByExample, IVPOffer, IVPRequest, IVPRDetails, IVPRQuery, IVerifiableCredential, IVerifiablePresentation, WalletRequestProfile } from './types.js';
|
|
16
16
|
import type { CHAPIGetEvent } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* The VC data model version a presentation carrying the given credentials must
|
|
19
|
+
* use, so its `@context` stays coherent with what it carries: `2.0` when any
|
|
20
|
+
* credential is a VC 2.0 one, else `1.0`. Shared by the bare-credential
|
|
21
|
+
* wrapping below and by the unsigned branch of `composeVp` (the signed branch
|
|
22
|
+
* takes its version from the negotiated cryptosuite instead).
|
|
23
|
+
*
|
|
24
|
+
* @param credentials {IVerifiableCredential[]}
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
export declare function presentationVersionFor(credentials: IVerifiableCredential[]): number;
|
|
17
28
|
/**
|
|
18
29
|
* The Verifiable Credentials carried by a presentation, normalized to an array.
|
|
19
30
|
*
|
|
@@ -103,7 +114,10 @@ export declare function isDidAuthOnly(profile: WalletRequestProfile): boolean;
|
|
|
103
114
|
/**
|
|
104
115
|
* Returns true if the wallet can satisfy the DID method a `DIDAuthentication`
|
|
105
116
|
* query constrains to. A wallet holding only `did:key` can satisfy a request
|
|
106
|
-
* that lists `key` among `acceptedMethods` or omits the constraint entirely.
|
|
117
|
+
* that lists `key` among `acceptedMethods` or omits the constraint entirely. A
|
|
118
|
+
* malformed `acceptedMethods` (not an array, or holding non-object entries) is
|
|
119
|
+
* read for the entries it does have rather than dereferenced blindly: an
|
|
120
|
+
* `acceptedMethods` that is not a list of constraints at all imposes none.
|
|
107
121
|
*
|
|
108
122
|
* @param queries {IVPRQuery[]}
|
|
109
123
|
* @returns {boolean}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/request/classify.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAEhB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EAEvB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/request/classify.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAEhB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EAEvB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAO/C;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,qBAAqB,EAAE,GACnC,MAAM,CAOR;AA0DD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,YAAY,EAAE,uBAAuB,GACpC,qBAAqB,EAAE,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAYtE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,QAAQ,CAKxE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACR,EAAE;IACD,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB,GAAG,OAAO,CAQV;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,CAS3D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,GACrB,gBAAgB,EAAE,CAMpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,sBAAsB,EAAE,CAoB5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,oBAAoB,CAS1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAMpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAQpE"}
|
package/dist/request/classify.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { typeArray } from '@interop/data-integrity-core/guards';
|
|
2
|
+
import { asRecord } from '../display/text.js';
|
|
2
3
|
const VC_1_CONTEXT_URL = 'https://www.w3.org/2018/credentials/v1';
|
|
3
4
|
const VC_2_CONTEXT_URL = 'https://www.w3.org/ns/credentials/v2';
|
|
5
|
+
/**
|
|
6
|
+
* The VC data model version a presentation carrying the given credentials must
|
|
7
|
+
* use, so its `@context` stays coherent with what it carries: `2.0` when any
|
|
8
|
+
* credential is a VC 2.0 one, else `1.0`. Shared by the bare-credential
|
|
9
|
+
* wrapping below and by the unsigned branch of `composeVp` (the signed branch
|
|
10
|
+
* takes its version from the negotiated cryptosuite instead).
|
|
11
|
+
*
|
|
12
|
+
* @param credentials {IVerifiableCredential[]}
|
|
13
|
+
* @returns {number}
|
|
14
|
+
*/
|
|
15
|
+
export function presentationVersionFor(credentials) {
|
|
16
|
+
const isV2 = credentials.some(credential => {
|
|
17
|
+
const contexts = credential?.['@context'];
|
|
18
|
+
const contextArray = Array.isArray(contexts) ? contexts : [contexts];
|
|
19
|
+
return contextArray.includes(VC_2_CONTEXT_URL);
|
|
20
|
+
});
|
|
21
|
+
return isV2 ? 2.0 : 1.0;
|
|
22
|
+
}
|
|
4
23
|
/**
|
|
5
24
|
* Wraps a bare Verifiable Credential in an unsigned Verifiable Presentation,
|
|
6
25
|
* matching the credential's VC data model version so the presentation's
|
|
@@ -10,9 +29,7 @@ const VC_2_CONTEXT_URL = 'https://www.w3.org/ns/credentials/v2';
|
|
|
10
29
|
* @returns {IVerifiablePresentation}
|
|
11
30
|
*/
|
|
12
31
|
function presentationWrapping(credential) {
|
|
13
|
-
const
|
|
14
|
-
const contextArray = Array.isArray(contexts) ? contexts : [contexts];
|
|
15
|
-
const isV2 = contextArray.includes(VC_2_CONTEXT_URL);
|
|
32
|
+
const isV2 = presentationVersionFor([credential]) === 2.0;
|
|
16
33
|
return {
|
|
17
34
|
'@context': [isV2 ? VC_2_CONTEXT_URL : VC_1_CONTEXT_URL],
|
|
18
35
|
type: ['VerifiablePresentation'],
|
|
@@ -22,21 +39,25 @@ function presentationWrapping(credential) {
|
|
|
22
39
|
/**
|
|
23
40
|
* The offered payload as a Verifiable Presentation: passed through when the
|
|
24
41
|
* issuer already offered one, and wrapped when it offered a bare Verifiable
|
|
25
|
-
* Credential.
|
|
42
|
+
* Credential. A `data` payload that is not an object at all is unrecognized,
|
|
43
|
+
* and reported with the same descriptive error as an unrecognized object.
|
|
26
44
|
*
|
|
27
45
|
* @param credential {CHAPIStoreEvent['credential']}
|
|
28
46
|
* @returns {IVerifiablePresentation}
|
|
29
47
|
*/
|
|
30
48
|
function offeredPresentation({ dataType, data }) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
'
|
|
49
|
+
const payload = asRecord(data);
|
|
50
|
+
const types = typeArray(payload?.type);
|
|
51
|
+
const isPresentation = !!payload &&
|
|
52
|
+
(dataType === 'VerifiablePresentation' ||
|
|
53
|
+
types.includes('VerifiablePresentation') ||
|
|
54
|
+
'verifiableCredential' in payload);
|
|
35
55
|
if (isPresentation) {
|
|
36
56
|
return data;
|
|
37
57
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
58
|
+
if (payload &&
|
|
59
|
+
(dataType === 'VerifiableCredential' ||
|
|
60
|
+
types.includes('VerifiableCredential'))) {
|
|
40
61
|
return presentationWrapping(data);
|
|
41
62
|
}
|
|
42
63
|
throw new Error(`CHAPI store event offered an unrecognized payload (dataType: ${dataType ?? 'undefined'}, type: ${JSON.stringify(types)}).`);
|
|
@@ -94,7 +115,7 @@ export function classifyCHAPIStoreEvent(event) {
|
|
|
94
115
|
* @returns {boolean}
|
|
95
116
|
*/
|
|
96
117
|
export function isDIDAuthRequested({ queries }) {
|
|
97
|
-
const didAuthRequests = queries.filter(
|
|
118
|
+
const didAuthRequests = queries.filter(query => query.type === 'DIDAuthentication');
|
|
98
119
|
if (didAuthRequests.length > 1) {
|
|
99
120
|
throw new Error('More than one DIDAuthentication request found, exiting.');
|
|
100
121
|
}
|
|
@@ -194,7 +215,10 @@ export function isDidAuthOnly(profile) {
|
|
|
194
215
|
/**
|
|
195
216
|
* Returns true if the wallet can satisfy the DID method a `DIDAuthentication`
|
|
196
217
|
* query constrains to. A wallet holding only `did:key` can satisfy a request
|
|
197
|
-
* that lists `key` among `acceptedMethods` or omits the constraint entirely.
|
|
218
|
+
* that lists `key` among `acceptedMethods` or omits the constraint entirely. A
|
|
219
|
+
* malformed `acceptedMethods` (not an array, or holding non-object entries) is
|
|
220
|
+
* read for the entries it does have rather than dereferenced blindly: an
|
|
221
|
+
* `acceptedMethods` that is not a list of constraints at all imposes none.
|
|
198
222
|
*
|
|
199
223
|
* @param queries {IVPRQuery[]}
|
|
200
224
|
* @returns {boolean}
|
|
@@ -202,9 +226,9 @@ export function isDidAuthOnly(profile) {
|
|
|
202
226
|
export function didAuthMethodSupported(queries) {
|
|
203
227
|
const didAuth = queries.find(query => query.type === 'DIDAuthentication');
|
|
204
228
|
const acceptedMethods = didAuth?.acceptedMethods;
|
|
205
|
-
if (!acceptedMethods || acceptedMethods.length === 0) {
|
|
229
|
+
if (!Array.isArray(acceptedMethods) || acceptedMethods.length === 0) {
|
|
206
230
|
return true;
|
|
207
231
|
}
|
|
208
|
-
return acceptedMethods.some(
|
|
232
|
+
return acceptedMethods.some(entry => asRecord(entry)?.method === 'key');
|
|
209
233
|
}
|
|
210
234
|
//# sourceMappingURL=classify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/request/classify.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/request/classify.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,MAAM,gBAAgB,GAAG,wCAAwC,CAAA;AACjE,MAAM,gBAAgB,GAAG,sCAAsC,CAAA;AAE/D;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAoC;IAEpC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;QACzC,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC,UAAU,CAAC,CAAA;QACzC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QACpE,OAAO,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAC,CAAC,CAAC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AU,eAAe,CAAC,OAAoB;IAClD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAClC,OAAO;QACL,OAAO,EAAE,kBAAkB,CAAC,EAAE,OAAO,EAAE,CAAC;QACxC,SAAS,EAAE,OAAO,CAAC,MAAM,CACvB,CAAC,KAAK,EAA4B,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CACrE;QACD,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC;KACrC,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,OAAO,CACL,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAC9B,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAClC,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,CACnC,CAAA;IACrC,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,CAAA;IAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composeVp.d.ts","sourceRoot":"","sources":["../../src/request/composeVp.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"composeVp.d.ts","sourceRoot":"","sources":["../../src/request/composeVp.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAGnE,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,EACL,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,eAEnB,CAAA;AA4GV;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,SAAS,CAAC,EAC9B,kBAAkB,EAClB,WAAgB,EAChB,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,KAAU,EACV,UAAU,EACV,YAAqC,EACrC,cAAc,EAAE,MAAuB,EACxC,EAAE;IACD,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,OAAO,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAA;IAClC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,eAAe,CAAA;CACjC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAyDnC;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,kBAAY,CAAA"}
|