@agent-cards/sdk 0.20.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/PREFLIGHT.md +314 -0
  3. package/README.md +864 -0
  4. package/dist/adyen-merchant-hosted.generated.d.ts +277 -0
  5. package/dist/adyen-merchant-hosted.generated.js +1902 -0
  6. package/dist/adyen.generated.d.ts +24 -0
  7. package/dist/adyen.generated.js +64 -0
  8. package/dist/agentcard.d.ts +72 -0
  9. package/dist/agentcard.js +71 -0
  10. package/dist/api-module.d.ts +54 -0
  11. package/dist/api-module.js +85 -0
  12. package/dist/attachment.d.ts +11 -0
  13. package/dist/attachment.js +50 -0
  14. package/dist/braintree.d.ts +2 -0
  15. package/dist/braintree.generated.d.ts +10 -0
  16. package/dist/braintree.generated.js +302 -0
  17. package/dist/braintree.js +2 -0
  18. package/dist/builtin-registry.generated.d.ts +2 -0
  19. package/dist/builtin-registry.generated.js +1 -0
  20. package/dist/buy.d.ts +374 -0
  21. package/dist/buy.js +314 -0
  22. package/dist/card-fields.generated.d.ts +3 -0
  23. package/dist/card-fields.generated.js +88 -0
  24. package/dist/cdp.d.ts +202 -0
  25. package/dist/cdp.js +2540 -0
  26. package/dist/checkout-com.generated.d.ts +4 -0
  27. package/dist/checkout-com.generated.js +183 -0
  28. package/dist/client.d.ts +929 -0
  29. package/dist/client.js +1896 -0
  30. package/dist/cse-body.d.ts +25 -0
  31. package/dist/cse-body.js +41 -0
  32. package/dist/fiserv.d.ts +65 -0
  33. package/dist/fiserv.generated.d.ts +73 -0
  34. package/dist/fiserv.generated.js +830 -0
  35. package/dist/fiserv.js +104 -0
  36. package/dist/hosted-form.d.ts +44 -0
  37. package/dist/hosted-form.js +78 -0
  38. package/dist/index.d.ts +37 -0
  39. package/dist/index.js +26 -0
  40. package/dist/languages.d.ts +23 -0
  41. package/dist/languages.js +76 -0
  42. package/dist/lifecycle.d.ts +235 -0
  43. package/dist/lifecycle.js +405 -0
  44. package/dist/mercado-checkout.d.ts +20 -0
  45. package/dist/mercado-checkout.generated.d.ts +52 -0
  46. package/dist/mercado-checkout.generated.js +198 -0
  47. package/dist/mercado-checkout.js +108 -0
  48. package/dist/merchant-handoff.d.ts +54 -0
  49. package/dist/merchant-handoff.js +100 -0
  50. package/dist/merchant-hosted.d.ts +140 -0
  51. package/dist/merchant-hosted.js +170 -0
  52. package/dist/merchant-total-watch.d.ts +115 -0
  53. package/dist/merchant-total-watch.js +268 -0
  54. package/dist/merchant-total.d.ts +257 -0
  55. package/dist/merchant-total.js +383 -0
  56. package/dist/owned-shop.generated.d.ts +24 -0
  57. package/dist/owned-shop.generated.js +108 -0
  58. package/dist/paysafe.generated.d.ts +12 -0
  59. package/dist/paysafe.generated.js +87 -0
  60. package/dist/playwright.d.ts +3 -0
  61. package/dist/playwright.js +3 -0
  62. package/dist/pre-claim.d.ts +123 -0
  63. package/dist/pre-claim.js +386 -0
  64. package/dist/preflight-capabilities.generated.d.ts +1311 -0
  65. package/dist/preflight-capabilities.generated.js +2007 -0
  66. package/dist/preflight-catalog.json +5031 -0
  67. package/dist/preflight-playwright.d.ts +34 -0
  68. package/dist/preflight-playwright.js +355 -0
  69. package/dist/preflight-schemas.json +1144 -0
  70. package/dist/preflight.d.ts +1 -0
  71. package/dist/preflight.generated.d.ts +2023 -0
  72. package/dist/preflight.generated.js +604 -0
  73. package/dist/preflight.js +2 -0
  74. package/dist/preparation.d.ts +38 -0
  75. package/dist/preparation.js +191 -0
  76. package/dist/prepared-processor.d.ts +43 -0
  77. package/dist/prepared-processor.js +172 -0
  78. package/dist/recurly.generated.d.ts +1 -0
  79. package/dist/recurly.generated.js +87 -0
  80. package/dist/registry.d.ts +145 -0
  81. package/dist/registry.js +338 -0
  82. package/dist/requests.d.ts +66 -0
  83. package/dist/requests.js +76 -0
  84. package/dist/spreedly.generated.d.ts +10 -0
  85. package/dist/spreedly.generated.js +332 -0
  86. package/dist/stripe-checkout.d.ts +81 -0
  87. package/dist/stripe-checkout.generated.d.ts +82 -0
  88. package/dist/stripe-checkout.generated.js +1153 -0
  89. package/dist/stripe-checkout.js +140 -0
  90. package/dist/substitute.d.ts +38 -0
  91. package/dist/substitute.js +23 -0
  92. package/dist/substitutions.generated.d.ts +11 -0
  93. package/dist/substitutions.generated.js +818 -0
  94. package/dist/voice-pkce.d.ts +49 -0
  95. package/dist/voice-pkce.js +147 -0
  96. package/dist/voice-retry.d.ts +6 -0
  97. package/dist/voice-retry.js +27 -0
  98. package/dist/voice-stream.generated.d.ts +118 -0
  99. package/dist/voice-stream.generated.js +170 -0
  100. package/dist/voice-types.d.ts +708 -0
  101. package/dist/voice-types.js +16 -0
  102. package/dist/voice.d.ts +365 -0
  103. package/dist/voice.js +807 -0
  104. package/dist/webhooks.d.ts +87 -0
  105. package/dist/webhooks.js +136 -0
  106. package/examples/existing-browser.mjs +62 -0
  107. package/examples/preflight/classify-direct.mjs +21 -0
  108. package/examples/preflight/classify-kernel.mjs +30 -0
  109. package/examples/preflight/inspect-browser.mjs +44 -0
  110. package/examples/preflight/kernel-native/README.md +112 -0
  111. package/examples/preflight/kernel-native/documented-adapters.json +113 -0
  112. package/examples/preflight/kernel-native/inventory.json +242 -0
  113. package/examples/preflight/kernel-native/qualification.mjs +182 -0
  114. package/examples/preflight/kernel-profile.empty.json +11 -0
  115. package/examples/preflight/mollie-hosted.observations.json +23 -0
  116. package/examples/preflight/mollie-hosted.result.json +103 -0
  117. package/examples/preflight/stripe-script.direct.result.json +92 -0
  118. package/examples/preflight/stripe-script.observations.json +16 -0
  119. package/examples/preflight/stripe-script.result.json +87 -0
  120. package/package.json +53 -0
  121. package/readme.test.mjs +53 -0
