@fun-xyz/fiat-contract 0.48.0 → 0.49.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.
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.48.0";
2
+ var version = "0.49.0";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -0,0 +1,8 @@
1
+ // src/providers/stripe.ts
2
+ var STRIPE_ENDPOINTS = {
3
+ next: "POST /fiat/next"
4
+ };
5
+
6
+ export {
7
+ STRIPE_ENDPOINTS
8
+ };
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ export * from './providers/moonpay';
16
16
  export * from './providers/moonpay.schemas';
17
17
  export * from './providers/coinbase';
18
18
  export * from './providers/coinbase.schemas';
19
+ export * from './providers/stripe';
20
+ export * from './providers/stripe.schemas';
19
21
  export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
20
22
  export * from './providers/moonpay-guest';
21
23
  export * from './providers/moonpay-guest.schemas';
package/dist/index.js CHANGED
@@ -194,9 +194,45 @@ __export(index_exports, {
194
194
  ReportSpecSchema: () => ReportSpecSchema,
195
195
  STANDARD_KYC_FIELD_IDS: () => STANDARD_KYC_FIELD_IDS,
196
196
  STATE_KEYS: () => STATE_KEYS,
197
+ STRIPE_ENDPOINTS: () => STRIPE_ENDPOINTS,
197
198
  SelectOptionSchema: () => SelectOptionSchema,
198
199
  SessionAuthStateSchema: () => SessionAuthStateSchema,
199
200
  StatusHistoryEntrySchema: () => StatusHistoryEntrySchema,
201
+ StripeAuthorizeNextActionSchema: () => StripeAuthorizeNextActionSchema,
202
+ StripeAuthorizeRequestSchema: () => StripeAuthorizeRequestSchema,
203
+ StripeCheckoutRequestSchema: () => StripeCheckoutRequestSchema,
204
+ StripeCheckoutResponseSchema: () => StripeCheckoutResponseSchema,
205
+ StripeCheckoutSchema: () => StripeCheckoutSchema,
206
+ StripeCheckoutSecretNextActionSchema: () => StripeCheckoutSecretNextActionSchema,
207
+ StripeConsentNextActionSchema: () => StripeConsentNextActionSchema,
208
+ StripeConsentRequestSchema: () => StripeConsentRequestSchema,
209
+ StripeDoneSchema: () => StripeDoneSchema,
210
+ StripeErrorBodySchema: () => StripeErrorBodySchema,
211
+ StripeFaultSchema: () => StripeFaultSchema,
212
+ StripeKycNextActionSchema: () => StripeKycNextActionSchema,
213
+ StripeKycRequestSchema: () => StripeKycRequestSchema,
214
+ StripeLinkAuthTokenSchema: () => StripeLinkAuthTokenSchema,
215
+ StripeNextActionSchema: () => StripeNextActionSchema,
216
+ StripeNextRequestSchema: () => StripeNextRequestSchema,
217
+ StripeObserveRequestSchema: () => StripeObserveRequestSchema,
218
+ StripeOrderPendingNextActionSchema: () => StripeOrderPendingNextActionSchema,
219
+ StripeOrderRequestSchema: () => StripeOrderRequestSchema,
220
+ StripeOrderResponseSchema: () => StripeOrderResponseSchema,
221
+ StripePayNextActionSchema: () => StripePayNextActionSchema,
222
+ StripePaySheetSchema: () => StripePaySheetSchema,
223
+ StripePlaceOrderNextActionSchema: () => StripePlaceOrderNextActionSchema,
224
+ StripePlaceOrderRequestSchema: () => StripePlaceOrderRequestSchema,
225
+ StripePriceSchema: () => StripePriceSchema,
226
+ StripeReaskSchema: () => StripeReaskSchema,
227
+ StripeRefusedSchema: () => StripeRefusedSchema,
228
+ StripeRequestContextSchema: () => StripeRequestContextSchema,
229
+ StripeRequestSchema: () => StripeRequestSchema,
230
+ StripeResponseSchemaFor: () => StripeResponseSchemaFor,
231
+ StripeSessionNextActionSchema: () => StripeSessionNextActionSchema,
232
+ StripeSessionRequestSchema: () => StripeSessionRequestSchema,
233
+ StripeStepResponseSchema: () => StripeStepResponseSchema,
234
+ StripeVerifyIdentityNextActionSchema: () => StripeVerifyIdentityNextActionSchema,
235
+ StripeWaitNextActionSchema: () => StripeWaitNextActionSchema,
200
236
  SurfaceKindSchema: () => SurfaceKindSchema,
201
237
  SurfaceProviderSchema: () => SurfaceProviderSchema,
202
238
  SurfaceSchema: () => SurfaceSchema,
@@ -1195,7 +1231,7 @@ var $routingTableRequest = obj({
1195
1231
  providers: $routingTableProviderInputs.optional(),
1196
1232
  destinationAsset: $destinationAsset.optional(),
1197
1233
  depositAddress: $nonBlank.optional()
1198
- }).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
1234
+ }).refine((request2) => hasUsRegion(request2.country, request2.region), { message: US_REGION_REQUIRED, path: ["region"] });
1199
1235
  var FiatRoutingTableRequestSchema = $routingTableRequest;
