@fun-xyz/fiat-contract 0.40.0 → 0.42.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.42.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",
@@ -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,
@@ -1248,7 +1279,7 @@ var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank,
1248
1279
  var FiatNextRequestSchema = $nextRequest;
1249
1280
  var $authStartRequest = import_zod.z.union([obj({ email: $nonBlank }), obj({ verificationRef: $nonBlank })]);
1250
1281
  var FiatAuthStartRequestSchema = $authStartRequest;
1251
- var $authVerifyRequest = obj({ verificationRef: $nonBlank, code: import_zod.z.string().regex(/^\d{6}$/, "must be six digits") });
1282
+ var $authVerifyRequest = obj({ verificationRef: $nonBlank, otpCode: import_zod.z.string().regex(/^\d{6}$/, "must be six digits") });
1252
1283
  var FiatAuthVerifyRequestSchema = $authVerifyRequest;
1253
1284
  var $authRefreshRequest = obj({ refreshHandle: $nonBlank });
1254
1285
  var FiatAuthRefreshRequestSchema = $authRefreshRequest;
@@ -1337,7 +1368,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
1337
1368
  var FiatStepResponseSchema = $stepResponse;
1338
1369
 
1339
1370
  // package.json
1340
- var version = "0.40.0";
1371
+ var version = "0.42.0";
1341
1372
 
1342
1373
  // src/table.ts
1343
1374
  var TABLE_VERSION = version;
@@ -1433,7 +1464,7 @@ var TRANSITION_TABLE = {
1433
1464
  id: "verify",
1434
1465
  mode: "SUBMIT",
1435
1466
  endpoint: "POST /fiat/auth/verify",
1436
- when: "phase CODE \u2014 params { verificationRef }, inputs { code: TEXT length 6, regex ^\\d{6}$ }"
1467
+ when: "phase CODE \u2014 params { verificationRef }, inputs { otpCode: TEXT length 6, regex ^\\d{6}$ }"
1437
1468
  },
