@fun-xyz/fiat-contract 0.40.0 → 0.43.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/coinbase.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/providers/coinbase';
package/coinbase.js ADDED
@@ -0,0 +1,2 @@
1
+ // Compat stub — see table.js. Metro before RN 0.79 resolves `@fun-xyz/fiat-contract/coinbase` by path.
2
+ module.exports = require('./dist/providers/coinbase.js');
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.40.0";
2
+ var version = "0.43.0";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -95,7 +95,7 @@ var TRANSITION_TABLE = {
95
95
  id: "verify",
96
96
  mode: "SUBMIT",
97
97
  endpoint: "POST /fiat/auth/verify",
98
- when: "phase CODE \u2014 params { verificationRef }, inputs { code: TEXT length 6, regex ^\\d{6}$ }"
98
+ when: "phase CODE \u2014 params { verificationRef }, inputs { otpCode: TEXT length 6, regex ^\\d{6}$ }"
99
99
  },
100
100
  {
101
101
  id: "resend",
@@ -112,7 +112,7 @@ var TRANSITION_TABLE = {
112
112
  "Not in the FE doc, so no screen number: the client renders it on its contact and OTP screens.",
113
113
  "Every FUN_AUTH error is category USER_ERROR with a code from FUN_AUTH_ERROR_CODES. A wrong code re-enters CODE with BAD_CODE and a lower attemptsRemaining; TOO_MANY_ATTEMPTS and CODE_EXPIRED drop the challenge and offer resend; OTP_DISPATCH_THROTTLED re-enters with resendAvailableAtMs set.",
114
114
  "resend carries the verificationRef the client holds, even one the server has dropped (expired, too many attempts); the server starts a fresh challenge for the same email while it still remembers the challenge (its code expiry plus a short grace); once it is forgotten the answer is IDENTIFIER with CODE_EXPIRED.",
115
- "POST /fiat/auth/refresh and /revoke are called by the SDK session store, never offered as transitions."
115
+ "POST /fiat/auth/refresh, /revoke and /recipient are called by the SDK session store, never offered as transitions."
116
116
  ]
117
117
  },