1200
1236
  var $routingTableProvider = obj({
1201
1237
  provider: $routingProvider,
@@ -1253,9 +1289,9 @@ var $routingQuoteRequest = import_zod.z.union([
1253
1289
  }),
1254
1290
  obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
1255
1291
  ]).refine(
1256
- (request) => {
1257
- const allowed = request.routingOverrides?.providers;
1258
- const selected = "providers" in request ? request.providers : [request.provider];
1292
+ (request2) => {
1293
+ const allowed = request2.routingOverrides?.providers;
1294
+ const selected = "providers" in request2 ? request2.providers : [request2.provider];
1259
1295
  return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
1260
1296
  },
1261
1297
  { message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
@@ -1397,7 +1433,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $funAuthStep
1397
1433
  var FiatStepResponseSchema = $stepResponse;
1398
1434
 
1399
1435
  // package.json
1400
- var version = "0.48.0";
1436
+ var version = "0.49.0";
1401
1437
 
1402
1438
  // src/table.ts
1403
1439
  var TABLE_VERSION = version;
@@ -3298,14 +3334,14 @@ function walkTable(fn) {
3298
3334
  function assertFixture(id) {
3299
3335
  const meta = fixtureMeta(id);
3300
3336
  const json = loadFixture(id);
3301
- const stepResponse = assertFiatStepResponse(json);
3302
- if (stateKey(stepResponse.state) !== meta.stateKey) {
3337
+ const stepResponse2 = assertFiatStepResponse(json);
3338
+ if (stateKey(stepResponse2.state) !== meta.stateKey) {
3303
3339
  throw new ContractViolation(
3304
- `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse.state)}`
3340
+ `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse2.state)}`
3305
3341
  );
3306
3342
  }
3307
- assertLegalEmission(stepResponse.state, stepResponse.transitions);
3308
- return { meta, stepResponse };
3343
+ assertLegalEmission(stepResponse2.state, stepResponse2.transitions);
3344
+ return { meta, stepResponse: stepResponse2 };
3309
3345
  }
3310
3346
  function assertAllFixtures() {
3311
3347
  return FIXTURES.map((meta) => assertFixture(meta.id));
@@ -3829,31 +3865,258 @@ var $errorBody2 = obj3({
3829
3865
  });
3830
3866
  var CoinbaseErrorBodySchema = $errorBody2;
3831
3867
 
3832
- // src/providers/moonpay-guest.schemas.ts
3868
+ // src/providers/stripe.ts
3869
+ var STRIPE_ENDPOINTS = {
3870
+ next: "POST /fiat/next"
3871
+ };
3872
+
3873
+ // src/providers/stripe.schemas.ts
3833
3874
  var import_zod4 = require("zod");
3834
- var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
3835
3875
  var obj4 = (shape) => import_zod4.z.object(shape).strict();
3836
3876
  var nonEmpty = import_zod4.z.string().refine((value) => value.trim().length > 0, "must not be blank");
3877
+ var hasUniqueIds4 = (ids) => new Set(ids).size === ids.length;
3878
+ var retryAfterMs = import_zod4.z.number().int().positive().max(6e4);
3879
+ var usdAmount = import_zod4.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/, "must be a USD amount in cents").refine((amount) => Number(amount) > 0, "must be positive");
3880
+ var kycValues = import_zod4.z.record(KycFieldIdSchema, import_zod4.z.string());
3881
+ var instant = import_zod4.z.string().datetime({ offset: true });
3882
+ var checkout = obj4({
3883
+ amount: obj4({ currency: import_zod4.z.literal("USD"), amount: usdAmount }),
3884
+ destination: obj4({ asset: nonEmpty, network: nonEmpty }),
3885
+ paymentMethod: import_zod4.z.literal("apple_pay")
3886
+ });
3887
+ var StripeCheckoutSchema = checkout;
3888
+ var contextFields2 = { checkout };
3889
+ var requestContext = obj4(contextFields2);
3890
+ var StripeRequestContextSchema = requestContext;
3891
+ var mintedOrderId = import_zod4.z.string().regex(/^sto_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
3892
+ var heldOrder = { orderId: mintedOrderId.optional() };
3893
+ var observeFields2 = { action: import_zod4.z.literal("observe"), ...heldOrder };
3894
+ var consentFields2 = {
3895
+ action: import_zod4.z.literal("consent"),
3896
+ acceptances: import_zod4.z.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds4(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once"),
3897
+ ...heldOrder
3898
+ };
3899
+ var sessionFields = { action: import_zod4.z.literal("session"), ...heldOrder };
3900
+ var authorizeConsentedFields = {
3901
+ action: import_zod4.z.literal("authorize"),
3902
+ linkAuthIntentId: nonEmpty,
3903
+ outcome: import_zod4.z.literal("Consented"),
3904
+ customerId: nonEmpty,
3905
+ ...heldOrder
3906
+ };
3907
+ var authorizeDeclinedFields = { action: import_zod4.z.literal("authorize"), linkAuthIntentId: nonEmpty, outcome: import_zod4.z.enum(["Denied", "Cancelled"]), ...heldOrder };
3908
+ var correctionRound = import_zod4.z.number().int().nonnegative();
3909
+ var kycFields2 = { action: import_zod4.z.literal("kyc"), correctionRound, values: kycValues, ...heldOrder };
3910
+ var placeOrderFields2 = { action: import_zod4.z.literal("placeOrder"), orderId: mintedOrderId, cryptoPaymentToken: nonEmpty };
3911
+ var checkoutFields = { action: import_zod4.z.literal("checkout"), orderId: mintedOrderId, callbackId: import_zod4.z.string().regex(/^[A-Za-z0-9_-]{1,200}$/) };
3912
+ var orderFields2 = { action: import_zod4.z.literal("order"), orderId: mintedOrderId };
3913
+ var observeRequest = obj4({ ...contextFields2, ...observeFields2 });
3914
+ var consentRequest = obj4({ ...contextFields2, ...consentFields2 });
3915
+ var sessionRequest = obj4({ ...contextFields2, ...sessionFields });
3916
+ var authorizeRequest = import_zod4.z.union([obj4({ ...contextFields2, ...authorizeConsentedFields }), obj4({ ...contextFields2, ...authorizeDeclinedFields })]);
3917
+ var kycRequest = obj4({ ...contextFields2, ...kycFields2 });
3918
+ var placeOrderRequest = obj4({ ...contextFields2, ...placeOrderFields2 });
3919
+ var checkoutRequest = obj4({ ...contextFields2, ...checkoutFields });
3920
+ var orderRequest = obj4({ ...contextFields2, ...orderFields2 });
3921
+ var StripeObserveRequestSchema = observeRequest;
3922
+ var StripeConsentRequestSchema = consentRequest;
3923
+ var StripeSessionRequestSchema = sessionRequest;
3924
+ var StripeAuthorizeRequestSchema = authorizeRequest;
3925
+ var StripeKycRequestSchema = kycRequest;
3926
+ var StripePlaceOrderRequestSchema = placeOrderRequest;
3927
+ var StripeCheckoutRequestSchema = checkoutRequest;
3928
+ var StripeOrderRequestSchema = orderRequest;
3929
+ var request = import_zod4.z.union([observeRequest, consentRequest, sessionRequest, authorizeRequest, kycRequest, placeOrderRequest, checkoutRequest, orderRequest]);
3930
+ var StripeRequestSchema = request;
3931
+ var envelope2 = { provider: import_zod4.z.literal("STRIPE"), geo: FiatGeoSchema, ...contextFields2 };
3932
+ var nextRequest = import_zod4.z.union([
3933
+ obj4({ ...envelope2, ...observeFields2 }),
3934
+ obj4({ ...envelope2, ...consentFields2 }),
3935
+ obj4({ ...envelope2, ...sessionFields }),
3936
+ obj4({ ...envelope2, ...authorizeConsentedFields }),
3937
+ obj4({ ...envelope2, ...authorizeDeclinedFields }),
3938
+ obj4({ ...envelope2, ...kycFields2 }),
3939
+ obj4({ ...envelope2, ...placeOrderFields2 }),
3940
+ obj4({ ...envelope2, ...checkoutFields }),
3941
+ obj4({ ...envelope2, ...orderFields2 })
3942
+ ]);
3943
+ var StripeNextRequestSchema = nextRequest;
3944
+ var price = obj4({ total: FiatAmountSchema, fees: import_zod4.z.array(FeeLineSchema), cryptoAmount: nonEmpty });
3945
+ var StripePriceSchema = price;
3946
+ var paySheet = obj4({
3947
+ destinationCurrency: nonEmpty,
3948
+ destinationNetwork: nonEmpty,
3949
+ walletAddress: nonEmpty,
3950
+ merchantCountryCode: import_zod4.z.literal("US"),
3951
+ currencyCode: import_zod4.z.literal("USD"),
3952
+ amount: usdAmount,
3953
+ label: nonEmpty
3954
+ });
3955
+ var StripePaySheetSchema = paySheet;
3956
+ var linkAuthToken = obj4({ clientSecret: nonEmpty, expiresAt: instant });
3957
+ var StripeLinkAuthTokenSchema = linkAuthToken;
3958
+ var reask = obj4({
3959
+ requirements: import_zod4.z.array(KycFieldIdSchema).min(1).refine(hasUniqueIds4, "requirements must be unique"),
3960
+ reason: import_zod4.z.enum(["REJECTED"]).nullable()
3961
+ });
3962
+ var StripeReaskSchema = reask;
3963
+ var consentShape = obj4({ next: import_zod4.z.literal("consent"), documents: import_zod4.z.array(TermsDocumentSchema).min(1) });
3964
+ var sessionNextAction = obj4({ next: import_zod4.z.literal("session") });
3965
+ var authorizeNextAction = obj4({ next: import_zod4.z.literal("authorize"), linkAuthIntentId: nonEmpty, expiresAt: instant });
3966
+ var kycShape = obj4({
3967
+ next: import_zod4.z.literal("kyc"),
3968
+ round: import_zod4.z.enum(["ACCOUNT", "IDENTITY"]),
3969
+ tier: import_zod4.z.enum(["l0", "l1"]),
3970
+ correctionRound,
3971
+ fields: import_zod4.z.array(FormFieldSchema),
3972
+ heldValues: kycValues,
3973
+ verifiedEmail: nonEmpty.nullable(),
3974
+ linkAuthToken: linkAuthToken.nullable(),
3975
+ fieldErrors: import_zod4.z.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
3976
+ reask: reask.nullable()
3977
+ });
3978
+ var verifyIdentityNextAction = obj4({ next: import_zod4.z.literal("verifyIdentity"), linkAuthToken: linkAuthToken.nullable() });
3979
+ var waitNextAction = obj4({ next: import_zod4.z.literal("wait"), retryAfterMs });
3980
+ var placeOrderNextAction = obj4({
3981
+ next: import_zod4.z.literal("placeOrder"),
3982
+ orderId: mintedOrderId,
3983
+ price,
3984
+ paySheet,
3985
+ linkAuthToken: linkAuthToken.nullable()
3986
+ });
3987
+ var payNextAction = obj4({ next: import_zod4.z.literal("pay"), orderId: mintedOrderId, sessionId: nonEmpty, linkAuthToken: linkAuthToken.nullable() });
3988
+ var checkoutSecretNextAction = obj4({ next: import_zod4.z.literal("checkoutSecret"), clientSecret: nonEmpty });
3989
+ var orderPendingNextAction = obj4({
3990
+ next: import_zod4.z.literal("orderPending"),
3991
+ orderId: mintedOrderId,
3992
+ retryAfterMs,
3993
+ order: FiatStepResponseSchema.nullable()
3994
+ });
3995
+ var checkConsent3 = (nextAction, context2) => {
3996
+ if (!hasUniqueIds4(nextAction.documents.map((document) => document.id))) {
3997
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
3998
+ }
3999
+ };
4000
+ var checkKyc3 = (nextAction, context2) => {
4001
+ const fieldIds = nextAction.fields.map((field) => field.id);
4002
+ if (!hasUniqueIds4(fieldIds)) {
4003
+ context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
4004
+ }
4005
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
4006
+ context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
4007
+ }
4008
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
4009
+ context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
4010
+ }
4011
+ if (nextAction.round === "ACCOUNT" !== (nextAction.verifiedEmail !== null)) {
4012
+ context2.addIssue({ code: "custom", path: ["verifiedEmail"], message: "only the account round carries the verified email" });
4013
+ }
4014
+ };
4015
+ var checkPlaceOrder = (nextAction, context2) => {
4016
+ if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
4017
+ context2.addIssue({ code: "custom", path: ["paySheet", "amount"], message: "the sheet charges the price shown" });
4018
+ }
4019
+ };
4020
+ var StripeConsentNextActionSchema = consentShape.superRefine(checkConsent3);
4021
+ var StripeSessionNextActionSchema = sessionNextAction;
4022
+ var StripeAuthorizeNextActionSchema = authorizeNextAction;
4023
+ var StripeKycNextActionSchema = kycShape.superRefine(checkKyc3);
4024
+ var StripeVerifyIdentityNextActionSchema = verifyIdentityNextAction;
4025
+ var StripeWaitNextActionSchema = waitNextAction;
4026
+ var StripePlaceOrderNextActionSchema = placeOrderNextAction.superRefine(checkPlaceOrder);
4027
+ var StripePayNextActionSchema = payNextAction;
4028
+ var StripeCheckoutSecretNextActionSchema = checkoutSecretNextAction;
4029
+ var StripeOrderPendingNextActionSchema = orderPendingNextAction;
4030
+ var checkNextAction3 = (response, context2) => {
4031
+ if (response.next === "consent") checkConsent3(response, context2);
4032
+ if (response.next === "kyc") checkKyc3(response, context2);
4033
+ if (response.next === "placeOrder") checkPlaceOrder(response, context2);
4034
+ };
4035
+ var nextActionOptions = [
4036
+ consentShape,
4037
+ sessionNextAction,
4038
+ authorizeNextAction,
4039
+ kycShape,
4040
+ verifyIdentityNextAction,
4041
+ waitNextAction,
4042
+ placeOrderNextAction,
4043
+ payNextAction,
4044
+ orderPendingNextAction
4045
+ ];
4046
+ var anyNextAction = import_zod4.z.discriminatedUnion("next", [...nextActionOptions]).superRefine(checkNextAction3);
4047
+ var StripeNextActionSchema = anyNextAction;
4048
+ var done = obj4({ next: import_zod4.z.literal("done"), order: FiatStepResponseSchema });
4049
+ var StripeDoneSchema = done;
4050
+ var refused = import_zod4.z.union([
4051
+ obj4({
4052
+ next: import_zod4.z.literal("refused"),
4053
+ reason: import_zod4.z.enum(["NOT_ELIGIBLE", "KYC_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
4054
+ recovery: import_zod4.z.enum(["REQUOTE", "NONE"])
4055
+ }),
4056
+ obj4({
4057
+ next: import_zod4.z.literal("refused"),
4058
+ reason: import_zod4.z.literal("LIMITS_EXCEEDED"),
4059
+ recovery: import_zod4.z.literal("REQUOTE"),
4060
+ maxAmount: FiatAmountSchema.nullable()
4061
+ })
4062
+ ]);
4063
+ var StripeRefusedSchema = refused;
4064
+ var stepResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next", [...nextActionOptions, done]), refused]).superRefine(checkNextAction3);
4065
+ var StripeStepResponseSchema = stepResponse;
4066
+ var checkoutResponse = import_zod4.z.union([import_zod4.z.discriminatedUnion("next", [...nextActionOptions, done, checkoutSecretNextAction]), refused]).superRefine(checkNextAction3);
4067
+ var StripeCheckoutResponseSchema = checkoutResponse;
4068
+ var orderResponse = import_zod4.z.discriminatedUnion("next", [done, orderPendingNextAction]);
4069
+ var StripeOrderResponseSchema = orderResponse;
4070
+ var StripeResponseSchemaFor = {
4071
+ observe: StripeStepResponseSchema,
4072
+ consent: StripeStepResponseSchema,
4073
+ session: StripeStepResponseSchema,
4074
+ authorize: StripeStepResponseSchema,
4075
+ kyc: StripeStepResponseSchema,
4076
+ placeOrder: StripeStepResponseSchema,
4077
+ checkout: StripeCheckoutResponseSchema,
4078
+ order: StripeOrderResponseSchema
4079
+ };
4080
+ var faultFields2 = {
4081
+ reason: import_zod4.z.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
4082
+ recovery: import_zod4.z.enum(["RETRY", "REQUOTE", "NONE"])
4083
+ };
4084
+ var fault = obj4(faultFields2);
4085
+ var StripeFaultSchema = fault;
4086
+ var errorBody = obj4({
4087
+ ...faultFields2,
4088
+ errorCode: nonEmpty,
4089
+ errorMsg: import_zod4.z.string(),
4090
+ reqId: import_zod4.z.string().optional(),
4091
+ retryAfterSeconds: import_zod4.z.number().int().nonnegative().optional()
4092
+ });
4093
+ var StripeErrorBodySchema = errorBody;
4094
+
4095
+ // src/providers/moonpay-guest.schemas.ts
4096
+ var import_zod5 = require("zod");
4097
+ var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
4098
+ var obj5 = (shape) => import_zod5.z.object(shape).strict();
4099
+ var nonEmpty2 = import_zod5.z.string().refine((value) => value.trim().length > 0, "must not be blank");
3837
4100
  var actions = [
3838
- { action: import_zod4.z.literal("observe") },
3839
- { action: import_zod4.z.literal("session") },
3840
- { action: import_zod4.z.literal("consent"), acceptances: import_zod4.z.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
3841
- { action: import_zod4.z.literal("order"), orderId: nonEmpty, quotedAmount: FiatAmountSchema, transactionId: nonEmpty.optional() },
3842
- { action: import_zod4.z.literal("phone"), phoneNumber: import_zod4.z.string().regex(/^\+[1-9]\d{1,14}$/) },
3843
- { action: import_zod4.z.literal("phone"), resend: nonEmpty },
3844
- { action: import_zod4.z.literal("phoneCode"), verificationRef: nonEmpty, otpCode: import_zod4.z.string().regex(/^\d{6}$/) },
3845
- { action: import_zod4.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
4101
+ { action: import_zod5.z.literal("observe") },
4102
+ { action: import_zod5.z.literal("session") },
4103
+ { action: import_zod5.z.literal("consent"), acceptances: import_zod5.z.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
4104
+ { action: import_zod5.z.literal("order"), orderId: nonEmpty2, quotedAmount: FiatAmountSchema, transactionId: nonEmpty2.optional() },
4105
+ { action: import_zod5.z.literal("phone"), phoneNumber: import_zod5.z.string().regex(/^\+[1-9]\d{1,14}$/) },
4106
+ { action: import_zod5.z.literal("phone"), resend: nonEmpty2 },
4107
+ { action: import_zod5.z.literal("phoneCode"), verificationRef: nonEmpty2, otpCode: import_zod5.z.string().regex(/^\d{6}$/) },
4108
+ { action: import_zod5.z.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
3846
4109
  ];
3847
- var MoonPayGuestObserveRequestSchema = obj4({ ...context, ...actions[0] });
3848
- var MoonPayGuestSessionRequestSchema = obj4({ ...context, ...actions[1] });
3849
- var MoonPayGuestConsentRequestSchema = obj4({ ...context, ...actions[2] });
3850
- var MoonPayGuestOrderRequestSchema = obj4({ ...context, ...actions[3] });
3851
- var MoonPayGuestPhoneNumberRequestSchema = obj4({ ...context, ...actions[4] });
3852
- var MoonPayGuestPhoneResendRequestSchema = obj4({ ...context, ...actions[5] });
3853
- var MoonPayGuestPhoneCodeRequestSchema = obj4({ ...context, ...actions[6] });
3854
- var MoonPayGuestDeclineRequestSchema = obj4({ ...context, ...actions[7] });
3855
- var MoonPayGuestPhoneRequestSchema = import_zod4.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
3856
- var MoonPayGuestRequestSchema = import_zod4.z.union([
4110
+ var MoonPayGuestObserveRequestSchema = obj5({ ...context, ...actions[0] });
4111
+ var MoonPayGuestSessionRequestSchema = obj5({ ...context, ...actions[1] });
4112
+ var MoonPayGuestConsentRequestSchema = obj5({ ...context, ...actions[2] });
4113
+ var MoonPayGuestOrderRequestSchema = obj5({ ...context, ...actions[3] });
4114
+ var MoonPayGuestPhoneNumberRequestSchema = obj5({ ...context, ...actions[4] });
4115
+ var MoonPayGuestPhoneResendRequestSchema = obj5({ ...context, ...actions[5] });
4116
+ var MoonPayGuestPhoneCodeRequestSchema = obj5({ ...context, ...actions[6] });
4117
+ var MoonPayGuestDeclineRequestSchema = obj5({ ...context, ...actions[7] });
4118
+ var MoonPayGuestPhoneRequestSchema = import_zod5.z.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
4119
+ var MoonPayGuestRequestSchema = import_zod5.z.union([
3857
4120
  MoonPayGuestObserveRequestSchema,
3858
4121
  MoonPayGuestSessionRequestSchema,
3859
4122
  MoonPayGuestConsentRequestSchema,
@@ -3863,22 +4126,22 @@ var MoonPayGuestRequestSchema = import_zod4.z.union([
3863
4126
  MoonPayGuestPhoneCodeRequestSchema,
3864
4127
  MoonPayGuestDeclineRequestSchema
3865
4128
  ]);
3866
- var MoonPayGuestNextRequestSchema = import_zod4.z.union([
3867
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[0] }),
3868
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[1] }),
3869
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[2] }),
3870
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[3] }),
3871
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[4] }),
3872
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[5] }),
3873
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[6] }),
3874
- obj4({ provider: import_zod4.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[7] })
4129
+ var MoonPayGuestNextRequestSchema = import_zod5.z.union([
4130
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[0] }),
4131
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[1] }),
4132
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[2] }),
4133
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[3] }),
4134
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[4] }),
4135
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[5] }),
4136
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[6] }),
4137
+ obj5({ provider: import_zod5.z.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[7] })
3875
4138
  ]);
