@sirosfoundation/wmp-js 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/profile.d.ts CHANGED
@@ -10,6 +10,27 @@ export interface PeerContext {
10
10
  notify(method: string, params: unknown): Promise<void>;
11
11
  /** Send a JSON-RPC request and wait for the response. */
12
12
  call<T = unknown>(method: string, params: unknown): Promise<T>;
13
+ /**
14
+ * Optional: run `fn` after the response to the wmp.flow.start currently being
15
+ * handled was sent. Call it synchronously from `startFlow`. Nothing runs if
16
+ * that start is answered with an error, and a start that fails discards only
17
+ * its own continuations. Lets a profile send a notification for a flow that
18
+ * must not reach the peer before the start's response.
19
+ */
20
+ afterResponse?(fn: () => void): void;
21
+ /**
22
+ * Optional: an opaque token for the flow `flowId` as it is NOW (undefined if the
23
+ * peer holds no active flow by that id). It changes when the flow ends and the
24
+ * id is started again, so work queued for one flow can tell it is stale.
25
+ */
26
+ flowGeneration?(flowId: string): object | undefined;
27
+ /**
28
+ * Optional: like `notify`, for a flow notification (wmp.flow.complete/error)
29
+ * on behalf of the flow generation `generation` (from {@link flowGeneration}).
30
+ * Rejects without sending when that generation is no longer the flow's, and
31
+ * retires the flow after the send only if it still is.
32
+ */
33
+ notifyFlow?(generation: object | undefined, method: string, params: unknown): Promise<void>;
13
34
  }
