@interop/wallet-core 0.68.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -41
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +12 -1
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -1
- package/dist/clientAnnex/credentialAnchoredGenesis.js +9 -2
- package/dist/clientAnnex/credentialAnchoredGenesis.js.map +1 -1
- package/dist/clientAnnex/establish.d.ts +10 -0
- package/dist/clientAnnex/establish.d.ts.map +1 -1
- package/dist/clientAnnex/establish.js +14 -2
- package/dist/clientAnnex/establish.js.map +1 -1
- package/dist/clientAnnex/ladder.d.ts +103 -57
- package/dist/clientAnnex/ladder.d.ts.map +1 -1
- package/dist/clientAnnex/ladder.js +254 -335
- package/dist/clientAnnex/ladder.js.map +1 -1
- package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
- package/dist/clientAnnex/ladderAnchored.js +10 -5
- package/dist/clientAnnex/ladderAnchored.js.map +1 -1
- package/dist/clientAnnex/mend.d.ts +19 -4
- package/dist/clientAnnex/mend.d.ts.map +1 -1
- package/dist/clientAnnex/mend.js +83 -35
- package/dist/clientAnnex/mend.js.map +1 -1
- package/dist/clientAnnex/recoveryLadderAnchored.d.ts +3 -15
- package/dist/clientAnnex/recoveryLadderAnchored.d.ts.map +1 -1
- package/dist/clientAnnex/recoveryLadderAnchored.js +22 -3
- package/dist/clientAnnex/recoveryLadderAnchored.js.map +1 -1
- package/dist/clientAnnex/rosterDeliveredEpochs.d.ts +13 -14
- package/dist/clientAnnex/rosterDeliveredEpochs.d.ts.map +1 -1
- package/dist/clientAnnex/rosterDeliveredEpochs.js +12 -12
- package/dist/clientAnnex/rosterDeliveredEpochs.js.map +1 -1
- package/dist/clients/grantState.d.ts +67 -0
- package/dist/clients/grantState.d.ts.map +1 -0
- package/dist/clients/grantState.js +72 -0
- package/dist/clients/grantState.js.map +1 -0
- package/dist/clients/index.d.ts +7 -0
- package/dist/clients/index.d.ts.map +1 -1
- package/dist/clients/index.js +6 -0
- package/dist/clients/index.js.map +1 -1
- package/dist/descriptors/index.d.ts +21 -46
- package/dist/descriptors/index.d.ts.map +1 -1
- package/dist/descriptors/index.js +21 -45
- package/dist/descriptors/index.js.map +1 -1
- package/dist/descriptors/logSource.d.ts +45 -56
- package/dist/descriptors/logSource.d.ts.map +1 -1
- package/dist/descriptors/logSource.js +64 -74
- package/dist/descriptors/logSource.js.map +1 -1
- package/dist/enrollment/connectCode.d.ts +4 -3
- package/dist/enrollment/connectCode.d.ts.map +1 -1
- package/dist/enrollment/connectCode.js +4 -3
- package/dist/enrollment/connectCode.js.map +1 -1
- package/dist/enrollment/index.d.ts +2 -2
- package/dist/enrollment/index.js +2 -2
- package/dist/enrollment/onboardingInvite.d.ts +1 -1
- package/dist/enrollment/onboardingInvite.js +1 -1
- package/dist/enrollment/onboardingResponse.js +1 -1
- package/dist/genesis/accountGenesis.d.ts +13 -1
- package/dist/genesis/accountGenesis.d.ts.map +1 -1
- package/dist/genesis/accountGenesis.js +11 -2
- package/dist/genesis/accountGenesis.js.map +1 -1
- package/dist/identity/index.d.ts +1 -1
- package/dist/identity/index.js +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +33 -19
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +36 -25
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keys/collectionLogStore.d.ts +73 -0
- package/dist/keys/collectionLogStore.d.ts.map +1 -0
- package/dist/keys/collectionLogStore.js +60 -0
- package/dist/keys/collectionLogStore.js.map +1 -0
- package/dist/keys/index.d.ts +18 -6
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +18 -6
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +44 -6
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +51 -238
- package/dist/keys/rosterLogStore.js.map +1 -1
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +2 -1
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/keys/spaceEpochs.d.ts +67 -34
- package/dist/keys/spaceEpochs.d.ts.map +1 -1
- package/dist/keys/spaceEpochs.js +80 -30
- package/dist/keys/spaceEpochs.js.map +1 -1
- package/dist/keys/userKeyCascade.d.ts +26 -1
- package/dist/keys/userKeyCascade.d.ts.map +1 -1
- package/dist/keys/userKeyCascade.js +29 -2
- package/dist/keys/userKeyCascade.js.map +1 -1
- package/dist/keys/userKeyRoster.d.ts +5 -0
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +5 -0
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/keys/userKeyRosterCascade.d.ts +54 -16
- package/dist/keys/userKeyRosterCascade.d.ts.map +1 -1
- package/dist/keys/userKeyRosterCascade.js +50 -22
- package/dist/keys/userKeyRosterCascade.js.map +1 -1
- package/dist/recovery/continuation.d.ts +5 -4
- package/dist/recovery/continuation.d.ts.map +1 -1
- package/dist/recovery/continuation.js +14 -13
- package/dist/recovery/continuation.js.map +1 -1
- package/dist/resourceLog/controller.d.ts +18 -6
- package/dist/resourceLog/controller.d.ts.map +1 -1
- package/dist/resourceLog/controller.js +5 -3
- package/dist/resourceLog/controller.js.map +1 -1
- package/dist/resourceLog/document.d.ts +10 -2
- package/dist/resourceLog/document.d.ts.map +1 -1
- package/dist/resourceLog/document.js +1 -2
- package/dist/resourceLog/document.js.map +1 -1
- package/dist/resourceLog/errors.d.ts +17 -43
- package/dist/resourceLog/errors.d.ts.map +1 -1
- package/dist/resourceLog/errors.js +17 -50
- package/dist/resourceLog/errors.js.map +1 -1
- package/dist/resourceLog/index.d.ts +4 -1
- package/dist/resourceLog/index.d.ts.map +1 -1
- package/dist/resourceLog/index.js +4 -1
- package/dist/resourceLog/index.js.map +1 -1
- package/dist/resourceLog/logClass.d.ts +69 -0
- package/dist/resourceLog/logClass.d.ts.map +1 -0
- package/dist/resourceLog/logClass.js +43 -0
- package/dist/resourceLog/logClass.js.map +1 -0
- package/dist/space/collections.d.ts +22 -2
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +18 -0
- package/dist/space/collections.js.map +1 -1
- package/dist/space/index.d.ts +8 -5
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +8 -5
- package/dist/space/index.js.map +1 -1
- package/dist/space/provisioning.d.ts +16 -6
- package/dist/space/provisioning.d.ts.map +1 -1
- package/dist/space/provisioning.js +11 -7
- package/dist/space/provisioning.js.map +1 -1
- package/dist/space/wasLink.d.ts +13 -2
- package/dist/space/wasLink.d.ts.map +1 -1
- package/dist/space/wasLink.js +28 -2
- package/dist/space/wasLink.js.map +1 -1
- package/dist/sync/engine.d.ts +4 -2
- package/dist/sync/engine.d.ts.map +1 -1
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/index.d.ts +9 -6
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -5
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/push.d.ts +0 -29
- package/dist/sync/push.d.ts.map +1 -1
- package/dist/sync/push.js +30 -28
- package/dist/sync/push.js.map +1 -1
- package/dist/sync/types.d.ts +39 -21
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +13 -7
- package/dist/sync/types.js.map +1 -1
- package/dist/unlock/index.d.ts +1 -1
- package/dist/unlock/index.d.ts.map +1 -1
- package/dist/unlock/index.js.map +1 -1
- package/dist/unlock/retire.d.ts +8 -1
- package/dist/unlock/retire.d.ts.map +1 -1
- package/dist/unlock/retire.js +8 -1
- package/dist/unlock/retire.js.map +1 -1
- package/dist/unlock/standingWebvh.d.ts +81 -19
- package/dist/unlock/standingWebvh.d.ts.map +1 -1
- package/dist/unlock/standingWebvh.js +170 -30
- package/dist/unlock/standingWebvh.js.map +1 -1
- package/dist/webvh/did.d.ts +2 -4
- package/dist/webvh/did.d.ts.map +1 -1
- package/dist/webvh/did.js +2 -4
- package/dist/webvh/did.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +3 -2
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +2 -1
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/revokeClient.d.ts +13 -7
- package/dist/webvh/revokeClient.d.ts.map +1 -1
- package/dist/webvh/revokeClient.js +14 -7
- package/dist/webvh/revokeClient.js.map +1 -1
- package/package.json +4 -19
- package/dist/descriptors/acquire.d.ts +0 -122
- package/dist/descriptors/acquire.d.ts.map +0 -1
- package/dist/descriptors/acquire.js +0 -100
- package/dist/descriptors/acquire.js.map +0 -1
- package/dist/descriptors/cipher.d.ts +0 -71
- package/dist/descriptors/cipher.d.ts.map +0 -1
- package/dist/descriptors/cipher.js +0 -109
- package/dist/descriptors/cipher.js.map +0 -1
- package/dist/descriptors/errors.d.ts +0 -44
- package/dist/descriptors/errors.d.ts.map +0 -1
- package/dist/descriptors/errors.js +0 -46
- package/dist/descriptors/errors.js.map +0 -1
- package/dist/descriptors/refresh.d.ts +0 -62
- package/dist/descriptors/refresh.d.ts.map +0 -1
- package/dist/descriptors/refresh.js +0 -69
- package/dist/descriptors/refresh.js.map +0 -1
- package/dist/request/appKey.d.ts +0 -295
- package/dist/request/appKey.d.ts.map +0 -1
- package/dist/request/appKey.js +0 -516
- package/dist/request/appKey.js.map +0 -1
- package/dist/request/capabilityRequest.d.ts +0 -41
- package/dist/request/capabilityRequest.d.ts.map +0 -1
- package/dist/request/capabilityRequest.js +0 -46
- package/dist/request/capabilityRequest.js.map +0 -1
- package/dist/request/classify.d.ts +0 -226
- package/dist/request/classify.d.ts.map +0 -1
- package/dist/request/classify.js +0 -416
- package/dist/request/classify.js.map +0 -1
- package/dist/request/composeVp.d.ts +0 -52
- package/dist/request/composeVp.d.ts.map +0 -1
- package/dist/request/composeVp.js +0 -176
- package/dist/request/composeVp.js.map +0 -1
- package/dist/request/ephemeralExchange.d.ts +0 -100
- package/dist/request/ephemeralExchange.d.ts.map +0 -1
- package/dist/request/ephemeralExchange.js +0 -230
- package/dist/request/ephemeralExchange.js.map +0 -1
- package/dist/request/exchangeClient.d.ts +0 -142
- package/dist/request/exchangeClient.d.ts.map +0 -1
- package/dist/request/exchangeClient.js +0 -241
- package/dist/request/exchangeClient.js.map +0 -1
- package/dist/request/index.d.ts +0 -59
- package/dist/request/index.d.ts.map +0 -1
- package/dist/request/index.js +0 -59
- package/dist/request/index.js.map +0 -1
- package/dist/request/interactionRequest.d.ts +0 -23
- package/dist/request/interactionRequest.d.ts.map +0 -1
- package/dist/request/interactionRequest.js +0 -46
- package/dist/request/interactionRequest.js.map +0 -1
- package/dist/request/interactionUrl.d.ts +0 -42
- package/dist/request/interactionUrl.d.ts.map +0 -1
- package/dist/request/interactionUrl.js +0 -104
- package/dist/request/interactionUrl.js.map +0 -1
- package/dist/request/matching.d.ts +0 -95
- package/dist/request/matching.d.ts.map +0 -1
- package/dist/request/matching.js +0 -205
- package/dist/request/matching.js.map +0 -1
- package/dist/request/onboarding.d.ts +0 -94
- package/dist/request/onboarding.d.ts.map +0 -1
- package/dist/request/onboarding.js +0 -167
- package/dist/request/onboarding.js.map +0 -1
- package/dist/request/parse.d.ts +0 -63
- package/dist/request/parse.d.ts.map +0 -1
- package/dist/request/parse.js +0 -153
- package/dist/request/parse.js.map +0 -1
- package/dist/request/presentationSuite.d.ts +0 -71
- package/dist/request/presentationSuite.d.ts.map +0 -1
- package/dist/request/presentationSuite.js +0 -143
- package/dist/request/presentationSuite.js.map +0 -1
- package/dist/request/processRequest.d.ts +0 -45
- package/dist/request/processRequest.d.ts.map +0 -1
- package/dist/request/processRequest.js +0 -147
- package/dist/request/processRequest.js.map +0 -1
- package/dist/request/queryPredicates.d.ts +0 -98
- package/dist/request/queryPredicates.d.ts.map +0 -1
- package/dist/request/queryPredicates.js +0 -107
- package/dist/request/queryPredicates.js.map +0 -1
- package/dist/request/types.d.ts +0 -257
- package/dist/request/types.d.ts.map +0 -1
- package/dist/request/types.js +0 -2
- package/dist/request/types.js.map +0 -1
- package/dist/request/walletInput.d.ts +0 -93
- package/dist/request/walletInput.d.ts.map +0 -1
- package/dist/request/walletInput.js +0 -179
- package/dist/request/walletInput.js.map +0 -1
package/dist/request/appKey.js
DELETED
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The App Connect app-key credential: a self-issued VC that carries a 32-byte
|
|
6
|
-
* seed an app keeps in the user's wallet so it can open its encrypted data on
|
|
7
|
-
* this and other devices. Unlike an ordinary credential, the issuer and
|
|
8
|
-
* subject are NOT the wallet user's DID -- they are a did:key derived from the
|
|
9
|
-
* seed itself (self-issued by the app key), so the credential validates
|
|
10
|
-
* standalone and the same seed reconstitutes the same identity on every
|
|
11
|
-
* client. The credential is bound to the attested requesting origin
|
|
12
|
-
* (`credentialSubject.origin`) and to the application's canonical URL
|
|
13
|
-
* (`credentialSubject.appUrl`), and matched wallet-side against both, so a
|
|
14
|
-
* phishing origin can neither recover an existing app key nor be handed one
|
|
15
|
-
* minted for another origin, and applications sharing an origin are kept
|
|
16
|
-
* apart by their `appUrl`s.
|
|
17
|
-
*
|
|
18
|
-
* Ported from Freewallet's `src/lib/appKey.ts`, migrated from the
|
|
19
|
-
* `credentialType` / `vocabBase` model to the App Connect spec's `appUrl`
|
|
20
|
-
* model: the type array is a fixed two-entry list, the `@context` is the VC
|
|
21
|
-
* 1.1 context URL followed by the hosted App Connect context URL (identical
|
|
22
|
-
* for every application), and which application a credential belongs to is a
|
|
23
|
-
* claim (`credentialSubject.appUrl`), not a type. See the App Connect spec's
|
|
24
|
-
* App Key Credential section for the normative shape, matching, and minting
|
|
25
|
-
* rules this module implements.
|
|
26
|
-
*/
|
|
27
|
-
import * as vc from '@interop/vc';
|
|
28
|
-
import { base64urlnopad } from '@scure/base';
|
|
29
|
-
import { CapabilityAgent } from '@interop/webkms-client';
|
|
30
|
-
import { Ed25519Signature2020 } from '@interop/ed25519-signature';
|
|
31
|
-
import { issuerId, subjectId, typeArray } from '@interop/data-integrity-core/guards';
|
|
32
|
-
import { CONTEXT_URL_V1 as APP_CONNECT_CONTEXT_URL } from 'byoe-context';
|
|
33
|
-
import { documentLoader } from './composeVp.js';
|
|
34
|
-
/**
|
|
35
|
-
* The semantic `handle` mixed into seed derivation. It identifies the agent
|
|
36
|
-
* but does not affect the derived key (only the seed bytes and the key name
|
|
37
|
-
* enter the HMAC), so it is cosmetic; kept for legibility.
|
|
38
|
-
*/
|
|
39
|
-
const APP_KEY_HANDLE = 'freewallet-app-key';
|
|
40
|
-
/**
|
|
41
|
-
* The key name mixed into seed derivation. Unlike the handle this is
|
|
42
|
-
* load-bearing: it is the HMAC message in `CapabilityAgent` derivation, so the
|
|
43
|
-
* exact string is a pinned input of the App Connect key-derivation rule --
|
|
44
|
-
* every existing app-key credential's identity depends on it.
|
|
45
|
-
*/
|
|
46
|
-
export const APP_KEY_KEY_NAME = 'app-key';
|
|
47
|
-
const VC_1_CONTEXT_URL = 'https://www.w3.org/2018/credentials/v1';
|
|
48
|
-
/**
|
|
49
|
-
* The marker type every app-key credential carries, mapped to one stable IRI
|
|
50
|
-
* for every application. It makes "presents as an app key" a term check rather
|
|
51
|
-
* than a shape heuristic, which is what the store-time refusal
|
|
52
|
-
* ({@link assertStorableAppKey}) and the match path key off.
|
|
53
|
-
*
|
|
54
|
-
* It is a self-declaration, not evidence: the `type` array of a planted
|
|
55
|
-
* credential is attacker-controlled like the rest of it. The seed-to-subject
|
|
56
|
-
* binding ({@link appKeySeedBindsSubject}) authenticates only a credential's
|
|
57
|
-
* internal consistency, never its provenance (a fully attacker-generated
|
|
58
|
-
* credential binds perfectly). That is exactly why external ingest refuses on
|
|
59
|
-
* the marker alone, binding or not ({@link assertStorableAppKey}): app keys
|
|
60
|
-
* are wallet-minted, never imported.
|
|
61
|
-
*/
|
|
62
|
-
export const APP_KEY_CREDENTIAL_TYPE = 'AppKeyCredential';
|
|
63
|
-
/**
|
|
64
|
-
* The fixed `type` array of every app-key credential: exactly two entries, in
|
|
65
|
-
* this order, identical for every application. Which application a credential
|
|
66
|
-
* belongs to is the `credentialSubject.appUrl` claim, not a type.
|
|
67
|
-
*/
|
|
68
|
-
export const APP_KEY_TYPE_ARRAY = Object.freeze([
|
|
69
|
-
'VerifiableCredential',
|
|
70
|
-
APP_KEY_CREDENTIAL_TYPE
|
|
71
|
-
]);
|
|
72
|
-
/**
|
|
73
|
-
* The hosted App Connect context URL every app-key credential carries as the
|
|
74
|
-
* second entry of its `@context` array (after the VC 1.1 context URL). The
|
|
75
|
-
* context document defines the profile's BYOE terms; document loaders resolve
|
|
76
|
-
* it from the bundled `byoe-context` document, so no fetch happens at sign or
|
|
77
|
-
* verification time.
|
|
78
|
-
*/
|
|
79
|
-
export { APP_CONNECT_CONTEXT_URL };
|
|
80
|
-
/**
|
|
81
|
-
* The number of random bytes in an app-key seed.
|
|
82
|
-
*/
|
|
83
|
-
const SEED_BYTE_LENGTH = 32;
|
|
84
|
-
/**
|
|
85
|
-
* Whether a credential presents as an app key -- that is, carries the
|
|
86
|
-
* {@link APP_KEY_CREDENTIAL_TYPE} marker in its `type` array. Says nothing
|
|
87
|
-
* about whether it IS one; that is the seed-to-subject binding's job.
|
|
88
|
-
*
|
|
89
|
-
* @param credential {IVerifiableCredential}
|
|
90
|
-
* @returns {boolean}
|
|
91
|
-
*/
|
|
92
|
-
export function presentsAsAppKey(credential) {
|
|
93
|
-
return typeArray(credential.type).includes(APP_KEY_CREDENTIAL_TYPE);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The refusal a store path raises for a credential that presents as an app key
|
|
97
|
-
* but arrived from outside the wallet's own mint path. A distinct class so the
|
|
98
|
-
* UI can show its own translated wording rather than this message.
|
|
99
|
-
*/
|
|
100
|
-
export class AppKeyRefusedError extends Error {
|
|
101
|
-
constructor() {
|
|
102
|
-
super('This credential claims to be an app key. App keys are created by the ' +
|
|
103
|
-
'wallet itself and cannot be added from outside, so it was not stored.');
|
|
104
|
-
this.name = 'AppKeyRefusedError';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Refuses any credential that presents as an app key, unconditionally --
|
|
109
|
-
* whether or not it binds to its own seed. Called on every path that puts a
|
|
110
|
-
* credential in the store from outside the wallet (a CHAPI store offer, a
|
|
111
|
-
* URL / QR / manual-paste import), so an externally arriving app key never
|
|
112
|
-
* reaches the store, the credential list, or the user's Space.
|
|
113
|
-
*
|
|
114
|
-
* The seed-to-subject binding ({@link appKeySeedBindsSubject}) authenticates
|
|
115
|
-
* only the credential's internal consistency, not its provenance: a fully
|
|
116
|
-
* attacker-generated credential binds perfectly (a fresh seed, the victim
|
|
117
|
-
* app's `origin` and `appUrl`, self-issued), and storing it would make its
|
|
118
|
-
* DID the controller the wallet delegates the user's storage to. So there is
|
|
119
|
-
* no "binds, so it stores" carve-out here: app-key credentials are
|
|
120
|
-
* wallet-minted, never imported, and only the wallet's own mint path may
|
|
121
|
-
* store one.
|
|
122
|
-
*
|
|
123
|
-
* A credential with no marker is left alone, so an ordinary credential that
|
|
124
|
-
* merely happens to carry a `seed` or `origin` claim is never caught.
|
|
125
|
-
*
|
|
126
|
-
* @param credential {IVerifiableCredential}
|
|
127
|
-
* @returns {void} throws the refusal reason
|
|
128
|
-
*/
|
|
129
|
-
export function assertStorableAppKey(credential) {
|
|
130
|
-
if (presentsAsAppKey(credential)) {
|
|
131
|
-
throw new AppKeyRefusedError();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Whether an app-key credential's subject DID is the one its own seed derives
|
|
136
|
-
* -- the binding that makes the credential an app key rather than merely a
|
|
137
|
-
* self-issued claim to be one. Self-issuance is a weak signal (anyone can
|
|
138
|
-
* self-issue); this is the strong one, and it is fully local: the credential
|
|
139
|
-
* carries the seed, so re-derive with the same call `mintAppKeyCredential`
|
|
140
|
-
* uses and compare. Fails closed on an absent, non-base64url, or otherwise
|
|
141
|
-
* unusable seed rather than throwing out of the match path.
|
|
142
|
-
*
|
|
143
|
-
* @param credential {IVerifiableCredential}
|
|
144
|
-
* @returns {Promise<boolean>}
|
|
145
|
-
*/
|
|
146
|
-
export async function appKeySeedBindsSubject(credential) {
|
|
147
|
-
const subjectDid = subjectId(credential);
|
|
148
|
-
const seed = appKeySeedBytes(credential);
|
|
149
|
-
if (!subjectDid || !seed || seed.length !== SEED_BYTE_LENGTH) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
const agent = await CapabilityAgent.fromSeed({
|
|
154
|
-
seed,
|
|
155
|
-
handle: APP_KEY_HANDLE,
|
|
156
|
-
keyName: APP_KEY_KEY_NAME
|
|
157
|
-
});
|
|
158
|
-
return agent.id === subjectDid;
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Raised by {@link assertMintedAppKey} when a credential offered to the mint
|
|
166
|
-
* path's store door does not carry the mint invariants. Reaching it means a
|
|
167
|
-
* caller tried to route a foreign credential through the wallet's own mint
|
|
168
|
-
* door -- a programming error, not a user-facing refusal, so it is not
|
|
169
|
-
* translated like {@link AppKeyRefusedError}.
|
|
170
|
-
*/
|
|
171
|
-
export class AppKeyMintInvariantError extends Error {
|
|
172
|
-
constructor() {
|
|
173
|
-
super('Only a wallet-minted app-key credential (marker type present, subject ' +
|
|
174
|
-
'DID derived from its own seed) can be stored through the mint path.');
|
|
175
|
-
this.name = 'AppKeyMintInvariantError';
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Asserts the mint invariants on a credential the wallet claims to have just
|
|
180
|
-
* minted: it presents as an app key (the marker type) and its subject DID
|
|
181
|
-
* re-derives from the seed it carries. The mirror image of
|
|
182
|
-
* {@link assertStorableAppKey} -- external ingest refuses every marker
|
|
183
|
-
* credential, the mint door stores only credentials that carry the full mint
|
|
184
|
-
* shape -- kept beside it so the two halves of the app-key store policy live
|
|
185
|
-
* in one module.
|
|
186
|
-
*
|
|
187
|
-
* @param credential {IVerifiableCredential}
|
|
188
|
-
* @returns {Promise<void>} throws {@link AppKeyMintInvariantError}
|
|
189
|
-
*/
|
|
190
|
-
export async function assertMintedAppKey(credential) {
|
|
191
|
-
if (!presentsAsAppKey(credential) ||
|
|
192
|
-
!(await appKeySeedBindsSubject(credential))) {
|
|
193
|
-
throw new AppKeyMintInvariantError();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Whether a credential is self-issued: it names an issuer, and that issuer is
|
|
198
|
-
* its own subject. The shape every app-key credential has and every planted
|
|
199
|
-
* one must not be allowed to fake alone.
|
|
200
|
-
*/
|
|
201
|
-
function isSelfIssued(credential) {
|
|
202
|
-
const issuer = issuerId(credential.issuer);
|
|
203
|
-
return !!issuer && issuer === subjectId(credential);
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* The instant a credential's `issuanceDate` denotes, or NaN when it is
|
|
207
|
-
* absent, not a string, or does not parse. Ranking is over instants, not raw
|
|
208
|
-
* strings: the ranking decides which DID the wallet delegates to, so a
|
|
209
|
-
* comparison manipulable by the *spelling* of a date (a numeric offset,
|
|
210
|
-
* differing fractional-second precision) would reopen the planted-credential
|
|
211
|
-
* path in a narrower form.
|
|
212
|
-
*/
|
|
213
|
-
function issuanceInstant(credential) {
|
|
214
|
-
const raw = credential.issuanceDate;
|
|
215
|
-
if (typeof raw !== 'string') {
|
|
216
|
-
return NaN;
|
|
217
|
-
}
|
|
218
|
-
return Date.parse(raw);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Sort comparator ordering credentials latest-first by the instant their
|
|
222
|
-
* `issuanceDate` denotes; a credential whose date is absent or unparseable
|
|
223
|
-
* sorts last.
|
|
224
|
-
*/
|
|
225
|
-
function byIssuanceInstantDesc(first, second) {
|
|
226
|
-
const firstInstant = issuanceInstant(first);
|
|
227
|
-
const secondInstant = issuanceInstant(second);
|
|
228
|
-
if (Number.isNaN(firstInstant)) {
|
|
229
|
-
return Number.isNaN(secondInstant) ? 0 : 1;
|
|
230
|
-
}
|
|
231
|
-
if (Number.isNaN(secondInstant)) {
|
|
232
|
-
return -1;
|
|
233
|
-
}
|
|
234
|
-
return secondInstant - firstInstant;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* The app-key candidates for an app + origin, latest-first: everything the
|
|
238
|
-
* cheap, synchronous predicates accept, so only plausible candidates pay for
|
|
239
|
-
* a key derivation. A candidate must carry the marker (required, not merely
|
|
240
|
-
* tolerated: a credential can then only reach the delegation path by carrying
|
|
241
|
-
* it, which is exactly what the store-time refusal screens), name the
|
|
242
|
-
* request's `appUrl` in `credentialSubject.appUrl` (both sides in serialized
|
|
243
|
-
* form -- the wallet mints the claim serialized, so the comparison is an
|
|
244
|
-
* exact string match), be self-issued, and be bound to the attested
|
|
245
|
-
* requesting origin. Sorting here (rather than after the binding check) lets
|
|
246
|
-
* {@link findAppKeyCredential} stop at the newest credential that binds.
|
|
247
|
-
*
|
|
248
|
-
* The legacy path ({@link findLegacyAppKeyCredential}) is the same chain
|
|
249
|
-
* with `appUrl` undefined: it selects the credentials carrying no
|
|
250
|
-
* `credentialSubject.appUrl` claim, so one predicate set and one sort serve
|
|
251
|
-
* both paths and a hardening applied here reaches the legacy path too.
|
|
252
|
-
*
|
|
253
|
-
* @param options {object}
|
|
254
|
-
* @param options.credentials {IVerifiableCredential[]}
|
|
255
|
-
* @param [options.appUrl] {string} - The request's `app.appUrl` in
|
|
256
|
-
* serialized form; undefined selects the legacy credentials that carry no
|
|
257
|
-
* `appUrl` claim.
|
|
258
|
-
* @param options.origin {string} - The attested requesting origin.
|
|
259
|
-
* @returns {IVerifiableCredential[]}
|
|
260
|
-
*/
|
|
261
|
-
export function appKeyCandidates({ credentials, appUrl, origin }) {
|
|
262
|
-
return credentials
|
|
263
|
-
.filter(credential => presentsAsAppKey(credential) &&
|
|
264
|
-
appKeyAppUrl(credential) === appUrl &&
|
|
265
|
-
isSelfIssued(credential) &&
|
|
266
|
-
appKeyOrigin(credential) === origin)
|
|
267
|
-
.sort(byIssuanceInstantDesc);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* The current (latest) app-key credential for an app + origin, or undefined
|
|
271
|
-
* when the user has none -- which signals first run for that (origin,
|
|
272
|
-
* `appUrl`) pair.
|
|
273
|
-
*
|
|
274
|
-
* @param options {object}
|
|
275
|
-
* @param options.credentials {IVerifiableCredential[]}
|
|
276
|
-
* @param options.appUrl {string} - The request's `app.appUrl` in serialized
|
|
277
|
-
* form.
|
|
278
|
-
* @param options.origin {string} - The attested requesting origin.
|
|
279
|
-
* @returns {Promise<IVerifiableCredential | undefined>}
|
|
280
|
-
*/
|
|
281
|
-
export async function findAppKeyCredential({ credentials, appUrl, origin }) {
|
|
282
|
-
// Newest-first, returning at the first credential that binds: a non-binding
|
|
283
|
-
// one ranked above it is discarded on the way, and the credentials below it
|
|
284
|
-
// never pay for a key derivation.
|
|
285
|
-
for (const candidate of appKeyCandidates({ credentials, appUrl, origin })) {
|
|
286
|
-
if (await appKeySeedBindsSubject(candidate)) {
|
|
287
|
-
return candidate;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return undefined;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* The `description` an app-key credential carries when the caller supplies
|
|
294
|
-
* none: the consent-surface sentence the wallet mints with.
|
|
295
|
-
*/
|
|
296
|
-
function defaultAppKeyDescription(appName) {
|
|
297
|
-
return (`The ${appName} app keeps this key in your wallet so it can open ` +
|
|
298
|
-
'your encrypted data on this and other devices.');
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Assembles and signs an app-key credential for a seed the caller supplies:
|
|
302
|
-
* the fixed two-entry type array, the hosted App Connect context URL, issuer
|
|
303
|
-
* and subject both the seed-derived DID, and the `seed` / `appUrl` / `origin`
|
|
304
|
-
* claims. `vc.issue` auto-fills `issuanceDate` in the canonical UTC form the
|
|
305
|
-
* ranking expects. Shared by the fresh mint and the legacy re-issue, and
|
|
306
|
-
* exported for an application's own self-issue path (dev-grant provisioning,
|
|
307
|
-
* tests), so the credential's shape is maintained in one place.
|
|
308
|
-
*
|
|
309
|
-
* @param options {object}
|
|
310
|
-
* @param options.seedBytes {Uint8Array} - The 32-byte master seed; the
|
|
311
|
-
* derived did:key is both issuer and subject.
|
|
312
|
-
* @param options.appName {string} - Shown on the credential (`name`, and the
|
|
313
|
-
* default `description`).
|
|
314
|
-
* @param options.appUrl {string} - The app's canonical URL, already in
|
|
315
|
-
* serialized form.
|
|
316
|
-
* @param options.origin {string} - The attested requesting origin.
|
|
317
|
-
* @param [options.description] {string} - Overrides the default consent
|
|
318
|
-
* sentence (the legacy re-issue carries the old credential's forward).
|
|
319
|
-
* @param [options.documentLoader] {IDocumentLoader} - JSON-LD loader; defaults
|
|
320
|
-
* to the shared security loader.
|
|
321
|
-
* @returns {Promise<{ credential: IVerifiableCredential; subjectDid: string }>}
|
|
322
|
-
*/
|
|
323
|
-
export async function issueAppKeyCredential({ seedBytes, appName, appUrl, origin, description = defaultAppKeyDescription(appName), documentLoader: loader = documentLoader }) {
|
|
324
|
-
const agent = await CapabilityAgent.fromSeed({
|
|
325
|
-
seed: seedBytes,
|
|
326
|
-
handle: APP_KEY_HANDLE,
|
|
327
|
-
keyName: APP_KEY_KEY_NAME
|
|
328
|
-
});
|
|
329
|
-
const controllerDid = agent.id;
|
|
330
|
-
const credential = {
|
|
331
|
-
'@context': [VC_1_CONTEXT_URL, APP_CONNECT_CONTEXT_URL],
|
|
332
|
-
id: `urn:uuid:${crypto.randomUUID()}`,
|
|
333
|
-
type: [...APP_KEY_TYPE_ARRAY],
|
|
334
|
-
name: `${appName} app key`,
|
|
335
|
-
description,
|
|
336
|
-
issuer: controllerDid,
|
|
337
|
-
credentialSubject: {
|
|
338
|
-
id: controllerDid,
|
|
339
|
-
seed: base64urlnopad.encode(seedBytes),
|
|
340
|
-
appUrl,
|
|
341
|
-
origin
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
const suite = new Ed25519Signature2020({ signer: agent.getSigner() });
|
|
345
|
-
const signed = (await vc.issue({
|
|
346
|
-
credential,
|
|
347
|
-
suite,
|
|
348
|
-
documentLoader: loader
|
|
349
|
-
}));
|
|
350
|
-
return { credential: signed, subjectDid: controllerDid };
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Mints a fresh app-key credential for an app + origin: generates a 32-byte
|
|
354
|
-
* seed, derives the seed's did:key, and self-issues the credential (issuer ==
|
|
355
|
-
* subject == the seed-derived DID) with the `credentialSubject.appUrl` claim
|
|
356
|
-
* set from the validated request value. Does NOT store the result -- the
|
|
357
|
-
* caller stores it before delegating, so a failed delegation is found as
|
|
358
|
-
* "returning" on the next attempt rather than minting a second identity.
|
|
359
|
-
*
|
|
360
|
-
* @param options {object}
|
|
361
|
-
* @param options.app {IAppConnectApp} - The validated app identity; its
|
|
362
|
-
* `appUrl` must already be in serialized form (`appConnectRequestOf`
|
|
363
|
-
* guarantees this).
|
|
364
|
-
* @param options.origin {string} - The attested requesting origin, never a
|
|
365
|
-
* value taken from the request body.
|
|
366
|
-
* @returns {Promise<{ credential: IVerifiableCredential; subjectDid: string }>}
|
|
367
|
-
*/
|
|
368
|
-
export async function mintAppKeyCredential({ app, origin }) {
|
|
369
|
-
const seedBytes = crypto.getRandomValues(new Uint8Array(SEED_BYTE_LENGTH));
|
|
370
|
-
return issueAppKeyCredential({
|
|
371
|
-
seedBytes,
|
|
372
|
-
appName: app.name,
|
|
373
|
-
appUrl: app.appUrl,
|
|
374
|
-
origin
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* The latest legacy app-key credential for an origin, or undefined. A legacy
|
|
379
|
-
* credential predates the `appUrl` model: it carries the marker and a
|
|
380
|
-
* per-app third type entry, but no `credentialSubject.appUrl` claim. Its
|
|
381
|
-
* identity was scoped to (origin, `credentialType`), and the request no
|
|
382
|
-
* longer carries a `credentialType` to select on, so the mapping is
|
|
383
|
-
* recoverable only when it is unambiguous: when the binding legacy candidates
|
|
384
|
-
* for the origin all name one subject DID. Two distinct legacy identities on
|
|
385
|
-
* one origin yield undefined rather than a guess -- re-issuing the wrong one
|
|
386
|
-
* would hand one application another's identity, which is worse than the
|
|
387
|
-
* caller treating the connect as a first run.
|
|
388
|
-
*
|
|
389
|
-
* @param options {object}
|
|
390
|
-
* @param options.credentials {IVerifiableCredential[]}
|
|
391
|
-
* @param options.origin {string} - The attested requesting origin.
|
|
392
|
-
* @returns {Promise<IVerifiableCredential | undefined>}
|
|
393
|
-
*/
|
|
394
|
-
export async function findLegacyAppKeyCredential({ credentials, origin }) {
|
|
395
|
-
const candidates = appKeyCandidates({
|
|
396
|
-
credentials,
|
|
397
|
-
appUrl: undefined,
|
|
398
|
-
origin
|
|
399
|
-
});
|
|
400
|
-
const bound = [];
|
|
401
|
-
for (const candidate of candidates) {
|
|
402
|
-
if (await appKeySeedBindsSubject(candidate)) {
|
|
403
|
-
bound.push(candidate);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
if (bound.length === 0) {
|
|
407
|
-
return undefined;
|
|
408
|
-
}
|
|
409
|
-
const subjects = new Set(bound.map(credential => subjectId(credential)));
|
|
410
|
-
if (subjects.size > 1) {
|
|
411
|
-
return undefined;
|
|
412
|
-
}
|
|
413
|
-
return bound[0];
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Re-issues a legacy app-key credential in place under the `appUrl` model:
|
|
417
|
-
* the same seed (so the same derived DID -- the app's identity and its
|
|
418
|
-
* encrypted-data access are preserved), the fixed two-entry type array, the
|
|
419
|
-
* hosted App Connect context URL, and the `credentialSubject.appUrl` claim set
|
|
420
|
-
* from the validated request value. A fresh mint would roll the seed and orphan
|
|
421
|
-
* the identity, and must never be the migration path. The fresh
|
|
422
|
-
* `issuanceDate` ranks the re-issued credential ahead of the legacy one, so
|
|
423
|
-
* subsequent connects match it directly.
|
|
424
|
-
*
|
|
425
|
-
* Does NOT store the result; the caller stores it through the mint door
|
|
426
|
-
* (it satisfies {@link assertMintedAppKey}) and may retire the legacy record.
|
|
427
|
-
*
|
|
428
|
-
* @param options {object}
|
|
429
|
-
* @param options.credential {IVerifiableCredential} - The legacy credential;
|
|
430
|
-
* it must bind per {@link appKeySeedBindsSubject} and be bound to `origin`,
|
|
431
|
-
* else this throws {@link AppKeyMintInvariantError}.
|
|
432
|
-
* @param options.app {IAppConnectApp} - The validated app identity; its
|
|
433
|
-
* `appUrl` must already be in serialized form.
|
|
434
|
-
* @param options.origin {string} - The attested requesting origin.
|
|
435
|
-
* @returns {Promise<{ credential: IVerifiableCredential; subjectDid: string }>}
|
|
436
|
-
*/
|
|
437
|
-
export async function reissueAppKeyCredential({ credential, app, origin }) {
|
|
438
|
-
if (!(await appKeySeedBindsSubject(credential)) ||
|
|
439
|
-
appKeyOrigin(credential) !== origin) {
|
|
440
|
-
throw new AppKeyMintInvariantError();
|
|
441
|
-
}
|
|
442
|
-
const seedBytes = appKeySeedBytes(credential);
|
|
443
|
-
if (!seedBytes) {
|
|
444
|
-
throw new AppKeyMintInvariantError();
|
|
445
|
-
}
|
|
446
|
-
const legacyDescription = credential
|
|
447
|
-
.description;
|
|
448
|
-
return issueAppKeyCredential({
|
|
449
|
-
seedBytes,
|
|
450
|
-
appName: app.name,
|
|
451
|
-
appUrl: app.appUrl,
|
|
452
|
-
origin,
|
|
453
|
-
description: typeof legacyDescription === 'string' ? legacyDescription : undefined
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* The subject DID (`credentialSubject.id`) of an app-key credential, or
|
|
458
|
-
* undefined. For a valid app-key credential this equals the issuer.
|
|
459
|
-
*
|
|
460
|
-
* @param credential {IVerifiableCredential}
|
|
461
|
-
* @returns {string | undefined}
|
|
462
|
-
*/
|
|
463
|
-
export function appKeySubjectDid(credential) {
|
|
464
|
-
return subjectId(credential);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* The 32-byte seed an app-key credential carries
|
|
468
|
-
* (`credentialSubject.seed`, base64url-no-pad), or undefined when it is absent
|
|
469
|
-
* or malformed. This is the app's client secret, the root of its identity and
|
|
470
|
-
* of the keys it encrypts its own data with. The wallet reads it only to
|
|
471
|
-
* re-derive the credential's subject DID ({@link appKeySeedBindsSubject}) and
|
|
472
|
-
* to re-issue a legacy credential under the same identity; nothing downstream
|
|
473
|
-
* of the match takes the seed, so it never reaches the grant path.
|
|
474
|
-
*
|
|
475
|
-
* @param credential {IVerifiableCredential}
|
|
476
|
-
* @returns {Uint8Array | undefined}
|
|
477
|
-
*/
|
|
478
|
-
function appKeySeedBytes(credential) {
|
|
479
|
-
const subject = credential.credentialSubject;
|
|
480
|
-
if (!subject || typeof subject.seed !== 'string') {
|
|
481
|
-
return undefined;
|
|
482
|
-
}
|
|
483
|
-
try {
|
|
484
|
-
return base64urlnopad.decode(subject.seed);
|
|
485
|
-
}
|
|
486
|
-
catch {
|
|
487
|
-
return undefined;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* The origin (`credentialSubject.origin`) an app-key credential is bound to,
|
|
492
|
-
* when present.
|
|
493
|
-
*
|
|
494
|
-
* @param credential {IVerifiableCredential}
|
|
495
|
-
* @returns {string | undefined}
|
|
496
|
-
*/
|
|
497
|
-
export function appKeyOrigin(credential) {
|
|
498
|
-
const subject = credential.credentialSubject;
|
|
499
|
-
return subject && typeof subject.origin === 'string'
|
|
500
|
-
? subject.origin
|
|
501
|
-
: undefined;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* The application URL (`credentialSubject.appUrl`) an app-key credential is
|
|
505
|
-
* scoped to, when present. Absent on a legacy (pre-`appUrl`) credential.
|
|
506
|
-
*
|
|
507
|
-
* @param credential {IVerifiableCredential}
|
|
508
|
-
* @returns {string | undefined}
|
|
509
|
-
*/
|
|
510
|
-
export function appKeyAppUrl(credential) {
|
|
511
|
-
const subject = credential.credentialSubject;
|
|
512
|
-
return subject && typeof subject.appUrl === 'string'
|
|
513
|
-
? subject.appUrl
|
|
514
|
-
: undefined;
|
|
515
|
-
}
|
|
516
|
-
//# sourceMappingURL=appKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appKey.js","sourceRoot":"","sources":["../../src/request/appKey.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAKjE,OAAO,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACV,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG/C;;;;GAIG;AACH,MAAM,cAAc,GAAG,oBAAoB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAA;AAEzC,MAAM,gBAAgB,GAAG,wCAAwC,CAAA;AAEjE;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACjE,sBAAsB;IAC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AAM;QAChB,CAAC,CAAC,SAAS,CAAA;AACf,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The zcap-only Verifiable Presentation Request: the request a relying party
|
|
6
|
-
* stores on an ephemeral exchange (`ephemeralExchange.ts`) when all it wants
|
|
7
|
-
* from the wallet is delegated capabilities on the user's Space. One
|
|
8
|
-
* `AuthorizationCapabilityQuery` (the canonical VCALM type string; the wallet
|
|
9
|
-
* side's `zcapQueriesOf` reads it back) carrying the requested capability
|
|
10
|
-
* details verbatim. Deliberately no `DIDAuthentication` query and no
|
|
11
|
-
* `domain`: the requester is asking for authority, not proving who it is to a
|
|
12
|
-
* verifier, and a requester without an attested origin (a CLI) has no domain
|
|
13
|
-
* a wallet could check.
|
|
14
|
-
*/
|
|
15
|
-
import type { ICapabilityQueryDetail, IVPRDetails } from './types.js';
|
|
16
|
-
/**
|
|
17
|
-
* REQUESTER: builds the zcap-only VPR details for a set of capability
|
|
18
|
-
* requests. Each detail must name its `controller` (the grantee DID) and its
|
|
19
|
-
* `invocationTarget` (a URL under the user's Space, or a wallet-defined
|
|
20
|
-
* descriptor object); an empty set, or a detail missing either, throws --
|
|
21
|
-
* there would be nothing for the wallet to ask consent for.
|
|
22
|
-
*
|
|
23
|
-
* @param options {object}
|
|
24
|
-
* @param options.capabilityQueries {ICapabilityQueryDetail[]}
|
|
25
|
-
* @param [options.challenge] {string} a requester-chosen nonce the wallet
|
|
26
|
-
* echoes in its response presentation
|
|
27
|
-
* @param [options.agent] {{ name: string }} the requester's self-declared
|
|
28
|
-
* display name, carried as the VPR's root `agent` member; shown at consent
|
|
29
|
-
* as what the agent calls itself, never as verified identity. Validated by
|
|
30
|
-
* `normalizeAgentName` (trimmed, 1 to 64 characters, no control
|
|
31
|
-
* characters), so a name the wallet would refuse fails here first.
|
|
32
|
-
* @returns {IVPRDetails}
|
|
33
|
-
*/
|
|
34
|
-
export declare function composeCapabilityRequest({ capabilityQueries, challenge, agent }: {
|
|
35
|
-
capabilityQueries: ICapabilityQueryDetail[];
|
|
36
|
-
challenge?: string;
|
|
37
|
-
agent?: {
|
|
38
|
-
name: string;
|
|
39
|
-
};
|
|
40
|
-
}): IVPRDetails;
|
|
41
|
-
//# sourceMappingURL=capabilityRequest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityRequest.d.ts","sourceRoot":"","sources":["../../src/request/capabilityRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,sBAAsB,EACtB,WAAW,EAGZ,MAAM,YAAY,CAAA;AAGnB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,iBAAiB,EACjB,SAAS,EACT,KAAK,EACN,EAAE;IACD,iBAAiB,EAAE,sBAAsB,EAAE,CAAA;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CACzB,GAAG,WAAW,CA2Bd"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { normalizeAgentName } from './classify.js';
|
|
2
|
-
/**
|
|
3
|
-
* REQUESTER: builds the zcap-only VPR details for a set of capability
|
|
4
|
-
* requests. Each detail must name its `controller` (the grantee DID) and its
|
|
5
|
-
* `invocationTarget` (a URL under the user's Space, or a wallet-defined
|
|
6
|
-
* descriptor object); an empty set, or a detail missing either, throws --
|
|
7
|
-
* there would be nothing for the wallet to ask consent for.
|
|
8
|
-
*
|
|
9
|
-
* @param options {object}
|
|
10
|
-
* @param options.capabilityQueries {ICapabilityQueryDetail[]}
|
|
11
|
-
* @param [options.challenge] {string} a requester-chosen nonce the wallet
|
|
12
|
-
* echoes in its response presentation
|
|
13
|
-
* @param [options.agent] {{ name: string }} the requester's self-declared
|
|
14
|
-
* display name, carried as the VPR's root `agent` member; shown at consent
|
|
15
|
-
* as what the agent calls itself, never as verified identity. Validated by
|
|
16
|
-
* `normalizeAgentName` (trimmed, 1 to 64 characters, no control
|
|
17
|
-
* characters), so a name the wallet would refuse fails here first.
|
|
18
|
-
* @returns {IVPRDetails}
|
|
19
|
-
*/
|
|
20
|
-
export function composeCapabilityRequest({ capabilityQueries, challenge, agent }) {
|
|
21
|
-
if (capabilityQueries.length === 0) {
|
|
22
|
-
throw new Error('A capability request must ask for at least one zcap.');
|
|
23
|
-
}
|
|
24
|
-
for (const detail of capabilityQueries) {
|
|
25
|
-
if (typeof detail.controller !== 'string' || detail.controller === '') {
|
|
26
|
-
throw new Error('A capability query must name its "controller".');
|
|
27
|
-
}
|
|
28
|
-
const target = detail.invocationTarget;
|
|
29
|
-
if ((typeof target !== 'string' || target === '') &&
|
|
30
|
-
(typeof target !== 'object' || target === null)) {
|
|
31
|
-
throw new Error('A capability query must name its "invocationTarget".');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const query = {
|
|
35
|
-
type: 'AuthorizationCapabilityQuery',
|
|
36
|
-
capabilityQuery: capabilityQueries,
|
|
37
|
-
...(challenge !== undefined && { challenge })
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
query: [query],
|
|
41
|
-
...(agent !== undefined && {
|
|
42
|
-
agent: { name: normalizeAgentName({ name: agent.name }) }
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=capabilityRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityRequest.js","sourceRoot":"","sources":["../../src/request/capabilityRequest.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,wBAAwB,CAAC,EACvC,iBAAiB,EACjB,SAAS,EAC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