3876
- var MoonPayGuestStepResponseSchema = import_zod4.z.union([
4139
+ var MoonPayGuestStepResponseSchema = import_zod5.z.union([
3877
4140
  MoonPayConsentNextActionSchema,
3878
4141
  MoonPaySessionNextActionSchema,
3879
4142
  MoonPayPhoneNextActionSchema,
3880
4143
  MoonPayPhoneCodeNextActionSchema,
3881
4144
  MoonPayPayNextActionSchema,
3882
- obj4({ next: import_zod4.z.literal("refused"), reason: import_zod4.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod4.z.enum(["REQUOTE", "NONE"]) })
4145
+ obj5({ next: import_zod5.z.literal("refused"), reason: import_zod5.z.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: import_zod5.z.enum(["REQUOTE", "NONE"]) })
3883
4146
  ]);
3884
- var MoonPayGuestResponseSchema = import_zod4.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
4147
+ var MoonPayGuestResponseSchema = import_zod5.z.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
package/dist/index.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ import {
2
+ ROUTING_ENDPOINTS
3
+ } from "./chunk-2NZSOZHV.mjs";
1
4
  import "./chunk-WBQAMGXK.mjs";
2
5
  import {
3
6
  DOCUMENTED_ENDPOINTS,
@@ -13,7 +16,7 @@ import {
13
16
  tableEntry,
14
17
  unofferedEndpoints,
15
18
  unreachableStates
16
- } from "./chunk-4ZHY4P3K.mjs";
19
+ } from "./chunk-6NZFTT7Q.mjs";
17
20
  import {
18
21
  MOONPAY_ENDPOINTS
19
22
  } from "./chunk-TIEGTTFY.mjs";
@@ -22,6 +25,9 @@ import {
22
25
  COINBASE_ENDPOINTS,
23
26
  COINBASE_TERMS
24
27
  } from "./chunk-SFR4SCDU.mjs";
28
+ import {
29
+ STRIPE_ENDPOINTS
30
+ } from "./chunk-KLAXY6H7.mjs";
25
31
  import {
26
32
  FIAT_TERMS_ENDPOINT,
27
33
  FUN_KYC_CONSENT_DOCUMENTS,
@@ -29,9 +35,6 @@ import {
29
35
  PROVIDER_KYC_DOCUMENTS,
30
36
  PUBLISHED_TERMS_DOCUMENTS
31
37
  } from "./chunk-TIQALG7X.mjs";
32
- import {
33
- ROUTING_ENDPOINTS
34
- } from "./chunk-2NZSOZHV.mjs";
35
38
 
36
39
  // src/codes.ts
37
40
  var US_STATE_CODES = [
@@ -994,7 +997,7 @@ var $routingTableRequest = obj({
994
997
  providers: $routingTableProviderInputs.optional(),
995
998
  destinationAsset: $destinationAsset.optional(),
996
999
  depositAddress: $nonBlank.optional()
997
- }).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
1000
+ }).refine((request2) => hasUsRegion(request2.country, request2.region), { message: US_REGION_REQUIRED, path: ["region"] });
998
1001
  var FiatRoutingTableRequestSchema = $routingTableRequest;
999
1002
  var $routingTableProvider = obj({
1000
1003
  provider: $routingProvider,
@@ -1052,9 +1055,9 @@ var $routingQuoteRequest = z.union([
1052
1055
  }),
1053
1056
  obj({ ...$routingQuoteTermsShape, provider: $routingProvider })
1054
1057
  ]).refine(
1055
- (request) => {
1056
- const allowed = request.routingOverrides?.providers;
1057
- const selected = "providers" in request ? request.providers : [request.provider];
1058
+ (request2) => {
1059
+ const allowed = request2.routingOverrides?.providers;
1060
+ const selected = "providers" in request2 ? request2.providers : [request2.provider];
1058
1061
  return allowed === void 0 || selected.every((provider) => allowed.includes(provider));
1059
1062
  },
1060
1063
  { message: "requested providers must be allowed by routingOverrides", path: ["routingOverrides"] }
@@ -2505,14 +2508,14 @@ function walkTable(fn) {
2505
2508
  function assertFixture(id) {
2506
2509
  const meta = fixtureMeta(id);
2507
2510
  const json = loadFixture(id);
2508
- const stepResponse = assertFiatStepResponse(json);
2509
- if (stateKey(stepResponse.state) !== meta.stateKey) {
2511
+ const stepResponse2 = assertFiatStepResponse(json);
2512
+ if (stateKey(stepResponse2.state) !== meta.stateKey) {
2510
2513
  throw new ContractViolation(
2511
- `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse.state)}`
2514
+ `fixture ${id}: manifest says ${meta.stateKey}, step response carries ${stateKey(stepResponse2.state)}`
2512
2515
  );
2513
2516
  }
2514
- assertLegalEmission(stepResponse.state, stepResponse.transitions);
2515
- return { meta, stepResponse };
2517
+ assertLegalEmission(stepResponse2.state, stepResponse2.transitions);
2518
+ return { meta, stepResponse: stepResponse2 };
2516
2519
  }
2517
2520
  function assertAllFixtures() {
2518
2521
  return FIXTURES.map((meta) => assertFixture(meta.id));
@@ -2946,31 +2949,253 @@ var $errorBody2 = obj3({
2946
2949
  });
2947
2950
  var CoinbaseErrorBodySchema = $errorBody2;
2948
2951
 
2949
- // src/providers/moonpay-guest.schemas.ts
2952
+ // src/providers/stripe.schemas.ts
2950
2953
  import { z as z4 } from "zod";
2951
- var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
2952
2954
  var obj4 = (shape) => z4.object(shape).strict();
2953
2955
  var nonEmpty = z4.string().refine((value) => value.trim().length > 0, "must not be blank");
2956
+ var hasUniqueIds4 = (ids) => new Set(ids).size === ids.length;
2957
+ var retryAfterMs = z4.number().int().positive().max(6e4);
2958
+ var usdAmount = z4.string().regex(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/, "must be a USD amount in cents").refine((amount) => Number(amount) > 0, "must be positive");
2959
+ var kycValues = z4.record(KycFieldIdSchema, z4.string());
2960
+ var instant = z4.string().datetime({ offset: true });
2961
+ var checkout = obj4({
2962
+ amount: obj4({ currency: z4.literal("USD"), amount: usdAmount }),
2963
+ destination: obj4({ asset: nonEmpty, network: nonEmpty }),
2964
+ paymentMethod: z4.literal("apple_pay")
2965
+ });
2966
+ var StripeCheckoutSchema = checkout;
2967
+ var contextFields2 = { checkout };
2968
+ var requestContext = obj4(contextFields2);
2969
+ var StripeRequestContextSchema = requestContext;
2970
+ var mintedOrderId = z4.string().regex(/^sto_[A-Za-z0-9_-]{22}$/, "must be an order id a placeOrder answer minted");
2971
+ var heldOrder = { orderId: mintedOrderId.optional() };
2972
+ var observeFields2 = { action: z4.literal("observe"), ...heldOrder };
2973
+ var consentFields2 = {
2974
+ action: z4.literal("consent"),
2975
+ acceptances: z4.array(TermsDocumentAcceptanceSchema).min(1).refine((acceptances) => hasUniqueIds4(acceptances.map((acceptance) => acceptance.documentId)), "each document is accepted once"),
2976
+ ...heldOrder
2977
+ };
2978
+ var sessionFields = { action: z4.literal("session"), ...heldOrder };
2979
+ var authorizeConsentedFields = {
2980
+ action: z4.literal("authorize"),
2981
+ linkAuthIntentId: nonEmpty,
2982
+ outcome: z4.literal("Consented"),
2983
+ customerId: nonEmpty,
2984
+ ...heldOrder
2985
+ };
2986
+ var authorizeDeclinedFields = { action: z4.literal("authorize"), linkAuthIntentId: nonEmpty, outcome: z4.enum(["Denied", "Cancelled"]), ...heldOrder };
2987
+ var correctionRound = z4.number().int().nonnegative();
2988
+ var kycFields2 = { action: z4.literal("kyc"), correctionRound, values: kycValues, ...heldOrder };
2989
+ var placeOrderFields2 = { action: z4.literal("placeOrder"), orderId: mintedOrderId, cryptoPaymentToken: nonEmpty };
2990
+ var checkoutFields = { action: z4.literal("checkout"), orderId: mintedOrderId, callbackId: z4.string().regex(/^[A-Za-z0-9_-]{1,200}$/) };
2991
+ var orderFields2 = { action: z4.literal("order"), orderId: mintedOrderId };
2992
+ var observeRequest = obj4({ ...contextFields2, ...observeFields2 });
2993
+ var consentRequest = obj4({ ...contextFields2, ...consentFields2 });
2994
+ var sessionRequest = obj4({ ...contextFields2, ...sessionFields });
2995
+ var authorizeRequest = z4.union([obj4({ ...contextFields2, ...authorizeConsentedFields }), obj4({ ...contextFields2, ...authorizeDeclinedFields })]);
2996
+ var kycRequest = obj4({ ...contextFields2, ...kycFields2 });
2997
+ var placeOrderRequest = obj4({ ...contextFields2, ...placeOrderFields2 });
2998
+ var checkoutRequest = obj4({ ...contextFields2, ...checkoutFields });
2999
+ var orderRequest = obj4({ ...contextFields2, ...orderFields2 });
3000
+ var StripeObserveRequestSchema = observeRequest;
3001
+ var StripeConsentRequestSchema = consentRequest;
3002
+ var StripeSessionRequestSchema = sessionRequest;
3003
+ var StripeAuthorizeRequestSchema = authorizeRequest;
3004
+ var StripeKycRequestSchema = kycRequest;
3005
+ var StripePlaceOrderRequestSchema = placeOrderRequest;
3006
+ var StripeCheckoutRequestSchema = checkoutRequest;
3007
+ var StripeOrderRequestSchema = orderRequest;
3008
+ var request = z4.union([observeRequest, consentRequest, sessionRequest, authorizeRequest, kycRequest, placeOrderRequest, checkoutRequest, orderRequest]);
3009
+ var StripeRequestSchema = request;
3010
+ var envelope2 = { provider: z4.literal("STRIPE"), geo: FiatGeoSchema, ...contextFields2 };
3011
+ var nextRequest = z4.union([
3012
+ obj4({ ...envelope2, ...observeFields2 }),
3013
+ obj4({ ...envelope2, ...consentFields2 }),
3014
+ obj4({ ...envelope2, ...sessionFields }),
3015
+ obj4({ ...envelope2, ...authorizeConsentedFields }),
3016
+ obj4({ ...envelope2, ...authorizeDeclinedFields }),
3017
+ obj4({ ...envelope2, ...kycFields2 }),
3018
+ obj4({ ...envelope2, ...placeOrderFields2 }),
3019
+ obj4({ ...envelope2, ...checkoutFields }),
3020
+ obj4({ ...envelope2, ...orderFields2 })
3021
+ ]);
3022
+ var StripeNextRequestSchema = nextRequest;
3023
+ var price = obj4({ total: FiatAmountSchema, fees: z4.array(FeeLineSchema), cryptoAmount: nonEmpty });
3024
+ var StripePriceSchema = price;
3025
+ var paySheet = obj4({
3026
+ destinationCurrency: nonEmpty,
3027
+ destinationNetwork: nonEmpty,
3028
+ walletAddress: nonEmpty,
3029
+ merchantCountryCode: z4.literal("US"),
3030
+ currencyCode: z4.literal("USD"),
3031
+ amount: usdAmount,
3032
+ label: nonEmpty
3033
+ });
3034
+ var StripePaySheetSchema = paySheet;
3035
+ var linkAuthToken = obj4({ clientSecret: nonEmpty, expiresAt: instant });
3036
+ var StripeLinkAuthTokenSchema = linkAuthToken;
3037
+ var reask = obj4({
3038
+ requirements: z4.array(KycFieldIdSchema).min(1).refine(hasUniqueIds4, "requirements must be unique"),
3039
+ reason: z4.enum(["REJECTED"]).nullable()
3040
+ });
3041
+ var StripeReaskSchema = reask;
3042
+ var consentShape = obj4({ next: z4.literal("consent"), documents: z4.array(TermsDocumentSchema).min(1) });
3043
+ var sessionNextAction = obj4({ next: z4.literal("session") });
3044
+ var authorizeNextAction = obj4({ next: z4.literal("authorize"), linkAuthIntentId: nonEmpty, expiresAt: instant });
3045
+ var kycShape = obj4({
3046
+ next: z4.literal("kyc"),
3047
+ round: z4.enum(["ACCOUNT", "IDENTITY"]),
3048
+ tier: z4.enum(["l0", "l1"]),
3049
+ correctionRound,
3050
+ fields: z4.array(FormFieldSchema),
3051
+ heldValues: kycValues,
3052
+ verifiedEmail: nonEmpty.nullable(),
3053
+ linkAuthToken: linkAuthToken.nullable(),
3054
+ fieldErrors: z4.array(obj4({ fieldId: nonEmpty, message: nonEmpty })).min(1).optional(),
3055
+ reask: reask.nullable()
3056
+ });
3057
+ var verifyIdentityNextAction = obj4({ next: z4.literal("verifyIdentity"), linkAuthToken: linkAuthToken.nullable() });
3058
+ var waitNextAction = obj4({ next: z4.literal("wait"), retryAfterMs });
3059
+ var placeOrderNextAction = obj4({
3060
+ next: z4.literal("placeOrder"),
3061
+ orderId: mintedOrderId,
3062
+ price,
3063
+ paySheet,
3064
+ linkAuthToken: linkAuthToken.nullable()
3065
+ });
3066
+ var payNextAction = obj4({ next: z4.literal("pay"), orderId: mintedOrderId, sessionId: nonEmpty, linkAuthToken: linkAuthToken.nullable() });
3067
+ var checkoutSecretNextAction = obj4({ next: z4.literal("checkoutSecret"), clientSecret: nonEmpty });
3068
+ var orderPendingNextAction = obj4({
3069
+ next: z4.literal("orderPending"),
3070
+ orderId: mintedOrderId,
3071
+ retryAfterMs,
3072
+ order: FiatStepResponseSchema.nullable()
3073
+ });
3074
+ var checkConsent3 = (nextAction, context2) => {
3075
+ if (!hasUniqueIds4(nextAction.documents.map((document) => document.id))) {
3076
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
3077
+ }
3078
+ };
3079
+ var checkKyc3 = (nextAction, context2) => {
3080
+ const fieldIds = nextAction.fields.map((field) => field.id);
3081
+ if (!hasUniqueIds4(fieldIds)) {
3082
+ context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
3083
+ }
3084
+ if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
3085
+ context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
3086
+ }
3087
+ if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
3088
+ context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
3089
+ }
3090
+ if (nextAction.round === "ACCOUNT" !== (nextAction.verifiedEmail !== null)) {
3091
+ context2.addIssue({ code: "custom", path: ["verifiedEmail"], message: "only the account round carries the verified email" });
3092
+ }
3093
+ };
3094
+ var checkPlaceOrder = (nextAction, context2) => {
3095
+ if (nextAction.paySheet.amount !== nextAction.price.total.amount) {
3096
+ context2.addIssue({ code: "custom", path: ["paySheet", "amount"], message: "the sheet charges the price shown" });
3097
+ }
3098
+ };
3099
+ var StripeConsentNextActionSchema = consentShape.superRefine(checkConsent3);
3100
+ var StripeSessionNextActionSchema = sessionNextAction;
3101
+ var StripeAuthorizeNextActionSchema = authorizeNextAction;
3102
+ var StripeKycNextActionSchema = kycShape.superRefine(checkKyc3);
3103
+ var StripeVerifyIdentityNextActionSchema = verifyIdentityNextAction;
3104
+ var StripeWaitNextActionSchema = waitNextAction;
3105
+ var StripePlaceOrderNextActionSchema = placeOrderNextAction.superRefine(checkPlaceOrder);
3106
+ var StripePayNextActionSchema = payNextAction;
3107
+ var StripeCheckoutSecretNextActionSchema = checkoutSecretNextAction;
3108
+ var StripeOrderPendingNextActionSchema = orderPendingNextAction;
3109
+ var checkNextAction3 = (response, context2) => {
3110
+ if (response.next === "consent") checkConsent3(response, context2);
3111
+ if (response.next === "kyc") checkKyc3(response, context2);
3112
+ if (response.next === "placeOrder") checkPlaceOrder(response, context2);
3113
+ };
3114
+ var nextActionOptions = [
3115
+ consentShape,
3116
+ sessionNextAction,
3117
+ authorizeNextAction,
3118
+ kycShape,
3119
+ verifyIdentityNextAction,
3120
+ waitNextAction,
3121
+ placeOrderNextAction,
3122
+ payNextAction,
3123
+ orderPendingNextAction
3124
+ ];
3125
+ var anyNextAction = z4.discriminatedUnion("next", [...nextActionOptions]).superRefine(checkNextAction3);
3126
+ var StripeNextActionSchema = anyNextAction;
3127
+ var done = obj4({ next: z4.literal("done"), order: FiatStepResponseSchema });
3128
+ var StripeDoneSchema = done;
3129
+ var refused = z4.union([
3130
+ obj4({
3131
+ next: z4.literal("refused"),
3132
+ reason: z4.enum(["NOT_ELIGIBLE", "KYC_REJECTED", "FINAL_REJECTION", "TOTAL_MISMATCH"]),
3133
+ recovery: z4.enum(["REQUOTE", "NONE"])
3134
+ }),
3135
+ obj4({
3136
+ next: z4.literal("refused"),
3137
+ reason: z4.literal("LIMITS_EXCEEDED"),
3138
+ recovery: z4.literal("REQUOTE"),
3139
+ maxAmount: FiatAmountSchema.nullable()
3140
+ })
3141
+ ]);
3142
+ var StripeRefusedSchema = refused;
3143
+ var stepResponse = z4.union([z4.discriminatedUnion("next", [...nextActionOptions, done]), refused]).superRefine(checkNextAction3);
3144
+ var StripeStepResponseSchema = stepResponse;
3145
+ var checkoutResponse = z4.union([z4.discriminatedUnion("next", [...nextActionOptions, done, checkoutSecretNextAction]), refused]).superRefine(checkNextAction3);
3146
+ var StripeCheckoutResponseSchema = checkoutResponse;
3147
+ var orderResponse = z4.discriminatedUnion("next", [done, orderPendingNextAction]);
3148
+ var StripeOrderResponseSchema = orderResponse;
3149
+ var StripeResponseSchemaFor = {
3150
+ observe: StripeStepResponseSchema,
3151
+ consent: StripeStepResponseSchema,
3152
+ session: StripeStepResponseSchema,
3153
+ authorize: StripeStepResponseSchema,
3154
+ kyc: StripeStepResponseSchema,
3155
+ placeOrder: StripeStepResponseSchema,
3156
+ checkout: StripeCheckoutResponseSchema,
3157
+ order: StripeOrderResponseSchema
3158
+ };
3159
+ var faultFields2 = {
3160
+ reason: z4.enum(["SESSION_BUDGET_SPENT", "RATE_LIMITED", "PROVIDER_UNAVAILABLE", "KYC_PROVIDER_UNAVAILABLE", "SERVICE_UNAVAILABLE", "INVALID_REQUEST"]),
3161
+ recovery: z4.enum(["RETRY", "REQUOTE", "NONE"])
3162
+ };
3163
+ var fault = obj4(faultFields2);
3164
+ var StripeFaultSchema = fault;
3165
+ var errorBody = obj4({
3166
+ ...faultFields2,
3167
+ errorCode: nonEmpty,
3168
+ errorMsg: z4.string(),
3169
+ reqId: z4.string().optional(),
3170
+ retryAfterSeconds: z4.number().int().nonnegative().optional()
3171
+ });
3172
+ var StripeErrorBodySchema = errorBody;
3173
+
3174
+ // src/providers/moonpay-guest.schemas.ts
3175
+ import { z as z5 } from "zod";
3176
+ var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
3177
+ var obj5 = (shape) => z5.object(shape).strict();
3178
+ var nonEmpty2 = z5.string().refine((value) => value.trim().length > 0, "must not be blank");
2954
3179
  var actions = [
2955
- { action: z4.literal("observe") },
2956
- { action: z4.literal("session") },
2957
- { action: z4.literal("consent"), acceptances: z4.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
2958
- { action: z4.literal("order"), orderId: nonEmpty, quotedAmount: FiatAmountSchema, transactionId: nonEmpty.optional() },
2959
- { action: z4.literal("phone"), phoneNumber: z4.string().regex(/^\+[1-9]\d{1,14}$/) },
2960
- { action: z4.literal("phone"), resend: nonEmpty },
2961
- { action: z4.literal("phoneCode"), verificationRef: nonEmpty, otpCode: z4.string().regex(/^\d{6}$/) },
2962
- { action: z4.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
3180
+ { action: z5.literal("observe") },
3181
+ { action: z5.literal("session") },
3182
+ { action: z5.literal("consent"), acceptances: z5.array(TermsDocumentAcceptanceSchema).min(1).refine((values) => new Set(values.map((v) => v.documentId)).size === values.length, "each document is accepted once") },
3183
+ { action: z5.literal("order"), orderId: nonEmpty2, quotedAmount: FiatAmountSchema, transactionId: nonEmpty2.optional() },
3184
+ { action: z5.literal("phone"), phoneNumber: z5.string().regex(/^\+[1-9]\d{1,14}$/) },
3185
+ { action: z5.literal("phone"), resend: nonEmpty2 },
3186
+ { action: z5.literal("phoneCode"), verificationRef: nonEmpty2, otpCode: z5.string().regex(/^\d{6}$/) },
3187
+ { action: z5.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
2963
3188
  ];
2964
- var MoonPayGuestObserveRequestSchema = obj4({ ...context, ...actions[0] });
2965
- var MoonPayGuestSessionRequestSchema = obj4({ ...context, ...actions[1] });
2966
- var MoonPayGuestConsentRequestSchema = obj4({ ...context, ...actions[2] });
2967
- var MoonPayGuestOrderRequestSchema = obj4({ ...context, ...actions[3] });
2968
- var MoonPayGuestPhoneNumberRequestSchema = obj4({ ...context, ...actions[4] });
2969
- var MoonPayGuestPhoneResendRequestSchema = obj4({ ...context, ...actions[5] });
2970
- var MoonPayGuestPhoneCodeRequestSchema = obj4({ ...context, ...actions[6] });
2971
- var MoonPayGuestDeclineRequestSchema = obj4({ ...context, ...actions[7] });
2972
- var MoonPayGuestPhoneRequestSchema = z4.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
2973
- var MoonPayGuestRequestSchema = z4.union([
3189
+ var MoonPayGuestObserveRequestSchema = obj5({ ...context, ...actions[0] });
3190
+ var MoonPayGuestSessionRequestSchema = obj5({ ...context, ...actions[1] });
3191
+ var MoonPayGuestConsentRequestSchema = obj5({ ...context, ...actions[2] });
3192
+ var MoonPayGuestOrderRequestSchema = obj5({ ...context, ...actions[3] });
3193
+ var MoonPayGuestPhoneNumberRequestSchema = obj5({ ...context, ...actions[4] });
3194
+ var MoonPayGuestPhoneResendRequestSchema = obj5({ ...context, ...actions[5] });
3195
+ var MoonPayGuestPhoneCodeRequestSchema = obj5({ ...context, ...actions[6] });
3196
+ var MoonPayGuestDeclineRequestSchema = obj5({ ...context, ...actions[7] });
3197
+ var MoonPayGuestPhoneRequestSchema = z5.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
3198
+ var MoonPayGuestRequestSchema = z5.union([
2974
3199
  MoonPayGuestObserveRequestSchema,
2975
3200
  MoonPayGuestSessionRequestSchema,
2976
3201
  MoonPayGuestConsentRequestSchema,
@@ -2980,25 +3205,25 @@ var MoonPayGuestRequestSchema = z4.union([
2980
3205
  MoonPayGuestPhoneCodeRequestSchema,
2981
3206
  MoonPayGuestDeclineRequestSchema
2982
3207
  ]);
2983
- var MoonPayGuestNextRequestSchema = z4.union([
2984
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[0] }),
2985
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[1] }),
2986
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[2] }),
2987
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[3] }),
2988
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[4] }),
2989
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[5] }),
2990
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[6] }),
2991
- obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[7] })
3208
+ var MoonPayGuestNextRequestSchema = z5.union([
3209
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[0] }),
3210
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[1] }),
3211
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[2] }),
3212
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[3] }),
3213
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[4] }),
3214
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[5] }),
3215
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[6] }),
3216
+ obj5({ provider: z5.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty2.optional(), ...context, ...actions[7] })
2992
3217
  ]);