1438
1469
  {
1439
1470
  id: "resend",
@@ -2010,7 +2041,7 @@ var FIXTURE_DATA = {
2010
2041
  "verificationRef": "vr_7c1"
2011
2042
  },
2012
2043
  "inputs": {
2013
- "code": {
2044
+ "otpCode": {
2014
2045
  "type": "TEXT",
2015
2046
  "length": 6,
2016
2047
  "regex": "^\\d{6}$"
@@ -3525,3 +3556,195 @@ var $fault = obj2($faultFields);
3525
3556
  var MoonPayFaultSchema = $fault;
3526
3557
  var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: import_zod2.z.string(), reqId: import_zod2.z.string().optional() });
3527
3558
  var MoonPayErrorBodySchema = $errorBody;
3559
+
3560
+ // src/providers/coinbase.ts
3561
+ var COINBASE_ENDPOINTS = {
3562
+ next: "POST /fiat/next"
3563
+ };
3564
+ var COINBASE_TERMS = {
3565
+ id: "COINBASE_TERMS",
3566
+ kind: "PROVIDER_TERMS",
3567
+ stage: "CHECKOUT",
3568
+ version: "2026-01",
3569
+ contentDigest: "22db1a8292d9ecd60b53adf640c8748ad8477646c26a31971a83f7a43457f1fe",
3570
+ links: [{ label: "Coinbase User Agreement", url: "https://www.coinbase.com/legal/user_agreement" }]
3571
+ };
3572
+
3573
+ // src/providers/coinbase.schemas.ts
3574
+ var import_zod3 = require("zod");
3575
+ var obj3 = (shape) => import_zod3.z.object(shape).strict();
3576
+ var $nonEmpty2 = import_zod3.z.string().refine((value) => value.trim().length > 0, "must not be blank");
3577
+ var hasUniqueIds3 = (ids) => new Set(ids).size === ids.length;
3578
+ var $retryAfterMs = import_zod3.z.number().int().positive().max(6e4);
3579
+ 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");
3580
+ var $checkout2 = obj3({
3581
+ amount: obj3({ currency: import_zod3.z.literal("USD"), amount: $positiveAmount }),
3582
+ destination: obj3({ asset: $nonEmpty2, network: $nonEmpty2 }),
3583
+ paymentMethod: import_zod3.z.literal("apple_pay")
3584
+ });
3585
+ var CoinbaseCheckoutSchema = $checkout2;
3586
+ var contextFields = { checkout: $checkout2, destinationAsset: DestinationAssetSchema.optional() };
3587
+ var $requestContext2 = obj3(contextFields);
3588
+ var CoinbaseRequestContextSchema = $requestContext2;
3589
+ var observeFields = { action: import_zod3.z.literal("observe") };
3590
+ var consentFields = {
3591
+ action: import_zod3.z.literal("consent"),
3592
+ acceptances: import_zod3.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds3(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
3593
+ };
3594
+ var sessionPhoneFields = { action: import_zod3.z.literal("session"), phoneNumber: import_zod3.z.string().regex(/^\+[1-9]\d{1,14}$/) };
3595
+ var sessionResendFields = { action: import_zod3.z.literal("session"), resend: $nonEmpty2 };
3596
+ var otpFields = { action: import_zod3.z.literal("otp"), verificationRef: $nonEmpty2, otpCode: import_zod3.z.string().regex(/^\d{6}$/) };
3597
+ var $kycValues = import_zod3.z.record(KycFieldIdSchema, import_zod3.z.string());
3598
+ var kycFields = { action: import_zod3.z.literal("kyc"), values: $kycValues };
3599
+ var $mintedOrderId = import_zod3.z.string().regex(/^cbo_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
3600
+ var placeOrderFields = { action: import_zod3.z.literal("placeOrder"), orderId: $mintedOrderId };
3601
+ var orderFields = { action: import_zod3.z.literal("order"), orderId: $mintedOrderId };
3602
+ var $observeRequest2 = obj3({ ...contextFields, ...observeFields });
3603
+ var $consentRequest2 = obj3({ ...contextFields, ...consentFields });
3604
+ var $sessionRequest2 = import_zod3.z.union([obj3({ ...contextFields, ...sessionPhoneFields }), obj3({ ...contextFields, ...sessionResendFields })]);
3605
+ var $otpRequest = obj3({ ...contextFields, ...otpFields });
3606
+ var $kycRequest2 = obj3({ ...contextFields, ...kycFields });
3607
+ var $placeOrderRequest = obj3({ ...contextFields, ...placeOrderFields });
3608
+ var $orderRequest2 = obj3({ ...contextFields, ...orderFields });
3609
+ var CoinbaseObserveRequestSchema = $observeRequest2;
3610
+ var CoinbaseConsentRequestSchema = $consentRequest2;
3611
+ var CoinbaseSessionRequestSchema = $sessionRequest2;
3612
+ var CoinbaseOtpRequestSchema = $otpRequest;
3613
+ var CoinbaseKycRequestSchema = $kycRequest2;
3614
+ var CoinbasePlaceOrderRequestSchema = $placeOrderRequest;
3615
+ var CoinbaseOrderRequestSchema = $orderRequest2;
3616
+ var $request2 = import_zod3.z.union([$observeRequest2, $consentRequest2, $sessionRequest2, $otpRequest, $kycRequest2, $placeOrderRequest, $orderRequest2]);
3617
+ var CoinbaseRequestSchema = $request2;
3618
+ var envelope = { provider: import_zod3.z.literal("COINBASE"), geo: FiatGeoSchema, ...contextFields };
3619
+ var $nextRequest3 = import_zod3.z.union([
3620
+ obj3({ ...envelope, ...observeFields }),
3621
+ obj3({ ...envelope, ...consentFields }),
3622
+ obj3({ ...envelope, ...sessionPhoneFields }),
3623
+ obj3({ ...envelope, ...sessionResendFields }),
3624
+ obj3({ ...envelope, ...otpFields }),
3625
+ obj3({ ...envelope, ...kycFields }),
3626
+ obj3({ ...envelope, ...placeOrderFields }),
3627
+ obj3({ ...envelope, ...orderFields })
3628
+ ]);
3629
+ var CoinbaseNextRequestSchema = $nextRequest3;
3630
+ var $price = obj3({ total: FiatAmountSchema, fees: import_zod3.z.array(FeeLineSchema), cryptoAmount: $nonEmpty2 });
3631
+ var CoinbasePriceSchema = $price;
3632
+ var $reask2 = obj3({
3633
+ requirements: import_zod3.z.array(KycFieldIdSchema).min(1).refine(hasUniqueIds3, "requirements must be unique"),
3634
+ reason: import_zod3.z.enum(["REJECTED"]).nullable()
3635
+ });
3636
+ var CoinbaseReaskSchema = $reask2;
3637
+ var $consentShape2 = obj3({ next: import_zod3.z.literal("consent"), documents: import_zod3.z.array(TermsDocumentSchema).min(1) });
3638
+ var $sessionNextAction2 = obj3({ next: import_zod3.z.literal("session"), error: import_zod3.z.literal("CODE_EXPIRED").nullable() });
3639
+ var $otpNextAction = obj3({
3640
+ next: import_zod3.z.literal("otp"),
3641
+ verificationRef: $nonEmpty2,
3642
+ expiresAt: import_zod3.z.string().datetime({ offset: true }),
3643
+ error: import_zod3.z.literal("CODE_INVALID").nullable()
3644
+ });
3645
+ var $kycShape2 = obj3({
3646
+ next: import_zod3.z.literal("kyc"),
3647
+ fields: import_zod3.z.array(FormFieldSchema),
3648
+ fieldErrors: import_zod3.z.array(obj3({ fieldId: $nonEmpty2, message: $nonEmpty2 })).min(1).optional(),
3649
+ reask: $reask2.nullable()
3650
+ });
3651
+ var $waitNextAction2 = obj3({ next: import_zod3.z.literal("wait"), retryAfterMs: $retryAfterMs });
3652
+ var $placeOrderNextAction = obj3({ next: import_zod3.z.literal("placeOrder"), price: $price, orderId: $nonEmpty2 });
3653
+ var $payNextAction = obj3({
3654
+ next: import_zod3.z.literal("pay"),
3655
+ orderId: $nonEmpty2,
3656
+ price: $price,
3657
+ // As the shared links are checked: `z.string().url()` would also take `http:` and `javascript:`.
3658
+ paymentLink: obj3({ url: import_zod3.z.string().regex(/^https:\/\/\S+$/, "must be an https URL") }),
3659
+ environment: import_zod3.z.enum(["sandbox", "production"])
3660
+ });
3661
+ var $orderPendingNextAction2 = obj3({
3662
+ next: import_zod3.z.literal("orderPending"),
3663
+ orderId: $nonEmpty2,
3664
+ retryAfterMs: $retryAfterMs,
3665
+ order: FiatStepResponseSchema.nullable()
3666
+ });
3667
+ var checkConsent2 = (nextAction, context) => {
3668
+ if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
3669
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
3670
+ }
3671
+ };
3672
+ var checkKyc2 = (nextAction, context) => {
3673
+ const fieldIds = nextAction.fields.map((field) => field.id);
3674
+ if (!hasUniqueIds3(fieldIds)) {
3675
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
3676
+ }
3677
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
3678
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
3679
+ }
3680
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
3681
+ context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
3682
+ }
3683
+ };
3684
+ var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
3685
+ var CoinbaseSessionNextActionSchema = $sessionNextAction2;
3686
+ var CoinbaseOtpNextActionSchema = $otpNextAction;
3687
+ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
3688
+ var CoinbaseWaitNextActionSchema = $waitNextAction2;
3689
+ var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
3690
+ var CoinbasePayNextActionSchema = $payNextAction;
3691
+ var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
3692
+ var checkNextAction2 = (response, context) => {
3693
+ if (response.next === "consent") checkConsent2(response, context);
3694
+ if (response.next === "kyc") checkKyc2(response, context);
3695
+ };
3696
+ var $nextActionOptions2 = [
3697
+ $consentShape2,
3698
+ $sessionNextAction2,
3699
+ $otpNextAction,
3700
+ $kycShape2,
3701
+ $waitNextAction2,
3702
+ $placeOrderNextAction,
3703
+ $payNextAction,
3704
+ $orderPendingNextAction2
3705
+ ];
3706
+ var $nextAction2 = import_zod3.z.discriminatedUnion("next", [...$nextActionOptions2]).superRefine(checkNextAction2);
3707
+ var CoinbaseNextActionSchema = $nextAction2;
3708
+ var $done2 = obj3({ next: import_zod3.z.literal("done"), order: FiatStepResponseSchema });
3709
+ var CoinbaseDoneSchema = $done2;
3710
+ var $refused = import_zod3.z.union([
3711
+ obj3({
3712
+ next: import_zod3.z.literal("refused"),
3713
+ reason: import_zod3.z.enum(["NOT_ELIGIBLE", "KYC_UPGRADE_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
3714
+ recovery: import_zod3.z.enum(["REQUOTE", "NONE"])
3715
+ }),
3716
+ obj3({
3717
+ next: import_zod3.z.literal("refused"),
3718
+ reason: import_zod3.z.literal("LIMITS_EXCEEDED"),
3719
+ recovery: import_zod3.z.literal("REQUOTE"),
3720
+ maxAmount: FiatAmountSchema.nullable()
3721
+ })
3722
+ ]);
3723
+ var CoinbaseRefusedSchema = $refused;
3724
+ var $stepResponse3 = import_zod3.z.union([import_zod3.z.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
3725
+ var CoinbaseStepResponseSchema = $stepResponse3;
3726
+ var $orderResponse2 = import_zod3.z.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
3727
+ var CoinbaseOrderResponseSchema = $orderResponse2;
3728
+ var CoinbaseResponseSchemaFor = {
3729
+ observe: CoinbaseStepResponseSchema,
3730
+ consent: CoinbaseStepResponseSchema,
3731
+ session: CoinbaseStepResponseSchema,
3732
+ otp: CoinbaseStepResponseSchema,
3733
+ kyc: CoinbaseStepResponseSchema,
3734
+ placeOrder: CoinbaseStepResponseSchema,
3735
+ order: CoinbaseOrderResponseSchema
3736
+ };
3737
+ var faultFields = {
3738
+ reason: import_zod3.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
3739
+ recovery: import_zod3.z.enum(["RETRY", "REQUOTE", "NONE"])
3740
+ };
3741
+ var $fault2 = obj3(faultFields);
3742
+ var CoinbaseFaultSchema = $fault2;
3743
+ var $errorBody2 = obj3({
3744
+ ...faultFields,
3745
+ errorCode: $nonEmpty2,
3746
+ errorMsg: import_zod3.z.string(),
3747
+ reqId: import_zod3.z.string().optional(),
3748
+ retryAfterSeconds: import_zod3.z.number().int().positive().optional()
3749
+ });
3750
+ 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-RGQE53YP.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;
@@ -1263,7 +1267,7 @@ var FIXTURE_DATA = {
1263
1267
  "verificationRef": "vr_7c1"
1264
1268
  },
1265
1269
  "inputs": {
1266
- "code": {
1270
+ "otpCode": {
1267
1271
  "type": "TEXT",
1268
1272
  "length": 6,
1269
1273
  "regex": "^\\d{6}$"
@@ -2702,12 +2706,222 @@ var $fault = obj2($faultFields);
2702
2706
  var MoonPayFaultSchema = $fault;
2703
2707
  var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: z2.string(), reqId: z2.string().optional() });
2704
2708
  var MoonPayErrorBodySchema = $errorBody;
2709
+
2710
+ // src/providers/coinbase.schemas.ts
2711
+ import { z as z3 } from "zod";
2712
+ var obj3 = (shape) => z3.object(shape).strict();
2713
+ var $nonEmpty2 = z3.string().refine((value) => value.trim().length > 0, "must not be blank");
2714
+ var hasUniqueIds3 = (ids) => new Set(ids).size === ids.length;
2715
+ var $retryAfterMs = z3.number().int().positive().max(6e4);
2716
+ var $positiveAmount = z3.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string").refine((amount) => Number(amount) > 0, "must be positive");
2717
+ var $checkout2 = obj3({
2718
+ amount: obj3({ currency: z3.literal("USD"), amount: $positiveAmount }),
2719
+ destination: obj3({ asset: $nonEmpty2, network: $nonEmpty2 }),
2720
+ paymentMethod: z3.literal("apple_pay")
2721
+ });
2722
+ var CoinbaseCheckoutSchema = $checkout2;
2723
+ var contextFields = { checkout: $checkout2, destinationAsset: DestinationAssetSchema.optional() };
2724
+ var $requestContext2 = obj3(contextFields);
2725
+ var CoinbaseRequestContextSchema = $requestContext2;
2726
+ var observeFields = { action: z3.literal("observe") };
2727
+ var consentFields = {
2728
+ action: z3.literal("consent"),
2729
+ acceptances: z3.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds3(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once")
2730
+ };
2731
+ var sessionPhoneFields = { action: z3.literal("session"), phoneNumber: z3.string().regex(/^\+[1-9]\d{1,14}$/) };
2732
+ var sessionResendFields = { action: z3.literal("session"), resend: $nonEmpty2 };
2733
+ var otpFields = { action: z3.literal("otp"), verificationRef: $nonEmpty2, otpCode: z3.string().regex(/^\d{6}$/) };
2734
+ var $kycValues = z3.record(KycFieldIdSchema, z3.string());
2735
+ var kycFields = { action: z3.literal("kyc"), values: $kycValues };
2736
+ var $mintedOrderId = z3.string().regex(/^cbo_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
2737
+ var placeOrderFields = { action: z3.literal("placeOrder"), orderId: $mintedOrderId };
2738
+ var orderFields = { action: z3.literal("order"), orderId: $mintedOrderId };
2739
+ var $observeRequest2 = obj3({ ...contextFields, ...observeFields });
2740
+ var $consentRequest2 = obj3({ ...contextFields, ...consentFields });
2741
+ var $sessionRequest2 = z3.union([obj3({ ...contextFields, ...sessionPhoneFields }), obj3({ ...contextFields, ...sessionResendFields })]);
2742
+ var $otpRequest = obj3({ ...contextFields, ...otpFields });
2743
+ var $kycRequest2 = obj3({ ...contextFields, ...kycFields });
2744
+ var $placeOrderRequest = obj3({ ...contextFields, ...placeOrderFields });
2745
+ var $orderRequest2 = obj3({ ...contextFields, ...orderFields });
2746
+ var CoinbaseObserveRequestSchema = $observeRequest2;
2747
+ var CoinbaseConsentRequestSchema = $consentRequest2;
2748
+ var CoinbaseSessionRequestSchema = $sessionRequest2;
2749
+ var CoinbaseOtpRequestSchema = $otpRequest;
2750
+ var CoinbaseKycRequestSchema = $kycRequest2;
2751
+ var CoinbasePlaceOrderRequestSchema = $placeOrderRequest;
2752
+ var CoinbaseOrderRequestSchema = $orderRequest2;
2753
+ var $request2 = z3.union([$observeRequest2, $consentRequest2, $sessionRequest2, $otpRequest, $kycRequest2, $placeOrderRequest, $orderRequest2]);
2754
+ var CoinbaseRequestSchema = $request2;
2755
+ var envelope = { provider: z3.literal("COINBASE"), geo: FiatGeoSchema, ...contextFields };
2756
+ var $nextRequest3 = z3.union([
2757
+ obj3({ ...envelope, ...observeFields }),
2758
+ obj3({ ...envelope, ...consentFields }),
2759
+ obj3({ ...envelope, ...sessionPhoneFields }),
2760
+ obj3({ ...envelope, ...sessionResendFields }),
2761
+ obj3({ ...envelope, ...otpFields }),
2762
+ obj3({ ...envelope, ...kycFields }),
2763
+ obj3({ ...envelope, ...placeOrderFields }),
2764
+ obj3({ ...envelope, ...orderFields })
2765
+ ]);
2766
+ var CoinbaseNextRequestSchema = $nextRequest3;
2767
+ var $price = obj3({ total: FiatAmountSchema, fees: z3.array(FeeLineSchema), cryptoAmount: $nonEmpty2 });
2768
+ var CoinbasePriceSchema = $price;
2769
+ var $reask2 = obj3({
2770
+ requirements: z3.array(KycFieldIdSchema).min(1).refine(hasUniqueIds3, "requirements must be unique"),
2771
+ reason: z3.enum(["REJECTED"]).nullable()
2772
+ });
2773
+ var CoinbaseReaskSchema = $reask2;
2774
+ var $consentShape2 = obj3({ next: z3.literal("consent"), documents: z3.array(TermsDocumentSchema).min(1) });
2775
+ var $sessionNextAction2 = obj3({ next: z3.literal("session"), error: z3.literal("CODE_EXPIRED").nullable() });
2776
+ var $otpNextAction = obj3({
2777
+ next: z3.literal("otp"),
2778
+ verificationRef: $nonEmpty2,
2779
+ expiresAt: z3.string().datetime({ offset: true }),
2780
+ error: z3.literal("CODE_INVALID").nullable()
2781
+ });
2782
+ var $kycShape2 = obj3({
2783
+ next: z3.literal("kyc"),
2784
+ fields: z3.array(FormFieldSchema),
2785
+ fieldErrors: z3.array(obj3({ fieldId: $nonEmpty2, message: $nonEmpty2 })).min(1).optional(),
2786
+ reask: $reask2.nullable()
2787
+ });
2788
+ var $waitNextAction2 = obj3({ next: z3.literal("wait"), retryAfterMs: $retryAfterMs });
2789
+ var $placeOrderNextAction = obj3({ next: z3.literal("placeOrder"), price: $price, orderId: $nonEmpty2 });
2790
+ var $payNextAction = obj3({
2791
+ next: z3.literal("pay"),
2792
+ orderId: $nonEmpty2,
2793
+ price: $price,
2794
+ // As the shared links are checked: `z.string().url()` would also take `http:` and `javascript:`.
2795
+ paymentLink: obj3({ url: z3.string().regex(/^https:\/\/\S+$/, "must be an https URL") }),
2796
+ environment: z3.enum(["sandbox", "production"])
2797
+ });
2798
+ var $orderPendingNextAction2 = obj3({
2799
+ next: z3.literal("orderPending"),
2800
+ orderId: $nonEmpty2,
2801
+ retryAfterMs: $retryAfterMs,
2802
+ order: FiatStepResponseSchema.nullable()
2803
+ });
2804
+ var checkConsent2 = (nextAction, context) => {
2805
+ if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
2806
+ context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2807
+ }
2808
+ };
2809
+ var checkKyc2 = (nextAction, context) => {
2810
+ const fieldIds = nextAction.fields.map((field) => field.id);
2811
+ if (!hasUniqueIds3(fieldIds)) {
2812
+ context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2813
+ }
2814
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2815
+ context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2816
+ }
2817
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
2818
+ context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2819
+ }
2820
+ };
2821
+ var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
2822
+ var CoinbaseSessionNextActionSchema = $sessionNextAction2;
2823
+ var CoinbaseOtpNextActionSchema = $otpNextAction;
2824
+ var CoinbaseKycNextActionSchema = $kycShape2.superRefine(checkKyc2);
2825
+ var CoinbaseWaitNextActionSchema = $waitNextAction2;
2826
+ var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
2827
+ var CoinbasePayNextActionSchema = $payNextAction;
2828
+ var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
2829
+ var checkNextAction2 = (response, context) => {
2830
+ if (response.next === "consent") checkConsent2(response, context);
2831
+ if (response.next === "kyc") checkKyc2(response, context);
2832
+ };
2833
+ var $nextActionOptions2 = [
2834
+ $consentShape2,
2835
+ $sessionNextAction2,
2836
+ $otpNextAction,
2837
+ $kycShape2,
2838
+ $waitNextAction2,
2839
+ $placeOrderNextAction,
2840
+ $payNextAction,
2841
+ $orderPendingNextAction2
2842
+ ];
2843
+ var $nextAction2 = z3.discriminatedUnion("next", [...$nextActionOptions2]).superRefine(checkNextAction2);
2844
+ var CoinbaseNextActionSchema = $nextAction2;
2845
+ var $done2 = obj3({ next: z3.literal("done"), order: FiatStepResponseSchema });
2846
+ var CoinbaseDoneSchema = $done2;
2847
+ var $refused = z3.union([
2848
+ obj3({
2849
+ next: z3.literal("refused"),
2850
+ reason: z3.enum(["NOT_ELIGIBLE", "KYC_UPGRADE_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
2851
+ recovery: z3.enum(["REQUOTE", "NONE"])
2852
+ }),
2853
+ obj3({
2854
+ next: z3.literal("refused"),
2855
+ reason: z3.literal("LIMITS_EXCEEDED"),
2856
+ recovery: z3.literal("REQUOTE"),
2857
+ maxAmount: FiatAmountSchema.nullable()
2858
+ })
2859
+ ]);
2860
+ var CoinbaseRefusedSchema = $refused;
2861
+ var $stepResponse3 = z3.union([z3.discriminatedUnion("next", [...$nextActionOptions2, $done2]), $refused]).superRefine(checkNextAction2);
2862
+ var CoinbaseStepResponseSchema = $stepResponse3;
2863
+ var $orderResponse2 = z3.discriminatedUnion("next", [$done2, $orderPendingNextAction2]);
2864
+ var CoinbaseOrderResponseSchema = $orderResponse2;
2865
+ var CoinbaseResponseSchemaFor = {
2866
+ observe: CoinbaseStepResponseSchema,
2867
+ consent: CoinbaseStepResponseSchema,
2868
+ session: CoinbaseStepResponseSchema,
2869
+ otp: CoinbaseStepResponseSchema,
2870
+ kyc: CoinbaseStepResponseSchema,
2871
+ placeOrder: CoinbaseStepResponseSchema,
2872
+ order: CoinbaseOrderResponseSchema
2873
+ };
2874
+ var faultFields = {
2875
+ reason: z3.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
2876
+ recovery: z3.enum(["RETRY", "REQUOTE", "NONE"])
2877
+ };
2878
+ var $fault2 = obj3(faultFields);
2879
+ var CoinbaseFaultSchema = $fault2;
2880
+ var $errorBody2 = obj3({
2881
+ ...faultFields,
2882
+ errorCode: $nonEmpty2,
2883
+ errorMsg: z3.string(),
2884
+ reqId: z3.string().optional(),
2885
+ retryAfterSeconds: z3.number().int().positive().optional()
2886
+ });
2887
+ var CoinbaseErrorBodySchema = $errorBody2;
2705
2888
  export {
2706
2889
  BlockedReasonSchema,
2707
2890
  BlockedStateSchema,
2891
+ COINBASE_ENDPOINTS,
2892
+ COINBASE_TERMS,
2708
2893
  COUNTRY_NAMES,
2709
2894
  COUNTRY_TO_CURRENCY,
2710
2895
  ClientExecutedDeliverySchema,
2896
+ CoinbaseCheckoutSchema,
2897
+ CoinbaseConsentNextActionSchema,
2898
+ CoinbaseConsentRequestSchema,
2899
+ CoinbaseDoneSchema,
2900
+ CoinbaseErrorBodySchema,
2901
+ CoinbaseFaultSchema,
2902
+ CoinbaseKycNextActionSchema,
2903
+ CoinbaseKycRequestSchema,
2904
+ CoinbaseNextActionSchema,
2905
+ CoinbaseNextRequestSchema,
2906
+ CoinbaseObserveRequestSchema,
2907
+ CoinbaseOrderPendingNextActionSchema,
2908
+ CoinbaseOrderRequestSchema,
2909
+ CoinbaseOrderResponseSchema,
2910
+ CoinbaseOtpNextActionSchema,
2911
+ CoinbaseOtpRequestSchema,
2912
+ CoinbasePayNextActionSchema,
2913
+ CoinbasePlaceOrderNextActionSchema,
2914
+ CoinbasePlaceOrderRequestSchema,
2915
+ CoinbasePriceSchema,
2916
+ CoinbaseReaskSchema,
2917
+ CoinbaseRefusedSchema,
2918
+ CoinbaseRequestContextSchema,
2919
+ CoinbaseRequestSchema,
2920
+ CoinbaseResponseSchemaFor,
2921
+ CoinbaseSessionNextActionSchema,
2922
+ CoinbaseSessionRequestSchema,
2923
+ CoinbaseStepResponseSchema,
2924
+ CoinbaseWaitNextActionSchema,
2711
2925
  ContractViolation,
2712
2926
  CountryCode,
2713
2927
  CryptoAmountSchema,
@@ -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/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.42.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",
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-RGQE53YP.mjs";
16
16
  export {
17
17
  DOCUMENTED_ENDPOINTS,
18
18
  FUN_AUTH_ERROR_CODES,
package/dist/types.d.ts CHANGED
@@ -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
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.42.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
  ],