@invonetwork/web-sdk 2.5.1 → 3.1.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/CHANGELOG.md +110 -0
- package/README.md +125 -39
- package/dist/{chunk-5X3ESHJR.js → chunk-BPZJ63RM.js} +68 -2
- package/dist/index.cjs +133 -189
- package/dist/index.d.cts +18 -39
- package/dist/index.d.ts +18 -39
- package/dist/index.js +69 -191
- package/dist/server.cjs +134 -69
- package/dist/server.d.cts +39 -19
- package/dist/server.d.ts +39 -19
- package/dist/server.js +70 -71
- package/dist/{types-BHvVjdMV.d.cts → types-DjY-50jn.d.cts} +115 -118
- package/dist/{types-BHvVjdMV.d.ts → types-DjY-50jn.d.ts} +115 -118
- package/package.json +1 -1
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, b as CallOptions, q as PlatformPurchaseResult, r as PlatformOrderStatusResult, s as PlatformRefundInput, t as PlatformRefundResult, S as ServerConfig, u as PlayerToken, v as InitiateSendInput, w as InitiateResult, x as InitiateTransferInput, y as CreateCheckoutInput, z as CreateCheckoutResult, F as PurchaseInput, G as PurchaseResult, J as ConfirmPaymentResult, O as OrderDetailsResult, K as PurchaseItemInput, N as PurchaseItemResult, Q as ItemHistoryQuery, T as ItemHistoryResult, U as ItemOrderQuery, W as PlayerBalanceQuery, X as PlayerBalanceResult, Y as InboundPendingQuery, Z as InboundPendingResult, _ as LinkedIdentitiesQuery, $ as LinkedIdentitiesResult, a0 as SmsVerifyResult, a1 as ClaimTransferInput, a2 as ClaimResult, a3 as ClaimCurrencyInput, a4 as TransactionStatusResult, a5 as GuardianApprovalStatusResult, a6 as ServerDestinationsQuery, d as DestinationsResult, a7 as PhoneShareContact, a8 as PhoneShareInitiateResult, a9 as PhoneShareApproveInput, aa as PhoneShareApproveResult, ab as PhoneShareStatusResult } from './types-DjY-50jn.cjs';
|
|
2
|
+
export { ac as CurrencyBalance, h as DestinationGame, ad as FundingSource, ae as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, af as LinkedIdentityEmail, ag as PlatformPurchaseStatus, n as Rail, V as VerificationMethod } from './types-DjY-50jn.cjs';
|
|
3
3
|
|
|
4
4
|
interface VerifyWebhookOptions {
|
|
5
5
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
|
@@ -222,19 +222,19 @@ declare class PlatformCommerceServer {
|
|
|
222
222
|
*
|
|
223
223
|
* - `fundingSource: "balance"` → settles synchronously; result `status:"success"` with
|
|
224
224
|
* `newBalance`/`financialBreakdown`. `totalPrice` is the tenant's network-currency amount.
|
|
225
|
-
* - `fundingSource: "card"` → result `status:"requires_payment"` + `
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
225
|
+
* - `fundingSource: "card"` → result `status:"requires_payment"` + `checkoutUrl`/`sessionId`.
|
|
226
|
+
* Send the buyer to `checkoutUrl` — INVO's hosted page owns the card form, wallets,
|
|
227
|
+
* billing address, and 3-D Secure (there is NO billing address in this request, and no
|
|
228
|
+
* client payment code to write; optionally embed via
|
|
229
|
+
* `InvoClient.platformCommerce.mountCheckout`). `totalPrice` is USD ($0.50–$999.99).
|
|
230
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — never on the
|
|
231
|
+
* client return.
|
|
229
232
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* 409 and the `clientSecret` cannot be re-fetched — reconcile that order via the
|
|
236
|
-
* `platform_commerce.purchased` webhook / `getStatus`, and use a NEW `clientRequestId`
|
|
237
|
-
* for a fresh attempt. The balance leg has no such gap.
|
|
233
|
+
* Idempotency on `clientRequestId`: the balance leg throws a 409
|
|
234
|
+
* (`err.isDuplicateRequest`) on a duplicate; the card leg REPLAYS the same checkout
|
|
235
|
+
* session (`idempotentReplay: true`) — a lost response is safely recovered by retrying
|
|
236
|
+
* with the SAME `clientRequestId`. A non-platform tenant throws
|
|
237
|
+
* `err.isNotPlatformTenant` (403).
|
|
238
238
|
*/
|
|
239
239
|
purchase(input: PlatformPurchaseInput, opts?: CallOptions): Promise<PlatformPurchaseResult>;
|
|
240
240
|
/** Poll an order's status: `completed` (balance immediately; card after the webhook),
|
|
@@ -365,13 +365,33 @@ declare class InvoServer {
|
|
|
365
365
|
*/
|
|
366
366
|
getLinkedIdentities(query: LinkedIdentitiesQuery, opts?: CallOptions): Promise<LinkedIdentitiesResult>;
|
|
367
367
|
/**
|
|
368
|
-
* Complete a TRANSFER's SMS-PIN step
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
368
|
+
* Complete a TRANSFER's SMS-PIN step — the LAST-RESORT fallback for a sender who has
|
|
369
|
+
* no passkey.
|
|
370
|
+
*
|
|
371
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
372
|
+
* remove this method. **Passkeys are the gold standard for authorizing money movement**
|
|
373
|
+
* — an SMS PIN is a shared secret on a channel exposed to SIM swap and interception,
|
|
374
|
+
* and it is not a peer of a WebAuthn assertion. When `initiate*` returns
|
|
375
|
+
* `verificationMethod: "sms"` it is telling you the sender has no passkey: prompt
|
|
376
|
+
* `InvoClient.enrollPasskey()` and then approve with
|
|
377
|
+
* `InvoClient.approveTransfer(transactionId)`. Reach for this method only when the user
|
|
378
|
+
* cannot enroll (unsupported device) or declines. Still fully functional — this
|
|
379
|
+
* annotation changes documentation only, not behavior.
|
|
380
|
+
*
|
|
381
|
+
* NOT idempotent — each attempt is counted server-side, so this is never auto-retried.
|
|
382
|
+
* A bad PIN throws a 400 InvoError carrying `attempts_remaining` on `err.body`; a
|
|
383
|
+
* blocked recipient throws 429 (`sms_verification_blocked`).
|
|
372
384
|
*/
|
|
373
385
|
verifySmsTransfer(transactionId: string, smsPin: string, opts?: CallOptions): Promise<SmsVerifyResult>;
|
|
374
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Complete a SEND's SMS-PIN step — the LAST-RESORT fallback for a sender who has no
|
|
388
|
+
* passkey. See {@link verifySmsTransfer}.
|
|
389
|
+
*
|
|
390
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
391
|
+
* remove this method. Prompt `InvoClient.enrollPasskey()` and approve with
|
|
392
|
+
* `InvoClient.approveSend(transactionId)` instead; use this only when the user cannot
|
|
393
|
+
* enroll or declines. Documentation only — behavior is unchanged.
|
|
394
|
+
*/
|
|
375
395
|
verifySmsSend(transactionId: string, smsPin: string, opts?: CallOptions): Promise<SmsVerifyResult>;
|
|
376
396
|
/**
|
|
377
397
|
* Claim an inbound TRANSFER by its claim code, crediting one of this game's currencies.
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, b as CallOptions, q as PlatformPurchaseResult, r as PlatformOrderStatusResult, s as PlatformRefundInput, t as PlatformRefundResult, S as ServerConfig, u as PlayerToken, v as InitiateSendInput, w as InitiateResult, x as InitiateTransferInput, y as CreateCheckoutInput, z as CreateCheckoutResult, F as PurchaseInput, G as PurchaseResult, J as ConfirmPaymentResult, O as OrderDetailsResult, K as PurchaseItemInput, N as PurchaseItemResult, Q as ItemHistoryQuery, T as ItemHistoryResult, U as ItemOrderQuery, W as PlayerBalanceQuery, X as PlayerBalanceResult, Y as InboundPendingQuery, Z as InboundPendingResult, _ as LinkedIdentitiesQuery, $ as LinkedIdentitiesResult, a0 as SmsVerifyResult, a1 as ClaimTransferInput, a2 as ClaimResult, a3 as ClaimCurrencyInput, a4 as TransactionStatusResult, a5 as GuardianApprovalStatusResult, a6 as ServerDestinationsQuery, d as DestinationsResult, a7 as PhoneShareContact, a8 as PhoneShareInitiateResult, a9 as PhoneShareApproveInput, aa as PhoneShareApproveResult, ab as PhoneShareStatusResult } from './types-DjY-50jn.js';
|
|
2
|
+
export { ac as CurrencyBalance, h as DestinationGame, ad as FundingSource, ae as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, af as LinkedIdentityEmail, ag as PlatformPurchaseStatus, n as Rail, V as VerificationMethod } from './types-DjY-50jn.js';
|
|
3
3
|
|
|
4
4
|
interface VerifyWebhookOptions {
|
|
5
5
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
|
@@ -222,19 +222,19 @@ declare class PlatformCommerceServer {
|
|
|
222
222
|
*
|
|
223
223
|
* - `fundingSource: "balance"` → settles synchronously; result `status:"success"` with
|
|
224
224
|
* `newBalance`/`financialBreakdown`. `totalPrice` is the tenant's network-currency amount.
|
|
225
|
-
* - `fundingSource: "card"` → result `status:"requires_payment"` + `
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
225
|
+
* - `fundingSource: "card"` → result `status:"requires_payment"` + `checkoutUrl`/`sessionId`.
|
|
226
|
+
* Send the buyer to `checkoutUrl` — INVO's hosted page owns the card form, wallets,
|
|
227
|
+
* billing address, and 3-D Secure (there is NO billing address in this request, and no
|
|
228
|
+
* client payment code to write; optionally embed via
|
|
229
|
+
* `InvoClient.platformCommerce.mountCheckout`). `totalPrice` is USD ($0.50–$999.99).
|
|
230
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — never on the
|
|
231
|
+
* client return.
|
|
229
232
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* 409 and the `clientSecret` cannot be re-fetched — reconcile that order via the
|
|
236
|
-
* `platform_commerce.purchased` webhook / `getStatus`, and use a NEW `clientRequestId`
|
|
237
|
-
* for a fresh attempt. The balance leg has no such gap.
|
|
233
|
+
* Idempotency on `clientRequestId`: the balance leg throws a 409
|
|
234
|
+
* (`err.isDuplicateRequest`) on a duplicate; the card leg REPLAYS the same checkout
|
|
235
|
+
* session (`idempotentReplay: true`) — a lost response is safely recovered by retrying
|
|
236
|
+
* with the SAME `clientRequestId`. A non-platform tenant throws
|
|
237
|
+
* `err.isNotPlatformTenant` (403).
|
|
238
238
|
*/
|
|
239
239
|
purchase(input: PlatformPurchaseInput, opts?: CallOptions): Promise<PlatformPurchaseResult>;
|
|
240
240
|
/** Poll an order's status: `completed` (balance immediately; card after the webhook),
|
|
@@ -365,13 +365,33 @@ declare class InvoServer {
|
|
|
365
365
|
*/
|
|
366
366
|
getLinkedIdentities(query: LinkedIdentitiesQuery, opts?: CallOptions): Promise<LinkedIdentitiesResult>;
|
|
367
367
|
/**
|
|
368
|
-
* Complete a TRANSFER's SMS-PIN step
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
368
|
+
* Complete a TRANSFER's SMS-PIN step — the LAST-RESORT fallback for a sender who has
|
|
369
|
+
* no passkey.
|
|
370
|
+
*
|
|
371
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
372
|
+
* remove this method. **Passkeys are the gold standard for authorizing money movement**
|
|
373
|
+
* — an SMS PIN is a shared secret on a channel exposed to SIM swap and interception,
|
|
374
|
+
* and it is not a peer of a WebAuthn assertion. When `initiate*` returns
|
|
375
|
+
* `verificationMethod: "sms"` it is telling you the sender has no passkey: prompt
|
|
376
|
+
* `InvoClient.enrollPasskey()` and then approve with
|
|
377
|
+
* `InvoClient.approveTransfer(transactionId)`. Reach for this method only when the user
|
|
378
|
+
* cannot enroll (unsupported device) or declines. Still fully functional — this
|
|
379
|
+
* annotation changes documentation only, not behavior.
|
|
380
|
+
*
|
|
381
|
+
* NOT idempotent — each attempt is counted server-side, so this is never auto-retried.
|
|
382
|
+
* A bad PIN throws a 400 InvoError carrying `attempts_remaining` on `err.body`; a
|
|
383
|
+
* blocked recipient throws 429 (`sms_verification_blocked`).
|
|
372
384
|
*/
|
|
373
385
|
verifySmsTransfer(transactionId: string, smsPin: string, opts?: CallOptions): Promise<SmsVerifyResult>;
|
|
374
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* Complete a SEND's SMS-PIN step — the LAST-RESORT fallback for a sender who has no
|
|
388
|
+
* passkey. See {@link verifySmsTransfer}.
|
|
389
|
+
*
|
|
390
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
391
|
+
* remove this method. Prompt `InvoClient.enrollPasskey()` and approve with
|
|
392
|
+
* `InvoClient.approveSend(transactionId)` instead; use this only when the user cannot
|
|
393
|
+
* enroll or declines. Documentation only — behavior is unchanged.
|
|
394
|
+
*/
|
|
375
395
|
verifySmsSend(transactionId: string, smsPin: string, opts?: CallOptions): Promise<SmsVerifyResult>;
|
|
376
396
|
/**
|
|
377
397
|
* Claim an inbound TRANSFER by its claim code, crediting one of this game's currencies.
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-BPZJ63RM.js';
|
|
2
|
+
export { InvoError } from './chunk-BPZJ63RM.js';
|
|
3
3
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
|
|
5
5
|
var DEFAULT_TOLERANCE_SEC = 300;
|
|
@@ -167,7 +167,7 @@ async function hmacHexSubtle(secret, message) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// src/server.ts
|
|
170
|
-
var DEFAULT_UA = "invonetwork-web-sdk/
|
|
170
|
+
var DEFAULT_UA = "invonetwork-web-sdk/3.0.0 (+https://invo.network)";
|
|
171
171
|
var MAX_USD_AMOUNT = 999.99;
|
|
172
172
|
var MAX_ITEM_PRICE = 999999.99;
|
|
173
173
|
function invalidInput(label, value, why) {
|
|
@@ -329,48 +329,8 @@ function requireField(value, field, raw) {
|
|
|
329
329
|
return s;
|
|
330
330
|
}
|
|
331
331
|
var FUNDING_SOURCES = /* @__PURE__ */ new Set(["balance", "card"]);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
function assertBillingAddress(addr, label) {
|
|
336
|
-
if (!addr || typeof addr !== "object") {
|
|
337
|
-
throw invalidInputNoEcho(label, 'is required for the "card" funding source and must be an object');
|
|
338
|
-
}
|
|
339
|
-
const required = [
|
|
340
|
-
[`${label}.line1`, addr.line1],
|
|
341
|
-
[`${label}.city`, addr.city],
|
|
342
|
-
[`${label}.postalCode`, addr.postalCode],
|
|
343
|
-
[`${label}.country`, addr.country]
|
|
344
|
-
];
|
|
345
|
-
for (const [k, v] of required) {
|
|
346
|
-
if (typeof v !== "string" || !v.trim()) throw invalidInputNoEcho(k, "is required");
|
|
347
|
-
}
|
|
348
|
-
if (!/^[A-Za-z]{2}$/.test(addr.country)) {
|
|
349
|
-
throw invalidInputNoEcho(`${label}.country`, "must be a 2-letter ISO country code");
|
|
350
|
-
}
|
|
351
|
-
const optional = [
|
|
352
|
-
[`${label}.name`, addr.name],
|
|
353
|
-
[`${label}.line2`, addr.line2],
|
|
354
|
-
[`${label}.state`, addr.state]
|
|
355
|
-
];
|
|
356
|
-
for (const [k, v] of optional) {
|
|
357
|
-
if (v !== void 0 && typeof v !== "string") {
|
|
358
|
-
throw invalidInputNoEcho(k, "must be a string when provided");
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function toBillingAddressBody(addr) {
|
|
363
|
-
const body = {
|
|
364
|
-
line1: addr.line1,
|
|
365
|
-
city: addr.city,
|
|
366
|
-
postal_code: addr.postalCode,
|
|
367
|
-
country: addr.country
|
|
368
|
-
};
|
|
369
|
-
if (addr.name) body["name"] = addr.name;
|
|
370
|
-
if (addr.line2) body["line2"] = addr.line2;
|
|
371
|
-
if (addr.state) body["state"] = addr.state;
|
|
372
|
-
return body;
|
|
373
|
-
}
|
|
332
|
+
var CARD_MIN_USD = 0.5;
|
|
333
|
+
var CARD_MAX_USD = 999.99;
|
|
374
334
|
var PlatformCommerceServer = class {
|
|
375
335
|
constructor(http, auth) {
|
|
376
336
|
this.http = http;
|
|
@@ -383,19 +343,19 @@ var PlatformCommerceServer = class {
|
|
|
383
343
|
*
|
|
384
344
|
* - `fundingSource: "balance"` → settles synchronously; result `status:"success"` with
|
|
385
345
|
* `newBalance`/`financialBreakdown`. `totalPrice` is the tenant's network-currency amount.
|
|
386
|
-
* - `fundingSource: "card"` → result `status:"requires_payment"` + `
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
346
|
+
* - `fundingSource: "card"` → result `status:"requires_payment"` + `checkoutUrl`/`sessionId`.
|
|
347
|
+
* Send the buyer to `checkoutUrl` — INVO's hosted page owns the card form, wallets,
|
|
348
|
+
* billing address, and 3-D Secure (there is NO billing address in this request, and no
|
|
349
|
+
* client payment code to write; optionally embed via
|
|
350
|
+
* `InvoClient.platformCommerce.mountCheckout`). `totalPrice` is USD ($0.50–$999.99).
|
|
351
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — never on the
|
|
352
|
+
* client return.
|
|
390
353
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* 409 and the `clientSecret` cannot be re-fetched — reconcile that order via the
|
|
397
|
-
* `platform_commerce.purchased` webhook / `getStatus`, and use a NEW `clientRequestId`
|
|
398
|
-
* for a fresh attempt. The balance leg has no such gap.
|
|
354
|
+
* Idempotency on `clientRequestId`: the balance leg throws a 409
|
|
355
|
+
* (`err.isDuplicateRequest`) on a duplicate; the card leg REPLAYS the same checkout
|
|
356
|
+
* session (`idempotentReplay: true`) — a lost response is safely recovered by retrying
|
|
357
|
+
* with the SAME `clientRequestId`. A non-platform tenant throws
|
|
358
|
+
* `err.isNotPlatformTenant` (403).
|
|
399
359
|
*/
|
|
400
360
|
async purchase(input, opts) {
|
|
401
361
|
const required = [
|
|
@@ -426,7 +386,20 @@ var PlatformCommerceServer = class {
|
|
|
426
386
|
);
|
|
427
387
|
}
|
|
428
388
|
if (input.fundingSource === "card") {
|
|
429
|
-
|
|
389
|
+
if (total < CARD_MIN_USD) {
|
|
390
|
+
throw new InvoError({
|
|
391
|
+
message: `Card purchases must be at least $${CARD_MIN_USD.toFixed(2)}.`,
|
|
392
|
+
code: "BELOW_STRIPE_MINIMUM",
|
|
393
|
+
status: 0
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (total > CARD_MAX_USD) {
|
|
397
|
+
throw new InvoError({
|
|
398
|
+
message: `Card purchases must be $${CARD_MAX_USD} or less.`,
|
|
399
|
+
code: "ABOVE_CARD_MAXIMUM",
|
|
400
|
+
status: 0
|
|
401
|
+
});
|
|
402
|
+
}
|
|
430
403
|
}
|
|
431
404
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
432
405
|
const body = {
|
|
@@ -443,31 +416,37 @@ var PlatformCommerceServer = class {
|
|
|
443
416
|
if (input.playerPhone) body["player_phone"] = input.playerPhone;
|
|
444
417
|
if (input.itemDescription) body["item_description"] = input.itemDescription;
|
|
445
418
|
if (input.itemCategory) body["item_category"] = input.itemCategory;
|
|
446
|
-
if (input.
|
|
419
|
+
if (input.successUrl) body["success_url"] = input.successUrl;
|
|
420
|
+
if (input.cancelUrl) body["cancel_url"] = input.cancelUrl;
|
|
421
|
+
if (input.metadata) body["metadata"] = input.metadata;
|
|
447
422
|
const raw = await this.http.post(
|
|
448
423
|
"/api/platform-commerce/purchase",
|
|
449
424
|
body,
|
|
450
425
|
this.auth,
|
|
426
|
+
// Safe to retry: balance dedupes (dup → 409); card REPLAYS the same session.
|
|
451
427
|
{ idempotent: true, signal: opts?.signal }
|
|
452
|
-
// client_request_id makes this safe to retry (dup → 409)
|
|
453
428
|
);
|
|
454
|
-
const orderIdRaw = raw["order_id"];
|
|
455
|
-
requireField(orderIdRaw, "order_id", raw);
|
|
456
429
|
const status = String(raw["status"] ?? "");
|
|
457
|
-
if (status === "requires_payment"
|
|
458
|
-
requireField(raw["
|
|
430
|
+
if (status === "requires_payment") {
|
|
431
|
+
requireField(raw["checkout_url"], "checkout_url", raw);
|
|
432
|
+
} else {
|
|
433
|
+
requireField(raw["order_id"], "order_id", raw);
|
|
459
434
|
}
|
|
435
|
+
const expiresAtRaw = raw["expires_at"];
|
|
460
436
|
return {
|
|
461
437
|
status,
|
|
462
438
|
fundingSource: String(raw["funding_source"] ?? input.fundingSource),
|
|
463
|
-
orderId:
|
|
439
|
+
orderId: raw["order_id"] ?? void 0,
|
|
464
440
|
transactionId: raw["transaction_id"],
|
|
465
441
|
newBalance: raw["new_balance"] ?? null,
|
|
466
442
|
previousBalance: raw["previous_balance"] ?? null,
|
|
467
443
|
currencyName: raw["currency_name"],
|
|
468
444
|
financialBreakdown: raw["financial_breakdown"],
|
|
469
|
-
|
|
445
|
+
sessionId: raw["session_id"],
|
|
446
|
+
checkoutUrl: raw["checkout_url"],
|
|
447
|
+
expiresAt: typeof expiresAtRaw === "number" ? expiresAtRaw : void 0,
|
|
470
448
|
amountUsd: raw["amount_usd"] ?? null,
|
|
449
|
+
idempotentReplay: raw["idempotent_replay"] === true,
|
|
471
450
|
raw
|
|
472
451
|
};
|
|
473
452
|
}
|
|
@@ -1003,10 +982,22 @@ var InvoServer = class {
|
|
|
1003
982
|
};
|
|
1004
983
|
}
|
|
1005
984
|
/**
|
|
1006
|
-
* Complete a TRANSFER's SMS-PIN step
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
985
|
+
* Complete a TRANSFER's SMS-PIN step — the LAST-RESORT fallback for a sender who has
|
|
986
|
+
* no passkey.
|
|
987
|
+
*
|
|
988
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
989
|
+
* remove this method. **Passkeys are the gold standard for authorizing money movement**
|
|
990
|
+
* — an SMS PIN is a shared secret on a channel exposed to SIM swap and interception,
|
|
991
|
+
* and it is not a peer of a WebAuthn assertion. When `initiate*` returns
|
|
992
|
+
* `verificationMethod: "sms"` it is telling you the sender has no passkey: prompt
|
|
993
|
+
* `InvoClient.enrollPasskey()` and then approve with
|
|
994
|
+
* `InvoClient.approveTransfer(transactionId)`. Reach for this method only when the user
|
|
995
|
+
* cannot enroll (unsupported device) or declines. Still fully functional — this
|
|
996
|
+
* annotation changes documentation only, not behavior.
|
|
997
|
+
*
|
|
998
|
+
* NOT idempotent — each attempt is counted server-side, so this is never auto-retried.
|
|
999
|
+
* A bad PIN throws a 400 InvoError carrying `attempts_remaining` on `err.body`; a
|
|
1000
|
+
* blocked recipient throws 429 (`sms_verification_blocked`).
|
|
1010
1001
|
*/
|
|
1011
1002
|
async verifySmsTransfer(transactionId, smsPin, opts) {
|
|
1012
1003
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
@@ -1024,7 +1015,15 @@ var InvoServer = class {
|
|
|
1024
1015
|
);
|
|
1025
1016
|
return toSmsVerifyResult(raw);
|
|
1026
1017
|
}
|
|
1027
|
-
/**
|
|
1018
|
+
/**
|
|
1019
|
+
* Complete a SEND's SMS-PIN step — the LAST-RESORT fallback for a sender who has no
|
|
1020
|
+
* passkey. See {@link verifySmsTransfer}.
|
|
1021
|
+
*
|
|
1022
|
+
* @deprecated The SMS-PIN path is being phased out and a future major version will
|
|
1023
|
+
* remove this method. Prompt `InvoClient.enrollPasskey()` and approve with
|
|
1024
|
+
* `InvoClient.approveSend(transactionId)` instead; use this only when the user cannot
|
|
1025
|
+
* enroll or declines. Documentation only — behavior is unchanged.
|
|
1026
|
+
*/
|
|
1028
1027
|
async verifySmsSend(transactionId, smsPin, opts) {
|
|
1029
1028
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
1030
1029
|
throw invalidInput("transactionId", transactionId, "is required");
|