@@ -0,0 +1,16 @@
1
+ export class AgentcardError extends Error {
2
+ code;
3
+ status;
4
+ details;
5
+ constructor(
6
+ /** The API's error code (`invalid_return_url`, `action_unavailable`, `voice_not_enrolled`, `slow_down`, `invalid_grant`), or the client's own (`unreachable`, `connect_timeout`, `oauth_failed`, `state_mismatch`). */
7
+ code, message, status,
8
+ /** The rest of the API's error envelope: `slow_down` carries `interval`, `grant_requires_exchange` carries `request_id`. */
9
+ details = {}) {
10
+ super(message);
11
+ this.code = code;
12
+ this.status = status;
13
+ this.details = details;
14
+ this.name = 'AgentcardError';
15
+ }
16
+ }
@@ -0,0 +1,365 @@
1
+ /**
2
+ * The voice module of the SDK: `agentcard.voice.*`. One client, one pair of
3
+ * credentials, one token for the paused request and the voice approval. It
4
+ * connects a person to your product once (the connect link, its exchange, a
5
+ * returning person, a revocation), creates the purchase, asks for the key
6
+ * word, streams or receives the answer, and reads results.
7
+ *
8
+ * One base URL. Test and live are decided by the credentials, never by host.
9
+ * The phone half is its own package, `@agent-cards/voice`: it ships to phones
10
+ * and holds no secret.
11
+ */
12
+ import type { PausedRequest } from './client.js';
13
+ import { ApiModule, type ApiTransport } from './api-module.js';
14
+ import { type StreamFormat, type StreamHandle, type ChannelKind } from './voice-stream.generated.js';
15
+ import { type PkceCrypto } from './voice-pkce.js';
16
+ import type { Language, LanguageInfo } from './languages.js';
17
+ import { type Action, type ActionState, type AppVoiceKeyDescription, type ApprovalPosture, type Authorization, type AuthorizationResult, type Cancelled, type CancelReason, type Connected, type ConnectInput, type ConnectResult, type CreateAuthorizationInput, type Done, type Exchanged, type ExchangeInput, type HostApprovalBundle, type Person, type Proposed, type RegisteredAppVoiceKey, type RevokedAppVoiceKey, type Revoked, type SessionState, type VaultSessionStep, type VoiceChallenge, type VoiceResetInput } from './voice-types.js';
18
+ export { stripePaymentIntentConfirm, type MintedIntent } from './requests.js';
19
+ /**
20
+ * The voice half of the client's options: named once, per business, when the
21
+ * product approves purchases by voice. A client built without it is a
22
+ * checkout client; every `voice.*` verb on it throws `missing_approval_posture`.
23
+ */
24
+ export interface VoiceOptions {
25
+ /**
26
+ * Required: how this product approves purchases. One choice per business,
27
+ * not per purchase. `'sheet'`: the person approves on Agentcard's page with
28
+ * a credential Agentcard verifies. `'in_app'`: hold-to-talk in your app,
29
+ * judged on the phone and by Agentcard, signed by a key in your app.
30
+ * Sandbox and live behave the same. No default.
31
+ */
32
+ approval: ApprovalPosture;
33
+ /** Where the Vault sends the person back when a call names no `return_url` of its own. Exactly one of your registered links. */
34
+ returnUrl?: string;
35
+ /**
36
+ * The verifier's address for the streaming door when your server pushes the
37
+ * audio itself (`wss://…`). A call may name `stream_url` instead, and a
38
+ * challenge minted by an API that names `verifier_url` needs neither.
39
+ */
40
+ verifierUrl?: string;
41
+ /** Deadline for the await calls; the poll spacing is the client's `pollIntervalMs`. Default 60 s. */
42
+ pollTimeoutMs?: number;
43
+ /** Test seam: the retry pauses. */
44
+ backoffMs?: readonly number[];
45
+ /**
46
+ * The pause between two polls. An app may pass one that also wakes when it
47
+ * returns to the foreground, so the answer does not wait for the next tick.
48
+ */
49
+ wait?: (ms: number) => Promise<void>;
50
+ /**
51
+ * Where the grant's random bytes and SHA-256 come from when the runtime has
52
+ * no WebCrypto (a phone runtime running this module). Node, browsers and
53
+ * workers need nothing here.
54
+ */
55
+ pkce?: PkceCrypto;
56
+ }
57
+ /** @deprecated The transport every module shares is `ApiTransport`; this name stays for one release. */
58
+ export type VoiceTransport = ApiTransport & {
59
+ options: VoiceOptions | undefined;
60
+ };
61
+ export declare const GRANT_REQUIRES_EXCHANGE_MESSAGE = "This session is an authorization grant: its result is not read by polling. Hand the return link to voice.completeConnect(url), or its code and state to voice.exchange({ code, state, session_id }).";
62
+ export declare function stepOf(v: unknown): VaultSessionStep | null;
63
+ export declare function reasonOf(v: unknown): string | null;
64
+ /** The business's words for withdrawing a purchase (`authorizations.cancel`); anything else is refused before any call. */
65
+ export declare const CANCEL_REASONS: readonly CancelReason[];
66
+ /**
67
+ * The origin a paused request pays from, when its `origin` header is one Agentcard admits as `checkout_origin`
68
+ * (an exact https origin, or http://localhost for a local run); null otherwise. The Stripe request builders
69
+ * set that header, so a create that names no `checkout_origin` still carries the app's.
70
+ */
71
+ export declare function checkoutOriginOf(request: PausedRequest): string | null;
72
+ export declare const MISSING_APPROVAL_POSTURE_MESSAGE = "Name how your product approves purchases: voice: { approval: 'sheet' } (the person approves on Agentcard's page with a credential Agentcard verifies) or voice: { approval: 'in_app' } (hold-to-talk in your app, judged on the phone and by Agentcard, signed by a key in your app). There is no default.";
73
+ /**
74
+ * The posture as named. Throws `missing_approval_posture` when `voice` was
75
+ * given without a valid posture, or, with `required`, when it was not given.
76
+ */
77
+ export declare function approvalPostureOf(options: VoiceOptions | undefined, required: boolean): ApprovalPosture | undefined;
78
+ export { streamAddress } from './voice-stream.generated.js';
79
+ /**
80
+ * The sandbox request: a first run's purchase, naming no processor. Under a
81
+ * sandbox client `voice.authorizations.create({ request: 'sandbox' })` sends
82
+ * this; the sandbox completes it without reaching any processor. A live
83
+ * client refuses it before any call (`sandbox_request_in_live`).
84
+ */
85
+ export declare const SANDBOX_REQUEST: PausedRequest;
86
+ /** The sealed bundle for the host, from a typed challenge; refuses one the frame cannot sign for. */
87
+ export declare function bundleOf(ch: VoiceChallenge): HostApprovalBundle;
88
+ /** `agentcard.voice`: constructed by the client, never on its own. */
89
+ export declare class VoiceModule extends ApiModule {
90
+ private readonly options;
91
+ private readonly clientIsSandbox;
92
+ /** The approval posture the client was constructed with, one per business; `undefined` when the client named none, and then every verb throws `missing_approval_posture`. */
93
+ readonly approval: ApprovalPosture | undefined;
94
+ /** The grants this client minted, by session id: the verifier and the state, then the exchanged result. Memory only. */
95
+ private readonly grants;
96
+ /** Session id by minted `state`, so a return link finds its grant without naming the session. */
97
+ private readonly grantsByState;
98
+ constructor(t: ApiTransport, options: VoiceOptions | undefined, clientIsSandbox: () => boolean);
99
+ private posture;
100
+ /** Where the Vault sends the person back when a call names nothing, as the client was constructed. */
101
+ get returnUrl(): string | undefined;
102
+ /**
103
+ * The languages Agentcard speaks, as the API lists them (`{ tag, name }`),
104
+ * read once and kept for ten minutes. Every call that names a `lang` checks
105
+ * it against this list first and refuses one not on it with
106
+ * `unsupported_language` before anything is sent. `null` on an API that
107
+ * does not serve the list yet; tags then travel unchecked.
108
+ */
109
+ languages(): Promise<LanguageInfo[] | null>;
110
+ private remember;
111
+ private forget;
112
+ /**
113
+ * Mints the connect link. The person signs in, stores a card if none, sets
114
+ * up their voice if the app requires it, and comes back. Open `url` in the
115
+ * in-app sheet. The link is an OAuth authorization grant: the client mints
116
+ * `state` and a PKCE challenge, keeps the verifier, and the return link
117
+ * comes back as `yourapp://connected?code=…&state=…`; hand it to
118
+ * `completeConnect(url)`, once, within 60 seconds. With no return link there
119
+ * is nothing to carry the code, so the mint polls (`grant: 'poll'`, then
120
+ * `awaitConnected`); `pkce: false` asks for that shape outright (deprecated).
121
+ * A grant asks for the terms it names in `authorization_details`, and for
122
+ * all three when it names none; the terms are enforced from then on. The
123
+ * result carries the client's approval posture as `approval`, for the app.
124
+ */
125
+ connect(input?: ConnectInput): Promise<ConnectResult>;
126
+ /**
127
+ * The grant's exchange: the `code` from the return link, under this client's
128
+ * credentials, with the verifier the client kept for the session. Answers
129
+ * once, within 60 seconds of the link. A `state` that is not the one minted
130
+ * for the session is refused here, before any call (`state_mismatch`). When
131
+ * another instance minted the link, pass the `code_verifier` AND the
132
+ * `expected_state` that `connect` returned there: the link's `state` is
133
+ * compared with `expected_state` locally, and no exchange is made without
134
+ * that comparison. The API's refusals come through verbatim: `invalid_grant`,
135
+ * `not_linked` (the person is not done; try again), `code_expired`,
136
+ * `already_exchanged`, `revoked`. `completeConnect(url)` reads the link and
137
+ * calls this.
138
+ */
139
+ exchange(input: ExchangeInput): Promise<Exchanged>;
140
+ /**
141
+ * The return link, as the sheet handed it back (`yourapp://connected?code=…&state=…`):
142
+ * finds the grant by its `state`, checks it, and exchanges the code. Throws
143
+ * `missing_code` when the link carries none (a session minted to poll, a
144
+ * reset or an action link: read those with `awaitConnected`).
145
+ */
146
+ completeConnect(returnUrl: string, opts?: {
147
+ session_id?: string;
148
+ code_verifier?: string;
149
+ expected_state?: string;
150
+ }): Promise<Exchanged>;
151
+ /**
152
+ * Resolves once the session is linked: who, and what the app may use.
153
+ * For a grant this client minted it resolves when `exchange` (or
154
+ * `completeConnect`) has answered for that session, and reads nothing
155
+ * meanwhile; for a polling mint it polls the session. Throws
156
+ * `connect_timeout` at the deadline, and `grant_requires_exchange` when the
157
+ * API says the session is a grant this client does not hold the verifier for.
158
+ * For one read with no wait, `sessions.get(session_id)`.
159
+ */
160
+ awaitConnected(sessionId: string, opts?: {
161
+ timeout_ms?: number;
162
+ }): Promise<Connected>;
163
+ readonly sessions: {
164
+ /**
165
+ * Where a link stands, in one read and with no wait: its status, how its result is collected (`grant`), and
166
+ * the diary (`last_step`, `reason`) that says why a link came back with nothing. On a linked grant the
167
+ * connected result stays behind the exchange (`exchange_required: true`, the person's fields null); a
168
+ * polling mint reads its result here as `awaitConnected` gives it. `slow_down` is waited out.
169
+ */
170
+ get: (sessionId: string) => Promise<SessionState>;
171
+ };
172
+ /**
173
+ * Revokes the connection a session made: the token its exchange minted is
174
+ * revoked, and an unexchanged code refuses from then on. Idempotent.
175
+ */
176
+ disconnect(sessionId: string): Promise<Revoked>;
177
+ readonly people: {
178
+ /**
179
+ * A returning person: what they already have with this business, without
180
+ * minting a link or sending them anywhere. Store `user_id` from the first
181
+ * exchange; on a later launch read here first, and `connect` only for what
182
+ * is missing (no card, or `voice: 'required'` and no voice for the bot's
183
+ * language). 404 `connection_not_found` when the person never connected
184
+ * through this client (or disconnected). The `user_id` in the answer is
185
+ * the effective one: a merged account answers with its survivor, worth
186
+ * storing from then on.
187
+ */
188
+ get: (userId: string) => Promise<Person>;
189
+ };
190
+ readonly authorizations: {
191
+ /**
192
+ * Creates the purchase, paused for approval, for the person `user_id`
193
+ * names (the `user_id` the connect exchange returned; required, so a
194
+ * server serving many people never charges the wrong one).
195
+ * `execution_mode: 'autopilot'` means the person's rule took it and no
196
+ * voice step follows. The return link (the call's, else the client's
197
+ * `returnUrl`) goes in the create, so Agentcard stores it on the request
198
+ * and the approval page reads it from there; the `approval_url` returned
199
+ * is id-only. `request: 'sandbox'` is the first-run form: under a sandbox
200
+ * client (`sandbox: true`, an `sk_test_` credential, or a mode the token
201
+ * exchange named) it sends the sandbox request and names no processor; a
202
+ * live client refuses it before the create leaves (`sandbox_request_in_live`). Every
203
+ * create carries an idempotency key, so a retried call makes one purchase.
204
+ */
205
+ create: (input: CreateAuthorizationInput) => Promise<Authorization>;
206
+ /**
207
+ * Names the card that pays, before the approval (decision 213): the person said "another card", or chose
208
+ * one from `cards`. `cardId` is one of the person's stored cards as `cards` lists them; a card that is not
209
+ * theirs is `card_not_found`. Refused once the purchase is decided (`already_finalized`) or while the card is
210
+ * with the processor (`replay_in_progress`). Answers the purchase as `get` reads it, `card` and `cards`
211
+ * included. Ask for the key word after this, so the line names the card that will pay.
212
+ */
213
+ setCard: (authorizationId: string, cardId: string) => Promise<AuthorizationResult>;
214
+ /**
215
+ * One read of a purchase, with no wait: its status, what approved it, the
216
+ * request fields, the settlement once it finished, and what a paused
217
+ * page resumes with. The way to ask "is it decided yet?" from a handler
218
+ * that cannot wait; `awaitResult` is the way to wait. `slow_down` is
219
+ * waited out.
220
+ */
221
+ get: (authorizationId: string) => Promise<AuthorizationResult>;
222
+ /**
223
+ * Withdraws a purchase that still awaits the person, in the business's own words: the person closed the
224
+ * sheet (`person_closed_sheet`), the person changed their mind (`person_changed_mind`), or a reason of the
225
+ * business's own (`business_cancelled`). The purchase reads `status: 'cancelled'` from then on, the reason
226
+ * is its `terminal_reason` on every read and on the `checkout_authorization.cancelled` webhook, and
227
+ * `awaitResult` reads `status: 'cancelled'` at once. Idempotent: a purchase already
228
+ * withdrawn answers what it became. One that the person already approved cannot be withdrawn
229
+ * (`409 already_finalized` once it finished, `409 outcome_unknown` while the card is with the processor).
230
+ */
231
+ cancel: (authorizationId: string, opts: {
232
+ reason: CancelReason;
233
+ }) => Promise<Cancelled>;
234
+ };
235
+ readonly approvals: {
236
+ /**
237
+ * The purchase's approval page on the Vault. It offers whichever doors the
238
+ * device has (voice, Face ID, Touch ID, the master password), so it is the
239
+ * way in for a person who forgot the passphrase, a bot with no microphone,
240
+ * or an agent with no screen, and it is the person-held tier of an in-app
241
+ * approval (`approve` from the app half opens it in the sheet). The read
242
+ * names the return link (this call's, else the client's `returnUrl`),
243
+ * the exact registered link the Vault sends the person back to once
244
+ * approved, and Agentcard stores it on the request, so the sheet closes on
245
+ * its own; the link returned is id-only, the page reads the return from
246
+ * Agentcard. Open it (or send it), then `awaitResult`. Null once the
247
+ * purchase no longer awaits a person.
248
+ */
249
+ approvalUrl: (authorizationId: string, opts?: {
250
+ return_url?: string;
251
+ }) => Promise<string | null>;
252
+ };
253
+ /**
254
+ * Asks for the one-time key word. Your bot says `say[lang]` when the
255
+ * person wears headphones, `say_private[lang]` when the phone plays through
256
+ * its speaker or the route is unknown (the line then points at the screen,
257
+ * where your app shows `word`). With `voice: 'braxter'` the response also
258
+ * carries `audio_url`, Agentcard's own voice saying the line, when the
259
+ * deployment has it; `delivery: 'screen'` asks for the private form of that
260
+ * audio. Every field is typed: `challenge` and `intent` are what the app's
261
+ * hosted frame signs over, `verifier_url` and `answer_token` where and with
262
+ * what the phone streams. `lang` defaults to `en` and is checked against
263
+ * `languages()` first. 409 `voice_not_enrolled` when the person has no
264
+ * voice key for apps.
265
+ */
266
+ challenge(authorizationId: string, opts?: {
267
+ lang?: Language;
268
+ voice?: 'braxter';
269
+ delivery?: 'spoken' | 'screen';
270
+ }): Promise<VoiceChallenge>;
271
+ /**
272
+ * The key word for an in-app approval, as one sealed bundle: mints the
273
+ * challenge and hands back the object your app forwards to
274
+ * `VoiceHost.approve` unread. It carries the word and both lines, Agentcard's
275
+ * audio when asked for, the nonce and the intent the frame signs over, and
276
+ * the verifier's address with the answer token the phone streams with (both
277
+ * absent from an API older than them). Refuses with `challenge_incomplete`
278
+ * when the API minted no nonce or intent, since the frame cannot sign
279
+ * without them.
280
+ */
281
+ challengeForHost(authorizationId: string, opts?: {
282
+ lang?: Language;
283
+ voice?: 'braxter';
284
+ delivery?: 'spoken' | 'screen';
285
+ }): Promise<HostApprovalBundle>;
286
+ readonly appKeys: {
287
+ /**
288
+ * Registers the app voice key your app's hosted frame minted (`VoiceHost.provision` relays its description),
289
+ * under this client's credentials, against the person connected to your app. Hand the `credential` back to
290
+ * the phone and nothing else. `user_id` is the person the connect exchange returned; required. 404
291
+ * `connection_not_found` when the person never connected through this client; 409 `credential_exists`
292
+ * when the credential id already names a different key. The same key again answers with a fresh credential.
293
+ */
294
+ register: (key: AppVoiceKeyDescription, opts: {
295
+ user_id: string;
296
+ }) => Promise<RegisteredAppVoiceKey>;
297
+ /** Revokes one app voice key of the person `user_id` names; the person's other keys, the card and the connection stay. Idempotent. */
298
+ revoke: (keyId: string, opts: {
299
+ user_id: string;
300
+ }) => Promise<RevokedAppVoiceKey>;
301
+ };
302
+ /**
303
+ * The streaming door from your server, the push direction: your pipeline
304
+ * already has the person's audio, so hand it to the verifier as it comes.
305
+ * `push` the bytes in `format`, `end` when the person is done (or let the
306
+ * verifier close the span itself), and read `hearing` and `verdict`. A
307
+ * finished recording is a short stream: see `streamBuffer`. The bearer is
308
+ * this client's token. The address is `stream_url` on the call, else the
309
+ * client's `voice.verifierUrl`, else the `verifier_url` the challenge
310
+ * itself carries. `lang` defaults to the challenge's language, else `en`.
311
+ */
312
+ stream(challenge: VoiceChallenge | HostApprovalBundle, opts: {
313
+ format: StreamFormat;
314
+ lang?: Language;
315
+ authorization_id?: string;
316
+ stream_url?: string;
317
+ channel?: ChannelKind;
318
+ }): Promise<StreamHandle>;
319
+ /**
320
+ * "I forgot my passphrase." Mints a voice-only link that starts the
321
+ * person's voice key over: the Vault forgets the device key, revokes the
322
+ * enrolment, and runs set-up again. Open `url` in the sheet, then
323
+ * `awaitConnected(session_id)`; `voice` reads `['en']` once it is done.
324
+ */
325
+ reset(input?: VoiceResetInput): Promise<ConnectResult>;
326
+ /**
327
+ * Polls the purchase until it leaves `awaiting_approval`; `{ status: 'timeout' }`
328
+ * at the deadline. The first read's `interval` (seconds) is the least this
329
+ * waits between reads, and a `slow_down` answer backs off to the interval
330
+ * it names and keeps polling. The result carries `request_id`,
331
+ * `terminal_reason`, `interaction_evidence`, `intent` and the other request
332
+ * fields beside `status`, and on a finished purchase the `settlement`
333
+ * answer the finishing webhook carries. For one read with no wait,
334
+ * `authorizations.get(id)`.
335
+ */
336
+ awaitResult(authorizationId: string, opts?: {
337
+ timeout_ms?: number;
338
+ }): Promise<AuthorizationResult>;
339
+ readonly actions: {
340
+ /**
341
+ * Mints the link that carries one action. Open `url` in the sheet:
342
+ * Agentcard's voice reads the action back, the person confirms it with the
343
+ * secure passphrase and the key word, the Vault runs it and returns.
344
+ * Throws `action_unavailable` for a kind the Vault cannot carry out yet.
345
+ */
346
+ propose: (action: Action, input?: {
347
+ return_url?: string;
348
+ lang?: Language;
349
+ }) => Promise<Proposed>;
350
+ /**
351
+ * One read of an action's link, with no wait: whether the action is done and confirmed, whether a rule
352
+ * covers the card now, the link's status, and the last step and reason its page recorded.
353
+ */
354
+ get: (sessionId: string) => Promise<ActionState>;
355
+ /**
356
+ * Polls the action's session until it reads done, or the deadline; the last state comes back either
357
+ * way, with the last step the Vault's page reached and the last reason it recorded, so a bot that
358
+ * gets `done: false` can say why ("your voice didn't confirm it", "that browser holds no voice key").
359
+ * For one read with no wait, `actions.get(session_id)`.
360
+ */
361
+ awaitDone: (sessionId: string, opts?: {
362
+ timeout_ms?: number;
363
+ }) => Promise<Done>;
364
+ };
365
+ }