2993
- var MoonPayGuestStepResponseSchema = z4.union([
3218
+ var MoonPayGuestStepResponseSchema = z5.union([
2994
3219
  MoonPayConsentNextActionSchema,
2995
3220
  MoonPaySessionNextActionSchema,
2996
3221
  MoonPayPhoneNextActionSchema,
2997
3222
  MoonPayPhoneCodeNextActionSchema,
2998
3223
  MoonPayPayNextActionSchema,
2999
- obj4({ next: z4.literal("refused"), reason: z4.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z4.enum(["REQUOTE", "NONE"]) })
3224
+ obj5({ next: z5.literal("refused"), reason: z5.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z5.enum(["REQUOTE", "NONE"]) })
3000
3225
  ]);
3001
- var MoonPayGuestResponseSchema = z4.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
3226
+ var MoonPayGuestResponseSchema = z5.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
3002
3227
  export {
3003
3228
  BlockedReasonSchema,
3004
3229
  BlockedStateSchema,
@@ -3174,9 +3399,45 @@ export {
3174
3399
  ReportSpecSchema,
3175
3400
  STANDARD_KYC_FIELD_IDS,
3176
3401
  STATE_KEYS,
3402
+ STRIPE_ENDPOINTS,
3177
3403
  SelectOptionSchema,
3178
3404
  SessionAuthStateSchema,
3179
3405
  StatusHistoryEntrySchema,
3406
+ StripeAuthorizeNextActionSchema,
3407
+ StripeAuthorizeRequestSchema,
3408
+ StripeCheckoutRequestSchema,
3409
+ StripeCheckoutResponseSchema,
3410
+ StripeCheckoutSchema,
3411
+ StripeCheckoutSecretNextActionSchema,
3412
+ StripeConsentNextActionSchema,
3413
+ StripeConsentRequestSchema,
3414
+ StripeDoneSchema,
3415
+ StripeErrorBodySchema,
3416
+ StripeFaultSchema,
3417
+ StripeKycNextActionSchema,
3418
+ StripeKycRequestSchema,
3419
+ StripeLinkAuthTokenSchema,
3420
+ StripeNextActionSchema,
3421
+ StripeNextRequestSchema,
3422
+ StripeObserveRequestSchema,
3423
+ StripeOrderPendingNextActionSchema,
3424
+ StripeOrderRequestSchema,
3425
+ StripeOrderResponseSchema,
3426
+ StripePayNextActionSchema,
3427
+ StripePaySheetSchema,
3428
+ StripePlaceOrderNextActionSchema,
3429
+ StripePlaceOrderRequestSchema,
3430
+ StripePriceSchema,
3431
+ StripeReaskSchema,
3432
+ StripeRefusedSchema,
3433
+ StripeRequestContextSchema,
3434
+ StripeRequestSchema,
3435
+ StripeResponseSchemaFor,
3436
+ StripeSessionNextActionSchema,
3437
+ StripeSessionRequestSchema,
3438
+ StripeStepResponseSchema,
3439
+ StripeVerifyIdentityNextActionSchema,
3440
+ StripeWaitNextActionSchema,
3180
3441
  SurfaceKindSchema,
3181
3442
  SurfaceProviderSchema,
3182
3443
  SurfaceSchema,
@@ -0,0 +1,283 @@
1
+ /**
2
+ * The Stripe 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` and `verifyIdentity` have no request: send `observe` after them. `orderPending` is
6
+ * answered by `order`. Identity, the verified email and the deposit wallet come from the verified partner assertion,
7
+ * never from a request body.
8
+ *
9
+ * A retry sends the same request and gets the current response. A fault is a 4xx/5xx whose body is
10
+ * `StripeErrorBody`; anything the buyer can act on is a 200.
11
+ *
12
+ * Zero runtime dependencies, so production React Native code can import it. The zod schemas are in
13
+ * `./stripe.schemas`, exported from the package root only.
14
+ */
15
+ import type { FiatTermsRequest, TermsDocument } from '../terms';
16
+ import type { FeeLine, FiatAmount, FiatGeo, FiatStepResponse, FormField, KycFieldId } from '../types';
17
+ export declare const STRIPE_ENDPOINTS: {
18
+ readonly next: "POST /fiat/next";
19
+ };
20
+ /**
21
+ * The checkout terms, sent on every request. No routing quote: the backend mints the order id on `placeOrder`. After
22
+ * `placeOrder`, `checkout` and `order` read the order as it was placed and ignore this copy, and a `placeOrder`
23
+ * retried under the same `orderId` places nothing new.
24
+ */
25
+ export interface StripeCheckout {
26
+ /** Stripe serves USD only. */
27
+ amount: FiatAmount & {
28
+ currency: 'USD';
29
+ };
30
+ /** The asset and its network, as the routing table or `/fiat/quote` named them. */
31
+ destination: {
32
+ asset: string;
33
+ network: string;
34
+ };
35
+ paymentMethod: 'apple_pay';
36
+ }
37
+ export type StripeRequestContext = {
38
+ checkout: StripeCheckout;
39
+ };
40
+ /**
41
+ * The last id a `placeOrder` answer minted, on every step request once the client holds one: a step-up after
42
+ * `placeOrder`, and a reopened app, reach that order instead of minting another.
43
+ */
44
+ export type StripeHeldOrder = {
45
+ orderId?: string;
46
+ };
47
+ /** No next action of its own: the answer is the current next action. Writes nothing. */
48
+ export type StripeObserveRequest = {
49
+ action: 'observe';
50
+ } & StripeHeldOrder;
51
+ /** Fun's KYC consent, before the first `kyc` round, if the buyer has not accepted it. */
52
+ export type StripeConsentNextAction = {
53
+ next: 'consent';
54
+ documents: TermsDocument[];
55
+ };
56
+ /** The `POST /fiat/terms` items, recorded under the same rules. */
57
+ export type StripeConsentRequest = {
58
+ action: 'consent';
59
+ acceptances: FiatTermsRequest['acceptances'];
60
+ } & StripeHeldOrder;
61
+ /** Send `session`. The backend asks Stripe for a Link sign-in for the assertion's verified email. */
62
+ export type StripeSessionNextAction = {
63
+ next: 'session';
64
+ };
65
+ export type StripeSessionRequest = {
66
+ action: 'session';
67
+ } & StripeHeldOrder;
68
+ /** Run the SDK's `authorize(linkAuthIntentId)` before `expiresAt` (ISO-8601), then send `authorize` with its outcome. */
69
+ export type StripeAuthorizeNextAction = {
70
+ next: 'authorize';
71
+ linkAuthIntentId: string;
72
+ expiresAt: string;
73
+ };
74
+ /** The SDK's outcome. `Consented` carries the customer the SDK names; the other outcomes carry none. */
75
+ export type StripeAuthorizeRequest = ({
76
+ action: 'authorize';
77
+ linkAuthIntentId: string;
78
+ outcome: 'Consented';
79
+ customerId: string;
80
+ } | {
81
+ action: 'authorize';
82
+ linkAuthIntentId: string;
83
+ outcome: 'Denied' | 'Cancelled';
84
+ }) & StripeHeldOrder;
85
+ /** Signs the device in to Link without a code. Give `clientSecret` to the SDK before `expiresAt` (ISO-8601). */
86
+ export type StripeLinkAuthToken = {
87
+ clientSecret: string;
88
+ expiresAt: string;
89
+ };
90
+ /** A reason on one field of a `kyc` next action. `fieldId` names a field in that next action. */
91
+ export interface StripeFieldError {
92
+ fieldId: string;
93
+ message: string;
94
+ }
95
+ /** Why a re-ask asks again. Treat an unknown code like `null`: adding a code is a minor contract change. */
96
+ export type StripeReaskReason = 'REJECTED';
97
+ /** Fields of the `kyc` form the buyer gave before that Stripe asks for again. `requirements` is never empty. */
98
+ export type StripeReask = {
99
+ requirements: KycFieldId[];
100
+ reason: StripeReaskReason | null;
101
+ };
102
+ /**
103
+ * Show the shared form, prefilled with `heldValues`. `ACCOUNT`: call `registerLinkUser` with the values and
104
+ * `verifiedEmail`. `IDENTITY`: sign in with `linkAuthToken`, then call `attachKycInfo` with the values. Then send `kyc`
105
+ * with `correctionRound`, which names this form: how many `l1` forms Stripe was handed before it. `linkAuthToken` is
106
+ * `null` when the backend could not mint one: the device pushes under the Link session `authorize` left it.
107
+ */
108
+ export type StripeKycNextAction = {
109
+ next: 'kyc';
110
+ round: 'ACCOUNT' | 'IDENTITY';
111
+ tier: 'l0' | 'l1';
112
+ correctionRound: number;
113
+ fields: FormField[];
114
+ heldValues: Partial<Record<KycFieldId, string>>;
115
+ verifiedEmail: string | null;
116
+ linkAuthToken: StripeLinkAuthToken | null;
117
+ fieldErrors?: StripeFieldError[];
118
+ reask: StripeReask | null;
119
+ };
120
+ /**
121
+ * `values` is keyed by the ids of the next action's fields: the values the device gave Stripe. `correctionRound` is the
122
+ * next action's, unchanged. A form that is no longer current writes nothing and answers the current next action, so a
123
+ * resent form counts once.
124
+ */
125
+ export type StripeKycRequest = {
126
+ action: 'kyc';
127
+ correctionRound: number;
128
+ values: Partial<Record<KycFieldId, string>>;
129
+ } & StripeHeldOrder;
130
+ /** Sign in with `linkAuthToken`, run the SDK's `verifyIdentity`, then send `observe`. */
131
+ export type StripeVerifyIdentityNextAction = {
132
+ next: 'verifyIdentity';
133
+ linkAuthToken: StripeLinkAuthToken | null;
134
+ };
135
+ /** Stripe is reviewing, or a sign-in is settling. No request of its own: send `observe` after the delay. */
136
+ export type StripeWaitNextAction = {
137
+ next: 'wait';
138
+ retryAfterMs: number;
139
+ };
140
+ /** The order's price: the checkout's amount, with Stripe's own fees and delivered amount for it. */
141
+ export interface StripePrice {
142
+ total: FiatAmount;
143
+ fees: FeeLine[];
144
+ cryptoAmount: string;
145
+ }
146
+ /** What the Apple Pay sheet shows and where Stripe delivers. `amount` is the charge, the checkout's own string. */
147
+ export interface StripePaySheet {
148
+ destinationCurrency: string;
149
+ destinationNetwork: string;
150
+ walletAddress: string;
151
+ merchantCountryCode: 'US';
152
+ currencyCode: 'USD';
153
+ amount: string;
154
+ label: string;
155
+ }
156
+ /**
157
+ * Show `price` and the Apple Pay button. The tap signs in with `linkAuthToken`, runs `registerWalletAddress`,
158
+ * `collectPaymentMethod` and `createCryptoPaymentToken` with `paySheet`, then sends `placeOrder`. `orderId` is minted for
159
+ * this answer: send it back on `placeOrder`, and on every `checkout` and `order` after it.
160
+ */
161
+ export type StripePlaceOrderNextAction = {
162
+ next: 'placeOrder';
163
+ orderId: string;
164
+ price: StripePrice;
165
+ paySheet: StripePaySheet;
166
+ linkAuthToken: StripeLinkAuthToken | null;
167
+ };
168
+ /**
169
+ * Creates the Stripe session under `orderId` with the payment token and answers `pay`. A retry with the same `orderId`
170
+ * places nothing new. `cryptoPaymentToken` is named so request logs redact it.
171
+ */
172
+ export type StripePlaceOrderRequest = {
173
+ action: 'placeOrder';
174
+ orderId: string;
175
+ cryptoPaymentToken: string;
176
+ };
177
+ /**
178
+ * Sign in with `linkAuthToken`, then run the SDK's `performCheckout(sessionId)`. Inside its callback send `checkout`;
179
+ * after it resolves, send `order`.
180
+ */
181
+ export type StripePayNextAction = {
182
+ next: 'pay';
183
+ orderId: string;
184
+ sessionId: string;
185
+ linkAuthToken: StripeLinkAuthToken | null;
186
+ };
187
+ /**
188
+ * Sent from inside `performCheckout`'s callback, which supplies no id. Create a fresh `callbackId` per invocation and
189
+ * reuse it only for transport retries of that invocation.
190
+ */
191
+ export type StripeCheckoutRequest = {
192
+ action: 'checkout';
193
+ orderId: string;
194
+ callbackId: string;
195
+ };
196
+ /** Return `clientSecret` to the SDK's callback. It is a credential: never stored, never logged. */
197
+ export type StripeCheckoutSecretNextAction = {
198
+ next: 'checkoutSecret';
199
+ clientSecret: string;
200
+ };
201
+ /** Reads Stripe and moves the order `orderId` forward. */
202
+ export type StripeOrderRequest = {
203
+ action: 'order';
204
+ orderId: string;
205
+ };
206
+ /**
207
+ * The order exists and is not terminal. `order` is its current body, or `null` before the order is recorded.
208
+ * Do not open a payment sheet. After `retryAfterMs`, send `order`.
209
+ */
210
+ export type StripeOrderPendingNextAction = {
211
+ next: 'orderPending';
212
+ orderId: string;
213
+ retryAfterMs: number;
214
+ order: FiatStepResponse | null;
215
+ };
216
+ export type StripeRequest = StripeRequestContext & (StripeObserveRequest | StripeConsentRequest | StripeSessionRequest | StripeAuthorizeRequest | StripeKycRequest | StripePlaceOrderRequest | StripeCheckoutRequest | StripeOrderRequest);
217
+ /** Every `action` a Stripe request names. `wait` and `verifyIdentity` are next actions the client answers with `observe`. */
218
+ export type StripeAction = StripeRequest['action'];
219
+ /** The wire body. The orchestrator reads `provider` and `geo`; Stripe's action schemas read the rest. */
220
+ export type StripeNextRequest = {
221
+ provider: 'STRIPE';
222
+ geo: FiatGeo;
223
+ } & StripeRequest;
224
+ /** Every next action but `checkoutSecret`, which only `checkout` answers. */
225
+ export type StripeNextAction = StripeConsentNextAction | StripeSessionNextAction | StripeAuthorizeNextAction | StripeKycNextAction | StripeVerifyIdentityNextAction | StripeWaitNextAction | StripePlaceOrderNextAction | StripePayNextAction | StripeOrderPendingNextAction;
226
+ /** The order is terminal. `order` is its body, which the shared order screen renders. */
227
+ export type StripeDone = {
228
+ next: 'done';
229
+ order: FiatStepResponse;
230
+ };
231
+ /**
232
+ * Read `recovery`, never derive it from the reason. `REQUOTE` goes back to routing; `NONE` ends the flow.
233
+ * `LIMITS_EXCEEDED` carries the cap that refused as `maxAmount` when that cap is an amount.
234
+ */
235
+ export type StripeStepRefusal = 'NOT_ELIGIBLE' | 'KYC_REJECTED' | 'FINAL_REJECTION' | 'TOTAL_MISMATCH';
236
+ export type StripeRefused = {
237
+ next: 'refused';
238
+ reason: StripeStepRefusal;
239
+ recovery: 'REQUOTE' | 'NONE';
240
+ } | {
241
+ next: 'refused';
242
+ reason: 'LIMITS_EXCEEDED';
243
+ recovery: 'REQUOTE';
244
+ maxAmount: FiatAmount | null;
245
+ };
246
+ /** Every action but `checkout` and `order`. An open order answers `orderPending` and a terminal one `done`. */
247
+ export type StripeStepResponse = StripeNextAction | StripeDone | StripeRefused;
248
+ /** The secret, or the current step when none can be given: return `null` to the SDK's callback and act on the step. */
249
+ export type StripeCheckoutResponse = StripeCheckoutSecretNextAction | StripeStepResponse;
250
+ /** `order` never refuses: it runs after the buyer may have paid. */
251
+ export type StripeOrderResponse = StripeDone | StripeOrderPendingNextAction;
252
+ /** Every answer Stripe's `/fiat/next` gives. */
253
+ export type StripeResponse = StripeCheckoutResponse | StripeOrderResponse;
254
+ export type StripeResponseFor = {
255
+ observe: StripeStepResponse;
256
+ consent: StripeStepResponse;
257
+ session: StripeStepResponse;
258
+ authorize: StripeStepResponse;
259
+ kyc: StripeStepResponse;
260
+ placeOrder: StripeStepResponse;
261
+ checkout: StripeCheckoutResponse;
262
+ order: StripeOrderResponse;
263
+ };
264
+ /** `RETRY` sends the same request again. `REQUOTE` goes back to routing. `NONE` ends the flow. */
265
+ export type StripeRecovery = 'RETRY' | 'REQUOTE' | 'NONE';
266
+ /**
267
+ * `SESSION_BUDGET_SPENT`: the per-login sign-in budget `session` spends (429). `RATE_LIMITED`: the action's request
268
+ * budget (429). `PROVIDER_UNAVAILABLE`: Stripe is down (503). `KYC_PROVIDER_UNAVAILABLE`: the KYC provider is down
269
+ * (503). `SERVICE_UNAVAILABLE`: one of Fun's own stores is down (503). `INVALID_REQUEST`: a bad body (400).
270
+ */
271
+ export type StripeFaultReason = 'SESSION_BUDGET_SPENT' | 'RATE_LIMITED' | 'PROVIDER_UNAVAILABLE' | 'KYC_PROVIDER_UNAVAILABLE' | 'SERVICE_UNAVAILABLE' | 'INVALID_REQUEST';
272
+ /** The fields a Stripe fault adds to the shared error body. */
273
+ export interface StripeFault {
274
+ reason: StripeFaultReason;
275
+ recovery: StripeRecovery;
276
+ }
277
+ /** The route's 4xx/5xx body: the shared error body plus `StripeFault`. A 429 adds `retryAfterSeconds`. */
278
+ export type StripeErrorBody = StripeFault & {
279
+ errorCode: string;
280
+ errorMsg: string;
281
+ reqId?: string;
282
+ retryAfterSeconds?: number;
283
+ };
@@ -0,0 +1,28 @@
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/stripe.ts
21
+ var stripe_exports = {};
22
+ __export(stripe_exports, {
23
+ STRIPE_ENDPOINTS: () => STRIPE_ENDPOINTS
24
+ });
25
+ module.exports = __toCommonJS(stripe_exports);
26
+ var STRIPE_ENDPOINTS = {
27
+ next: "POST /fiat/next"
28
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ STRIPE_ENDPOINTS
3
+ } from "../chunk-KLAXY6H7.mjs";
4
+ export {
5
+ STRIPE_ENDPOINTS
6
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * zod schemas for the Stripe flow on `POST /fiat/next`. Test-time and backend-boundary only:
3
+ * exported from the package root, never from `./stripe`, so the production entry stays free of zod.
4
+ */
5
+ import { z } from 'zod';
6
+ import type { StripeAuthorizeNextAction, StripeAuthorizeRequest, StripeCheckout, StripeCheckoutRequest, StripeCheckoutResponse, StripeCheckoutSecretNextAction, StripeConsentNextAction, StripeConsentRequest, StripeDone, StripeErrorBody, StripeFault, StripeKycNextAction, StripeKycRequest, StripeLinkAuthToken, StripeNextAction, StripeNextRequest, StripeObserveRequest, StripeOrderPendingNextAction, StripeOrderRequest, StripeOrderResponse, StripePayNextAction, StripePaySheet, StripePlaceOrderNextAction, StripePlaceOrderRequest, StripePrice, StripeReask, StripeRefused, StripeRequest, StripeRequestContext, StripeResponseFor, StripeSessionNextAction, StripeSessionRequest, StripeStepResponse, StripeVerifyIdentityNextAction, StripeWaitNextAction } from './stripe';
7
+ export declare const StripeCheckoutSchema: z.ZodType<StripeCheckout>;
8
+ export declare const StripeRequestContextSchema: z.ZodType<StripeRequestContext>;
9
+ export declare const StripeObserveRequestSchema: z.ZodType<StripeRequestContext & StripeObserveRequest>;
10
+ export declare const StripeConsentRequestSchema: z.ZodType<StripeRequestContext & StripeConsentRequest>;
11
+ export declare const StripeSessionRequestSchema: z.ZodType<StripeRequestContext & StripeSessionRequest>;
12
+ export declare const StripeAuthorizeRequestSchema: z.ZodType<StripeRequestContext & StripeAuthorizeRequest>;
13
+ export declare const StripeKycRequestSchema: z.ZodType<StripeRequestContext & StripeKycRequest>;
14
+ export declare const StripePlaceOrderRequestSchema: z.ZodType<StripeRequestContext & StripePlaceOrderRequest>;
15
+ export declare const StripeCheckoutRequestSchema: z.ZodType<StripeRequestContext & StripeCheckoutRequest>;
16
+ export declare const StripeOrderRequestSchema: z.ZodType<StripeRequestContext & StripeOrderRequest>;
17
+ export declare const StripeRequestSchema: z.ZodType<StripeRequest>;
18
+ export declare const StripeNextRequestSchema: z.ZodType<StripeNextRequest>;
19
+ export declare const StripePriceSchema: z.ZodType<StripePrice>;
20
+ export declare const StripePaySheetSchema: z.ZodType<StripePaySheet>;
21
+ export declare const StripeLinkAuthTokenSchema: z.ZodType<StripeLinkAuthToken>;
22
+ export declare const StripeReaskSchema: z.ZodType<StripeReask>;
23
+ export declare const StripeConsentNextActionSchema: z.ZodType<StripeConsentNextAction>;
24
+ export declare const StripeSessionNextActionSchema: z.ZodType<StripeSessionNextAction>;
25
+ export declare const StripeAuthorizeNextActionSchema: z.ZodType<StripeAuthorizeNextAction>;
26
+ export declare const StripeKycNextActionSchema: z.ZodType<StripeKycNextAction>;
27
+ export declare const StripeVerifyIdentityNextActionSchema: z.ZodType<StripeVerifyIdentityNextAction>;
28
+ export declare const StripeWaitNextActionSchema: z.ZodType<StripeWaitNextAction>;
29
+ export declare const StripePlaceOrderNextActionSchema: z.ZodType<StripePlaceOrderNextAction>;
30
+ export declare const StripePayNextActionSchema: z.ZodType<StripePayNextAction>;
31
+ export declare const StripeCheckoutSecretNextActionSchema: z.ZodType<StripeCheckoutSecretNextAction>;
32
+ export declare const StripeOrderPendingNextActionSchema: z.ZodType<StripeOrderPendingNextAction>;
33
+ export declare const StripeNextActionSchema: z.ZodType<StripeNextAction>;
34
+ export declare const StripeDoneSchema: z.ZodType<StripeDone>;
35
+ export declare const StripeRefusedSchema: z.ZodType<StripeRefused>;
36
+ export declare const StripeStepResponseSchema: z.ZodType<StripeStepResponse>;
37
+ export declare const StripeCheckoutResponseSchema: z.ZodType<StripeCheckoutResponse>;
38
+ export declare const StripeOrderResponseSchema: z.ZodType<StripeOrderResponse>;
39
+ /** The response schema for each request action, as `StripeResponseFor` types it. */
40
+ export declare const StripeResponseSchemaFor: {
41
+ readonly [A in keyof StripeResponseFor]: z.ZodType<StripeResponseFor[A]>;
42
+ };
43
+ export declare const StripeFaultSchema: z.ZodType<StripeFault>;
44
+ export declare const StripeErrorBodySchema: z.ZodType<StripeErrorBody>;
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.48.0";
40
+ var version = "0.49.0";
41
41
 
42
42
  // src/table.ts
43
43
  var TABLE_VERSION = version;
package/dist/table.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-4ZHY4P3K.mjs";
15
+ } from "./chunk-6NZFTT7Q.mjs";
16
16
  export {
17
17
  DOCUMENTED_ENDPOINTS,
18
18
  FUN_AUTH_ERROR_CODES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.48.0",
3
+ "version": "0.49.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": {
@@ -38,6 +38,11 @@
38
38
  "import": "./dist/providers/coinbase.mjs",
39
39
  "require": "./dist/providers/coinbase.js"
40
40
  },
41
+ "./stripe": {
42
+ "types": "./dist/providers/stripe.d.ts",
43
+ "import": "./dist/providers/stripe.mjs",
44
+ "require": "./dist/providers/stripe.js"
45
+ },
41
46
  "./terms": {
42
47
  "types": "./dist/terms.d.ts",
43
48
  "import": "./dist/terms.mjs",
@@ -65,6 +70,8 @@
65
70
  "moonpay.d.ts",
66
71
  "coinbase.js",
67
72
  "coinbase.d.ts",
73
+ "stripe.js",
74
+ "stripe.d.ts",
68
75
  "terms.js",
69
76
  "terms.d.ts",
70
77
  "routing.js",
@@ -113,6 +120,9 @@
113
120
  "coinbase": [
114
121
  "./dist/providers/coinbase.d.ts"
115
122
  ],
123
+ "stripe": [
124
+ "./dist/providers/stripe.d.ts"
125
+ ],
116
126
  "terms": [
117
127
  "./dist/terms.d.ts"
118
128
  ],
package/stripe.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/providers/stripe';
package/stripe.js ADDED
@@ -0,0 +1,2 @@
1
+ // Compat stub — see table.js. Metro before RN 0.79 resolves `@fun-xyz/fiat-contract/stripe` by path.
2
+ module.exports = require('./dist/providers/stripe.js');