@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.
@@ -4,8 +4,9 @@
4
4
  * Provides OID4VCI (credential issuance) and OID4VP (credential presentation)
5
5
  * flow handling via the WMP profile system.
6
6
  */
7
- import type { FlowStartParams, FlowStartResult, FlowActionParams, FlowActionResult, FlowProgressParams, FlowCompleteParams, FlowErrorParams, Metadata, ResolveParams, ResolveResult } from "./types.js";
7
+ import type { Capabilities, FlowStartParams, FlowStartResult, FlowActionParams, FlowActionResult, FlowProgressParams, FlowCompleteParams, FlowErrorParams, Metadata, ResolveParams, ResolveResult } from "./types.js";
8
8
  import type { Profile, PeerContext, FlowHandler, ResolveHandler, MethodHandler } from "./profile.js";
9
+ import { SignFlow, type MatchResult, type MatchStartParams, type TransactionDataCapability } from "./signflow.js";
9
10
  export declare const CredentialFormat: {
10
11
  readonly VC_SDJWT: "vc+sd-jwt";
11
12
  readonly DC_SDJWT: "dc+sd-jwt";
@@ -203,7 +204,9 @@ export interface OID4VPFlowParams {
203
204
  * Helper to build WMP FlowStartParams for an OID4VCI flow.
204
205
  * If attestation is provided, it is included in the params.
205
206
  */
206
- export declare function buildVCIFlowStart(sessionId: string, flowId: string, params: OID4VCIFlowParams, timeout?: number): FlowStartParams;
207
+ export declare function buildVCIFlowStart(sessionId: string, flowId: string, params: OID4VCIFlowParams, timeout?: number,
208
+ /** The protocol version the session negotiated (default "0.1"). */
209
+ version?: string): FlowStartParams;
207
210
  /**
208
211
  * Helper to build VCI flow params with attestation from a provider.
209
212
  * Calls the provider to obtain WIA + PoP, then merges into the params.
@@ -215,39 +218,131 @@ export declare function buildVCIFlowStart(sessionId: string, flowId: string, par
215
218
  */
216
219
  export declare function withAttestation(provider: ClientAttestationProvider, audience: string, params: OID4VCIFlowParams): Promise<OID4VCIFlowParams>;
217
220
  /**
218
- * TransactionData represents a single transaction data object from
219
- * the verifier's OID4VP authorization request (TS12/SCA).
221
+ * A single transaction data entry of the verifier's OID4VP request (EC TS12),
222
+ * as the orchestrator sends it in a sign_presentation sub-flow (profile
223
+ * Section 3.2.5).
224
+ *
225
+ * A presentation binds to `raw`, not to the object it decodes to: OID4VP 1.0
226
+ * (Appendix B) hashes the base64url string as received, and re-encoding the
227
+ * decoded object does not reproduce it. A wallet hashes `raw`
228
+ * ({@link transactionDataHash}), decodes it itself and refuses an entry whose
229
+ * other members disagree with the decoding ({@link checkTransactionDataEntry}).
220
230
  */
221
231
  export interface TransactionData {
232
+ /** The entry exactly as the verifier sent it: the base64url string. */
233
+ raw: string;
234
+ /** `type` of the decoded entry. */
222
235
  type: string;
236
+ /** `credential_ids` of the decoded entry: the DCQL credential query ids it is bound to. */
237
+ credential_ids: string[];
238
+ /** `payload` of the decoded entry (EC TS12 Section 4.2). For validation and display; never hash it. */
239
+ payload?: Record<string, unknown>;
240
+ /**
241
+ * The verifier's acceptable hash algorithms for this entry (OID4VP). An
242
+ * array on the wire; a bare string is accepted from older peers. Read it
243
+ * through {@link transactionDataHashesAlgs}.
244
+ */
245
+ transaction_data_hashes_alg?: string[] | string;
246
+ /** @deprecated TS12 types carry their members in `payload`. */
223
247
  params?: Record<string, unknown>;
224
- /** Credential IDs this transaction data applies to */
225
- credential_ids?: string[];
226
- /** Hash algorithm for transaction_data_hashes */
248
+ /** @deprecated Non-standard; use transaction_data_hashes_alg. */
227
249
  hash_alg?: string;
228
- /** Algorithm identifier for the hashes claim in KB-JWT */
229
- transaction_data_hashes_alg?: string;
230
250
  }
251
+ /**
252
+ * Normalizes TransactionData.transaction_data_hashes_alg to an array (the
253
+ * spec shape); a bare string from an older peer becomes a one-element array.
254
+ * Anything else (including empty strings and non-string array members) is
255
+ * dropped.
256
+ */
257
+ export declare function transactionDataHashesAlgs(td: Pick<TransactionData, "transaction_data_hashes_alg">): string[];
258
+ /** One element of `credentials_to_include`: the credential query the user consented to answer, and nothing else. */
259
+ export interface CredentialToInclude {
260
+ credential_query_id: string;
261
+ }
262
+ /** `credential_response_encryption` of a generate_proof request (profile 3.1.5.1). */
263
+ export interface CredentialResponseEncryption {
264
+ alg: string;
265
+ enc: string;
266
+ required: boolean;
267
+ }
268
+ /**
269
+ * Params of a `sign` flow.start the wallet answers (Core Section 6, profile
270
+ * Sections 3.1.5, 3.2.5 and 7). Mirrors go-wmp openid4x.SignSubFlowParams
271
+ * (v0.11.0) member for member; members a peer sends that are not listed here
272
+ * are kept by {@link parseSignSubFlowParams}, never dropped.
273
+ */
231
274
  export interface SignSubFlowParams {
275
+ /** generate_proof, sign_presentation, decrypt_credential_response, sign_client_auth, ... */
232
276
  action: string;
233
- nonce: string;
234
- audience: string;
277
+ /** The oid4vci/oid4vp flow this sub-flow belongs to. Absent for a plain Core sign flow. */
278
+ parent_flow_id?: string;
279
+ nonce?: string;
280
+ audience?: string;
235
281
  proof_type?: string;
236
- parent_flow_id: string;
282
+ /** JWT `iss` for generated proof JWTs (typically the OAuth client_id). */
283
+ issuer?: string;
284
+ /** The issuer's proof_types_supported map. */
285
+ proof_types_supported?: Record<string, unknown>;
286
+ /** Number of proofs to generate (batch size); 1 when absent. */
287
+ count?: number;
288
+ /** Verifier's response endpoint (mdoc session transcript; sign_presentation). */
289
+ response_uri?: string;
290
+ verifier_jwk_thumbprint?: string;
291
+ verifier_session_id?: string;
292
+ /** The verifier's client_metadata, verbatim (profile 7.1). */
293
+ client_metadata?: Record<string, unknown>;
294
+ /** The request as the engine validated it (profile 7.5). Carries no trust verdict. */
295
+ verified_request?: Record<string, unknown>;
296
+ /** Recipient the wallet encrypts the JARM response to (direct_post.jwt; profile 7.7). */
297
+ response_encryption?: Record<string, unknown>;
298
+ state?: string;
299
+ /** The OID4VP response_mode; required in the key binding JWT of an SCA presentation. */
300
+ response_mode?: string;
301
+ /** The request's transaction data, in the verifier's order. */
237
302
  transaction_data?: TransactionData[];
303
+ /** The credential queries the user consented to answer; nothing but the query id of each. */
304
+ credentials_to_include?: CredentialToInclude[];
305
+ /** The handle of the select_credentials action, handed back unchanged. */
306
+ selection_handle?: string;
307
+ /** Renewal: sign with the existing key identified by this kid. */
308
+ reissuance_kid?: string;
309
+ htm?: string;
310
+ htu?: string;
311
+ dpop_nonce?: string;
312
+ ath?: string;
313
+ key_id?: string;
314
+ attestation_challenge?: string;
315
+ credential_response_encryption?: CredentialResponseEncryption;
316
+ auxiliary_data_to_issuer?: Record<string, unknown>[];
317
+ credential_type?: string;
318
+ credential_issuer?: string;
319
+ jwe?: string;
320
+ deferred?: boolean;
321
+ /** Members this library does not model are preserved. */
322
+ [member: string]: unknown;
238
323
  }
324
+ /** Accept offer action params (OID4VCI). */
239
325
  export interface SelectionAction {
240
326
  selected_indices: number[];
241
327
  consent: boolean;
242
328
  }
329
+ /**
330
+ * `select_credentials` action params (profile 3.2.3.1): a closed set. The
331
+ * orchestrator learns that the user consented and for which of the verifier's
332
+ * own query ids; never a credential, claim, count or free text. Build with
333
+ * {@link buildSelectCredentials}, check with {@link validateSelectCredentialsParams}.
334
+ */
243
335
  export interface ConsentAction {
244
- selections: CredentialSelection[];
245
336
  consent: boolean;
337
+ /** At least one element when consent is true; absent or empty otherwise. */
338
+ selections?: CredentialSelection[];
246
339
  }
340
+ /** One consented credential query and the opaque per-flow handle. Both members, nothing else. */
247
341
  export interface CredentialSelection {
248
- credential_id: string;
249
- credential_query_id?: string;
250
- disclosed_claims: string[];
342
+ /** The `id` of a credential query of the verifier's request. */
343
+ query_id: string;
344
+ /** 22+ base64url characters, the same in every element: the match result's handle, or one the wallet chose. */
345
+ selection_handle: string;
251
346
  }
252
347
  export type FlowStartHandler = (params: FlowStartParams) => Promise<FlowStartResult>;
253
348
  export type ActionHandler = (params: FlowActionParams) => Promise<FlowActionResult>;
@@ -255,8 +350,30 @@ export type CredentialNotificationHandler = (params: CredentialNotificationParam
255
350
  export interface OpenID4xConfig {
256
351
  /** OID4VCI capability. Omit to disable issuance. */
257
352
  oid4vci?: OID4VCICapability;
258
- /** OID4VCI capability. Omit to disable issuance. */
353
+ /** OID4VP capability. Omit to disable presentation. */
259
354
  oid4vp?: OID4VPCapability;
355
+ /**
356
+ * transaction_data capability (profile 2.3). Offer it only if the wallet does
357
+ * everything profile 3.2.5 requires: hash `raw`, validate and display the
358
+ * decoded entry, fail closed. Omit to not advertise it; a sign sub-flow that
359
+ * carries transaction_data is then refused with -31005.
360
+ */
361
+ transactionData?: TransactionDataCapability;
362
+ /**
363
+ * Called for each `sign` sub-flow the orchestrator starts (generate_proof,
364
+ * sign_presentation, decrypt_credential_response, ...), after the start was
365
+ * validated and answered. Answer through the SignFlow: complete(), reject()
366
+ * (-31006 rejected), fail() or unsupportedTransactionData(). A throw ends the
367
+ * sub-flow with wmp.flow.error. Without it the profile does not handle `sign`.
368
+ */
369
+ onSign?: (flow: SignFlow) => void | Promise<void>;
370
+ /**
371
+ * Answers a `match` flow (profile 3.3): evaluate the DCQL query locally and
372
+ * return the closed result. Throw {@link SubFlowRejectedError} when the user
373
+ * declines; any other throw answers satisfiable=false, code "error". The result
374
+ * is validated before it is sent. Needs `oid4vp`.
375
+ */
376
+ onMatch?: (params: MatchStartParams) => MatchResult | Promise<MatchResult>;
260
377
  /** Called when an OID4VCI flow starts. */
261
378
  onVCIStart?: FlowStartHandler;
262
379
  /** Called when an action arrives for an OID4VCI flow. */
@@ -277,6 +394,10 @@ export interface OpenID4xConfig {
277
394
  */
278
395
  requireRegisteredNotification?: boolean;
279
396
  }
397
+ /** Thrown from `onMatch` when the user declines: the match flow ends with -31006 rejected. */
398
+ export declare class SubFlowRejectedError extends Error {
399
+ constructor();
400
+ }
280
401
  /**
281
402
  * OpenID4xProfile implements Profile, FlowHandler, and ResolveHandler
282
403
  * for OID4VCI and OID4VP credential exchange flows.
@@ -293,6 +414,14 @@ export declare class OpenID4xProfile implements Profile, FlowHandler, ResolveHan
293
414
  private registeredNotifications;
294
415
  constructor(config: OpenID4xConfig);
295
416
  capabilities(): string[];
417
+ /**
418
+ * The capability descriptors for session negotiation (mirror of go-wmp
419
+ * CapabilityDescriptors): "oid4vci", "oid4vp" and "transaction_data", each
420
+ * present only when configured, required list members as [] rather than
421
+ * missing. Throws for a transaction_data descriptor that lists no version:
422
+ * it would advertise a capability no peer can use.
423
+ */
424
+ capabilityDescriptors(): Capabilities;
296
425
  init(ctx: PeerContext): void;
297
426
  methods(): string[];
298
427
  handleMethod(method: string, params: unknown): Promise<unknown>;
@@ -302,7 +431,26 @@ export declare class OpenID4xProfile implements Profile, FlowHandler, ResolveHan
302
431
  */
303
432
  registerCredentialNotification(flowId: string, notificationId: string): void;
304
433
  flowTypes(): string[];
434
+ /** Each flow type needs the capability of the same name (Core 6.5 item 2; profile Section 2). */
435
+ requiredCapability(flowType: string): string;
305
436
  startFlow(params: FlowStartParams): Promise<FlowStartResult>;
437
+ /**
438
+ * Runs `fn` after the flow.start response has been sent, so the sub-flow's
439
+ * terminal notification can never overtake it. The Peer reports when the
440
+ * response send resolved (for HTTP: when its POST completed); a PeerContext
441
+ * without that falls back to a zero-delay timer.
442
+ */
443
+ private defer;
444
+ private runMatch;
445
+ /**
446
+ * select_credentials for an oid4vp flow is a closed set (profile 3.2.3.1): a
447
+ * member outside it (a credential id, claim names or values, ...) would hand
448
+ * the orchestrator data it must never receive, so the action is refused before
449
+ * any handler sees it. The response is -32602 with no data, the parent flow ends
450
+ * with a terminal wmp.flow.error -32602 (also without data), and nothing of the
451
+ * refused params is echoed.
452
+ */
453
+ validateAction(params: FlowActionParams, flowType: string): void;
306
454
  handleAction(params: FlowActionParams): Promise<FlowActionResult>;
307
455
  handleProgress(_params: FlowProgressParams): void;
308
456
  handleComplete(params: FlowCompleteParams): void;
package/dist/openid4x.js CHANGED
@@ -6,6 +6,10 @@
6
6
  */
7
7
  import { Method, ErrorCode, VERSION } from "./types.js";
8
8
  import { WMPError } from "./jsonrpc.js";
9
+ import { unsupportedError } from "./errors.js";
10
+ import { dcqlQueryIds, validateMatchResult } from "./completion.js";
11
+ import { ActionParamsError, validateSelectCredentialsParams } from "./consent.js";
12
+ import { CAPABILITY_TRANSACTION_DATA, SignFlow, boundNotifier, completeSubFlow, parseMatchStartParams, parseSignSubFlowParams, rejectSubFlow, transactionDataUnsupportedError, } from "./signflow.js";
9
13
  // ---------------------------------------------------------------------------
10
14
  // Credential format constants — aligned with wallet-common VerifiableCredentialFormat
11
15
  // ---------------------------------------------------------------------------
@@ -97,9 +101,11 @@ export const OID4Action = {
97
101
  * Helper to build WMP FlowStartParams for an OID4VCI flow.
98
102
  * If attestation is provided, it is included in the params.
99
103
  */
100
- export function buildVCIFlowStart(sessionId, flowId, params, timeout) {
104
+ export function buildVCIFlowStart(sessionId, flowId, params, timeout,
105
+ /** The protocol version the session negotiated (default "0.1"). */
106
+ version = VERSION) {
101
107
  return {
102
- wmp: { version: VERSION, session_id: sessionId },
108
+ wmp: { version, session_id: sessionId },
103
109
  flow_type: OID4FlowType.OID4VCI,
104
110
  flow_id: flowId,
105
111
  params,
@@ -125,6 +131,27 @@ export async function withAttestation(provider, audience, params) {
125
131
  client_attestation_pop: attestation.client_attestation_pop,
126
132
  };
127
133
  }
134
+ /**
135
+ * Normalizes TransactionData.transaction_data_hashes_alg to an array (the
136
+ * spec shape); a bare string from an older peer becomes a one-element array.
137
+ * Anything else (including empty strings and non-string array members) is
138
+ * dropped.
139
+ */
140
+ export function transactionDataHashesAlgs(td) {
141
+ const v = td.transaction_data_hashes_alg;
142
+ if (typeof v === "string")
143
+ return v === "" ? [] : [v];
144
+ if (Array.isArray(v))
145
+ return v.filter((x) => typeof x === "string" && x !== "");
146
+ return [];
147
+ }
148
+ /** Thrown from `onMatch` when the user declines: the match flow ends with -31006 rejected. */
149
+ export class SubFlowRejectedError extends Error {
150
+ constructor() {
151
+ super("sub-flow rejected");
152
+ this.name = "SubFlowRejectedError";
153
+ }
154
+ }
128
155
  // ---------------------------------------------------------------------------
129
156
  // OpenID4x Profile
130
157
  // ---------------------------------------------------------------------------
@@ -152,6 +179,30 @@ export class OpenID4xProfile {
152
179
  caps.push("oid4vci");
153
180
  if (this.config.oid4vp)
154
181
  caps.push("oid4vp");
182
+ if (this.config.transactionData)
183
+ caps.push(CAPABILITY_TRANSACTION_DATA);
184
+ return caps;
185
+ }
186
+ /**
187
+ * The capability descriptors for session negotiation (mirror of go-wmp
188
+ * CapabilityDescriptors): "oid4vci", "oid4vp" and "transaction_data", each
189
+ * present only when configured, required list members as [] rather than
190
+ * missing. Throws for a transaction_data descriptor that lists no version:
191
+ * it would advertise a capability no peer can use.
192
+ */
193
+ capabilityDescriptors() {
194
+ const caps = {};
195
+ const c = this.config;
196
+ if (c.oid4vci)
197
+ caps.oid4vci = { ...c.oid4vci, supported_grants: c.oid4vci.supported_grants ?? [], supported_formats: c.oid4vci.supported_formats ?? [] };
198
+ if (c.oid4vp)
199
+ caps.oid4vp = { ...c.oid4vp, supported_response_modes: c.oid4vp.supported_response_modes ?? [], supported_formats: c.oid4vp.supported_formats ?? [] };
200
+ if (c.transactionData) {
201
+ if (!Array.isArray(c.transactionData.versions) || c.transactionData.versions.length === 0) {
202
+ throw new Error("openid4x: transaction_data descriptor lists no versions");
203
+ }
204
+ caps[CAPABILITY_TRANSACTION_DATA] = { ...c.transactionData };
205
+ }
155
206
  return caps;
156
207
  }
157
208
  init(ctx) {
@@ -199,8 +250,24 @@ export class OpenID4xProfile {
199
250
  types.push(OID4FlowType.OID4VCI);
200
251
  if (this.config.oid4vp)
201
252
  types.push(OID4FlowType.OID4VP);
253
+ if (this.config.onSign)
254
+ types.push("sign");
255
+ if (this.config.onMatch && this.config.oid4vp)
256
+ types.push("match");
202
257
  return types;
203
258
  }
259
+ /** Each flow type needs the capability of the same name (Core 6.5 item 2; profile Section 2). */
260
+ requiredCapability(flowType) {
261
+ switch (flowType) {
262
+ case OID4FlowType.OID4VCI:
263
+ return "oid4vci";
264
+ case OID4FlowType.OID4VP:
265
+ case "match": // a nested flow of an oid4vp flow, defined for the oid4vp capability (profile 3.3)
266
+ return "oid4vp";
267
+ default:
268
+ return "";
269
+ }
270
+ }
204
271
  async startFlow(params) {
205
272
  switch (params.flow_type) {
206
273
  case OID4FlowType.OID4VCI: {
@@ -225,8 +292,114 @@ export class OpenID4xProfile {
225
292
  flow_type: params.flow_type,
226
293
  };
227
294
  }
295
+ case "sign": {
296
+ const sp = parseSignSubFlowParams(params.params);
297
+ // Transaction data the wallet did not offer to process: refuse, never sign without binding.
298
+ if (sp.transaction_data && sp.transaction_data.length > 0 && !this.config.transactionData) {
299
+ throw transactionDataUnsupportedError();
300
+ }
301
+ // Bound to THIS flow generation: if the flow is cancelled and the id started
302
+ // again before the callback runs or answers, nothing it does reaches the new flow.
303
+ const bound = boundNotifier(this.peer, params.flow_id);
304
+ const flow = new SignFlow(bound, params.wmp, params.flow_id, sp);
305
+ this.defer(async () => {
306
+ if (!bound.current())
307
+ return; // cancelled or replaced before the callback could run
308
+ try {
309
+ await this.config.onSign(flow);
310
+ }
311
+ catch (err) {
312
+ // The callback already ended the sub-flow (and then threw in cleanup):
313
+ // a second terminal could end another flow that took the id since.
314
+ if (flow.ended)
315
+ return;
316
+ // A fixed message: whatever the callback threw may carry credential data.
317
+ if (err instanceof WMPError)
318
+ await flow.fail(err.code, err.rpcMessage, err.data);
319
+ else
320
+ await flow.fail(ErrorCode.FlowError, "Sign failed");
321
+ }
322
+ });
323
+ return { wmp: params.wmp, flow_id: params.flow_id, flow_type: params.flow_type };
324
+ }
325
+ case "match": {
326
+ const mp = parseMatchStartParams(params.params);
327
+ const bound = boundNotifier(this.peer, params.flow_id);
328
+ this.defer(async () => {
329
+ if (!bound.current())
330
+ return;
331
+ await this.runMatch(params, mp, bound);
332
+ });
333
+ return { wmp: params.wmp, flow_id: params.flow_id, flow_type: params.flow_type };
334
+ }
228
335
  default:
229
- throw new WMPError(ErrorCode.FlowError, `Unsupported flow type: ${params.flow_type}`);
336
+ throw unsupportedError(params.flow_type);
337
+ }
338
+ }
339
+ /**
340
+ * Runs `fn` after the flow.start response has been sent, so the sub-flow's
341
+ * terminal notification can never overtake it. The Peer reports when the
342
+ * response send resolved (for HTTP: when its POST completed); a PeerContext
343
+ * without that falls back to a zero-delay timer.
344
+ */
345
+ defer(fn) {
346
+ const run = () => {
347
+ fn().catch(() => {
348
+ /* the answer could not be sent: the orchestrator's flow timeout applies */
349
+ });
350
+ };
351
+ if (this.peer?.afterResponse)
352
+ this.peer.afterResponse(run);
353
+ else
354
+ setTimeout(run, 0);
355
+ }
356
+ async runMatch(start, mp, peer) {
357
+ let result;
358
+ try {
359
+ result = await this.config.onMatch(mp);
360
+ validateMatchResult(result, dcqlQueryIds(mp.dcql_query));
361
+ }
362
+ catch (err) {
363
+ if (err instanceof SubFlowRejectedError) {
364
+ await rejectSubFlow(peer, start.wmp, start.flow_id);
365
+ return;
366
+ }
367
+ // The wallet could not evaluate the query (or produced a result the
368
+ // orchestrator would refuse): code is the whole reason, never the cause.
369
+ result = { satisfiable: false, code: "error" };
370
+ }
371
+ await completeSubFlow(peer, start.wmp, start.flow_id, result, (r) => validateMatchResult(r, dcqlQueryIds(mp.dcql_query)));
372
+ }
373
+ /**
374
+ * select_credentials for an oid4vp flow is a closed set (profile 3.2.3.1): a
375
+ * member outside it (a credential id, claim names or values, ...) would hand
376
+ * the orchestrator data it must never receive, so the action is refused before
377
+ * any handler sees it. The response is -32602 with no data, the parent flow ends
378
+ * with a terminal wmp.flow.error -32602 (also without data), and nothing of the
379
+ * refused params is echoed.
380
+ */
381
+ validateAction(params, flowType) {
382
+ // The type is the one the Peer recorded when the flow started (so flows this
383
+ // peer started outbound are covered too); the flow stays recorded, so every
384
+ // further action is judged the same way, until the refusal's terminal is sent.
385
+ if (params.action !== OID4Action.SelectCredentials || flowType !== OID4FlowType.OID4VP)
386
+ return;
387
+ try {
388
+ validateSelectCredentialsParams(params.params);
389
+ }
390
+ catch (err) {
391
+ if (!(err instanceof ActionParamsError))
392
+ throw err;
393
+ if (this.peer) {
394
+ const flowId = params.flow_id;
395
+ const bound = boundNotifier(this.peer, flowId);
396
+ void bound
397
+ .notify(Method.FlowError, { wmp: { version: params.wmp?.version ?? VERSION, ...(params.wmp?.session_id ? { session_id: params.wmp.session_id } : {}) }, flow_id: flowId, code: ErrorCode.InvalidParams, message: "Invalid params" })
398
+ .catch(() => {
399
+ /* the terminal could not be sent: the refusal response still goes out */
400
+ });
401
+ }
402
+ throw new WMPError(ErrorCode.InvalidParams, "Invalid params");
230
403
  }
231
404
  }
232
405
  async handleAction(params) {