@interop/wallet-core 0.69.0 → 0.71.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 +22 -36
- 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/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/selfEnroll.js +1 -1
- package/dist/clientAnnex/selfEnroll.js.map +1 -1
- package/dist/clientAnnex/zcap.js +1 -1
- package/dist/clientAnnex/zcap.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/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/enrollment.js +1 -1
- package/dist/enrollment/enrollment.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/index.d.ts +4 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -1
- package/dist/keyring/index.d.ts +1 -1
- package/dist/keyring/index.js +1 -1
- package/dist/keyring/kdf.d.ts +34 -20
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +37 -26
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keys/userKey.js +1 -1
- package/dist/keys/userKey.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/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/space/index.d.ts +4 -2
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +4 -2
- package/dist/space/index.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/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/standingClient.d.ts +1 -1
- package/dist/unlock/standingClient.d.ts.map +1 -1
- package/dist/unlock/standingClient.js +3 -3
- package/dist/unlock/standingClient.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/index.d.ts +1 -1
- package/dist/webvh/index.js +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/dist/webvh/zcap.js +1 -1
- package/dist/webvh/zcap.js.map +1 -1
- package/package.json +2 -23
- package/dist/identity/agents.d.ts +0 -100
- package/dist/identity/agents.d.ts.map +0 -1
- package/dist/identity/agents.js +0 -120
- package/dist/identity/agents.js.map +0 -1
- package/dist/identity/index.d.ts +0 -24
- package/dist/identity/index.d.ts.map +0 -1
- package/dist/identity/index.js +0 -23
- package/dist/identity/index.js.map +0 -1
- package/dist/identity/keyResolver.d.ts +0 -30
- package/dist/identity/keyResolver.d.ts.map +0 -1
- package/dist/identity/keyResolver.js +0 -25
- package/dist/identity/keyResolver.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
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* VCALM `interaction:` URL handling: detecting an interaction URL, normalizing
|
|
6
|
-
* it to its inner HTTPS URL, and fetching the protocols map it advertises. An
|
|
7
|
-
* interaction URL is a level of indirection a verifier / issuer hands the wallet
|
|
8
|
-
* (over a deep link or QR code) that resolves to a `protocols` map naming the
|
|
9
|
-
* real exchange endpoints.
|
|
10
|
-
*
|
|
11
|
-
* Ported verbatim from DCW's `app/lib/interactionUrl.ts`, with the network
|
|
12
|
-
* transport injected ({@link FetchLike}, default `globalThis.fetch`).
|
|
13
|
-
*/
|
|
14
|
-
import { log } from '../log.js';
|
|
15
|
-
import { EphemeralExchangeGoneError } from './ephemeralExchange.js';
|
|
16
|
-
const INTERACTION_SCHEME_PREFIX = 'interaction:';
|
|
17
|
-
/**
|
|
18
|
-
* Detects whether a URL is a VCALM interaction URL.
|
|
19
|
-
*
|
|
20
|
-
* Two formats:
|
|
21
|
-
* - `interaction:` scheme: `interaction:https://example.com/path?iuv=1`
|
|
22
|
-
* - HTTPS URL with an `iuv` query param: `https://example.com/path?iuv=1`
|
|
23
|
-
*
|
|
24
|
-
* @param url {string}
|
|
25
|
-
* @returns {boolean}
|
|
26
|
-
*/
|
|
27
|
-
export function isInteractionUrl(url) {
|
|
28
|
-
if (url.startsWith(INTERACTION_SCHEME_PREFIX)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const parsed = new URL(url);
|
|
33
|
-
return parsed.searchParams.has('iuv');
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Normalizes any interaction URL to the inner HTTPS interaction URL. Accepts any
|
|
41
|
-
* URL that passed {@link isInteractionUrl}.
|
|
42
|
-
*
|
|
43
|
-
* - `interaction:https://...?iuv=1` strips the prefix
|
|
44
|
-
* - `interaction:https%3A%2F%2F...` strips the prefix and decodes (URL-encoded
|
|
45
|
-
* after `interaction:` is non-standard, but handled for robustness)
|
|
46
|
-
* - `https://...?iuv=1` is returned as-is
|
|
47
|
-
*
|
|
48
|
-
* @param url {string}
|
|
49
|
-
* @returns {string}
|
|
50
|
-
*/
|
|
51
|
-
export function parseInteractionUrl(url) {
|
|
52
|
-
if (!url.startsWith(INTERACTION_SCHEME_PREFIX)) {
|
|
53
|
-
return url;
|
|
54
|
-
}
|
|
55
|
-
const inner = url.slice(INTERACTION_SCHEME_PREFIX.length);
|
|
56
|
-
// Non-standard: the inner URL may be URL-encoded after the `interaction:`
|
|
57
|
-
// prefix.
|
|
58
|
-
if (inner.startsWith('http%3A') || inner.startsWith('https%3A')) {
|
|
59
|
-
return decodeURIComponent(inner);
|
|
60
|
-
}
|
|
61
|
-
return inner;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Fetches the interaction protocols response from a VCALM interaction URL. Sends
|
|
65
|
-
* GET with `Accept: application/json` per the VCALM spec, and returns the
|
|
66
|
-
* protocols map. Logs a warning if the `iuv` param value is not `1`; throws if
|
|
67
|
-
* the response is not ok or the `protocols` key is missing. A `404` is reported
|
|
68
|
-
* as {@link EphemeralExchangeGoneError} (dispatch on `err.name`): the
|
|
69
|
-
* interaction URL points at an exchange that expired or was never there.
|
|
70
|
-
*
|
|
71
|
-
* @param interactionUrl {string}
|
|
72
|
-
* @param [options] {object}
|
|
73
|
-
* @param [options.fetch] {FetchLike}
|
|
74
|
-
* @returns {Promise<Record<string, string>>}
|
|
75
|
-
*/
|
|
76
|
-
export async function fetchInteractionProtocols(interactionUrl, { fetch = globalThis.fetch } = {}) {
|
|
77
|
-
try {
|
|
78
|
-
const parsed = new URL(interactionUrl);
|
|
79
|
-
const iuv = parsed.searchParams.get('iuv');
|
|
80
|
-
if (iuv && iuv !== '1') {
|
|
81
|
-
log.warn('Unexpected iuv value (expected "1"); proceeding anyway', {
|
|
82
|
-
iuv
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
throw new Error(`Invalid interaction URL: ${interactionUrl}`);
|
|
88
|
-
}
|
|
89
|
-
const response = await fetch(interactionUrl, {
|
|
90
|
-
headers: { Accept: 'application/json' }
|
|
91
|
-
});
|
|
92
|
-
if (response.status === 404) {
|
|
93
|
-
throw new EphemeralExchangeGoneError(`The interaction URL ${interactionUrl} is no longer available.`);
|
|
94
|
-
}
|
|
95
|
-
if (!response.ok) {
|
|
96
|
-
throw new Error(`Interaction URL fetch failed: ${response.status} ${response.statusText}`);
|
|
97
|
-
}
|
|
98
|
-
const body = await response.json();
|
|
99
|
-
if (!body.protocols || typeof body.protocols !== 'object') {
|
|
100
|
-
throw new Error('Interaction URL response missing "protocols" map.');
|
|
101
|
-
}
|
|
102
|
-
return body.protocols;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=interactionUrl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interactionUrl.js","sourceRoot":"","sources":["../../src/request/interactionUrl.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;GASG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAGnE,MAAM,yBAAyB,GAAG,cAAc,CAAA;AAEhD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,GAAG,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO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0BAA0B,CAClC,uBAAuB,cAAc,0BAA0B,CAChE,CAAA;IACH,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,iCAAiC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAC1E,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAElC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;IACtE,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAA;AACvB,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* QueryByExample matching: which stored credentials satisfy a verifier's
|
|
6
|
-
* `QueryByExample` request. Two independent algorithms ship here because the two
|
|
7
|
-
* apps genuinely differ, and each wallet matches only its own local store (no
|
|
8
|
-
* cross-replica agreement is required):
|
|
9
|
-
*
|
|
10
|
-
* - `credentialMatchesVprExampleQuery` / `filterCredentialsByExample` -- DCW's
|
|
11
|
-
* deep matcher, which walks the example object and matches any nested field
|
|
12
|
-
* (arrays, nested objects, literals) against the credential.
|
|
13
|
-
* - `vcMatchesFor` / `hasTypedExample` / `requestsCredentialType` --
|
|
14
|
-
* Freewallet's type-and-issuer matcher, which constrains only on the
|
|
15
|
-
* example's `type` (and, when pinned, `issuer`).
|
|
16
|
-
*
|
|
17
|
-
* Both operate on plain `IVerifiableCredential`s; each app maps its own record
|
|
18
|
-
* type down to the credential before calling. Ported from DCW's
|
|
19
|
-
* `app/lib/credentialMatching.ts` and Freewallet's
|
|
20
|
-
* `src/lib/walletRequest/vcMatches.ts`.
|
|
21
|
-
*/
|
|
22
|
-
import type { IVerifiableCredential } from './types.js';
|
|
23
|
-
import type { IQueryByExample } from './types.js';
|
|
24
|
-
export { issuerId, typeArray } from '@interop/data-integrity-core/guards';
|
|
25
|
-
export type { ICredentialQuery, IQueryByExample, IVerifiableCredential } from './types.js';
|
|
26
|
-
/**
|
|
27
|
-
* Whether a credential matches a QueryByExample `example` object, by the DCW
|
|
28
|
-
* deep-matching algorithm: every key of the example is resolved as a literal
|
|
29
|
-
* property of the credential and compared. Array example values require the
|
|
30
|
-
* credential to contain (at least) every listed value; object example values
|
|
31
|
-
* recurse; literal example values compare by strict equality. An empty example
|
|
32
|
-
* matches any credential.
|
|
33
|
-
*
|
|
34
|
-
* Both sides are normalized for JSON-LD's single-value / array duality: a
|
|
35
|
-
* literal example value also matches a credential field holding the array form
|
|
36
|
-
* (`"type": "AlumniCredential"` vs `type: ['VerifiableCredential',
|
|
37
|
-
* 'AlumniCredential']`), and an array example value also matches a credential
|
|
38
|
-
* field holding the compacted single value.
|
|
39
|
-
*
|
|
40
|
-
* @param vprExample {Record<string, unknown>} - The QueryByExample `example`.
|
|
41
|
-
* @param credential {IVerifiableCredential} - The stored credential to test.
|
|
42
|
-
* @returns {boolean}
|
|
43
|
-
*/
|
|
44
|
-
export declare function credentialMatchesVprExampleQuery(vprExample: Record<string, unknown>, credential: IVerifiableCredential): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Filters credentials to those matching a `QueryByExample`, using the deep
|
|
47
|
-
* matcher. Each of the query's `credentialQuery` details contributes its
|
|
48
|
-
* `example`; a credential is included when it matches any of them. A malformed
|
|
49
|
-
* query with no example matches nothing.
|
|
50
|
-
*
|
|
51
|
-
* @param credentials {IVerifiableCredential[]}
|
|
52
|
-
* @param query {IQueryByExample}
|
|
53
|
-
* @returns {IVerifiableCredential[]}
|
|
54
|
-
*/
|
|
55
|
-
export declare function filterCredentialsByExample(credentials: IVerifiableCredential[], query: IQueryByExample): IVerifiableCredential[];
|
|
56
|
-
/**
|
|
57
|
-
* The credentials matching any of the given QueryByExample queries by the
|
|
58
|
-
* type-and-issuer algorithm. Only queries whose `example` carries a `type`
|
|
59
|
-
* constrain the result; a query with no example type matches nothing here (the
|
|
60
|
-
* caller keeps its list-all behavior when *no* query specifies a type).
|
|
61
|
-
*
|
|
62
|
-
* @param options {object}
|
|
63
|
-
* @param options.credentials {IVerifiableCredential[]}
|
|
64
|
-
* @param options.queries {IQueryByExample[]}
|
|
65
|
-
* @returns {IVerifiableCredential[]}
|
|
66
|
-
*/
|
|
67
|
-
export declare function vcMatchesFor({ credentials, queries }: {
|
|
68
|
-
credentials: IVerifiableCredential[];
|
|
69
|
-
queries: IQueryByExample[];
|
|
70
|
-
}): IVerifiableCredential[];
|
|
71
|
-
/**
|
|
72
|
-
* Whether any of the QueryByExample queries pins an example `type` (and so
|
|
73
|
-
* should filter the share list). When false, the caller keeps showing all
|
|
74
|
-
* stored credentials.
|
|
75
|
-
*
|
|
76
|
-
* @param queries {IQueryByExample[]}
|
|
77
|
-
* @returns {boolean}
|
|
78
|
-
*/
|
|
79
|
-
export declare function hasTypedExample(queries: IQueryByExample[]): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Whether any typed example in the query set explicitly lists the given
|
|
82
|
-
* credential `type`. Lets the caller distinguish a request that actually asks
|
|
83
|
-
* for a particular type (e.g. a LoginCredential) from a generic, untyped "any
|
|
84
|
-
* VC" request.
|
|
85
|
-
*
|
|
86
|
-
* @param options {object}
|
|
87
|
-
* @param options.queries {IQueryByExample[]}
|
|
88
|
-
* @param options.type {string}
|
|
89
|
-
* @returns {boolean}
|
|
90
|
-
*/
|
|
91
|
-
export declare function requestsCredentialType({ queries, type }: {
|
|
92
|
-
queries: IQueryByExample[];
|
|
93
|
-
type: string;
|
|
94
|
-
}): boolean;
|
|
95
|
-
//# sourceMappingURL=matching.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matching.d.ts","sourceRoot":"","sources":["../../src/request/matching.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,YAAY,CAAA;AAMnE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAKzE,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAET;AAiGD;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,qBAAqB,EAAE,EACpC,KAAK,EAAE,eAAe,GACrB,qBAAqB,EAAE,CAgBzB;AAiCD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,EAC3B,WAAW,EACX,OAAO,EACR,EAAE;IACD,WAAW,EAAE,qBAAqB,EAAE,CAAA;IACpC,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,GAAG,qBAAqB,EAAE,CAQ1B;AAqBD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAEnE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,IAAI,EACL,EAAE;IACD,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAIV"}
|
package/dist/request/matching.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { credentialQueriesOf } from './classify.js';
|
|
2
|
-
import { issuerId, typeArray } from '@interop/data-integrity-core/guards';
|
|
3
|
-
// The loose-field normalizers are owned by data-integrity-core; re-export them
|
|
4
|
-
// here so a matching consumer imports one module.
|
|
5
|
-
export { issuerId, typeArray } from '@interop/data-integrity-core/guards';
|
|
6
|
-
/**
|
|
7
|
-
* Whether a credential matches a QueryByExample `example` object, by the DCW
|
|
8
|
-
* deep-matching algorithm: every key of the example is resolved as a literal
|
|
9
|
-
* property of the credential and compared. Array example values require the
|
|
10
|
-
* credential to contain (at least) every listed value; object example values
|
|
11
|
-
* recurse; literal example values compare by strict equality. An empty example
|
|
12
|
-
* matches any credential.
|
|
13
|
-
*
|
|
14
|
-
* Both sides are normalized for JSON-LD's single-value / array duality: a
|
|
15
|
-
* literal example value also matches a credential field holding the array form
|
|
16
|
-
* (`"type": "AlumniCredential"` vs `type: ['VerifiableCredential',
|
|
17
|
-
* 'AlumniCredential']`), and an array example value also matches a credential
|
|
18
|
-
* field holding the compacted single value.
|
|
19
|
-
*
|
|
20
|
-
* @param vprExample {Record<string, unknown>} - The QueryByExample `example`.
|
|
21
|
-
* @param credential {IVerifiableCredential} - The stored credential to test.
|
|
22
|
-
* @returns {boolean}
|
|
23
|
-
*/
|
|
24
|
-
export function credentialMatchesVprExampleQuery(vprExample, credential) {
|
|
25
|
-
return matchesExampleScope(vprExample, credential);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The recursive half of the deep matcher: whether an example object matches the
|
|
29
|
-
* given scope of a credential. Each example key is resolved as a literal
|
|
30
|
-
* property of the scope, and an object example value recurses into the value it
|
|
31
|
-
* resolved to.
|
|
32
|
-
*
|
|
33
|
-
* @param vprExample {Record<string, unknown>} - The example (or sub-example).
|
|
34
|
-
* @param scope {unknown} - The credential value the example is matched against
|
|
35
|
-
* (the credential itself at the top level).
|
|
36
|
-
* @returns {boolean}
|
|
37
|
-
*/
|
|
38
|
-
function matchesExampleScope(vprExample, scope) {
|
|
39
|
-
const matches = [];
|
|
40
|
-
for (const [vprExampleKey, vprExampleValue] of Object.entries(vprExample)) {
|
|
41
|
-
const credentialScope = propertyOf(scope, vprExampleKey);
|
|
42
|
-
if (Array.isArray(vprExampleValue)) {
|
|
43
|
-
// Array query values require that the matching credential contains at
|
|
44
|
-
// least every value specified. This assumes each element is a literal.
|
|
45
|
-
// The credential side may hold the compacted single-value form.
|
|
46
|
-
const scopeValues = valueList(credentialScope);
|
|
47
|
-
if (scopeValues.length < vprExampleValue.length) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
matches.push(vprExampleValue.every(exampleValue => scopeValues.includes(exampleValue)));
|
|
51
|
-
}
|
|
52
|
-
else if (typeof vprExampleValue === 'object' &&
|
|
53
|
-
vprExampleValue !== null) {
|
|
54
|
-
// Object query values recurse, to handle nested queries.
|
|
55
|
-
matches.push(matchesExampleScope(vprExampleValue, credentialScope));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// Literal query values compare directly, or by membership when the
|
|
59
|
-
// credential holds the array form of the field.
|
|
60
|
-
matches.push(Array.isArray(credentialScope)
|
|
61
|
-
? credentialScope.includes(vprExampleValue)
|
|
62
|
-
: credentialScope === vprExampleValue);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return matches.every(match => match);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Normalizes a credential field value to the array form, so an example's array
|
|
69
|
-
* value can be compared against a field holding either the array or the
|
|
70
|
-
* compacted single value. An absent field yields `[]`.
|
|
71
|
-
*
|
|
72
|
-
* @param value {unknown}
|
|
73
|
-
* @returns {unknown[]}
|
|
74
|
-
*/
|
|
75
|
-
function valueList(value) {
|
|
76
|
-
if (Array.isArray(value)) {
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
if (value === undefined) {
|
|
80
|
-
return [];
|
|
81
|
-
}
|
|
82
|
-
return [value];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The value of an own property of a credential scope, or `undefined` when the
|
|
86
|
-
* scope carries no such property. Example keys are arbitrary strings, so only
|
|
87
|
-
* own properties resolve: an inherited name (`toString`, `constructor`,
|
|
88
|
-
* `__proto__`) reads as absent rather than reaching the prototype chain. An
|
|
89
|
-
* array scope is an ordinary object here -- a key is not mapped over its
|
|
90
|
-
* elements.
|
|
91
|
-
*
|
|
92
|
-
* @param scope {unknown} - The credential value to read from.
|
|
93
|
-
* @param key {string} - The literal property name.
|
|
94
|
-
* @returns {unknown}
|
|
95
|
-
*/
|
|
96
|
-
function propertyOf(scope, key) {
|
|
97
|
-
if (scope === null || scope === undefined) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
if (!Object.hasOwn(scope, key)) {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
return scope[key];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Filters credentials to those matching a `QueryByExample`, using the deep
|
|
107
|
-
* matcher. Each of the query's `credentialQuery` details contributes its
|
|
108
|
-
* `example`; a credential is included when it matches any of them. A malformed
|
|
109
|
-
* query with no example matches nothing.
|
|
110
|
-
*
|
|
111
|
-
* @param credentials {IVerifiableCredential[]}
|
|
112
|
-
* @param query {IQueryByExample}
|
|
113
|
-
* @returns {IVerifiableCredential[]}
|
|
114
|
-
*/
|
|
115
|
-
export function filterCredentialsByExample(credentials, query) {
|
|
116
|
-
const examples = credentialQueriesOf(query)
|
|
117
|
-
.map(({ example }) => example)
|
|
118
|
-
.filter((example) => !!example);
|
|
119
|
-
if (examples.length === 0) {
|
|
120
|
-
// Malformed request: no example to match against.
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
return credentials.filter(credential => examples.some(example => credentialMatchesVprExampleQuery(example, credential)));
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Whether a credential matches a single QueryByExample `example` by the
|
|
127
|
-
* type-and-issuer algorithm: every type listed in `example.type` must appear in
|
|
128
|
-
* the credential's `type`, and -- when the example pins an `issuer` -- the
|
|
129
|
-
* credential's issuer must equal it.
|
|
130
|
-
*
|
|
131
|
-
* @param options {object}
|
|
132
|
-
* @param options.credential {IVerifiableCredential}
|
|
133
|
-
* @param options.example {ICredentialQuery['example']}
|
|
134
|
-
* @returns {boolean}
|
|
135
|
-
*/
|
|
136
|
-
function matchesExample({ credential, example }) {
|
|
137
|
-
const wantedTypes = typeArray(example.type);
|
|
138
|
-
const credentialTypes = typeArray(credential.type);
|
|
139
|
-
const typesMatch = wantedTypes.every(type => credentialTypes.includes(type));
|
|
140
|
-
if (!typesMatch) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
const wantedIssuer = issuerId(example.issuer);
|
|
144
|
-
if (wantedIssuer) {
|
|
145
|
-
return issuerId(credential.issuer) === wantedIssuer;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* The credentials matching any of the given QueryByExample queries by the
|
|
151
|
-
* type-and-issuer algorithm. Only queries whose `example` carries a `type`
|
|
152
|
-
* constrain the result; a query with no example type matches nothing here (the
|
|
153
|
-
* caller keeps its list-all behavior when *no* query specifies a type).
|
|
154
|
-
*
|
|
155
|
-
* @param options {object}
|
|
156
|
-
* @param options.credentials {IVerifiableCredential[]}
|
|
157
|
-
* @param options.queries {IQueryByExample[]}
|
|
158
|
-
* @returns {IVerifiableCredential[]}
|
|
159
|
-
*/
|
|
160
|
-
export function vcMatchesFor({ credentials, queries }) {
|
|
161
|
-
const examples = typedExamplesOf(queries);
|
|
162
|
-
if (examples.length === 0) {
|
|
163
|
-
return [];
|
|
164
|
-
}
|
|
165
|
-
return credentials.filter(credential => examples.some(example => matchesExample({ credential, example })));
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* The example credential shapes pinned by a query set: every `credentialQuery`
|
|
169
|
-
* detail carrying an example `type`. Only these constrain the share list.
|
|
170
|
-
*
|
|
171
|
-
* @param queries {IQueryByExample[]}
|
|
172
|
-
* @returns {Array<ICredentialQuery['example']>}
|
|
173
|
-
*/
|
|
174
|
-
function typedExamplesOf(queries) {
|
|
175
|
-
return queries
|
|
176
|
-
.flatMap(query => credentialQueriesOf(query))
|
|
177
|
-
.map(({ example }) => example)
|
|
178
|
-
.filter((example) => !!example && typeArray(example.type).length > 0);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Whether any of the QueryByExample queries pins an example `type` (and so
|
|
182
|
-
* should filter the share list). When false, the caller keeps showing all
|
|
183
|
-
* stored credentials.
|
|
184
|
-
*
|
|
185
|
-
* @param queries {IQueryByExample[]}
|
|
186
|
-
* @returns {boolean}
|
|
187
|
-
*/
|
|
188
|
-
export function hasTypedExample(queries) {
|
|
189
|
-
return typedExamplesOf(queries).length > 0;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Whether any typed example in the query set explicitly lists the given
|
|
193
|
-
* credential `type`. Lets the caller distinguish a request that actually asks
|
|
194
|
-
* for a particular type (e.g. a LoginCredential) from a generic, untyped "any
|
|
195
|
-
* VC" request.
|
|
196
|
-
*
|
|
197
|
-
* @param options {object}
|
|
198
|
-
* @param options.queries {IQueryByExample[]}
|
|
199
|
-
* @param options.type {string}
|
|
200
|
-
* @returns {boolean}
|
|
201
|
-
*/
|
|
202
|
-
export function requestsCredentialType({ queries, type }) {
|
|
203
|
-
return typedExamplesOf(queries).some(example => typeArray(example.type).includes(type));
|
|
204
|
-
}
|
|
205
|
-
//# sourceMappingURL=matching.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matching.js","sourceRoot":"","sources":["../../src/request/matching.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAEzE,+EAA+E;AAC/E,kDAAkD;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAWzE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gCAAgC,CAC9C,UAAmC,EACnC,UAAiC;IA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AC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAClD,CAAA;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACxD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,OAAO,EACP,IAAI,EAIL;IACC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAC7C,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CACvC,CAAA;AACH,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { IVPRDetails, IVPRQuery, IWalletOnboardingRequest } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Validates a wallet-onboarding `host` and returns its serialized form. The
|
|
4
|
-
* value must parse as an absolute URL and must be `http:` or `https:` (it is
|
|
5
|
-
* dereferenced as a WAS server base URL) and must not carry a fragment; any
|
|
6
|
-
* violation throws. Compose and classification share this one rule, so the
|
|
7
|
-
* spelling the inviter publishes is the spelling the enrollee resolves, and
|
|
8
|
-
* URLs differing only in a default port, percent-encoding case, or dot
|
|
9
|
-
* segments do not name distinct servers.
|
|
10
|
-
*
|
|
11
|
-
* There is no attested origin to compare against here -- an exchange has no
|
|
12
|
-
* CHAPI requesting origin -- so unlike an App Connect `appUrl` the check is
|
|
13
|
-
* shape only. The channel's trust comes from the point-to-point fingerprint
|
|
14
|
-
* comparison of the enrollment ceremony, not from this value.
|
|
15
|
-
*
|
|
16
|
-
* The fragment check reads the serialized URL rather than `url.hash`: a bare
|
|
17
|
-
* trailing `#` sets an empty (non-null) fragment that `hash` reports as `''`.
|
|
18
|
-
*
|
|
19
|
-
* @param options {object}
|
|
20
|
-
* @param options.host {string} - The query's `host`.
|
|
21
|
-
* @returns {string} The parsed URL's serialization.
|
|
22
|
-
*/
|
|
23
|
-
export declare function serializedOnboardingHost({ host }: {
|
|
24
|
-
host: string;
|
|
25
|
-
}): string;
|
|
26
|
-
/**
|
|
27
|
-
* Validates the account members a `WalletOnboardingQuery` carries and returns
|
|
28
|
-
* them in the classified form: the account's did:webvh `did`, its `spaceId`,
|
|
29
|
-
* the serialized `host`, and the account controller did:key. Compose and
|
|
30
|
-
* classification share this one rule, so the two sides cannot drift.
|
|
31
|
-
*
|
|
32
|
-
* The `did` must be a did:webvh id: only a promoted account (one whose Space
|
|
33
|
-
* controller is its published did:webvh) has the world-readable log the
|
|
34
|
-
* enrollee verifies its approval from. The `controller` check is shape only
|
|
35
|
-
* (a non-empty `did:key:` string) -- it is a discovery value the enrollee
|
|
36
|
-
* stores, and the channel's trust comes from the ceremony's confirmation-code
|
|
37
|
-
* comparison, not from any member of the query.
|
|
38
|
-
*
|
|
39
|
-
* @param options {object}
|
|
40
|
-
* @param options.did {string | undefined} the account's did:webvh id.
|
|
41
|
-
* @param options.spaceId {string | undefined} the account's Space id.
|
|
42
|
-
* @param options.host {string | undefined} the WAS server base URL.
|
|
43
|
-
* @param options.controller {string | undefined} the account controller
|
|
44
|
-
* did:key.
|
|
45
|
-
* @returns {IWalletOnboardingRequest}
|
|
46
|
-
*/
|
|
47
|
-
export declare function validatedOnboardingAccount({ did, spaceId, host, controller }: {
|
|
48
|
-
did?: string | undefined;
|
|
49
|
-
spaceId?: string | undefined;
|
|
50
|
-
host?: string | undefined;
|
|
51
|
-
controller?: string | undefined;
|
|
52
|
-
}): IWalletOnboardingRequest;
|
|
53
|
-
/**
|
|
54
|
-
* INVITER: the VPR details body to store on the ephemeral exchange -- one
|
|
55
|
-
* `WalletOnboardingQuery` and nothing else, since the query is one mental
|
|
56
|
-
* model per exchange. The account members are validated by
|
|
57
|
-
* {@link validatedOnboardingAccount} and the `host` is stored in its
|
|
58
|
-
* serialized form ({@link serializedOnboardingHost}).
|
|
59
|
-
*
|
|
60
|
-
* @param options {object}
|
|
61
|
-
* @param options.pointer {object} the account pointer (keyring's
|
|
62
|
-
* `AccountPointer` shape: the inviter passes its session pointer straight
|
|
63
|
-
* in), whose `did` must already be the promoted did:webvh id.
|
|
64
|
-
* @param options.controller {string} the account controller did:key.
|
|
65
|
-
* @returns {IVPRDetails}
|
|
66
|
-
*/
|
|
67
|
-
export declare function composeWalletOnboardingRequest({ pointer, controller }: {
|
|
68
|
-
pointer: {
|
|
69
|
-
did?: string;
|
|
70
|
-
spaceId: string;
|
|
71
|
-
host: string;
|
|
72
|
-
};
|
|
73
|
-
controller: string;
|
|
74
|
-
}): IVPRDetails;
|
|
75
|
-
/**
|
|
76
|
-
* ENROLLEE: extracts the wallet-onboarding request from a query set, when one
|
|
77
|
-
* is present. Like an `AppConnectQuery`, a `WalletOnboardingQuery` is one
|
|
78
|
-
* mental model per exchange: at most one may appear, and it must not be
|
|
79
|
-
* combined with `QueryByExample`, standalone capability queries, or an
|
|
80
|
-
* `AppConnectQuery` (a screen that asks the person to connect a wallet must
|
|
81
|
-
* not simultaneously ask them to share credentials or grant capabilities).
|
|
82
|
-
* Its account members must satisfy {@link validatedOnboardingAccount} (so a
|
|
83
|
-
* query missing the pointer or the controller is malformed), and its `host` is
|
|
84
|
-
* rewritten to its serialized form. Violations throw; classification-time
|
|
85
|
-
* callers surface the throw as a malformed-request state.
|
|
86
|
-
*
|
|
87
|
-
* @param options {object}
|
|
88
|
-
* @param options.queries {IVPRQuery[]}
|
|
89
|
-
* @returns {IWalletOnboardingRequest | null}
|
|
90
|
-
*/
|
|
91
|
-
export declare function walletOnboardingRequestOf({ queries }: {
|
|
92
|
-
queries: IVPRQuery[];
|
|
93
|
-
}): IWalletOnboardingRequest | null;
|
|
94
|
-
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/request/onboarding.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EAET,wBAAwB,EACzB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAc3E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,EACX,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAChC,GAAG,wBAAwB,CA6B3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,OAAO,EACP,UAAU,EACX,EAAE;IACD,OAAO,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxD,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,WAAW,CAMd;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,OAAO,EACR,EAAE;IACD,OAAO,EAAE,SAAS,EAAE,CAAA;CACrB,GAAG,wBAAwB,GAAG,IAAI,CAkBlC"}
|