@agent-cards/sdk 0.23.28 → 0.24.1

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 (110) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/PREFLIGHT.md +7 -1
  3. package/README.md +197 -102
  4. package/dist/aci.d.ts +52 -22
  5. package/dist/aci.js +79 -15
  6. package/dist/adyen-merchant-hosted.generated.d.ts +2 -2
  7. package/dist/adyen-merchant-hosted.generated.js +586 -55
  8. package/dist/agent-amount.generated.js +1 -1
  9. package/dist/agentcard.d.ts +4 -5
  10. package/dist/agentcard.js +4 -5
  11. package/dist/amadeus.d.ts +9 -3
  12. package/dist/amadeus.js +33 -4
  13. package/dist/api-module.d.ts +1 -7
  14. package/dist/api-module.js +3 -5
  15. package/dist/{voice-retry.js → api-retry.js} +1 -1
  16. package/dist/api-types.d.ts +53 -0
  17. package/dist/{voice-types.js → api-types.js} +7 -2
  18. package/dist/approvals.d.ts +166 -0
  19. package/dist/approvals.js +213 -0
  20. package/dist/aurus.d.ts +33 -0
  21. package/dist/aurus.js +75 -0
  22. package/dist/builtin-registry.generated.js +1 -1
  23. package/dist/buy.d.ts +20 -101
  24. package/dist/buy.js +19 -74
  25. package/dist/capabilities.generated.js +1 -1
  26. package/dist/card-fields.generated.js +2864 -249
  27. package/dist/cardlink-vpos.d.ts +43 -0
  28. package/dist/cardlink-vpos.js +90 -0
  29. package/dist/cdp.d.ts +3 -13
  30. package/dist/cdp.js +244 -175
  31. package/dist/checkout-com.generated.js +5 -1
  32. package/dist/client.d.ts +170 -22
  33. package/dist/client.js +281 -40
  34. package/dist/creditguard.generated.d.ts +4 -4
  35. package/dist/cybersource-flex.generated.d.ts +39 -1
  36. package/dist/cybersource-flex.generated.js +100 -11
  37. package/dist/datatrans.generated.js +22 -1
  38. package/dist/eghl.d.ts +40 -0
  39. package/dist/eghl.js +72 -0
  40. package/dist/elavon-converge.generated.js +5 -3
  41. package/dist/gmo.generated.js +7 -2
  42. package/dist/hold.d.ts +8 -0
  43. package/dist/hold.js +43 -2
  44. package/dist/hosted-entry.js +4 -0
  45. package/dist/index.d.ts +9 -15
  46. package/dist/index.js +6 -10
  47. package/dist/lifecycle.d.ts +9 -61
  48. package/dist/lifecycle.js +24 -10
  49. package/dist/merchant-card-endpoints.generated.d.ts +6 -1
  50. package/dist/merchant-card-endpoints.generated.js +344 -19
  51. package/dist/merchant-hosted.d.ts +8 -1
  52. package/dist/nike-order.d.ts +51 -0
  53. package/dist/nike-order.js +81 -0
  54. package/dist/oceanpayment.d.ts +38 -0
  55. package/dist/oceanpayment.js +70 -0
  56. package/dist/paddle-tokenex.generated.js +111 -11
  57. package/dist/payplug.d.ts +41 -0
  58. package/dist/payplug.js +71 -0
  59. package/dist/payrails.generated.js +33 -8
  60. package/dist/pre-claim.d.ts +11 -0
  61. package/dist/pre-claim.js +130 -7
  62. package/dist/preflight-capabilities.generated.d.ts +0 -4
  63. package/dist/preflight-capabilities.generated.js +0 -5
  64. package/dist/preflight-catalog.json +200 -6
  65. package/dist/preflight-playwright.d.ts +2 -2
  66. package/dist/preflight-playwright.js +63 -14
  67. package/dist/preflight-schemas.json +18 -0
  68. package/dist/preflight.generated.d.ts +5 -4
  69. package/dist/preflight.generated.js +63 -3
  70. package/dist/preparation.d.ts +7 -0
  71. package/dist/preparation.js +21 -0
  72. package/dist/prepared-processor.d.ts +18 -5
  73. package/dist/prepared-processor.js +48 -8
  74. package/dist/primer.generated.js +2889 -268
  75. package/dist/processout.generated.d.ts +61 -0
  76. package/dist/processout.generated.js +577 -0
  77. package/dist/requests.js +1 -1
  78. package/dist/shiji-sts.generated.js +111 -11
  79. package/dist/stripe-checkout.generated.js +2761 -319
  80. package/dist/substitutions.generated.js +553 -26
  81. package/dist/tap-payments.generated.js +111 -11
  82. package/dist/twoc2p.generated.js +111 -11
  83. package/dist/url-masks/bluesnap.d.ts +2 -0
  84. package/dist/url-masks/bluesnap.js +15 -0
  85. package/dist/url-masks/oceanpayment.d.ts +2 -0
  86. package/dist/url-masks/oceanpayment.js +13 -0
  87. package/dist/url-masks/payplug.d.ts +2 -0
  88. package/dist/url-masks/payplug.js +13 -0
  89. package/dist/url-masks/vtex_payments.d.ts +2 -0
  90. package/dist/url-masks/vtex_payments.js +12 -0
  91. package/dist/url-masks.generated.d.ts +1 -1
  92. package/dist/url-masks.generated.js +6 -2
  93. package/dist/verifone.generated.js +42 -2
  94. package/dist/vtex-payments.generated.d.ts +127 -0
  95. package/dist/vtex-payments.generated.js +544 -0
  96. package/dist/webhooks.d.ts +2 -2
  97. package/dist/webhooks.js +2 -2
  98. package/examples/preflight/kernel-native/inventory.json +1 -1
  99. package/package.json +6 -8
  100. package/dist/languages.d.ts +0 -23
  101. package/dist/languages.js +0 -76
  102. package/dist/voice-pkce.d.ts +0 -49
  103. package/dist/voice-pkce.js +0 -147
  104. package/dist/voice-stream.generated.d.ts +0 -118
  105. package/dist/voice-stream.generated.js +0 -170
  106. package/dist/voice-types.d.ts +0 -735
  107. package/dist/voice.d.ts +0 -373
  108. package/dist/voice.js +0 -815
  109. package/readme.test.mjs +0 -53
  110. /package/dist/{voice-retry.d.ts → api-retry.d.ts} +0 -0