118
118
  SESSION_AUTH: {
@@ -478,6 +478,7 @@ var DOCUMENTED_ENDPOINTS = [
478
478
  "POST /fiat/auth/verify",
479
479
  "POST /fiat/auth/refresh",
480
480
  "POST /fiat/auth/revoke",
481
+ "POST /fiat/auth/recipient",
481
482
  "POST /fiat/payment-session",
482
483
  "POST /fiat/session",
483
484
  "POST /fiat/session/verify",
@@ -509,6 +510,10 @@ var UNOFFERED_ENDPOINTS = [
509
510
  endpoint: "POST /fiat/auth/revoke",
510
511
  reason: "SDK session store, not a transition."
511
512
  },
513
+ {
514
+ endpoint: "POST /fiat/auth/recipient",
515
+ reason: "SDK session store at beginDeposit, not a transition."
516
+ },
512
517
  {
513
518
  endpoint: "POST /fiat/kyc/document",
514
519
  reason: "FILE fields use it for a direct provider/vendor upload handshake and completion report; the harness owns that auxiliary path and it is not a transition (see KYC/INPUT_REQUIRED notes)."
@@ -0,0 +1,17 @@
1
+ // src/providers/coinbase.ts
2
+ var COINBASE_ENDPOINTS = {
3
+ next: "POST /fiat/next"
4
+ };
5
+ var COINBASE_TERMS = {
6
+ id: "COINBASE_TERMS",
7
+ kind: "PROVIDER_TERMS",
8
+ stage: "CHECKOUT",
9
+ version: "2026-01",
10
+ contentDigest: "22db1a8292d9ecd60b53adf640c8748ad8477646c26a31971a83f7a43457f1fe",
11
+ links: [{ label: "Coinbase User Agreement", url: "https://www.coinbase.com/legal/user_agreement" }]
12
+ };
13
+
14
+ export {
15
+ COINBASE_ENDPOINTS,
16
+ COINBASE_TERMS
17
+ };
package/dist/index.d.ts CHANGED
@@ -14,4 +14,6 @@ export * from './terms';
14
14
  export * from './routing';
15
15
  export * from './providers/moonpay';
16
16
  export * from './providers/moonpay.schemas';
17
+ export * from './providers/coinbase';
18
+ export * from './providers/coinbase.schemas';
17
19
  export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
package/dist/index.js CHANGED
@@ -22,9 +22,40 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  BlockedReasonSchema: () => BlockedReasonSchema,
24
24
  BlockedStateSchema: () => BlockedStateSchema,
25
+ COINBASE_ENDPOINTS: () => COINBASE_ENDPOINTS,
26
+ COINBASE_TERMS: () => COINBASE_TERMS,
25
27
  COUNTRY_NAMES: () => COUNTRY_NAMES,
26
28
  COUNTRY_TO_CURRENCY: () => COUNTRY_TO_CURRENCY,
27
29
  ClientExecutedDeliverySchema: () => ClientExecutedDeliverySchema,
30
+ CoinbaseCheckoutSchema: () => CoinbaseCheckoutSchema,
31
+ CoinbaseConsentNextActionSchema: () => CoinbaseConsentNextActionSchema,
32
+ CoinbaseConsentRequestSchema: () => CoinbaseConsentRequestSchema,
33
+ CoinbaseDoneSchema: () => CoinbaseDoneSchema,
34
+ CoinbaseErrorBodySchema: () => CoinbaseErrorBodySchema,
35
+ CoinbaseFaultSchema: () => CoinbaseFaultSchema,
36
+ CoinbaseKycNextActionSchema: () => CoinbaseKycNextActionSchema,
37
+ CoinbaseKycRequestSchema: () => CoinbaseKycRequestSchema,
38
+ CoinbaseNextActionSchema: () => CoinbaseNextActionSchema,
39
+ CoinbaseNextRequestSchema: () => CoinbaseNextRequestSchema,
40
+ CoinbaseObserveRequestSchema: () => CoinbaseObserveRequestSchema,
41
+ CoinbaseOrderPendingNextActionSchema: () => CoinbaseOrderPendingNextActionSchema,
42
+ CoinbaseOrderRequestSchema: () => CoinbaseOrderRequestSchema,
43
+ CoinbaseOrderResponseSchema: () => CoinbaseOrderResponseSchema,
44
+ CoinbaseOtpNextActionSchema: () => CoinbaseOtpNextActionSchema,
45
+ CoinbaseOtpRequestSchema: () => CoinbaseOtpRequestSchema,
46
+ CoinbasePayNextActionSchema: () => CoinbasePayNextActionSchema,
47
+ CoinbasePlaceOrderNextActionSchema: () => CoinbasePlaceOrderNextActionSchema,
48
+ CoinbasePlaceOrderRequestSchema: () => CoinbasePlaceOrderRequestSchema,
49
+ CoinbasePriceSchema: () => CoinbasePriceSchema,
50
+ CoinbaseReaskSchema: () => CoinbaseReaskSchema,
51
+ CoinbaseRefusedSchema: () => CoinbaseRefusedSchema,
52
+ CoinbaseRequestContextSchema: () => CoinbaseRequestContextSchema,
53
+ CoinbaseRequestSchema: () => CoinbaseRequestSchema,
54
+ CoinbaseResponseSchemaFor: () => CoinbaseResponseSchemaFor,
55
+ CoinbaseSessionNextActionSchema: () => CoinbaseSessionNextActionSchema,
56
+ CoinbaseSessionRequestSchema: () => CoinbaseSessionRequestSchema,
57
+ CoinbaseStepResponseSchema: () => CoinbaseStepResponseSchema,
58
+ CoinbaseWaitNextActionSchema: () => CoinbaseWaitNextActionSchema,
28
59
  ContractViolation: () => ContractViolation,
29
60
  CountryCode: () => CountryCode,
30
61
  CryptoAmountSchema: () => CryptoAmountSchema,
@@ -42,6 +73,8 @@ __export(index_exports, {
42
73
  FailureReasonSchema: () => FailureReasonSchema,
43
74
  FeeLineSchema: () => FeeLineSchema,
44
75
  FiatAmountSchema: () => FiatAmountSchema,
76
+ FiatAuthRecipientRequestSchema: () => FiatAuthRecipientRequestSchema,
77
+ FiatAuthRecipientResponseSchema: () => FiatAuthRecipientResponseSchema,
45
78
  FiatAuthRefreshRequestSchema: () => FiatAuthRefreshRequestSchema,
46
79
  FiatAuthRefreshResponseSchema: () => FiatAuthRefreshResponseSchema,
47
80
  FiatAuthRevokeRequestSchema: () => FiatAuthRevokeRequestSchema,
@@ -1248,7 +1281,7 @@ var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank,
1248
1281
  var FiatNextRequestSchema = $nextRequest;
1249
1282
  var $authStartRequest = import_zod.z.union([obj({ email: $nonBlank }), obj({ verificationRef: $nonBlank })]);
1250
1283
  var FiatAuthStartRequestSchema = $authStartRequest;
1251
- var $authVerifyRequest = obj({ verificationRef: $nonBlank, code: import_zod.z.string().regex(/^\d{6}$/, "must be six digits") });
1284
+ var $authVerifyRequest = obj({ verificationRef: $nonBlank, otpCode: import_zod.z.string().regex(/^\d{6}$/, "must be six digits") });
1252
1285
  var FiatAuthVerifyRequestSchema = $authVerifyRequest;
1253
1286
  var $authRefreshRequest = obj({ refreshHandle: $nonBlank });
1254
1287
  var FiatAuthRefreshRequestSchema = $authRefreshRequest;
@@ -1256,6 +1289,16 @@ var $authRefreshResponse = obj({ session: $fiatSession });
1256
1289
  var FiatAuthRefreshResponseSchema = $authRefreshResponse;
1257
1290
  var $authRevokeRequest = obj({ refreshHandle: $nonBlank });
1258
1291
  var FiatAuthRevokeRequestSchema = $authRevokeRequest;
1292
+ var $authRecipientRequest = import_zod.z.discriminatedUnion("vm", [
1293
+ obj({ refreshHandle: $nonBlank, vm: import_zod.z.literal("EVM"), chainId: import_zod.z.number().int().positive(), depositAddress: $evmAddress }),
1294
+ obj({ refreshHandle: $nonBlank, vm: import_zod.z.literal("SOLANA"), depositAddress: $solanaAddress })
1295
+ ]);
1296
+ var FiatAuthRecipientRequestSchema = $authRecipientRequest;
1297
+ var $authRecipientResponse = obj({
1298
+ boundAtMs: import_zod.z.number().int().nonnegative(),
1299
+ expiresAtMs: import_zod.z.number().int().nonnegative()
1300
+ });
1301
+ var FiatAuthRecipientResponseSchema = $authRecipientResponse;
1259
1302
  var $stepResponseBase = {
1260
1303
  transitions: import_zod.z.array($transition),
1261
1304
  routingSessionRef: import_zod.z.string().optional(),
@@ -1337,7 +1380,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
1337
1380
  var FiatStepResponseSchema = $stepResponse;
1338
1381
 
1339
1382
  // package.json
1340
- var version = "0.40.0";
1383
+ var version = "0.43.0";
1341
1384
 
1342
1385
  // src/table.ts
1343
1386
  var TABLE_VERSION = version;
@@ -1433,7 +1476,7 @@ var TRANSITION_TABLE = {
1433
1476
  id: "verify",
1434
1477
  mode: "SUBMIT",
1435
1478
  endpoint: "POST /fiat/auth/verify",
1436
- when: "phase CODE \u2014 params { verificationRef }, inputs { code: TEXT length 6, regex ^\\d{6}$ }"
1479
+ when: "phase CODE \u2014 params { verificationRef }, inputs { otpCode: TEXT length 6, regex ^\\d{6}$ }"
1437
1480
  },
1438
1481
  {
1439
1482
  id: "resend",
@@ -1450,7 +1493,7 @@ var TRANSITION_TABLE = {
1450
1493
  "Not in the FE doc, so no screen number: the client renders it on its contact and OTP screens.",
1451
1494
  "Every FUN_AUTH error is category USER_ERROR with a code from FUN_AUTH_ERROR_CODES. A wrong code re-enters CODE with BAD_CODE and a lower attemptsRemaining; TOO_MANY_ATTEMPTS and CODE_EXPIRED drop the challenge and offer resend; OTP_DISPATCH_THROTTLED re-enters with resendAvailableAtMs set.",
1452
1495
  "resend carries the verificationRef the client holds, even one the server has dropped (expired, too many attempts); the server starts a fresh challenge for the same email while it still remembers the challenge (its code expiry plus a short grace); once it is forgotten the answer is IDENTIFIER with CODE_EXPIRED.",
1453
- "POST /fiat/auth/refresh and /revoke are called by the SDK session store, never offered as transitions."
1496
+ "POST /fiat/auth/refresh, /revoke and /recipient are called by the SDK session store, never offered as transitions."
1454
1497
  ]
1455
1498
  },
1456
1499
  SESSION_AUTH: {
@@ -1816,6 +1859,7 @@ var DOCUMENTED_ENDPOINTS = [
1816
1859
  "POST /fiat/auth/verify",
1817
1860
  "POST /fiat/auth/refresh",
1818
1861
  "POST /fiat/auth/revoke",
1862
+ "POST /fiat/auth/recipient",
1819
1863
  "POST /fiat/payment-session",
1820
1864
  "POST /fiat/session",
1821
1865
  "POST /fiat/session/verify",
@@ -1847,6 +1891,10 @@ var UNOFFERED_ENDPOINTS = [
1847
1891
  endpoint: "POST /fiat/auth/revoke",
1848
1892
  reason: "SDK session store, not a transition."
1849
1893
  },
1894
+ {
1895
+ endpoint: "POST /fiat/auth/recipient",
1896
+ reason: "SDK session store at beginDeposit, not a transition."
1897
+ },
1850
1898
  {
1851
1899
  endpoint: "POST /fiat/kyc/document",
1852
1900
  reason: "FILE fields use it for a direct provider/vendor upload handshake and completion report; the harness owns that auxiliary path and it is not a transition (see KYC/INPUT_REQUIRED notes)."
@@ -2010,7 +2058,7 @@ var FIXTURE_DATA = {
2010
2058
  "verificationRef": "vr_7c1"
2011
2059
  },
2012
2060
  "inputs": {
2013
- "code": {
2061
+ "otpCode": {
2014
2062
  "type": "TEXT",
2015
2063
  "length": 6,
2016
2064
  "regex": "^\\d{6}$"
@@ -3525,3 +3573,195 @@ var $fault = obj2($faultFields);
3525
3573
  var MoonPayFaultSchema = $fault;
3526
3574
  var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: import_zod2.z.string(), reqId: import_zod2.z.string().optional() });
3527
3575
  var MoonPayErrorBodySchema = $errorBody;
3576
+
3577
+ // src/providers/coinbase.ts
3578
+ var COINBASE_ENDPOINTS = {
3579
+ next: "POST /fiat/next"
3580
+ };
3581
+ var COINBASE_TERMS = {
3582
+ id: "COINBASE_TERMS",
3583
+ kind: "PROVIDER_TERMS",
3584
+ stage: "CHECKOUT",
3585
+ version: "2026-01",
3586
+ contentDigest: "22db1a8292d9ecd60b53adf640c8748ad8477646c26a31971a83f7a43457f1fe",
3587
+ links: [{ label: "Coinbase User Agreement", url: "https://www.coinbase.com/legal/user_agreement" }]
3588
+ };
3589
+
3590
+ // src/providers/coinbase.schemas.ts
3591
+ var import_zod3 = require("zod");
3592
+ var obj3 = (shape) => import_zod3.z.object(shape).strict();
3593
+ var $nonEmpty2 = import_zod3.z.string().refine((value) => value.trim().length > 0, "must not be blank");
3594
+ var hasUniqueIds3 = (ids) => new Set(ids).size === ids.length;
3595
+ var $retryAfterMs = import_zod3.z.number().int().positive().max(6e4);
3596
+ var $positiveAmount = import_zod3.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string").refine((amount) => Number(amount) > 0, "must be positive");
3597
+ var $checkout2 = obj3({
3598
+ amount: obj3({ currency: import_zod3.z.literal("USD"), amount: $positiveAmount }),
3599
+ destination: obj3({ asset: $nonEmpty2, network: $nonEmpty2 }),
3600
+ paymentMethod: import_zod3.z.literal("apple_pay")
3601
+ });
3602
+ var CoinbaseCheckoutSchema = $checkout2;
3603
+ var contextFields = { checkout: $checkout2, destinationAsset: DestinationAssetSchema.optional() };
3604
+ var $requestContext2 = obj3(contextFields);
3605
+ var CoinbaseRequestContextSchema = $requestContext2;
3606
+ var observeFields = { action: import_zod3.z.literal("observe") };
3607
+ var consentFields = {
3608
+ action: import_zod3.z.literal("consent"),
3609
+ acceptances: import_zod3.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds3(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
3610
+ };
3611
+ var sessionPhoneFields = { action: import_zod3.z.literal("session"), phoneNumber: import_zod3.z.string().regex(/^\+[1-9]\d{1,14}$/) };
3612
+ var sessionResendFields = { action: import_zod3.z.literal("session"), resend: $nonEmpty2 };
3613
+ var otpFields = { action: import_zod3.z.literal("otp"), verificationRef: $nonEmpty2, otpCode: import_zod3.z.string().regex(/^\d{6}$/) };
3614
+ var $kycValues = import_zod3.z.record(KycFieldIdSchema, import_zod3.z.string());
3615
+ var kycFields = { action: import_zod3.z.literal("kyc"), values: $kycValues };
3616
+ var $mintedOrderId = import_zod3.z.string().regex(/^cbo_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
3617
+ var placeOrderFields = { action: import_zod3.z.literal("placeOrder"), orderId: $mintedOrderId };
3618
+ var orderFields = { action: import_zod3.z.literal("order"), orderId: $mintedOrderId };
3619
+ var $observeRequest2 = obj3({ ...contextFields, ...observeFields });
3620
+ var $consentRequest2 = obj3({ ...contextFields, ...consentFields });
3621
+ var $sessionRequest2 = import_zod3.z.union([obj3({ ...contextFields, ...sessionPhoneFields }), obj3({ ...contextFields, ...sessionResendFields })]);
3622
+ var $otpRequest = obj3({ ...contextFields, ...otpFields });
3623
+ var $kycRequest2 = obj3({ ...contextFields, ...kycFields });
3624
+ var $placeOrderRequest = obj3({ ...contextFields, ...placeOrderFields });
3625
+ var $orderRequest2 = obj3({ ...contextFields, ...orderFields });
3626
+ var CoinbaseObserveRequestSchema = $observeRequest2;
3627
+ var CoinbaseConsentRequestSchema = $consentRequest2;
3628
+ var CoinbaseSessionRequestSchema = $sessionRequest2;
3629
+ var CoinbaseOtpRequestSchema = $otpRequest;
3630
+ var CoinbaseKycRequestSchema = $kycRequest2;
3631
+ var CoinbasePlaceOrderRequestSchema = $placeOrderRequest;
3632
+ var CoinbaseOrderRequestSchema = $orderRequest2;
3633
+ var $request2 = import_zod3.z.union([$observeRequest2, $consentRequest2, $sessionRequest2, $otpRequest, $kycRequest2, $placeOrderRequest, $orderRequest2]);
3634
+ var CoinbaseRequestSchema = $request2;
3635
+ var envelope = { provider: import_zod3.z.literal("COINBASE"), geo: FiatGeoSchema, ...contextFields };
3636
+ var $nextRequest3 = import_zod3.z.union([
3637
+ obj3({ ...envelope, ...observeFields }),
3638
+ obj3({ ...envelope, ...consentFields }),
3639
+ obj3({ ...envelope, ...sessionPhoneFields }),
3640
+ obj3({ ...envelope, ...sessionResendFields }),
3641
+ obj3({ ...envelope, ...otpFields }),
3642
+ obj3({ ...envelope, ...kycFields }),
3643
+ obj3({ ...envelope, ...placeOrderFields }),
3644
+ obj3({ ...envelope, ...orderFields })
3645
+ ]);
3646
+ var CoinbaseNextRequestSchema = $nextRequest3;
3647
+ var $price = obj3({ total: FiatAmountSchema, fees: import_zod3.z.array(FeeLineSchema), cryptoAmount: $nonEmpty2 });
3648
+ var CoinbasePriceSchema = $price;
3649
+ var $reask2 = obj3({
3650
+ requirements: import_zod3.z.array(KycFieldIdSchema).min(1).refine(hasUniqueIds3, "requirements must be unique"),
3651
+ reason: import_zod3.z.enum(["REJECTED"]).nullable()
3652
+ });
3653
+ var CoinbaseReaskSchema = $reask2;
3654
+ var $consentShape2 = obj3({ next: import_zod3.z.literal("consent"), documents: import_zod3.z.array(TermsDocumentSchema).min(1) });
3655
+ var $sessionNextAction2 = obj3({ next: import_zod3.z.literal("session"), error: import_zod3.z.literal("CODE_EXPIRED").nullable() });
3656
+ var $otpNextAction = obj3({
3657
+ next: import_zod3.z.literal("otp"),
3658
+ verificationRef: $nonEmpty2,
3659
+ expiresAt: import_zod3.z.string().datetime({ offset: true }),
3660
+ error: import_zod3.z.literal("CODE_INVALID").nullable()
3661
+ });
3662
+ var $kycShape2 = obj3({
3663
+ next: import_zod3.z.literal("kyc"),
3664
+ fields: import_zod3.z.array(FormFieldSchema),
3665
+ fieldErrors: import_zod3.z.array(obj3({ fieldId: $nonEmpty2, message: $nonEmpty2 })).min(1).optional(),
3666
+ reask: $reask2.nullable()
3667
+ });
3668
+ var $waitNextAction2 = obj3({ next: import_zod3.z.literal("wait"), retryAfterMs: $retryAfterMs });
3669
+ var $placeOrderNextAction = obj3({ next: import_zod3.z.literal("placeOrder"), price: $price, orderId: $nonEmpty2 });
3670
+ var $payNextAction = obj3({
3671
+ next: import_zod3.z.literal("pay"),
3672
+ orderId: $nonEmpty2,
3673
+ price: $price,
3674
+ // As the shared links are checked: `z.string().url()` would also take `http:` and `javascript:`.
3675
+ paymentLink: obj3({ url: import_zod3.z.string().regex(/^https:\/\/\S+$/, "must be an https URL") }),
3676
+ environment: import_zod3.z.enum(["sandbox", "production"])
3677
+ });
3678
+ var $orderPendingNextAction2 = obj3({
3679
+ next: import_zod3.z.literal("orderPending"),
3680
+ orderId: $nonEmpty2,
3681
+ retryAfterMs: $retryAfterMs,
3682
+ order: FiatStepResponseSchema.nullable()
3683
+ });
3684
+ var checkConsent2 = (nextAction, context) => {
3685
+ if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
3686
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
3687
+ }
3688
+ };
3689
+ var checkKyc2 = (nextAction, context) => {
3690
+ const fieldIds = nextAction.fields.map((field) => field.id);
3691
+ if (!hasUniqueIds3(fieldIds)) {
3692
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
3693
+ }
3694
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
3695
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
3696
+ }
3697
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
3698
+ context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
3699
+ }
3700
+ };
3701
+ var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
3702
+ var CoinbaseSessionNextActionSchema = $sessionNextAction2;
3703
+ var CoinbaseOtpNextActionSchema = $otpNextAction;
3704
+ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
3705
+ var CoinbaseWaitNextActionSchema = $waitNextAction2;
3706
+ var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
3707
+ var CoinbasePayNextActionSchema = $payNextAction;
3708
+ var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
3709
+ var checkNextAction2 = (response, context) => {
3710
+ if (response.next === "consent") checkConsent2(response, context);
3711
+ if (response.next === "kyc") checkKyc2(response, context);
3712
+ };
3713
+ var $nextActionOptions2 = [
3714
+ $consentShape2,
3715
+ $sessionNextAction2,
3716
+ $otpNextAction,
3717
+ $kycShape2,
3718
+ $waitNextAction2,
3719
+ $placeOrderNextAction,
3720
+ $payNextAction,
3721
+ $orderPendingNextAction2
3722
+ ];
3723
+ var $nextAction2 = import_zod3.z.discriminatedUnion("next", [...$nextActionOptions2]).superRefine(checkNextAction2);
3724
+ var CoinbaseNextActionSchema = $nextAction2;
3725
+ var $done2 = obj3({ next: import_zod3.z.literal("done"), order: FiatStepResponseSchema });
3726
+ var CoinbaseDoneSchema = $done2;
3727
+ var $refused = import_zod3.z.union([
3728
+ obj3({
3729
+ next: import_zod3.z.literal("refused"),
3730
+ reason: import_zod3.z.enum(["NOT_ELIGIBLE", "KYC_UPGRADE_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
3731
+ recovery: import_zod3.z.enum(["REQUOTE", "NONE"])
3732
+ }),
3733
+ obj3({
3734
+ next: import_zod3.z.literal("refused"),
3735
+ reason: import_zod3.z.literal("LIMITS_EXCEEDED"),
3736
+ recovery: import_zod3.z.literal("REQUOTE"),
3737
+ maxAmount: FiatAmountSchema.nullable()
3738
+ })
3739
+ ]);
3740
+ var CoinbaseRefusedSchema = $refused;
3741
+ var $stepResponse3 = import_zod3.z.union([import_zod3.z.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
3742
+ var CoinbaseStepResponseSchema = $stepResponse3;
3743
+ var $orderResponse2 = import_zod3.z.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
3744
+ var CoinbaseOrderResponseSchema = $orderResponse2;
3745
+ var CoinbaseResponseSchemaFor = {
3746
+ observe: CoinbaseStepResponseSchema,
3747
+ consent: CoinbaseStepResponseSchema,
3748
+ session: CoinbaseStepResponseSchema,
3749
+ otp: CoinbaseStepResponseSchema,
3750
+ kyc: CoinbaseStepResponseSchema,
3751
+ placeOrder: CoinbaseStepResponseSchema,
3752
+ order: CoinbaseOrderResponseSchema
3753
+ };
3754
+ var faultFields = {
3755
+ reason: import_zod3.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
3756
+ recovery: import_zod3.z.enum(["RETRY", "REQUOTE", "NONE"])
3757
+ };
3758
+ var $fault2 = obj3(faultFields);
3759
+ var CoinbaseFaultSchema = $fault2;
3760
+ var $errorBody2 = obj3({
3761
+ ...faultFields,
3762
+ errorCode: $nonEmpty2,
3763
+ errorMsg: import_zod3.z.string(),
3764
+ reqId: import_zod3.z.string().optional(),
3765
+ retryAfterSeconds: import_zod3.z.number().int().positive().optional()
3766
+ });
3767
+ var CoinbaseErrorBodySchema = $errorBody2;
package/dist/index.mjs CHANGED
@@ -13,10 +13,14 @@ import {
13
13
  tableEntry,
14
14
  unofferedEndpoints,
15
15
  unreachableStates
16
- } from "./chunk-4Y22UVT4.mjs";
16
+ } from "./chunk-6O7Z7WYW.mjs";
17
17
  import {
18
18
  MOONPAY_ENDPOINTS
19
19
  } from "./chunk-TIEGTTFY.mjs";
20
+ import {
21
+ COINBASE_ENDPOINTS,
22
+ COINBASE_TERMS
23
+ } from "./chunk-SFR4SCDU.mjs";
20
24
  import {
21
25
  FIAT_TERMS_ENDPOINT,
22
26
  FUN_KYC_CONSENT_DOCUMENTS,
@@ -1093,7 +1097,7 @@ var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiat
1093
1097
  var FiatNextRequestSchema = $nextRequest;
1094
1098
  var $authStartRequest = z.union([obj({ email: $nonBlank }), obj({ verificationRef: $nonBlank })]);
1095
1099
  var FiatAuthStartRequestSchema = $authStartRequest;
1096
- var $authVerifyRequest = obj({ verificationRef: $nonBlank, code: z.string().regex(/^\d{6}$/, "must be six digits") });
1100
+ var $authVerifyRequest = obj({ verificationRef: $nonBlank, otpCode: z.string().regex(/^\d{6}$/, "must be six digits") });
1097
1101
  var FiatAuthVerifyRequestSchema = $authVerifyRequest;
1098
1102
  var $authRefreshRequest = obj({ refreshHandle: $nonBlank });
1099
1103
  var FiatAuthRefreshRequestSchema = $authRefreshRequest;
@@ -1101,6 +1105,16 @@ var $authRefreshResponse = obj({ session: $fiatSession });
1101
1105
  var FiatAuthRefreshResponseSchema = $authRefreshResponse;
1102
1106
  var $authRevokeRequest = obj({ refreshHandle: $nonBlank });
1103
1107
  var FiatAuthRevokeRequestSchema = $authRevokeRequest;
1108
+ var $authRecipientRequest = z.discriminatedUnion("vm", [
1109
+ obj({ refreshHandle: $nonBlank, vm: z.literal("EVM"), chainId: z.number().int().positive(), depositAddress: $evmAddress }),
1110
+ obj({ refreshHandle: $nonBlank, vm: z.literal("SOLANA"), depositAddress: $solanaAddress })
1111
+ ]);
1112
+ var FiatAuthRecipientRequestSchema = $authRecipientRequest;
1113
+ var $authRecipientResponse = obj({
1114
+ boundAtMs: z.number().int().nonnegative(),
1115
+ expiresAtMs: z.number().int().nonnegative()
1116
+ });
1117
+ var FiatAuthRecipientResponseSchema = $authRecipientResponse;
1104
1118
  var $stepResponseBase = {
1105
1119
  transitions: z.array($transition),
1106
1120
  routingSessionRef: z.string().optional(),
@@ -1263,7 +1277,7 @@ var FIXTURE_DATA = {
1263
1277
  "verificationRef": "vr_7c1"
1264
1278
  },
1265
1279
  "inputs": {
1266
- "code": {
1280
+ "otpCode": {
1267
1281
  "type": "TEXT",
1268
1282
  "length": 6,
1269
1283
  "regex": "^\\d{6}$"
@@ -2702,12 +2716,222 @@ var $fault = obj2($faultFields);
2702
2716
  var MoonPayFaultSchema = $fault;
2703
2717
  var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: z2.string(), reqId: z2.string().optional() });
2704
2718
  var MoonPayErrorBodySchema = $errorBody;
2719
+
2720
+ // src/providers/coinbase.schemas.ts
2721
+ import { z as z3 } from "zod";
2722
+ var obj3 = (shape) => z3.object(shape).strict();
2723
+ var $nonEmpty2 = z3.string().refine((value) => value.trim().length > 0, "must not be blank");
2724
+ var hasUniqueIds3 = (ids) => new Set(ids).size === ids.length;
2725
+ var $retryAfterMs = z3.number().int().positive().max(6e4);
2726
+ var $positiveAmount = z3.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string").refine((amount) => Number(amount) > 0, "must be positive");
2727
+ var $checkout2 = obj3({
2728
+ amount: obj3({ currency: z3.literal("USD"), amount: $positiveAmount }),
2729
+ destination: obj3({ asset: $nonEmpty2, network: $nonEmpty2 }),
2730
+ paymentMethod: z3.literal("apple_pay")
2731
+ });
2732
+ var CoinbaseCheckoutSchema = $checkout2;
2733
+ var contextFields = { checkout: $checkout2, destinationAsset: DestinationAssetSchema.optional() };
2734
+ var $requestContext2 = obj3(contextFields);
2735
+ var CoinbaseRequestContextSchema = $requestContext2;
2736
+ var observeFields = { action: z3.literal("observe") };
2737
+ var consentFields = {
2738
+ action: z3.literal("consent"),
2739
+ acceptances: z3.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds3(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
2740
+ };
2741
+ var sessionPhoneFields = { action: z3.literal("session"), phoneNumber: z3.string().regex(/^\+[1-9]\d{1,14}$/) };
2742
+ var sessionResendFields = { action: z3.literal("session"), resend: $nonEmpty2 };
2743
+ var otpFields = { action: z3.literal("otp"), verificationRef: $nonEmpty2, otpCode: z3.string().regex(/^\d{6}$/) };
2744
+ var $kycValues = z3.record(KycFieldIdSchema, z3.string());
2745
+ var kycFields = { action: z3.literal("kyc"), values: $kycValues };
2746
+ var $mintedOrderId = z3.string().regex(/^cbo_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
2747
+ var placeOrderFields = { action: z3.literal("placeOrder"), orderId: $mintedOrderId };
2748
+ var orderFields = { action: z3.literal("order"), orderId: $mintedOrderId };
2749
+ var $observeRequest2 = obj3({ ...contextFields, ...observeFields });
2750
+ var $consentRequest2 = obj3({ ...contextFields, ...consentFields });
2751
+ var $sessionRequest2 = z3.union([obj3({ ...contextFields, ...sessionPhoneFields }), obj3({ ...contextFields, ...sessionResendFields })]);
2752
+ var $otpRequest = obj3({ ...contextFields, ...otpFields });
2753
+ var $kycRequest2 = obj3({ ...contextFields, ...kycFields });
2754
+ var $placeOrderRequest = obj3({ ...contextFields, ...placeOrderFields });
2755
+ var $orderRequest2 = obj3({ ...contextFields, ...orderFields });
2756
+ var CoinbaseObserveRequestSchema = $observeRequest2;
2757
+ var CoinbaseConsentRequestSchema = $consentRequest2;
2758
+ var CoinbaseSessionRequestSchema = $sessionRequest2;
2759
+ var CoinbaseOtpRequestSchema = $otpRequest;
2760
+ var CoinbaseKycRequestSchema = $kycRequest2;
2761
+ var CoinbasePlaceOrderRequestSchema = $placeOrderRequest;
2762
+ var CoinbaseOrderRequestSchema = $orderRequest2;
2763
+ var $request2 = z3.union([$observeRequest2, $consentRequest2, $sessionRequest2, $otpRequest, $kycRequest2, $placeOrderRequest, $orderRequest2]);
2764
+ var CoinbaseRequestSchema = $request2;
2765
+ var envelope = { provider: z3.literal("COINBASE"), geo: FiatGeoSchema, ...contextFields };
2766
+ var $nextRequest3 = z3.union([
2767
+ obj3({ ...envelope, ...observeFields }),
2768
+ obj3({ ...envelope, ...consentFields }),
2769
+ obj3({ ...envelope, ...sessionPhoneFields }),
2770
+ obj3({ ...envelope, ...sessionResendFields }),
2771
+ obj3({ ...envelope, ...otpFields }),
2772
+ obj3({ ...envelope, ...kycFields }),
2773
+ obj3({ ...envelope, ...placeOrderFields }),
2774
+ obj3({ ...envelope, ...orderFields })
2775
+ ]);
2776
+ var CoinbaseNextRequestSchema = $nextRequest3;
2777
+ var $price = obj3({ total: FiatAmountSchema, fees: z3.array(FeeLineSchema), cryptoAmount: $nonEmpty2 });
2778
+ var CoinbasePriceSchema = $price;
2779
+ var $reask2 = obj3({
2780
+ requirements: z3.array(KycFieldIdSchema).min(1).refine(hasUniqueIds3, "requirements must be unique"),
2781
+ reason: z3.enum(["REJECTED"]).nullable()
2782
+ });
2783
+ var CoinbaseReaskSchema = $reask2;
2784
+ var $consentShape2 = obj3({ next: z3.literal("consent"), documents: z3.array(TermsDocumentSchema).min(1) });
2785
+ var $sessionNextAction2 = obj3({ next: z3.literal("session"), error: z3.literal("CODE_EXPIRED").nullable() });
2786
+ var $otpNextAction = obj3({
2787
+ next: z3.literal("otp"),
2788
+ verificationRef: $nonEmpty2,
2789
+ expiresAt: z3.string().datetime({ offset: true }),
2790
+ error: z3.literal("CODE_INVALID").nullable()
2791
+ });
2792
+ var $kycShape2 = obj3({
2793
+ next: z3.literal("kyc"),
2794
+ fields: z3.array(FormFieldSchema),
2795
+ fieldErrors: z3.array(obj3({ fieldId: $nonEmpty2, message: $nonEmpty2 })).min(1).optional(),
2796
+ reask: $reask2.nullable()
2797
+ });
2798
+ var $waitNextAction2 = obj3({ next: z3.literal("wait"), retryAfterMs: $retryAfterMs });
2799
+ var $placeOrderNextAction = obj3({ next: z3.literal("placeOrder"), price: $price, orderId: $nonEmpty2 });
2800
+ var $payNextAction = obj3({
2801
+ next: z3.literal("pay"),
2802
+ orderId: $nonEmpty2,
2803
+ price: $price,
2804
+ // As the shared links are checked: `z.string().url()` would also take `http:` and `javascript:`.
2805
+ paymentLink: obj3({ url: z3.string().regex(/^https:\/\/\S+$/, "must be an https URL") }),
2806
+ environment: z3.enum(["sandbox", "production"])
2807
+ });
2808
+ var $orderPendingNextAction2 = obj3({
2809
+ next: z3.literal("orderPending"),
2810
+ orderId: $nonEmpty2,
2811
+ retryAfterMs: $retryAfterMs,
2812
+ order: FiatStepResponseSchema.nullable()
2813
+ });
2814
+ var checkConsent2 = (nextAction, context) => {
2815
+ if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
2816
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2817
+ }
2818
+ };
2819
+ var checkKyc2 = (nextAction, context) => {
2820
+ const fieldIds = nextAction.fields.map((field) => field.id);
2821
+ if (!hasUniqueIds3(fieldIds)) {
2822
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2823
+ }
2824
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2825
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2826
+ }
2827
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
2828
+ context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2829
+ }
2830
+ };
2831
+ var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
2832
+ var CoinbaseSessionNextActionSchema = $sessionNextAction2;
2833
+ var CoinbaseOtpNextActionSchema = $otpNextAction;
2834
+ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
2835
+ var CoinbaseWaitNextActionSchema = $waitNextAction2;
2836
+ var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
2837
+ var CoinbasePayNextActionSchema = $payNextAction;
2838
+ var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
2839
+ var checkNextAction2 = (response, context) => {
2840
+ if (response.next === "consent") checkConsent2(response, context);
2841
+ if (response.next === "kyc") checkKyc2(response, context);
2842
+ };
2843
+ var $nextActionOptions2 = [
2844
+ $consentShape2,
2845
+ $sessionNextAction2,
2846
+ $otpNextAction,
2847
+ $kycShape2,
2848
+ $waitNextAction2,
2849
+ $placeOrderNextAction,
2850
+ $payNextAction,
2851
+ $orderPendingNextAction2
2852
+ ];
2853
+ var $nextAction2 = z3.discriminatedUnion("next", [...$nextActionOptions2]).superRefine(checkNextAction2);
2854
+ var CoinbaseNextActionSchema = $nextAction2;
2855
+ var $done2 = obj3({ next: z3.literal("done"), order: FiatStepResponseSchema });
2856
+ var CoinbaseDoneSchema = $done2;
2857
+ var $refused = z3.union([
2858
+ obj3({
2859
+ next: z3.literal("refused"),
2860
+ reason: z3.enum(["NOT_ELIGIBLE", "KYC_UPGRADE_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
2861
+ recovery: z3.enum(["REQUOTE", "NONE"])
2862
+ }),
2863
+ obj3({
2864
+ next: z3.literal("refused"),
2865
+ reason: z3.literal("LIMITS_EXCEEDED"),
2866
+ recovery: z3.literal("REQUOTE"),
2867
+ maxAmount: FiatAmountSchema.nullable()
2868
+ })
2869
+ ]);
2870
+ var CoinbaseRefusedSchema = $refused;
2871
+ var $stepResponse3 = z3.union([z3.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
2872
+ var CoinbaseStepResponseSchema = $stepResponse3;
2873
+ var $orderResponse2 = z3.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
2874
+ var CoinbaseOrderResponseSchema = $orderResponse2;
2875
+ var CoinbaseResponseSchemaFor = {
2876
+ observe: CoinbaseStepResponseSchema,
2877
+ consent: CoinbaseStepResponseSchema,
2878
+ session: CoinbaseStepResponseSchema,
2879
+ otp: CoinbaseStepResponseSchema,
2880
+ kyc: CoinbaseStepResponseSchema,
2881
+ placeOrder: CoinbaseStepResponseSchema,
2882
+ order: CoinbaseOrderResponseSchema
2883
+ };
2884
+ var faultFields = {
2885
+ reason: z3.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
2886
+ recovery: z3.enum(["RETRY", "REQUOTE", "NONE"])
2887
+ };
2888
+ var $fault2 = obj3(faultFields);
2889
+ var CoinbaseFaultSchema = $fault2;
2890
+ var $errorBody2 = obj3({
2891
+ ...faultFields,
2892
+ errorCode: $nonEmpty2,
2893
+ errorMsg: z3.string(),
2894
+ reqId: z3.string().optional(),
2895
+ retryAfterSeconds: z3.number().int().positive().optional()
2896
+ });
2897
+ var CoinbaseErrorBodySchema = $errorBody2;
2705
2898
  export {
2706
2899
  BlockedReasonSchema,
2707
2900
  BlockedStateSchema,
2901
+ COINBASE_ENDPOINTS,
2902
+ COINBASE_TERMS,
2708
2903
  COUNTRY_NAMES,
2709
2904
  COUNTRY_TO_CURRENCY,
2710
2905
  ClientExecutedDeliverySchema,
2906
+ CoinbaseCheckoutSchema,
2907
+ CoinbaseConsentNextActionSchema,
2908
+ CoinbaseConsentRequestSchema,
2909
+ CoinbaseDoneSchema,
2910
+ CoinbaseErrorBodySchema,
2911
+ CoinbaseFaultSchema,
2912
+ CoinbaseKycNextActionSchema,
2913
+ CoinbaseKycRequestSchema,
2914
+ CoinbaseNextActionSchema,
2915
+ CoinbaseNextRequestSchema,
2916
+ CoinbaseObserveRequestSchema,
2917
+ CoinbaseOrderPendingNextActionSchema,
2918
+ CoinbaseOrderRequestSchema,
2919
+ CoinbaseOrderResponseSchema,
2920
+ CoinbaseOtpNextActionSchema,
2921
+ CoinbaseOtpRequestSchema,
2922
+ CoinbasePayNextActionSchema,
2923
+ CoinbasePlaceOrderNextActionSchema,
2924
+ CoinbasePlaceOrderRequestSchema,
2925
+ CoinbasePriceSchema,
2926
+ CoinbaseReaskSchema,
2927
+ CoinbaseRefusedSchema,
2928
+ CoinbaseRequestContextSchema,
2929
+ CoinbaseRequestSchema,
2930
+ CoinbaseResponseSchemaFor,
2931
+ CoinbaseSessionNextActionSchema,
2932
+ CoinbaseSessionRequestSchema,
2933
+ CoinbaseStepResponseSchema,
2934
+ CoinbaseWaitNextActionSchema,
2711
2935
  ContractViolation,
2712
2936
  CountryCode,
2713
2937
  CryptoAmountSchema,
@@ -2725,6 +2949,8 @@ export {
2725
2949
  FailureReasonSchema,
2726
2950
  FeeLineSchema,
2727
2951
  FiatAmountSchema,
2952
+ FiatAuthRecipientRequestSchema,
2953
+ FiatAuthRecipientResponseSchema,
2728
2954
  FiatAuthRefreshRequestSchema,
2729
2955
  FiatAuthRefreshResponseSchema,
2730
2956
  FiatAuthRevokeRequestSchema,
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The Coinbase flow on `POST /fiat/next`.
3
+ *
4
+ * A response names the next action in `next`; the client's request names it in `action`. `observe` answers the
5
+ * current next action. `wait` has no request: send `observe` after it. `pay` and `orderPending` are answered by `order`.
6
+ * Identity and the deposit wallet come from the verified partner assertion, never from a request body.
7
+ *
8
+ * A retry sends the same request and gets the current response. A fault is a 4xx/5xx whose body is
9
+ * `CoinbaseErrorBody`; anything the buyer can act on is a 200.
10
+ *
11
+ * Zero runtime dependencies, so production React Native code can import it. The zod schemas are in
12
+ * `./coinbase.schemas`, exported from the package root only.
13
+ */
14
+ import type { FiatTermsRequest, TermsDocument } from '../terms';
15
+ import type { DestinationAsset, FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId } from '../types';
16
+ export declare const COINBASE_ENDPOINTS: {
17
+ readonly next: "POST /fiat/next";
18
+ };
19
+ /** The checkout terms, sent on every request. No routing quote: the backend mints the order id on `placeOrder`. */
20
+ export interface CoinbaseCheckout {
21
+ /** Coinbase serves USD only. */
22
+ amount: FiatAmount & {
23
+ currency: 'USD';
24
+ };
25
+ /** The asset and its network, as the routing table or `/fiat/quote` named them. */
26
+ destination: {
27
+ asset: string;
28
+ network: string;
29
+ };
30
+ paymentMethod: 'apple_pay';
31
+ }
32
+ /**
33
+ * On every request. `destinationAsset` is the asset the user receives at the end, as on every `FiatNextRequest`;
34
+ * `checkout.destination` stays the asset Coinbase delivers.
35
+ */
36
+ export type CoinbaseRequestContext = {
37
+ checkout: CoinbaseCheckout;
38
+ destinationAsset?: DestinationAsset;
39
+ };
40
+ /** No next action of its own: the answer is the current next action. Writes nothing. */
41
+ export type CoinbaseObserveRequest = {
42
+ action: 'observe';
43
+ };
44
+ /** Coinbase's terms first. Later, before the first `kyc`, Fun's KYC consent if the buyer has not accepted it. */
45
+ export type CoinbaseConsentNextAction = {
46
+ next: 'consent';
47
+ documents: TermsDocument[];
48
+ };
49
+ /** The `POST /fiat/terms` items, recorded under the same rules. */
50
+ export type CoinbaseConsentRequest = {
51
+ action: 'consent';
52
+ acceptances: FiatTermsRequest['acceptances'];
53
+ };
54
+ /** Ask for the buyer's phone. `CODE_EXPIRED`: the last code's ten minutes ran out, or five wrong codes ended it. */
55
+ export type CoinbaseSessionNextAction = {
56
+ next: 'session';
57
+ error: 'CODE_EXPIRED' | null;
58
+ };
59
+ /** Text a code to `phoneNumber` (E.164), or send a new code to the phone of the live challenge `resend` names. */
60
+ export type CoinbaseSessionRequest = {
61
+ action: 'session';
62
+ phoneNumber: string;
63
+ } | {
64
+ action: 'session';
65
+ resend: string;
66
+ };
67
+ /** Ask for the code Coinbase texted. `expiresAt` is ISO-8601. `CODE_INVALID`: the last code sent was wrong. */
68
+ export type CoinbaseOtpNextAction = {
69
+ next: 'otp';
70
+ verificationRef: string;
71
+ expiresAt: string;
72
+ error: 'CODE_INVALID' | null;
73
+ };
74
+ /** `otpCode` is six digits. Named so request logs redact it. */
75
+ export type CoinbaseOtpRequest = {
76
+ action: 'otp';
77
+ verificationRef: string;
78
+ otpCode: string;
79
+ };
80
+ /** A reason on one field of a `kyc` next action. `fieldId` names a field in that next action. */
81
+ export interface CoinbaseFieldError {
82
+ fieldId: string;
83
+ message: string;
84
+ }
85
+ /** Why a re-ask asks again. Treat an unknown code like `null`: adding a code is a minor contract change. */
86
+ export type CoinbaseReaskReason = 'REJECTED';
87
+ /** Fields of the `kyc` form the buyer gave before that Coinbase asks for again. `requirements` is never empty. */
88
+ export type CoinbaseReask = {
89
+ requirements: KycFieldId[];
90
+ reason: CoinbaseReaskReason | null;
91
+ };
92
+ /** Show the shared form for Coinbase's limit upgrade. */
93
+ export type CoinbaseKycNextAction = {
94
+ next: 'kyc';
95
+ fields: FormField[];
96
+ fieldErrors?: CoinbaseFieldError[];
97
+ reask: CoinbaseReask | null;
98
+ };
99
+ /** Keyed by the ids of the next action's fields. */
100
+ export type CoinbaseKycRequest = {
101
+ action: 'kyc';
102
+ values: Partial<Record<KycFieldId, string>>;
103
+ };
104
+ /** Coinbase is reviewing, or cannot be read right now. No request of its own: send `observe` after the delay. */
105
+ export type CoinbaseWaitNextAction = {
106
+ next: 'wait';
107
+ retryAfterMs: number;
108
+ };
109
+ /** The order's price: Coinbase's own totals, never Fun's. */
110
+ export interface CoinbasePrice {
111
+ total: FiatAmount;
112
+ fees: FeeLine[];
113
+ cryptoAmount: string;
114
+ }
115
+ /**
116
+ * Coinbase priced the checkout. `orderId` is minted for this answer: send it back on `placeOrder`, and on every
117
+ * `order` after it. A retry with the same `orderId` places nothing new.
118
+ */
119
+ export type CoinbasePlaceOrderNextAction = {
120
+ next: 'placeOrder';
121
+ price: CoinbasePrice;
122
+ orderId: string;
123
+ };
124
+ /** Creates the Coinbase order under `orderId` and answers `pay`. */
125
+ export type CoinbasePlaceOrderRequest = {
126
+ action: 'placeOrder';
127
+ orderId: string;
128
+ };
129
+ /** Open `paymentLink`, then send `order`. The link is a credential: never stored, never logged, never sent twice. */
130
+ export type CoinbasePayNextAction = {
131
+ next: 'pay';
132
+ orderId: string;
133
+ price: CoinbasePrice;
134
+ paymentLink: {
135
+ url: string;
136
+ };
137
+ environment: 'sandbox' | 'production';
138
+ };
139
+ /** Reads Coinbase and moves the order `orderId` forward. */
140
+ export type CoinbaseOrderRequest = {
141
+ action: 'order';
142
+ orderId: string;
143
+ };
144
+ /**
145
+ * The order exists and is not terminal. `order` is its current body, or `null` before the order is recorded.
146
+ * Do not open a payment link. After `retryAfterMs`, send `order`.
147
+ */
148
+ export type CoinbaseOrderPendingNextAction = {
149
+ next: 'orderPending';
150
+ orderId: string;
151
+ retryAfterMs: number;
152
+ order: FiatStepResponse | null;
153
+ };
154
+ export type CoinbaseRequest = CoinbaseRequestContext & (CoinbaseObserveRequest | CoinbaseConsentRequest | CoinbaseSessionRequest | CoinbaseOtpRequest | CoinbaseKycRequest | CoinbasePlaceOrderRequest | CoinbaseOrderRequest);
155
+ /**
156
+ * Every `action` a Coinbase request names, derived from the requests. Unlike `MoonPayAction` it leaves out `wait`:
157
+ * `wait` is a next action the client answers by sending `observe` again, never a request action.
158
+ */
159
+ export type CoinbaseAction = CoinbaseRequest['action'];
160
+ /** The wire body. The orchestrator reads `provider` and `geo`; Coinbase's action schemas read the rest. */
161
+ export type CoinbaseNextRequest = {
162
+ provider: 'COINBASE';
163
+ geo: FiatGeo;
164
+ } & CoinbaseRequest;
165
+ export type CoinbaseNextAction = CoinbaseConsentNextAction | CoinbaseSessionNextAction | CoinbaseOtpNextAction | CoinbaseKycNextAction | CoinbaseWaitNextAction | CoinbasePlaceOrderNextAction | CoinbasePayNextAction | CoinbaseOrderPendingNextAction;
166
+ /** The order is terminal. `order` is its body, which the shared order screen renders. */
167
+ export type CoinbaseDone = {
168
+ next: 'done';
169
+ order: FiatStepResponse;
170
+ };
171
+ /**
172
+ * Read `recovery`, never derive it from the reason. `REQUOTE` goes back to routing; `NONE` ends the flow.
173
+ * `LIMITS_EXCEEDED` carries the cap that refused as `maxAmount` when that cap is an amount.
174
+ */
175
+ export type CoinbaseStepRefusal = 'NOT_ELIGIBLE' | 'KYC_UPGRADE_REJECTED' | 'FINAL_REJECTION' | 'TOTAL_MISMATCH';
176
+ export type CoinbaseRefused = {
177
+ next: 'refused';
178
+ reason: CoinbaseStepRefusal;
179
+ recovery: 'REQUOTE' | 'NONE';
180
+ } | {
181
+ next: 'refused';
182
+ reason: 'LIMITS_EXCEEDED';
183
+ recovery: 'REQUOTE';
184
+ maxAmount: FiatAmount | null;
185
+ };
186
+ /** Every action but `order`. An open order answers `orderPending` and a terminal one `done`, whichever action asked. */
187
+ export type CoinbaseStepResponse = CoinbaseNextAction | CoinbaseDone | CoinbaseRefused;
188
+ /** `order` never refuses: it runs after the buyer may have paid. */
189
+ export type CoinbaseOrderResponse = CoinbaseDone | CoinbaseOrderPendingNextAction;
190
+ export type CoinbaseResponseFor = {
191
+ observe: CoinbaseStepResponse;
192
+ consent: CoinbaseStepResponse;
193
+ session: CoinbaseStepResponse;
194
+ otp: CoinbaseStepResponse;
195
+ kyc: CoinbaseStepResponse;
196
+ placeOrder: CoinbaseStepResponse;
197
+ order: CoinbaseOrderResponse;
198
+ };
199
+ /** `RETRY` sends the same request again. `REQUOTE` goes back to routing. `NONE` ends the flow. */
200
+ export type CoinbaseRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
201
+ /**
202
+ * `SESSION_BUDGET_SPENT`: the per-login code budget `session` spends (429). `RATE_LIMITED`: the action's request
203
+ * budget (429). `PROVIDER_UNAVAILABLE`: Coinbase is down (503). `KYC_PROVIDER_UNAVAILABLE`: the KYC provider is down
204
+ * (503). `SERVICE_UNAVAILABLE`: one of Fun's own stores is down (503). `INVALID_REQUEST`: a bad body (400).
205
+ */
206
+ export type CoinbaseFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'KYC_PROVIDER_UNAVAILABLE' | 'SERVICE_UNAVAILABLE' | 'INVALID_REQUEST';
207
+ /** The fields a Coinbase fault adds to the shared error body. */
208
+ export interface CoinbaseFault {
209
+ reason: CoinbaseFaultReason;
210
+ recovery: CoinbaseRecovery;
211
+ }
212
+ /** The route's 4xx/5xx body: the shared error body plus `CoinbaseFault`. A 429 adds `retryAfterSeconds`. */
213
+ export type CoinbaseErrorBody = CoinbaseFault & {
214
+ errorCode: string;
215
+ errorMsg: string;
216
+ reqId?: string;
217
+ retryAfterSeconds?: number;
218
+ };
219
+ /** Coinbase's user agreement, the version the legacy flow records under `COINBASE`. */
220
+ export declare const COINBASE_TERMS: TermsDocument;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/providers/coinbase.ts
21
+ var coinbase_exports = {};
22
+ __export(coinbase_exports, {
23
+ COINBASE_ENDPOINTS: () => COINBASE_ENDPOINTS,
24
+ COINBASE_TERMS: () => COINBASE_TERMS
25
+ });
26
+ module.exports = __toCommonJS(coinbase_exports);
27
+ var COINBASE_ENDPOINTS = {
28
+ next: "POST /fiat/next"
29
+ };
30
+ var COINBASE_TERMS = {
31
+ id: "COINBASE_TERMS",
32
+ kind: "PROVIDER_TERMS",
33
+ stage: "CHECKOUT",
34
+ version: "2026-01",
35
+ contentDigest: "22db1a8292d9ecd60b53adf640c8748ad8477646c26a31971a83f7a43457f1fe",
36
+ links: [{ label: "Coinbase User Agreement", url: "https://www.coinbase.com/legal/user_agreement" }]
37
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ COINBASE_ENDPOINTS,
3
+ COINBASE_TERMS
4
+ } from "../chunk-SFR4SCDU.mjs";
5
+ export {
6
+ COINBASE_ENDPOINTS,
7
+ COINBASE_TERMS
8
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * zod schemas for the Coinbase flow on `POST /fiat/next`. Test-time and backend-boundary only:
3
+ * exported from the package root, never from `./coinbase`, so the production entry stays free of zod.
4
+ */
5
+ import { z } from 'zod';
6
+ import type { CoinbaseCheckout, CoinbaseConsentNextAction, CoinbaseConsentRequest, CoinbaseDone, CoinbaseErrorBody, CoinbaseFault, CoinbaseKycNextAction, CoinbaseKycRequest, CoinbaseNextAction, CoinbaseNextRequest, CoinbaseObserveRequest, CoinbaseOrderPendingNextAction, CoinbaseOrderRequest, CoinbaseOrderResponse, CoinbaseOtpNextAction, CoinbaseOtpRequest, CoinbasePayNextAction, CoinbasePlaceOrderNextAction, CoinbasePlaceOrderRequest, CoinbasePrice, CoinbaseReask, CoinbaseRefused, CoinbaseRequest, CoinbaseRequestContext, CoinbaseResponseFor, CoinbaseSessionNextAction, CoinbaseSessionRequest, CoinbaseStepResponse, CoinbaseWaitNextAction } from './coinbase';
7
+ export declare const CoinbaseCheckoutSchema: z.ZodType<CoinbaseCheckout>;
8
+ export declare const CoinbaseRequestContextSchema: z.ZodType<CoinbaseRequestContext>;
9
+ export declare const CoinbaseObserveRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseObserveRequest>;
10
+ export declare const CoinbaseConsentRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseConsentRequest>;
11
+ export declare const CoinbaseSessionRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseSessionRequest>;
12
+ export declare const CoinbaseOtpRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseOtpRequest>;
13
+ export declare const CoinbaseKycRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseKycRequest>;
14
+ export declare const CoinbasePlaceOrderRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbasePlaceOrderRequest>;
15
+ export declare const CoinbaseOrderRequestSchema: z.ZodType<CoinbaseRequestContext & CoinbaseOrderRequest>;
16
+ export declare const CoinbaseRequestSchema: z.ZodType<CoinbaseRequest>;
17
+ export declare const CoinbaseNextRequestSchema: z.ZodType<CoinbaseNextRequest>;
18
+ export declare const CoinbasePriceSchema: z.ZodType<CoinbasePrice>;
19
+ export declare const CoinbaseReaskSchema: z.ZodType<CoinbaseReask>;
20
+ export declare const CoinbaseConsentNextActionSchema: z.ZodType<CoinbaseConsentNextAction>;
21
+ export declare const CoinbaseSessionNextActionSchema: z.ZodType<CoinbaseSessionNextAction>;
22
+ export declare const CoinbaseOtpNextActionSchema: z.ZodType<CoinbaseOtpNextAction>;
23
+ export declare const CoinbaseKycNextActionSchema: z.ZodType<CoinbaseKycNextAction>;
24
+ export declare const CoinbaseWaitNextActionSchema: z.ZodType<CoinbaseWaitNextAction>;
25
+ export declare const CoinbasePlaceOrderNextActionSchema: z.ZodType<CoinbasePlaceOrderNextAction>;
26
+ export declare const CoinbasePayNextActionSchema: z.ZodType<CoinbasePayNextAction>;
27
+ export declare const CoinbaseOrderPendingNextActionSchema: z.ZodType<CoinbaseOrderPendingNextAction>;
28
+ export declare const CoinbaseNextActionSchema: z.ZodType<CoinbaseNextAction>;
29
+ export declare const CoinbaseDoneSchema: z.ZodType<CoinbaseDone>;
30
+ export declare const CoinbaseRefusedSchema: z.ZodType<CoinbaseRefused>;
31
+ export declare const CoinbaseStepResponseSchema: z.ZodType<CoinbaseStepResponse>;
32
+ export declare const CoinbaseOrderResponseSchema: z.ZodType<CoinbaseOrderResponse>;
33
+ /** The response schema for each request action, as `CoinbaseResponseFor` types it. */
34
+ export declare const CoinbaseResponseSchemaFor: {
35
+ readonly [A in keyof CoinbaseResponseFor]: z.ZodType<CoinbaseResponseFor[A]>;
36
+ };
37
+ export declare const CoinbaseFaultSchema: z.ZodType<CoinbaseFault>;
38
+ export declare const CoinbaseErrorBodySchema: z.ZodType<CoinbaseErrorBody>;
package/dist/schemas.d.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
  import { z } from 'zod';
30
30
  import type { UsStateCode } from './codes';
31
- import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatAuthRefreshRequest, FiatAuthRefreshResponse, FiatAuthRevokeRequest, FiatAuthStartRequest, FiatAuthVerifyRequest, FiatSession, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, DestinationAsset, FiatGeo, FiatNextRequest } from './types';
31
+ import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatAuthRecipientRequest, FiatAuthRecipientResponse, FiatAuthRefreshRequest, FiatAuthRefreshResponse, FiatAuthRevokeRequest, FiatAuthStartRequest, FiatAuthVerifyRequest, FiatSession, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, DestinationAsset, FiatGeo, FiatNextRequest } from './types';
32
32
  import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
33
33
  import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingQuoteTerms, FiatRoutingTableErrorBody, FiatRoutingTableRequest, FiatRoutingTableResponse } from './routing';
34
34
  export declare const JsonSchema: z.ZodType<JsonValue>;
@@ -128,5 +128,7 @@ export declare const FiatAuthVerifyRequestSchema: z.ZodType<FiatAuthVerifyReques
128
128
  export declare const FiatAuthRefreshRequestSchema: z.ZodType<FiatAuthRefreshRequest>;
129
129
  export declare const FiatAuthRefreshResponseSchema: z.ZodType<FiatAuthRefreshResponse>;
130
130
  export declare const FiatAuthRevokeRequestSchema: z.ZodType<FiatAuthRevokeRequest>;
131
+ export declare const FiatAuthRecipientRequestSchema: z.ZodType<FiatAuthRecipientRequest>;
132
+ export declare const FiatAuthRecipientResponseSchema: z.ZodType<FiatAuthRecipientResponse>;
131
133
  export declare const FiatStepResponseSchema: z.ZodType<FiatStepResponse>;
132
134
  export {};
package/dist/table.d.ts CHANGED
@@ -97,7 +97,7 @@ export declare const STATE_KEYS: StateKey[];
97
97
  * session-minting call for that rail. The `/fiat/auth/*` routes come from the Fun identity design
98
98
  * that specifies `FUN_AUTH`.
99
99
  */
100
- export declare const DOCUMENTED_ENDPOINTS: readonly ["GET /fiat/payment-methods", "POST /fiat/quote", "POST /fiat/auth", "POST /fiat/auth/verify", "POST /fiat/auth/refresh", "POST /fiat/auth/revoke", "POST /fiat/payment-session", "POST /fiat/session", "POST /fiat/session/verify", "GET /fiat/quotes/:quoteRef", "POST /fiat/kyc/form", "POST /fiat/kyc/capture", "POST /fiat/kyc/sdk-token", "POST /fiat/kyc/document", "POST /fiat/instruments", "POST /fiat/orders", "GET /fiat/orders/:id", "GET /fiat/delivery/:deliveryId", "GET /fiat/orders/:id/instructions", "POST /fiat/orders/:id/confirm-payment", "POST /fiat/orders/:id/reference", "POST /fiat/orders/:id/cancel", "POST /fiat/orders/:id/surface-result"];
100
+ export declare const DOCUMENTED_ENDPOINTS: readonly ["GET /fiat/payment-methods", "POST /fiat/quote", "POST /fiat/auth", "POST /fiat/auth/verify", "POST /fiat/auth/refresh", "POST /fiat/auth/revoke", "POST /fiat/auth/recipient", "POST /fiat/payment-session", "POST /fiat/session", "POST /fiat/session/verify", "GET /fiat/quotes/:quoteRef", "POST /fiat/kyc/form", "POST /fiat/kyc/capture", "POST /fiat/kyc/sdk-token", "POST /fiat/kyc/document", "POST /fiat/instruments", "POST /fiat/orders", "GET /fiat/orders/:id", "GET /fiat/delivery/:deliveryId", "GET /fiat/orders/:id/instructions", "POST /fiat/orders/:id/confirm-payment", "POST /fiat/orders/:id/reference", "POST /fiat/orders/:id/cancel", "POST /fiat/orders/:id/surface-result"];
101
101
  /**
102
102
  * Documented endpoints no flow state offers, and why. Declared so an endpoint nothing can reach is
103
103
  * visible instead of silent — the table test asserts the unoffered set equals exactly these.
package/dist/table.js CHANGED
@@ -37,7 +37,7 @@ __export(table_exports, {
37
37
  module.exports = __toCommonJS(table_exports);
38
38
 
39
39
  // package.json
40
- var version = "0.40.0";
40
+ var version = "0.43.0";
41
41
 
42
42
  // src/table.ts
43
43
  var TABLE_VERSION = version;
@@ -133,7 +133,7 @@ var TRANSITION_TABLE = {
133
133
  id: "verify",
134
134
  mode: "SUBMIT",
135
135
  endpoint: "POST /fiat/auth/verify",
136
- when: "phase CODE \u2014 params { verificationRef }, inputs { code: TEXT length 6, regex ^\\d{6}$ }"
136
+ when: "phase CODE \u2014 params { verificationRef }, inputs { otpCode: TEXT length 6, regex ^\\d{6}$ }"
137
137
  },
138
138
  {
139
139
  id: "resend",
@@ -150,7 +150,7 @@ var TRANSITION_TABLE = {
150
150
  "Not in the FE doc, so no screen number: the client renders it on its contact and OTP screens.",
151
151
  "Every FUN_AUTH error is category USER_ERROR with a code from FUN_AUTH_ERROR_CODES. A wrong code re-enters CODE with BAD_CODE and a lower attemptsRemaining; TOO_MANY_ATTEMPTS and CODE_EXPIRED drop the challenge and offer resend; OTP_DISPATCH_THROTTLED re-enters with resendAvailableAtMs set.",
152
152
  "resend carries the verificationRef the client holds, even one the server has dropped (expired, too many attempts); the server starts a fresh challenge for the same email while it still remembers the challenge (its code expiry plus a short grace); once it is forgotten the answer is IDENTIFIER with CODE_EXPIRED.",
153
- "POST /fiat/auth/refresh and /revoke are called by the SDK session store, never offered as transitions."
153
+ "POST /fiat/auth/refresh, /revoke and /recipient are called by the SDK session store, never offered as transitions."
154
154
  ]
155
155
  },
156
156
  SESSION_AUTH: {
@@ -516,6 +516,7 @@ var DOCUMENTED_ENDPOINTS = [
516
516
  "POST /fiat/auth/verify",
517
517
  "POST /fiat/auth/refresh",
518
518
  "POST /fiat/auth/revoke",
519
+ "POST /fiat/auth/recipient",
519
520
  "POST /fiat/payment-session",
520
521
  "POST /fiat/session",
521
522
  "POST /fiat/session/verify",
@@ -547,6 +548,10 @@ var UNOFFERED_ENDPOINTS = [
547
548
  endpoint: "POST /fiat/auth/revoke",
548
549
  reason: "SDK session store, not a transition."
549
550
  },
551
+ {
552
+ endpoint: "POST /fiat/auth/recipient",
553
+ reason: "SDK session store at beginDeposit, not a transition."
554
+ },
550
555
  {
551
556
  endpoint: "POST /fiat/kyc/document",
552
557
  reason: "FILE fields use it for a direct provider/vendor upload handshake and completion report; the harness owns that auxiliary path and it is not a transition (see KYC/INPUT_REQUIRED notes)."
package/dist/table.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-4Y22UVT4.mjs";
15
+ } from "./chunk-6O7Z7WYW.mjs";
16
16
  export {
17
17
  DOCUMENTED_ENDPOINTS,
18
18
  FUN_AUTH_ERROR_CODES,
package/dist/types.d.ts CHANGED
@@ -56,7 +56,7 @@ export type HttpVerb = 'GET' | 'POST';
56
56
  * cannot express "no slash", so `GET /fiat/orders/${string}` also admits sub-paths. Precision at
57
57
  * that level is the table's job (`allowedTransitions` + `endpointMatches`), not the type's.
58
58
  */
59
- export type FiatEndpoint = 'GET /fiat/payment-methods' | 'POST /fiat/quote' | 'POST /fiat/auth' | 'POST /fiat/auth/verify' | 'POST /fiat/auth/refresh' | 'POST /fiat/auth/revoke' | 'POST /fiat/payment-session' | 'POST /fiat/session' | 'POST /fiat/session/verify' | `GET /fiat/quotes/${string}` | 'POST /fiat/kyc/form' | 'POST /fiat/kyc/capture' | 'POST /fiat/kyc/sdk-token' | 'POST /fiat/kyc/document' | 'POST /fiat/instruments' | 'POST /fiat/orders' | `GET /fiat/orders/${string}` | `GET /fiat/delivery/${string}` | `GET /fiat/orders/${string}/instructions` | `POST /fiat/orders/${string}/confirm-payment` | `POST /fiat/orders/${string}/reference` | `POST /fiat/orders/${string}/cancel` | `POST /fiat/orders/${string}/surface-result`;
59
+ export type FiatEndpoint = 'GET /fiat/payment-methods' | 'POST /fiat/quote' | 'POST /fiat/auth' | 'POST /fiat/auth/verify' | 'POST /fiat/auth/refresh' | 'POST /fiat/auth/revoke' | 'POST /fiat/auth/recipient' | 'POST /fiat/payment-session' | 'POST /fiat/session' | 'POST /fiat/session/verify' | `GET /fiat/quotes/${string}` | 'POST /fiat/kyc/form' | 'POST /fiat/kyc/capture' | 'POST /fiat/kyc/sdk-token' | 'POST /fiat/kyc/document' | 'POST /fiat/instruments' | 'POST /fiat/orders' | `GET /fiat/orders/${string}` | `GET /fiat/delivery/${string}` | `GET /fiat/orders/${string}/instructions` | `POST /fiat/orders/${string}/confirm-payment` | `POST /fiat/orders/${string}/reference` | `POST /fiat/orders/${string}/cancel` | `POST /fiat/orders/${string}/surface-result`;
60
60
  /**
61
61
  * Routing metadata, not sequencing policy. Reserved values may be emitted only after their adapter
62
62
  * and conformance fixture land.
@@ -569,7 +569,7 @@ export type FiatAuthStartRequest = {
569
569
  */
570
570
  export type FiatAuthVerifyRequest = {
571
571
  verificationRef: string;
572
- code: string;
572
+ otpCode: string;
573
573
  };
574
574
  /**
575
575
  * Body of `POST /fiat/auth/refresh`. Returns 200 `FiatAuthRefreshResponse` with a rotated handle, or
@@ -587,6 +587,45 @@ export type FiatAuthRefreshResponse = {
587
587
  export type FiatAuthRevokeRequest = {
588
588
  refreshHandle: string;
589
589
  };
590
+ /**
591
+ * Body of `POST /fiat/auth/recipient`, sent with `Authorization: Bearer <accessToken>`. Binds the
592
+ * recipient of the deposit in progress for the partner the API key names. The backend records the
593
+ * binding for this login session; the session and its handle are unchanged. `refreshHandle` is the
594
+ * write credential, not a rotation: it must belong to the same login as the Bearer. The SDK calls it
595
+ * at `beginDeposit`, once a session is held, and may bind a new address for every deposit.
596
+ *
597
+ * Split by VM, as `DestinationAsset` is. The recipient is a destination-side value, so the backend
598
+ * checks the binding against the chain the delivery lands on: the quote's `destinationAsset` when
599
+ * there is one, else the rail. Solana carries no chain id for the same reason `DestinationAsset` does
600
+ * not: the backend maps each VM to its own chain ids in one place. `depositAddress` must be a wallet
601
+ * on that chain, and the chain must be a destination registered for the partner.
602
+ *
603
+ * Address form. EVM: any case accepted; a mixed-case address must pass its EIP-55 checksum, and the
604
+ * backend stores and reports the checksummed form. Solana: base58 as given.
605
+ *
606
+ * Errors: 401 when the bearer is expired or not a Fun session, or the handle is not this login's or
607
+ * has ended. The SDK refreshes once and retries; a 401 on the refresh itself means sign in again.
608
+ * 400 with `CHAIN_NOT_SERVED` or `RECIPIENT_NOT_A_WALLET`.
609
+ */
610
+ export type FiatAuthRecipientRequest = {
611
+ refreshHandle: string;
612
+ } & ({
613
+ vm: 'EVM';
614
+ chainId: number;
615
+ depositAddress: `0x${string}`;
616
+ } | {
617
+ vm: 'SOLANA';
618
+ depositAddress: string;
619
+ });
620
+ /**
621
+ * 200 body of `POST /fiat/auth/recipient`. The session and its handle are unchanged. `expiresAtMs`
622
+ * (server clock, ms) is when the binding stops being honoured, 24 h after `boundAtMs`; the SDK binds
623
+ * again after that, or on a `NO_WALLET` or `RECIPIENT_CHAIN_MISMATCH` refusal.
624
+ */
625
+ export type FiatAuthRecipientResponse = {
626
+ boundAtMs: number;
627
+ expiresAtMs: number;
628
+ };
590
629
  /**
591
630
  * The expected length of a provider's KYC review. `BRIEF`: the client stays on its current screen,
592
631
  * polling, for up to `holdMs` (at most 600000), then shows the in-review screen. `EXTENDED`: the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.40.0",
3
+ "version": "0.43.0",
4
4
  "description": "Published conformance contract for Fun's headless fiat onramp: FlowState/Transition types, zod schemas, the transition table as data, recorded fixtures, assertion helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,6 +33,11 @@
33
33
  "import": "./dist/providers/moonpay.mjs",
34
34
  "require": "./dist/providers/moonpay.js"
35
35
  },
36
+ "./coinbase": {
37
+ "types": "./dist/providers/coinbase.d.ts",
38
+ "import": "./dist/providers/coinbase.mjs",
39
+ "require": "./dist/providers/coinbase.js"
40
+ },
36
41
  "./terms": {
37
42
  "types": "./dist/terms.d.ts",
38
43
  "import": "./dist/terms.mjs",
@@ -53,6 +58,8 @@
53
58
  "types.d.ts",
54
59
  "moonpay.js",
55
60
  "moonpay.d.ts",
61
+ "coinbase.js",
62
+ "coinbase.d.ts",
56
63
  "terms.js",
57
64
  "terms.d.ts",
58
65
  "routing.js",
@@ -98,6 +105,9 @@
98
105
  "moonpay": [
99
106
  "./dist/providers/moonpay.d.ts"
100
107
  ],
108
+ "coinbase": [
109
+ "./dist/providers/coinbase.d.ts"
110
+ ],
101
111
  "terms": [
102
112
  "./dist/terms.d.ts"
103
113
  ],