14
35
  export interface Profile {
15
36
  /** Profile identifier (e.g., "openid4x", "evidence"). */
@@ -27,6 +48,24 @@ export interface FlowHandler {
27
48
  handleProgress(params: FlowProgressParams): void;
28
49
  handleComplete(params: FlowCompleteParams): void;
29
50
  handleError(params: FlowErrorParams): void;
51
+ /**
52
+ * Optional: refuse a wmp.flow.action for a flow this handler started BEFORE any
53
+ * handler sees it (the Peer calls it for a recorded flow of one of this
54
+ * handler's flow types, whatever handler goes on to answer the action, and
55
+ * before any generic schema validation). `flowType` is the type the Peer
56
+ * recorded for the flow when it started: authoritative, whoever started it.
57
+ * Throw a WMPError to refuse; the error is the response, with no member of the
58
+ * refused params echoed.
59
+ */
60
+ validateAction?(params: FlowActionParams, flowType: string): void;
61
+ /**
62
+ * Optional (go-wmp CapabilityRequirer): the capability that MUST have been
63
+ * negotiated before a flow of `flowType` may start (Core 6.5, 10.3), or ""
64
+ * for none. A Peer refuses wmp.flow.start for a flow type whose capability is
65
+ * not negotiated with -31005 {"unsupported": flowType, "capability": cap}
66
+ * before startFlow is called. A handler that does not implement it is not gated.
67
+ */
68
+ requiredCapability?(flowType: string): string;
30
69
  }
31
70
  export interface MethodHandler {
32
71
  /** Method names this handler supports. */
@@ -0,0 +1,2 @@
1
+ /** Cryptographically secure random bytes (browser, Node 20+, workers). */
2
+ export declare function getRandomValues(n: number): Uint8Array;
package/dist/random.js ADDED
@@ -0,0 +1,7 @@
1
+ /** Cryptographically secure random bytes (browser, Node 20+, workers). */
2
+ export function getRandomValues(n) {
3
+ const c = globalThis.crypto;
4
+ if (!c?.getRandomValues)
5
+ throw new Error("no secure random source available");
6
+ return c.getRandomValues(new Uint8Array(n));
7
+ }
package/dist/relay.js CHANGED
@@ -6,7 +6,8 @@
6
6
  * - Routes incoming traffic to registered participants
7
7
  * - Queues messages when a participant is offline
8
8
  */
9
- import { Method, ErrorCode } from "./types.js";
9
+ import { Method, ErrorCode, VERSION } from "./types.js";
10
+ import { parseVersion } from "./version.js";
10
11
  import { WMPError } from "./jsonrpc.js";
11
12
  // ---------------------------------------------------------------------------
12
13
  // Relay
@@ -46,7 +47,8 @@ export class Relay {
46
47
  expiresAt: now + this.registrationTTL,
47
48
  });
48
49
  const result = {
49
- wmp: { version: "0.1" },
50
+ // The version of the session the request came in on (answered in kind), else the default.
51
+ wmp: { version: parseVersion(p.wmp.version) ? p.wmp.version : VERSION },
50
52
  registered: true,
51
53
  ttl: Math.floor(this.registrationTTL / 1000),
52
54
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * SessionStore — server-side session persistence interface.
3
- * Mirrors go-wmp/pkg/wmp/session.go for alignment.
3
+ * Mirrors go-wmp/pkg/wmp/session.go (v0.11.0) for alignment.
4
4
  */
5
5
  import type { Capabilities, SecurityMode } from "./types.js";
6
6
  export interface Session {
@@ -9,25 +9,97 @@ export interface Session {
9
9
  capabilities: Capabilities;
10
10
  security: SecurityMode;
11
11
  createdAt: string;
12
+ /** RFC 3339 expiry of the session. Absent means the session does not expire. */
12
13
  expiresAt?: string;
13
14
  metadata?: Record<string, unknown>;
15
+ /** Current single-use resumption token (go-wmp Session.ResumptionToken). */
16
+ resumptionToken?: string;
17
+ /**
18
+ * Opaque key of the authenticated principal that created the session
19
+ * (go-wmp Session.Owner). Absent or empty means unowned.
20
+ */
21
+ owner?: string;
22
+ /**
23
+ * RFC 3339 bound on the validity of {@link resumptionToken}. Absent means the
24
+ * token does not expire on its own (it still dies with the session).
25
+ */
26
+ resumptionTokenExpiresAt?: string;
14
27
  }
28
+ /** Sentinel error codes, mirroring the go-wmp sentinel errors in session.go. */
29
+ export type SessionStoreErrorCode = "no_such_session" | "token_mismatch" | "invalid_new_token" | "session_exists" | "token_expired";
30
+ /** Error raised by the optional store extensions. */
31
+ export declare class SessionStoreError extends Error {
32
+ readonly code: SessionStoreErrorCode;
33
+ constructor(code: SessionStoreErrorCode, message: string);
34
+ }
35
+ /** Mirrors go-wmp Session.IsExpired. */
36
+ export declare function isSessionExpired(session: Session, now?: number): boolean;
37
+ /**
38
+ * Mirrors go-wmp Session.OwnedBy: an empty key never matches, so an
39
+ * unauthenticated caller cannot claim an unowned session.
40
+ */
41
+ export declare function sessionOwnedBy(session: Session, ownerKey: string): boolean;
42
+ /**
43
+ * Compares two tokens without an early exit on the first differing character
44
+ * (mirrors go-wmp TokensEqual). Differing lengths are unequal.
45
+ */
46
+ export declare function tokensEqual(a: string, b: string): boolean;
15
47
  export interface SessionStore {
16
48
  create(session: Session): Promise<void>;
49
+ /** Returns the session, or undefined when it is absent or expired. */
17
50
  get(id: string): Promise<Session | undefined>;
18
51
  update(session: Session): Promise<void>;
19
52
  delete(id: string): Promise<void>;
53
+ /** Returns all non-expired sessions where metadata[key] === value. */
54
+ getByMetadata(key: string, value: string): Promise<Session[]>;
55
+ /** Returns all active (non-expired) sessions. */
56
+ list(): Promise<Session[]>;
57
+ /** Removes all expired sessions and returns the count removed. */
20
58
  cleanup(): Promise<number>;
21
59
  }
60
+ /**
61
+ * Optional extension (go-wmp TokenRotator): atomic compare-and-swap rotation of
62
+ * a single-use resumption token. Rejects with a {@link SessionStoreError}:
63
+ * no_such_session (absent or expired), token_mismatch (old token empty or not
64
+ * current), token_expired (current but past resumptionTokenExpiresAt),
65
+ * invalid_new_token (empty or equal to the old token).
66
+ */
67
+ export interface TokenRotator {
68
+ rotateResumptionToken(id: string, oldToken: string, newToken: string, expiresAt?: string): Promise<Session>;
69
+ }
70
+ /** Optional extension (go-wmp SessionCreator): create without overwriting. */
71
+ export interface SessionCreator {
72
+ /** Rejects with session_exists when the id is already stored. */
73
+ createIfAbsent(session: Session): Promise<void>;
74
+ }
75
+ /** Optional extension (go-wmp SessionUpdater): update without resurrecting. */
76
+ export interface SessionUpdater {
77
+ /** Rejects with no_such_session when the id is not stored. */
78
+ updateIfPresent(session: Session): Promise<void>;
79
+ }
80
+ /** Optional extension (go-wmp ExpiredSessionLister). */
81
+ export interface ExpiredSessionLister {
82
+ listExpired(): Promise<Session[]>;
83
+ }
22
84
  /**
23
85
  * In-memory SessionStore — suitable for development and testing.
24
86
  */
25
- export declare class MemorySessionStore implements SessionStore {
26
- private sessions;
87
+ export declare class MemorySessionStore implements SessionStore, TokenRotator, SessionCreator, SessionUpdater, ExpiredSessionLister {
88
+ private readonly sessions;
27
89
  create(session: Session): Promise<void>;
28
90
  get(id: string): Promise<Session | undefined>;
29
91
  update(session: Session): Promise<void>;
30
92
  delete(id: string): Promise<void>;
93
+ getByMetadata(key: string, value: string): Promise<Session[]>;
94
+ list(): Promise<Session[]>;
31
95
  cleanup(): Promise<number>;
96
+ listExpired(): Promise<Session[]>;
97
+ createIfAbsent(session: Session): Promise<void>;
98
+ updateIfPresent(session: Session): Promise<void>;
99
+ /**
100
+ * The stored session is replaced by an updated copy, so objects handed out
101
+ * earlier by {@link get} are never mutated.
102
+ */
103
+ rotateResumptionToken(id: string, oldToken: string, newToken: string, expiresAt?: string): Promise<Session>;
32
104
  get size(): number;
33
105
  }
@@ -1,7 +1,50 @@
1
1
  /**
2
2
  * SessionStore — server-side session persistence interface.
3
- * Mirrors go-wmp/pkg/wmp/session.go for alignment.
3
+ * Mirrors go-wmp/pkg/wmp/session.go (v0.11.0) for alignment.
4
4
  */
5
+ /** Error raised by the optional store extensions. */
6
+ export class SessionStoreError extends Error {
7
+ code;
8
+ constructor(code, message) {
9
+ super(message);
10
+ this.code = code;
11
+ this.name = "SessionStoreError";
12
+ }
13
+ }
14
+ /**
15
+ * True when `now` is past `deadline`. Only an absent (undefined) deadline never
16
+ * expires; a deadline that does not parse, an empty string included, counts as
17
+ * expired (fail closed).
18
+ */
19
+ function pastDeadline(deadline, now) {
20
+ if (deadline === undefined)
21
+ return false;
22
+ const t = Date.parse(deadline);
23
+ return Number.isNaN(t) || now > t;
24
+ }
25
+ /** Mirrors go-wmp Session.IsExpired. */
26
+ export function isSessionExpired(session, now = Date.now()) {
27
+ return pastDeadline(session.expiresAt, now);
28
+ }
29
+ /**
30
+ * Mirrors go-wmp Session.OwnedBy: an empty key never matches, so an
31
+ * unauthenticated caller cannot claim an unowned session.
32
+ */
33
+ export function sessionOwnedBy(session, ownerKey) {
34
+ return ownerKey !== "" && (session.owner ?? "") === ownerKey;
35
+ }
36
+ /**
37
+ * Compares two tokens without an early exit on the first differing character
38
+ * (mirrors go-wmp TokensEqual). Differing lengths are unequal.
39
+ */
40
+ export function tokensEqual(a, b) {
41
+ let diff = a.length ^ b.length;
42
+ const n = Math.max(a.length, b.length);
43
+ for (let i = 0; i < n; i++) {
44
+ diff |= (a.codePointAt(i) ?? 0) ^ (b.codePointAt(i) ?? 0);
45
+ }
46
+ return diff === 0;
47
+ }
5
48
  /**
6
49
  * In-memory SessionStore — suitable for development and testing.
7
50
  */
@@ -11,7 +54,10 @@ export class MemorySessionStore {
11
54
  this.sessions.set(session.id, { ...session });
12
55
  }
13
56
  async get(id) {
14
- return this.sessions.get(id);
57
+ const s = this.sessions.get(id);
58
+ if (!s || isSessionExpired(s))
59
+ return undefined;
60
+ return s;
15
61
  }
16
62
  async update(session) {
17
63
  this.sessions.set(session.id, { ...session });
@@ -19,17 +65,72 @@ export class MemorySessionStore {
19
65
  async delete(id) {
20
66
  this.sessions.delete(id);
21
67
  }
68
+ async getByMetadata(key, value) {
69
+ const now = Date.now();
70
+ const out = [];
71
+ for (const s of this.sessions.values()) {
72
+ if (s.metadata?.[key] === value && !isSessionExpired(s, now))
73
+ out.push(s);
74
+ }
75
+ return out;
76
+ }
77
+ async list() {
78
+ const now = Date.now();
79
+ return [...this.sessions.values()].filter((s) => !isSessionExpired(s, now));
80
+ }
22
81
  async cleanup() {
23
- const now = new Date().toISOString();
82
+ const now = Date.now();
24
83
  let count = 0;
25
84
  for (const [id, session] of this.sessions) {
26
- if (session.expiresAt && session.expiresAt < now) {
85
+ if (isSessionExpired(session, now)) {
27
86
  this.sessions.delete(id);
28
87
  count++;
29
88
  }
30
89
  }
31
90
  return count;
32
91
  }
92
+ async listExpired() {
93
+ const now = Date.now();
94
+ return [...this.sessions.values()].filter((s) => isSessionExpired(s, now));
95
+ }
96
+ async createIfAbsent(session) {
97
+ if (this.sessions.has(session.id)) {
98
+ throw new SessionStoreError("session_exists", "wmp: session already exists");
99
+ }
100
+ this.sessions.set(session.id, { ...session });
101
+ }
102
+ async updateIfPresent(session) {
103
+ if (!this.sessions.has(session.id)) {
104
+ throw new SessionStoreError("no_such_session", "wmp: no such session");
105
+ }
106
+ this.sessions.set(session.id, { ...session });
107
+ }
108
+ /**
109
+ * The stored session is replaced by an updated copy, so objects handed out
110
+ * earlier by {@link get} are never mutated.
111
+ */
112
+ async rotateResumptionToken(id, oldToken, newToken, expiresAt) {
113
+ if (newToken === "" || tokensEqual(newToken, oldToken)) {
114
+ throw new SessionStoreError("invalid_new_token", "wmp: invalid replacement resumption token");
115
+ }
116
+ const sess = this.sessions.get(id);
117
+ if (!sess || isSessionExpired(sess)) {
118
+ throw new SessionStoreError("no_such_session", "wmp: no such session");
119
+ }
120
+ if (oldToken === "" || !tokensEqual(sess.resumptionToken ?? "", oldToken)) {
121
+ throw new SessionStoreError("token_mismatch", "wmp: resumption token mismatch");
122
+ }
123
+ if (pastDeadline(sess.resumptionTokenExpiresAt, Date.now())) {
124
+ throw new SessionStoreError("token_expired", "wmp: resumption token expired");
125
+ }
126
+ const updated = { ...sess, resumptionToken: newToken };
127
+ if (expiresAt === undefined)
128
+ delete updated.resumptionTokenExpiresAt;
129
+ else
130
+ updated.resumptionTokenExpiresAt = expiresAt;
131
+ this.sessions.set(id, updated);
132
+ return updated;
133
+ }
33
134
  get size() {
34
135
  return this.sessions.size;
35
136
  }
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Wallet side of the WMP sign sub-flows and the match flow (profile Sections
3
+ * 3.1.5, 3.2.5, 3.2.6 and 3.3) — the responder counterpart of go-wmp's
4
+ * orchestrator-side FlowContext.RequestSign / RequestMatch.
5
+ */
6
+ import { WMPError } from "./jsonrpc.js";
7
+ import { type Capabilities, type Metadata } from "./types.js";
8
+ import type { PeerContext } from "./profile.js";
9
+ import type { SignSubFlowParams, TransactionData } from "./openid4x.js";
10
+ /** The capability a wallet offers when it processes OID4VP transaction_data end to end. */
11
+ export declare const CAPABILITY_TRANSACTION_DATA = "transaction_data";
12
+ /** First version of the transaction_data capability. */
13
+ export declare const TRANSACTION_DATA_VERSION_1 = 1;
14
+ /** Parameters of the `transaction_data` capability. */
15
+ export interface TransactionDataCapability {
16
+ /** Versions of the capability the wallet implements. A non-empty array. */
17
+ versions: number[];
18
+ /** transaction_data_hashes_alg names the wallet can compute, e.g. "sha-256". */
19
+ hash_algs?: string[];
20
+ }
21
+ /**
22
+ * Whether `caps` contains a transaction_data capability that lists `version`
23
+ * (go-wmp Capabilities.OffersTransactionData). Absence, an unparsable value or a
24
+ * list without the version all mean "not offered". Use it on what the peer
25
+ * OFFERED (`capabilities_offered`), never on the negotiated result: negotiation
26
+ * may fall back to all of the responder's capabilities when a peer offers none,
27
+ * which would read as support the peer never claimed.
28
+ */
29
+ export declare function offersTransactionData(caps: Capabilities | undefined, version?: number): boolean;
30
+ /**
31
+ * The `data` of the -31005 a wallet answers with for transaction_data it will not
32
+ * process: {"unsupported": "transaction_data"}, plus `redirect_uri` when the
33
+ * verifier's response mode produced a redirect (additive, profile 2.3).
34
+ */
35
+ export declare function transactionDataUnsupportedData(redirectUri?: string): Record<string, unknown>;
36
+ /** The -31005 error carrying {@link transactionDataUnsupportedData}. */
37
+ export declare function transactionDataUnsupportedError(redirectUri?: string): WMPError;
38
+ /** Hash algorithms {@link transactionDataHash} computes. */
39
+ export declare const TRANSACTION_DATA_HASH_ALGS: readonly string[];
40
+ /**
41
+ * `transaction_data_hashes` element for an entry: base64url (no padding) of the
42
+ * hash of the ASCII bytes of `raw`, exactly as received (OID4VP 1.0 Appendix B:
43
+ * "base64url decoding is not performed before hashing"). Never hash a decoded
44
+ * and re-serialized object. Throws for an algorithm this library does not
45
+ * compute (the wallet then fails the sub-flow: it cannot bind) or a `raw` that is
46
+ * not ASCII.
47
+ */
48
+ export declare function transactionDataHash(raw: string, alg?: string): string;
49
+ /**
50
+ * Decodes an entry's `raw` and returns the decoded object. The wallet validates
51
+ * and displays THIS, not the members the orchestrator sent next to it. Throws
52
+ * -32602 when `raw` is not base64url of a JSON object.
53
+ */
54
+ export declare function decodeTransactionData(raw: string): Record<string, unknown>;
55
+ /**
56
+ * Refuses an entry whose members disagree with what `raw` decodes to (profile
57
+ * 3.2.5 requirement 2): otherwise a compromised orchestrator could show one
58
+ * transaction and bind another. Returns the decoded entry for display.
59
+ */
60
+ export declare function checkTransactionDataEntry(entry: TransactionData): Record<string, unknown>;
61
+ /** Sign actions a wallet answers: Core (generate_proof, sign_document, authorize) and the profile's. */
62
+ export declare const SIGN_ACTIONS: readonly string[];
63
+ /** Upper bound on `count` (batch size) a wallet will generate proofs for. */
64
+ export declare const MAX_PROOF_COUNT = 256;
65
+ /**
66
+ * Validates the `params` of a `sign` flow.start and returns them (a shallow
67
+ * copy that keeps members this library does not model). Throws a WMPError:
68
+ * -32602 for a malformed member, an unknown action or the old
69
+ * `credentials_to_include` shape; -31005 {"unsupported":"transaction_data"}
70
+ * for an entry that lacks `raw` (the wallet cannot bind to it and MUST refuse,
71
+ * profile 3.2.5). Error data names members, never values.
72
+ */
73
+ export declare function parseSignSubFlowParams(raw: unknown): SignSubFlowParams;
74
+ /**
75
+ * The response mode a sign_presentation is answered in: the top-level member
76
+ * (profile 3.2.5, optional without transaction_data) or, when it is omitted, the
77
+ * one of the verified request. Without either the mode is plaintext.
78
+ */
79
+ export declare function effectiveResponseMode(p: {
80
+ response_mode?: unknown;
81
+ verified_request?: unknown;
82
+ }): string | undefined;
83
+ /** What the answer helpers need of a Peer. */
84
+ export type FlowNotifier = Pick<PeerContext, "notify">;
85
+ /**
86
+ * A notifier bound to ONE flow generation: its sends fail, without sending, once
87
+ * that flow ended (cancelled, completed, replaced under the same id), and never
88
+ * retire another generation's record. Falls back to plain `notify` for a
89
+ * PeerContext that cannot tell generations apart.
90
+ */
91
+ export declare function boundNotifier(peer: PeerContext, flowId: string): FlowNotifier & {
92
+ current(): boolean;
93
+ };
94
+ /**
95
+ * Ends a sub-flow successfully (wmp.flow.complete). The result is checked first
96
+ * (default: the completion rules of {@link validateCompletionResult}; for a
97
+ * match flow pass {@link validateMatchResult}); a result that would be refused
98
+ * by the orchestrator is never sent.
99
+ */
100
+ export declare function completeSubFlow(peer: FlowNotifier, wmp: Metadata, flowId: string, result: unknown, validate?: (result: unknown) => void): Promise<void>;
101
+ /** Ends a sub-flow with wmp.flow.error (a failure, not a refusal). */
102
+ export declare function failSubFlow(peer: FlowNotifier, wmp: Metadata, flowId: string, code: number, message: string, data?: unknown): Promise<void>;
103
+ /**
104
+ * The wallet declines the sub-flow (the user said no, it does not trust the
105
+ * verifier, a value the signature must bind is missing): wmp.flow.error -31006
106
+ * with data {"reason": "rejected"}, the well-known reason of Core 6.2
107
+ * (profile 3.2.6). Any other error is a failure, not a refusal.
108
+ */
109
+ export declare function rejectSubFlow(peer: FlowNotifier, wmp: Metadata, flowId: string, message?: string): Promise<void>;
110
+ /**
111
+ * The wallet will not process the sub-flow's transaction_data: wmp.flow.error
112
+ * -31005 with data {"unsupported": "transaction_data"} (profile 2.3).
113
+ */
114
+ export declare function unsupportedTransactionData(peer: FlowNotifier, wmp: Metadata, flowId: string): Promise<void>;
115
+ /**
116
+ * Checks the result of a sign sub-flow before it is sent: the completion rules
117
+ * and, per action, what must never reach the orchestrator. A
118
+ * decrypt_credential_response result carries control members only
119
+ * (credential_count or transaction_id with an optional interval, or an error):
120
+ * the decrypted credentials and their metadata stay in the wallet (profile
121
+ * 3.1.5.1), so any other member, credentials and credential_metadata first,
122
+ * refuses the result.
123
+ */
124
+ export declare function validateSignResult(action: string, result: unknown, responseMode?: string): void;
125
+ /** The sub-flow a wallet was asked to answer, with the means to answer it. A sub-flow ends once. */
126
+ export declare class SignFlow {
127
+ private peer;
128
+ private wmp;
129
+ readonly flowId: string;
130
+ readonly params: SignSubFlowParams;
131
+ private done;
132
+ constructor(peer: FlowNotifier, wmp: Metadata, flowId: string, params: SignSubFlowParams);
133
+ /** True once a terminal message (complete, reject, fail) was sent for this sub-flow. */
134
+ get ended(): boolean;
135
+ /**
136
+ * Sends at most one terminal message. The sub-flow counts as ended from the
137
+ * moment the send starts (a concurrent second terminal is refused); if the
138
+ * message is not sent (a result that fails validation, a transport error) it
139
+ * counts as not ended, so the caller can still answer another way.
140
+ */
141
+ private terminal;
142
+ /** Completes with the sign result (e.g. `{ proof_jwt }`, `{ response_jwe }`). */
143
+ complete(result: unknown): Promise<void>;
144
+ /** Declines the sub-flow (-31006, reason rejected). */
145
+ reject(message?: string): Promise<void>;
146
+ /** Fails the sub-flow without refusing it. */
147
+ fail(code: number, message: string, data?: unknown): Promise<void>;
148
+ /** Cannot process the request's transaction_data (-31005). */
149
+ unsupportedTransactionData(): Promise<void>;
150
+ }
151
+ /** Params of a `match` flow.start. */
152
+ export interface MatchStartParams {
153
+ parent_flow_id: string;
154
+ /** The verifier's DCQL query as validated by the orchestrator. */
155
+ dcql_query: {
156
+ credentials?: {
157
+ id: string;
158
+ [m: string]: unknown;
159
+ }[];
160
+ [m: string]: unknown;
161
+ };
162
+ client_metadata?: Record<string, unknown>;
163
+ verified_request?: Record<string, unknown>;
164
+ }
165
+ /** The result of a match: the closed set of profile 3.3.2. */
166
+ export interface MatchResult {
167
+ satisfiable: boolean;
168
+ satisfiable_query_ids?: string[];
169
+ selection_handle?: string;
170
+ code?: "no_match" | "insufficient" | "error";
171
+ }
172
+ /** Validates the params of a match flow.start (-32602 when malformed). */
173
+ export declare function parseMatchStartParams(raw: unknown): MatchStartParams;