@@ -1,170 +0,0 @@
1
- // GENERATED by scripts/generate-voice-stream.mjs from packages/voice/src/core/stream.ts. Do not edit; edit the source and rebuild.
2
- /**
3
- * The streaming door, from either side: the person's
4
- * answer goes to the verifier as it is spoken, over one WebSocket, and the
5
- * verifier says `hearing` the moment the key word is out and `verdict` when it
6
- * has closed the span. One call serves a live microphone and a finished
7
- * recording alike: a buffer pushed in one go and ended is a short stream.
8
- *
9
- * Uses the platform's WebSocket (Node 22, React Native, the browser). The
10
- * credential rides in the first frame, never in a header, so every platform
11
- * behaves the same.
12
- */
13
- import { AgentcardError } from './voice-types.js';
14
- export const CHANNEL_KINDS = ['builtin', 'wired', 'bluetooth', 'unknown'];
15
- /** The receipt as the verifier sends it, every field a string, or null for anything else: a receipt with a piece missing cannot be checked, so it is not carried. */
16
- function receiptOf(r) {
17
- if (!r || typeof r !== 'object')
18
- return null;
19
- const { payload, signature, alg, kid } = r;
20
- return typeof payload === 'string' && typeof signature === 'string' && typeof alg === 'string' && typeof kid === 'string' ? { payload, signature, alg, kid } : null;
21
- }
22
- function toArrayBuffer(chunk) {
23
- if (chunk instanceof ArrayBuffer)
24
- return chunk;
25
- return chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength);
26
- }
27
- /** Opens the door and hands back the handle. The first frame names the challenge; bytes follow. */
28
- export function openStream(input) {
29
- const WS = input.WebSocket ?? globalThis.WebSocket;
30
- if (!WS)
31
- throw new AgentcardError('no_websocket', 'This runtime has no WebSocket; the streaming door needs one.');
32
- const ws = new WS(input.stream_url);
33
- ws.binaryType = 'arraybuffer';
34
- const listeners = { hearing: [], verdict: [], error: [] };
35
- // Audio chunks and, ahead of the first sealed chunk, the `sealed` text frame: sent in the order they were queued.
36
- const queue = [];
37
- let open = false, ended = false, settled = false, sealed = false;
38
- let channelKind = input.channel && CHANNEL_KINDS.includes(input.channel) ? input.channel : undefined;
39
- // A channel named after the open goes as its own text frame; one named before rides the first frame.
40
- let channelPending = null;
41
- let resolveVerdict, rejectVerdict;
42
- const verdictPromise = new Promise((resolve, reject) => { resolveVerdict = resolve; rejectVerdict = reject; });
43
- verdictPromise.catch(() => { });
44
- const fail = (err) => {
45
- if (settled)
46
- return;
47
- settled = true;
48
- for (const fn of listeners.error)
49
- fn(err);
50
- rejectVerdict(err);
51
- };
52
- const flush = () => { while (open && queue.length)
53
- ws.send(queue.shift()); };
54
- ws.onopen = () => {
55
- // No token on the frame when the caller has none: a fronting door may carry the credential on the upgrade instead.
56
- ws.send(JSON.stringify({ authorization_id: input.authorization_id, challenge_id: input.challenge_id, lang: input.lang, format: input.format, ...(input.token ? { token: input.token } : {}), ...(channelKind ? { channel: channelKind } : {}) }));
57
- open = true;
58
- if (channelPending) {
59
- ws.send(JSON.stringify({ type: 'channel', kind: channelPending }));
60
- channelPending = null;
61
- }
62
- flush();
63
- if (ended)
64
- ws.send(JSON.stringify({ type: 'end' }));
65
- };
66
- ws.onmessage = (ev) => {
67
- if (typeof ev.data !== 'string')
68
- return;
69
- let msg;
70
- try {
71
- msg = JSON.parse(ev.data);
72
- }
73
- catch {
74
- return;
75
- }
76
- if (msg.type === 'hearing') {
77
- const h = { heard_count: Math.max(0, Math.floor(Number(msg.heard_count)) || 0) };
78
- for (const fn of listeners.hearing)
79
- fn(h);
80
- }
81
- else if (msg.type === 'verdict') {
82
- if (settled)
83
- return;
84
- settled = true;
85
- const receipt = receiptOf(msg.receipt);
86
- const v = {
87
- accepted: msg.accepted === true, spent: true,
88
- approved_with: typeof msg.approved_with === 'string' ? msg.approved_with : null,
89
- reason: String(msg.reason ?? ''), bits: msg.bits ?? { words: 0, voice: 0, total: 0 },
90
- cos: typeof msg.cos === 'number' ? msg.cos : null, z: typeof msg.z === 'number' ? msg.z : null,
91
- speech_s: Number(msg.speech_s ?? 0), ms: Number(msg.ms ?? 0), since_end_ms: Number(msg.since_end_ms ?? 0), closed_by: String(msg.closed_by ?? ''),
92
- ...(receipt ? { receipt } : {}),
93
- };
94
- for (const fn of listeners.verdict)
95
- fn(v);
96
- resolveVerdict(v);
97
- }
98
- else if (msg.type === 'error') {
99
- fail(new AgentcardError(String(msg.code ?? 'verifier_error'), String(msg.message ?? 'The verifier refused the stream.')));
100
- }
101
- };
102
- ws.onerror = () => fail(new AgentcardError('unreachable', 'The verifier could not be reached.'));
103
- ws.onclose = () => fail(new AgentcardError('stream_closed', 'The verifier closed the stream without a verdict.'));
104
- const handle = {
105
- format: input.format,
106
- push(chunk) { if (ended || settled)
107
- return; queue.push(toArrayBuffer(chunk)); flush(); },
108
- end() { if (ended)
109
- return; ended = true; if (open) {
110
- flush();
111
- ws.send(JSON.stringify({ type: 'end' }));
112
- } },
113
- channel(kind) {
114
- if (settled || ended || !CHANNEL_KINDS.includes(kind))
115
- return;
116
- if (!open) {
117
- channelKind = kind;
118
- channelPending = null;
119
- return;
120
- }
121
- channelKind = kind;
122
- ws.send(JSON.stringify({ type: 'channel', kind }));
123
- },
124
- seal(head) {
125
- if (settled || ended || sealed || typeof head.eph !== 'string' || !head.eph)
126
- return;
127
- sealed = true;
128
- const kid = typeof head.kid === 'string' && head.kid ? head.kid : null;
129
- queue.push(JSON.stringify({ type: 'sealed', alg: head.alg, eph: head.eph, ...(kid ? { kid } : {}) }));
130
- flush();
131
- },
132
- on(event, fn) { listeners[event].push(fn); return handle; },
133
- verdict: () => verdictPromise,
134
- close() { if (!settled) {
135
- settled = true;
136
- rejectVerdict(new AgentcardError('stream_closed', 'The stream was closed before a verdict.'));
137
- } try {
138
- ws.close();
139
- }
140
- catch { /* already closed */ } },
141
- };
142
- return handle;
143
- }
144
- const PCM16_16K_BYTES_PER_MS = 32;
145
- /**
146
- * A finished recording through the same door. For `pcm16-16k` with `chunkMs`
147
- * the bytes go in timed chunks, as a microphone would send them; otherwise
148
- * the whole buffer goes at once. Ends the stream and resolves the verdict.
149
- */
150
- export async function streamBuffer(handle, bytes, chunkMs) {
151
- const u8 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
152
- if (chunkMs && chunkMs > 0 && handle.format === 'pcm16-16k') {
153
- const step = PCM16_16K_BYTES_PER_MS * chunkMs;
154
- for (let i = 0; i < u8.length; i += step) {
155
- handle.push(u8.subarray(i, Math.min(u8.length, i + step)));
156
- if (i + step < u8.length)
157
- await new Promise((r) => setTimeout(r, chunkMs));
158
- }
159
- }
160
- else {
161
- handle.push(u8);
162
- }
163
- handle.end();
164
- return handle.verdict();
165
- }
166
- /** The verifier's streaming address from its origin (`/v1/stream` appended) or a full address, as given. */
167
- export function streamAddress(verifierUrl) {
168
- const trimmed = verifierUrl.replace(/\/+$/, '');
169
- return /\/v1\/stream$/.test(trimmed) ? trimmed : trimmed + '/v1/stream';
170
- }