@interop/wallet-core 0.1.1 → 0.2.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 +18 -2
- package/dist/display/alignment.d.ts +49 -0
- package/dist/display/alignment.d.ts.map +1 -0
- package/dist/display/alignment.js +114 -0
- package/dist/display/alignment.js.map +1 -0
- package/dist/display/credentialName.d.ts +42 -0
- package/dist/display/credentialName.d.ts.map +1 -0
- package/dist/display/credentialName.js +106 -0
- package/dist/display/credentialName.js.map +1 -0
- package/dist/display/displayFields.d.ts +55 -0
- package/dist/display/displayFields.d.ts.map +1 -0
- package/dist/display/displayFields.js +136 -0
- package/dist/display/displayFields.js.map +1 -0
- package/dist/display/evidence.d.ts +44 -0
- package/dist/display/evidence.d.ts.map +1 -0
- package/dist/display/evidence.js +65 -0
- package/dist/display/evidence.js.map +1 -0
- package/dist/display/image.d.ts +18 -0
- package/dist/display/image.d.ts.map +1 -0
- package/dist/display/image.js +23 -0
- package/dist/display/image.js.map +1 -0
- package/dist/display/index.d.ts +38 -0
- package/dist/display/index.d.ts.map +1 -0
- package/dist/display/index.js +32 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/issuer.d.ts +97 -0
- package/dist/display/issuer.d.ts.map +1 -0
- package/dist/display/issuer.js +126 -0
- package/dist/display/issuer.js.map +1 -0
- package/dist/display/obv3.d.ts +77 -0
- package/dist/display/obv3.d.ts.map +1 -0
- package/dist/display/obv3.js +127 -0
- package/dist/display/obv3.js.map +1 -0
- package/dist/display/parse.d.ts +62 -0
- package/dist/display/parse.d.ts.map +1 -0
- package/dist/display/parse.js +100 -0
- package/dist/display/parse.js.map +1 -0
- package/dist/display/subject.d.ts +75 -0
- package/dist/display/subject.d.ts.map +1 -0
- package/dist/display/subject.js +122 -0
- package/dist/display/subject.js.map +1 -0
- package/dist/display/text.d.ts +42 -0
- package/dist/display/text.d.ts.map +1 -0
- package/dist/display/text.js +62 -0
- package/dist/display/text.js.map +1 -0
- package/dist/display/types.d.ts +55 -0
- package/dist/display/types.d.ts.map +1 -0
- package/dist/display/types.js +41 -0
- package/dist/display/types.js.map +1 -0
- package/dist/display/validity.d.ts +51 -0
- package/dist/display/validity.d.ts.map +1 -0
- package/dist/display/validity.js +51 -0
- package/dist/display/validity.js.map +1 -0
- package/dist/display/verificationView.d.ts +101 -0
- package/dist/display/verificationView.d.ts.map +1 -0
- package/dist/display/verificationView.js +199 -0
- package/dist/display/verificationView.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/request/classify.d.ts +112 -0
- package/dist/request/classify.d.ts.map +1 -0
- package/dist/request/classify.js +210 -0
- package/dist/request/classify.js.map +1 -0
- package/dist/request/composeVp.d.ts +52 -0
- package/dist/request/composeVp.d.ts.map +1 -0
- package/dist/request/composeVp.js +177 -0
- package/dist/request/composeVp.js.map +1 -0
- package/dist/request/exchangeClient.d.ts +165 -0
- package/dist/request/exchangeClient.d.ts.map +1 -0
- package/dist/request/exchangeClient.js +212 -0
- package/dist/request/exchangeClient.js.map +1 -0
- package/dist/request/index.d.ts +35 -0
- package/dist/request/index.d.ts.map +1 -0
- package/dist/request/index.js +35 -0
- package/dist/request/index.js.map +1 -0
- package/dist/request/interactionUrl.d.ts +53 -0
- package/dist/request/interactionUrl.d.ts.map +1 -0
- package/dist/request/interactionUrl.js +83 -0
- package/dist/request/interactionUrl.js.map +1 -0
- package/dist/request/matching.d.ts +69 -0
- package/dist/request/matching.d.ts.map +1 -0
- package/dist/request/matching.js +183 -0
- package/dist/request/matching.js.map +1 -0
- package/dist/request/parse.d.ts +68 -0
- package/dist/request/parse.d.ts.map +1 -0
- package/dist/request/parse.js +114 -0
- package/dist/request/parse.js.map +1 -0
- package/dist/request/presentationSuite.d.ts +71 -0
- package/dist/request/presentationSuite.d.ts.map +1 -0
- package/dist/request/presentationSuite.js +139 -0
- package/dist/request/presentationSuite.js.map +1 -0
- package/dist/request/processRequest.d.ts +48 -0
- package/dist/request/processRequest.d.ts.map +1 -0
- package/dist/request/processRequest.js +139 -0
- package/dist/request/processRequest.js.map +1 -0
- package/dist/request/types.d.ts +150 -0
- package/dist/request/types.d.ts.map +1 -0
- package/dist/request/types.js +2 -0
- package/dist/request/types.js.map +1 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/package.json +21 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Framework-agnostic request processing: turns a classified VPR body plus the
|
|
6
|
+
* user's VC selection into a {@link WalletResponse} (a possibly-signed VP, plus
|
|
7
|
+
* any delegated zcaps). The response channel (CHAPI `respondWith`, an
|
|
8
|
+
* exchange-URL POST) stays with the caller -- this function only returns data,
|
|
9
|
+
* and assumes the user has already consented and picked which credentials to
|
|
10
|
+
* send.
|
|
11
|
+
*
|
|
12
|
+
* Ported from Freewallet's `src/lib/walletRequest/processRequest.ts` (the pure
|
|
13
|
+
* shape). The two app-specific side effects -- capability delegation and the App
|
|
14
|
+
* Connect branch -- are injected as {@link RequestProcessors} rather than
|
|
15
|
+
* imported, so this layer carries no session / grant-resolution machinery. The
|
|
16
|
+
* signer and holder DID are injected as a {@link PresentationSigner}.
|
|
17
|
+
*/
|
|
18
|
+
import { classifyRequest, queriesOf } from './classify.js';
|
|
19
|
+
import { composeVp } from './composeVp.js';
|
|
20
|
+
import { negotiateCryptosuite } from './presentationSuite.js';
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the host (`host:port`) from a value that may be a full URL or a bare
|
|
23
|
+
* host / host:port. Returns undefined if it cannot be parsed.
|
|
24
|
+
*/
|
|
25
|
+
function hostOf(value) {
|
|
26
|
+
try {
|
|
27
|
+
const url = value.includes('://')
|
|
28
|
+
? new URL(value)
|
|
29
|
+
: new URL(`https://${value}`);
|
|
30
|
+
return url.host;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.warn(`Could not parse host from "${value}":`, err);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Domain-binding check (VCALM §3.4.3 advisement): a DID-Auth `domain` MUST match
|
|
39
|
+
* the channel the request arrived on, otherwise a dishonest verifier could relay
|
|
40
|
+
* the challenge from another origin and replay the response.
|
|
41
|
+
*
|
|
42
|
+
* @param options {object}
|
|
43
|
+
* @param options.domain {string} - The `domain` from the request.
|
|
44
|
+
* @param [options.origin] {string} - The channel origin (for CHAPI,
|
|
45
|
+
* `event.credentialRequestOrigin`).
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
export function domainMatchesOrigin({ domain, origin }) {
|
|
49
|
+
if (!origin) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const originHost = hostOf(origin);
|
|
53
|
+
const domainHost = hostOf(domain);
|
|
54
|
+
return !!originHost && originHost === domainHost;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Processes a Verifiable Presentation Request and composes the wallet's
|
|
58
|
+
* response. Assumes the user has already consented and (for VC sharing) picked
|
|
59
|
+
* which credentials to send.
|
|
60
|
+
*
|
|
61
|
+
* @param options {object}
|
|
62
|
+
* @param options.request {IVPRDetails} - The VPR body.
|
|
63
|
+
* @param options.presentationSigner {PresentationSigner} - Authentication signer
|
|
64
|
+
* and holder DID.
|
|
65
|
+
* @param [options.selectedVCs] {IVerifiableCredential[]} - VCs the user chose to
|
|
66
|
+
* share (empty for a DID-Auth-only or zcap-only response).
|
|
67
|
+
* @param [options.credentialRequestOrigin] {string} - Channel origin, used for
|
|
68
|
+
* the domain-binding check and required by the App Connect branch.
|
|
69
|
+
* @param [options.processors] {RequestProcessors} - App-side capability /
|
|
70
|
+
* App Connect processors.
|
|
71
|
+
* @param [options.cryptosuite] {string} - Cryptosuite override; when absent it
|
|
72
|
+
* is negotiated from the request's `acceptedCryptosuites`.
|
|
73
|
+
* @param [options.vocabBaseIri] {string} - Vocabulary base IRI passed through to
|
|
74
|
+
* {@link composeVp} for embedded-grant term definitions.
|
|
75
|
+
* @returns {Promise<WalletResponse>} The response VP (and any granted zcaps), or
|
|
76
|
+
* `{}` when there is nothing to send.
|
|
77
|
+
*/
|
|
78
|
+
export async function processRequest({ request, presentationSigner, selectedVCs = [], credentialRequestOrigin, processors, cryptosuite, vocabBaseIri }) {
|
|
79
|
+
const { didAuth, zcapRequests } = classifyRequest(request);
|
|
80
|
+
const queries = queriesOf(request);
|
|
81
|
+
const { challenge, domain } = request;
|
|
82
|
+
// Honor any cryptosuite the verifier asks for (VCALM `acceptedCryptosuites`),
|
|
83
|
+
// unless the caller pinned one.
|
|
84
|
+
const negotiatedCryptosuite = cryptosuite ?? negotiateCryptosuite(queries);
|
|
85
|
+
// Security: never sign an authentication proof bound to a domain the request
|
|
86
|
+
// did not actually arrive from. Enforced whenever a `domain` is present,
|
|
87
|
+
// including a zcap-only request whose (unsigned) VP still names an origin.
|
|
88
|
+
if (domain &&
|
|
89
|
+
!domainMatchesOrigin({ domain, origin: credentialRequestOrigin })) {
|
|
90
|
+
throw new Error(`DID Auth domain "${domain}" does not match request origin ` +
|
|
91
|
+
`"${credentialRequestOrigin}".`);
|
|
92
|
+
}
|
|
93
|
+
// An App Connect request (a Freewallet-only query kind) takes its own
|
|
94
|
+
// single-round branch, handled entirely by the injected processor. The
|
|
95
|
+
// requesting origin is what the app key is bound to, so it is required.
|
|
96
|
+
// `AppConnectQuery` is a Freewallet-side extension to the VPR query union, so
|
|
97
|
+
// it is matched by its `type` string rather than a union member here.
|
|
98
|
+
const appConnectRequested = queries.some(q => q.type === 'AppConnectQuery');
|
|
99
|
+
if (appConnectRequested) {
|
|
100
|
+
if (!processors?.processAppConnect) {
|
|
101
|
+
throw new Error('An App Connect request was received but no processAppConnect ' +
|
|
102
|
+
'processor was provided.');
|
|
103
|
+
}
|
|
104
|
+
if (!credentialRequestOrigin) {
|
|
105
|
+
throw new Error('An App Connect request requires a requesting origin.');
|
|
106
|
+
}
|
|
107
|
+
return processors.processAppConnect({
|
|
108
|
+
request,
|
|
109
|
+
origin: credentialRequestOrigin,
|
|
110
|
+
challenge,
|
|
111
|
+
domain,
|
|
112
|
+
didAuthRequested: didAuth,
|
|
113
|
+
cryptosuite: negotiatedCryptosuite
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// Delegate the approved capabilities first, then embed them in the VP.
|
|
117
|
+
const zcaps = zcapRequests.length > 0 && processors?.processZcaps
|
|
118
|
+
? await processors.processZcaps({ zcapRequests })
|
|
119
|
+
: [];
|
|
120
|
+
if (!didAuth && selectedVCs.length === 0 && zcaps.length === 0) {
|
|
121
|
+
// Nothing to send: no DID Auth, no VCs, and no satisfiable grants.
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
const verifiablePresentation = await composeVp({
|
|
125
|
+
presentationSigner,
|
|
126
|
+
selectedVcs: selectedVCs,
|
|
127
|
+
challenge,
|
|
128
|
+
domain,
|
|
129
|
+
didAuthRequested: didAuth,
|
|
130
|
+
cryptosuite: negotiatedCryptosuite,
|
|
131
|
+
zcaps,
|
|
132
|
+
...(vocabBaseIri !== undefined && { vocabBaseIri })
|
|
133
|
+
});
|
|
134
|
+
// Return the delegated capabilities alongside the VP so the caller can log
|
|
135
|
+
// exactly what was granted from these objects, rather than reading them back
|
|
136
|
+
// off the composed VP.
|
|
137
|
+
return { verifiablePresentation, zcaps };
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=processRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/request/processRequest.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,SAAS,E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AI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/D,mEAAmE;QACnE,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC;QAC7C,kBAAkB;QAClB,WAAW,EAAE,WAAW;QACxB,SAAS;QACT,MAAM;QACN,gBAAgB,EAAE,OAAO;QACzB,WAAW,EAAE,qBAAqB;QAClC,KAAK;QACL,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,CAAC;KACpD,CAAC,CAAA;IACF,2EAA2E;IAC3E,6EAA6E;IAC7E,uBAAuB;IACvB,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Shared types for the `@interop/wallet-core/request` subpath. The Verifiable
|
|
6
|
+
* Presentation Request (VPR) vocabulary itself is owned by
|
|
7
|
+
* `@interop/data-integrity-core` (its `VPR` module) and re-exported here so a
|
|
8
|
+
* request consumer imports one package; this file adds only the request-local
|
|
9
|
+
* types the app sources carried alongside that vocabulary: the CHAPI event
|
|
10
|
+
* shapes, the VC-API exchange reply shape, the classified-request profile, and
|
|
11
|
+
* the injection-seam types (`PresentationSigner`, `FetchLike`,
|
|
12
|
+
* `RequestProcessors`) that keep this layer free of any single app's session /
|
|
13
|
+
* network / consent machinery.
|
|
14
|
+
*
|
|
15
|
+
* Ported from DCW's `app/lib/walletRequestApi.ts` and Freewallet's
|
|
16
|
+
* `src/lib/walletRequest/{types,classify}.ts`.
|
|
17
|
+
*
|
|
18
|
+
* The VPR vocabulary (and the loose-shape guards in `classify` / `matching`) is
|
|
19
|
+
* imported from the `@interop/data-integrity-core/vpr` and `/guards` subpaths
|
|
20
|
+
* rather than the package root: the vocabulary was added to data-integrity-core
|
|
21
|
+
* without a version bump, so the package root can dedup onto an older cached
|
|
22
|
+
* build that predates it, whereas the subpath entry points resolve only against
|
|
23
|
+
* the current build that defines them.
|
|
24
|
+
*/
|
|
25
|
+
import type { ISigner } from '@interop/data-integrity-core';
|
|
26
|
+
import type { IVerifiableCredential, IVerifiablePresentation, IZcap } from '@interop/data-integrity-core';
|
|
27
|
+
import type { ICapabilityQueryDetail, IQueryByExample, IVPRDetails, WalletResponse } from '@interop/data-integrity-core/vpr';
|
|
28
|
+
export type { IVPRequest, IVPOffer, IIssueRequest, IExchangeInvitation, IOid4VCIOffer, IVPRDetails, IVPRInteract, IVPRQuery, IQueryByExample, ICredentialQuery, IAcceptedCryptosuites, IDIDAuthenticationQuery, IZcapQuery, ICapabilityQueryDetail, IInvocationTarget, IAllowedAction, WalletApiMessage, WalletResponse, IVpRequest, IVpOffer, IVprDetails, IVprQuery, IDidAuthenticationQuery } from '@interop/data-integrity-core/vpr';
|
|
29
|
+
export type { IVerifiableCredential, IVerifiablePresentation, IZcap } from '@interop/data-integrity-core';
|
|
30
|
+
/**
|
|
31
|
+
* The protocol handles a verifier offers alongside a CHAPI request. Only
|
|
32
|
+
* `vcapi` (and the newer `interact` meta-protocol) are acted on; `OID4VP` /
|
|
33
|
+
* `OID4VCI` are recognized but unused.
|
|
34
|
+
*/
|
|
35
|
+
export interface CHAPIProtocols {
|
|
36
|
+
vcapi?: string;
|
|
37
|
+
interact?: string;
|
|
38
|
+
OID4VP?: string;
|
|
39
|
+
OID4VCI?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Raw CHAPI credential-get event. The `VerifiablePresentation` object CHAPI
|
|
43
|
+
* hands us *is* the VPR body (`query` / `challenge` / `domain`); classification
|
|
44
|
+
* rewraps it as an `IVPRequest`. When the verifier names a `protocols` handle
|
|
45
|
+
* it sends that body empty instead, and the VPR must be fetched from the
|
|
46
|
+
* protocol exchange (see `exchangeClient.ts`).
|
|
47
|
+
*/
|
|
48
|
+
export interface CHAPIGetEvent {
|
|
49
|
+
credentialRequestOrigin: string;
|
|
50
|
+
credentialRequestOptions?: {
|
|
51
|
+
web?: {
|
|
52
|
+
VerifiablePresentation?: IVPRDetails;
|
|
53
|
+
protocols?: CHAPIProtocols;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
respondWith(promise: Promise<{
|
|
57
|
+
dataType: string;
|
|
58
|
+
data: unknown;
|
|
59
|
+
} | null>): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Raw CHAPI credential-store event. `credential.data` is the offered payload,
|
|
63
|
+
* and `credential.dataType` names its shape: issuers may offer either a
|
|
64
|
+
* `VerifiablePresentation` wrapping the credential(s), or a bare
|
|
65
|
+
* `VerifiableCredential` (what vcplayground.org sends). An issuer that names a
|
|
66
|
+
* `protocols` handle in `credential.options` sends `data` empty instead, and
|
|
67
|
+
* the offered credentials must be fetched from the protocol exchange (see
|
|
68
|
+
* `exchangeClient.ts`).
|
|
69
|
+
*/
|
|
70
|
+
export interface CHAPIStoreEvent {
|
|
71
|
+
credentialRequestOrigin?: string;
|
|
72
|
+
credential: {
|
|
73
|
+
dataType?: string;
|
|
74
|
+
data: IVerifiablePresentation | IVerifiableCredential;
|
|
75
|
+
options?: {
|
|
76
|
+
protocols?: CHAPIProtocols;
|
|
77
|
+
recommendedHandlerOrigins?: string[];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
respondWith(promise: Promise<{
|
|
81
|
+
dataType: string;
|
|
82
|
+
data: unknown;
|
|
83
|
+
} | null>): void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The exchange's reply to either wallet call. A multi-step exchange answers a
|
|
87
|
+
* submitted presentation with another `verifiablePresentationRequest`; a
|
|
88
|
+
* finished one answers with nothing, or with credentials it issued, or with a
|
|
89
|
+
* `redirectUrl` for the user to land on.
|
|
90
|
+
*/
|
|
91
|
+
export interface VCAPIExchangeResponse {
|
|
92
|
+
verifiablePresentationRequest?: IVPRDetails;
|
|
93
|
+
verifiablePresentation?: IVerifiablePresentation;
|
|
94
|
+
redirectUrl?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A VP Request classified on independent axes: whether DID Authentication is
|
|
98
|
+
* requested, what credentials are asked for (`vcQueries`), and what capability
|
|
99
|
+
* delegations are asked for (`zcapRequests`). Any combination is valid,
|
|
100
|
+
* including zcap-only. An app that layers additional query kinds on top (e.g.
|
|
101
|
+
* Freewallet's App Connect) extends this shape with its own field.
|
|
102
|
+
*/
|
|
103
|
+
export interface WalletRequestProfile {
|
|
104
|
+
didAuth: boolean;
|
|
105
|
+
vcQueries: IQueryByExample[];
|
|
106
|
+
zcapRequests: ICapabilityQueryDetail[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The authentication signer plus the DID to name as the VP `holder`. Each app
|
|
110
|
+
* resolves this from its own key material (DCW from the selected profile's
|
|
111
|
+
* `authentication` signer + DID; Freewallet from the KMS did:web key or the
|
|
112
|
+
* passphrase-derived root key) before handing it to the shared compose path.
|
|
113
|
+
*/
|
|
114
|
+
export interface PresentationSigner {
|
|
115
|
+
signer: ISigner;
|
|
116
|
+
holder: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Injected network transport. Defaults to `globalThis.fetch`; DCW passes its
|
|
120
|
+
* `fetchWithTimeout`, Freewallet its CORS-proxy fetch.
|
|
121
|
+
*/
|
|
122
|
+
export type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
|
|
123
|
+
/**
|
|
124
|
+
* App-side processors injected into {@link processRequest}. Both are optional:
|
|
125
|
+
* a wallet that grants no capabilities omits `processZcaps`, and a wallet
|
|
126
|
+
* without an App Connect flow omits `processAppConnect` (the branch is then
|
|
127
|
+
* inert).
|
|
128
|
+
*/
|
|
129
|
+
export interface RequestProcessors {
|
|
130
|
+
/**
|
|
131
|
+
* Delegates the approved capabilities and returns the minted zcaps.
|
|
132
|
+
* Freewallet supplies `processZcaps(session)`; DCW supplies a no-op / `[]`.
|
|
133
|
+
*/
|
|
134
|
+
processZcaps?: (args: {
|
|
135
|
+
zcapRequests: ICapabilityQueryDetail[];
|
|
136
|
+
}) => Promise<IZcap[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Handles the App Connect single-round branch (Freewallet only). Invoked when
|
|
139
|
+
* the request carries an `AppConnectQuery`; absent for DCW.
|
|
140
|
+
*/
|
|
141
|
+
processAppConnect?: (args: {
|
|
142
|
+
request: IVPRDetails;
|
|
143
|
+
origin: string;
|
|
144
|
+
challenge?: string;
|
|
145
|
+
domain?: string;
|
|
146
|
+
didAuthRequested: boolean;
|
|
147
|
+
cryptosuite?: string;
|
|
148
|
+
}) => Promise<WalletResponse>;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/request/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,EACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,cAAc,EACf,MAAM,kCAAkC,CAAA;AAMzC,YAAY,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,uBAAuB,EACxB,MAAM,kCAAkC,CAAA;AACzC,YAAY,EACV,qBAAqB,EACrB,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AED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,eAAe,EAAE,CAAA;IAC5B,YAAY,EAAE,sBAAsB,EAAE,CAAA;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,sBAAsB,EAAE,CAAA;KACvC,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QACzB,OAAO,EAAE,WAAW,CAAA;QACpB,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,gBAAgB,EAAE,OAAO,CAAA;QACzB,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/request/types.ts"],"names":[],"mappings":""}
|
package/dist/sync/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AACjC,YAAY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Shared wallet-domain logic (WAS sync engine core and wallet Space layout contracts) for Interop wallet apps.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -41,6 +41,18 @@
|
|
|
41
41
|
"react-native": "./dist/space/index.js",
|
|
42
42
|
"import": "./dist/space/index.js",
|
|
43
43
|
"default": "./dist/space/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./request": {
|
|
46
|
+
"types": "./dist/request/index.d.ts",
|
|
47
|
+
"react-native": "./dist/request/index.js",
|
|
48
|
+
"import": "./dist/request/index.js",
|
|
49
|
+
"default": "./dist/request/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./display": {
|
|
52
|
+
"types": "./dist/display/index.d.ts",
|
|
53
|
+
"react-native": "./dist/display/index.js",
|
|
54
|
+
"import": "./dist/display/index.js",
|
|
55
|
+
"default": "./dist/display/index.js"
|
|
44
56
|
}
|
|
45
57
|
},
|
|
46
58
|
"module": "dist/index.js",
|
|
@@ -48,11 +60,18 @@
|
|
|
48
60
|
"types": "dist/index.d.ts",
|
|
49
61
|
"sideEffects": false,
|
|
50
62
|
"dependencies": {
|
|
63
|
+
"@interop/data-integrity-core": "^8.4.0",
|
|
64
|
+
"@interop/data-integrity-proof": "^3.4.2",
|
|
65
|
+
"@interop/ed25519-signature": "^7.1.4",
|
|
66
|
+
"@interop/security-document-loader": "^9.4.4",
|
|
67
|
+
"@interop/vc": "^11.0.5",
|
|
51
68
|
"@interop/was-client": "^0.19.0",
|
|
52
|
-
"@scure/base": "^1.2.1"
|
|
69
|
+
"@scure/base": "^1.2.1",
|
|
70
|
+
"jsonpath-plus": "^10.3.0"
|
|
53
71
|
},
|
|
54
72
|
"devDependencies": {
|
|
55
73
|
"@eslint/js": "^10.0.1",
|
|
74
|
+
"@interop/ed25519-verification-key": "^8.0.3",
|
|
56
75
|
"@playwright/test": "^1.60.0",
|
|
57
76
|
"@types/node": "^26.0.1",
|
|
58
77
|
"@vitest/coverage-v8": "^4.1.7",
|