@fun-xyz/fiat-contract 0.45.0 → 0.47.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/dist/index.mjs CHANGED
@@ -13,10 +13,11 @@ import {
13
13
  tableEntry,
14
14
  unofferedEndpoints,
15
15
  unreachableStates
16
- } from "./chunk-FXHH22VB.mjs";
16
+ } from "./chunk-JMJ45E27.mjs";
17
17
  import {
18
18
  MOONPAY_ENDPOINTS
19
19
  } from "./chunk-TIEGTTFY.mjs";
20
+ import "./chunk-LTJWGDSA.mjs";
20
21
  import {
21
22
  COINBASE_ENDPOINTS,
22
23
  COINBASE_TERMS
@@ -27,7 +28,7 @@ import {
27
28
  PROVIDER_CHECKOUT_DOCUMENTS,
28
29
  PROVIDER_KYC_DOCUMENTS,
29
30
  PUBLISHED_TERMS_DOCUMENTS
30
- } from "./chunk-2CCO7UIS.mjs";
31
+ } from "./chunk-TIQALG7X.mjs";
31
32
  import {
32
33
  ROUTING_ENDPOINTS
33
34
  } from "./chunk-2NZSOZHV.mjs";
@@ -377,15 +378,12 @@ var $provider = z.enum([
377
378
  "SWAPPED",
378
379
  "BANXA",
379
380
  "MOONPAY",
381
+ "MOONPAY_GUEST",
380
382
  "STRIPE",
381
383
  "COINBASE",
382
384
  "CROSSMINT"
383
385
  ]);
384
386
  var FiatProviderSchema = $provider;
385
- var HANDOFF_PATHS = ["MOONPAY/guest_checkout"];
386
- var $handoffPath = z.enum(HANDOFF_PATHS);
387
- var FiatHandoffPathSchema = $handoffPath;
388
- var $handoffPathName = z.literal("guest_checkout");
389
387
  var $kycProvider = z.enum(["SUMSUB"]);
390
388
  var KYCProviderSchema = $kycProvider;
391
389
  var $surfaceProvider = z.enum([...$provider.options, ...$kycProvider.options]);
@@ -567,9 +565,9 @@ var $clientExecutedDelivery = obj({
567
565
  channel: z.literal("CLIENT_EXECUTED"),
568
566
  source: z.literal("CURRENT_SESSION_INPUTS"),
569
567
  allowedFieldIds: z.array($kycFieldId).min(1)
570
- }).superRefine((delivery, context) => {
568
+ }).superRefine((delivery, context2) => {
571
569
  if (new Set(delivery.allowedFieldIds).size !== delivery.allowedFieldIds.length) {
572
- context.addIssue({
570
+ context2.addIssue({
573
571
  code: "custom",
574
572
  path: ["allowedFieldIds"],
575
573
  message: "allowedFieldIds must be unique"
@@ -978,7 +976,7 @@ var compareDecimals = (left, right) => {
978
976
  return leftDigits < rightDigits ? -1 : leftDigits > rightDigits ? 1 : 0;
979
977
  };
980
978
  var $countryCode = z.enum(Object.keys(CountryCode));
981
- var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "STRIPE", "COINBASE"]);
979
+ var $routingProvider = $provider.extract(["TRANSAK", "BANXA", "MOONPAY", "MOONPAY_GUEST", "STRIPE", "COINBASE"]);
982
980
  var $optionalGeoField = z.union([$nonBlank, z.literal("")]).optional();
983
981
  var US_REGION_REQUIRED = "a US buyer needs a US state code as region";
984
982
  var hasUsRegion = (country, region) => country !== "US" || UsStateCodeSchema.safeParse(region).success;
@@ -994,7 +992,8 @@ var $routingTableRequest = obj({
994
992
  // Duplicates are allowed; the response lists each method once.
995
993
  methods: z.array(z.enum(PAYMENT_METHOD_CATEGORIES)).min(1),
996
994
  providers: $routingTableProviderInputs.optional(),
997
- destinationAsset: $destinationAsset.optional()
995
+ destinationAsset: $destinationAsset.optional(),
996
+ depositAddress: $nonBlank.optional()
998
997
  }).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
999
998
  var FiatRoutingTableRequestSchema = $routingTableRequest;
1000
999
  var $routingTableProvider = obj({
@@ -1011,11 +1010,11 @@ var $routingTableInterval = obj({
1011
1010
  var $routingTableMethod = obj({
1012
1011
  method: z.enum(PAYMENT_METHOD_CATEGORIES),
1013
1012
  unavailableReason: z.enum(["USER_LIMIT", "KYC_REJECTED", "PROVIDER_OUTAGE", "NOT_SERVED"]).optional(),
1014
- intervals: z.array($routingTableInterval).superRefine((intervals, context) => {
1013
+ intervals: z.array($routingTableInterval).superRefine((intervals, context2) => {
1015
1014
  intervals.forEach((interval, index) => {
1016
1015
  const previous = intervals[index - 1];
1017
1016
  if (previous !== void 0 && compareDecimals(interval.min, previous.max) <= 0) {
1018
- context.addIssue({ code: "custom", path: [index, "min"], message: "intervals are sorted and do not overlap" });
1017
+ context2.addIssue({ code: "custom", path: [index, "min"], message: "intervals are sorted and do not overlap" });
1019
1018
  }
1020
1019
  });
1021
1020
  })
@@ -1042,7 +1041,7 @@ var $routingQuoteTermsShape = {
1042
1041
  prepareSessionAuth: z.boolean().optional(),
1043
1042
  routingOverrides: obj({ providers: z.array($routingProvider) }).optional(),
1044
1043
  destinationAsset: $destinationAsset.optional(),
1045
- handoffPaths: z.array($handoffPath).refine(hasUniqueIds, "each handoff path is listed once").optional()
1044
+ depositAddress: $nonBlank.optional()
1046
1045
  };
1047
1046
  var $routingQuoteTerms = obj($routingQuoteTermsShape);
1048
1047
  var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
@@ -1098,7 +1097,13 @@ var $routingQuoteErrorBody = z.union([$routingNoRouteErrorBody, $routingAmountEr
1098
1097
  var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
1099
1098
  var $fiatGeo = obj({ alpha2: z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
1100
1099
  var FiatGeoSchema = $fiatGeo;
1101
- var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destinationAsset: $destinationAsset.optional() }).catchall(z.unknown());
1100
+ var $nextRequest = z.object({
1101
+ provider: $provider,
1102
+ action: $nonBlank,
1103
+ geo: $fiatGeo,
1104
+ destinationAsset: $destinationAsset.optional(),
1105
+ depositAddress: $nonBlank.optional()
1106
+ }).catchall(z.unknown());
1102
1107
  var FiatNextRequestSchema = $nextRequest;
1103
1108
  var $authStartRequest = z.union([obj({ email: $nonBlank }), obj({ verificationRef: $nonBlank })]);
1104
1109
  var FiatAuthStartRequestSchema = $authStartRequest;
@@ -1125,38 +1130,31 @@ var $providerBoundStepResponse = obj({
1125
1130
  state: $providerBoundFlowState,
1126
1131
  provider: $provider,
1127
1132
  preparedPayment: $preparedPayment.optional(),
1128
- handoff: obj({ provider: $provider, path: $handoffPathName.optional() }).optional()
1129
- }).superRefine((response, context) => {
1133
+ handoff: obj({ provider: $provider }).optional()
1134
+ }).superRefine((response, context2) => {
1130
1135
  if (response.preparedPayment !== void 0 && response.preparedPayment.surface.provider !== response.provider) {
1131
- context.addIssue({
1136
+ context2.addIssue({
1132
1137
  code: "custom",
1133
1138
  path: ["preparedPayment", "surface", "provider"],
1134
1139
  message: "preparedPayment.surface.provider must match the response provider"
1135
1140
  });
1136
1141
  }
1137
1142
  if (response.handoff !== void 0 && response.handoff.provider !== response.provider) {
1138
- context.addIssue({
1143
+ context2.addIssue({
1139
1144
  code: "custom",
1140
1145
  path: ["handoff", "provider"],
1141
1146
  message: "handoff.provider must match the response provider"
1142
1147
  });
1143
1148
  }
1144
- if (response.handoff?.path !== void 0 && !HANDOFF_PATHS.includes(`${response.handoff.provider}/${response.handoff.path}`)) {
1145
- context.addIssue({
1146
- code: "custom",
1147
- path: ["handoff", "path"],
1148
- message: "handoff.path must name a handoff path of handoff.provider"
1149
- });
1150
- }
1151
1149
  if (response.handoff !== void 0 && response.state.kind !== "QUOTE") {
1152
- context.addIssue({
1150
+ context2.addIssue({
1153
1151
  code: "custom",
1154
1152
  path: ["handoff"],
1155
1153
  message: "only a QUOTE response hands off to a provider"
1156
1154
  });
1157
1155
  }
1158
1156
  if (response.handoff !== void 0 && response.transitions.length > 0) {
1159
- context.addIssue({
1157
+ context2.addIssue({
1160
1158
  code: "custom",
1161
1159
  path: ["transitions"],
1162
1160
  message: "a handoff response carries no transitions"
@@ -1178,15 +1176,15 @@ var $funAuthStepResponse = obj({
1178
1176
  state: $funAuthState,
1179
1177
  provider: $provider.optional(),
1180
1178
  session: $fiatSession.optional()
1181
- }).superRefine((response, context) => {
1179
+ }).superRefine((response, context2) => {
1182
1180
  const { phase } = response.state;
1183
1181
  if (response.session !== void 0 && phase !== "VERIFIED") {
1184
- context.addIssue({ code: "custom", path: ["session"], message: "only a FUN_AUTH response in phase VERIFIED carries session" });
1182
+ context2.addIssue({ code: "custom", path: ["session"], message: "only a FUN_AUTH response in phase VERIFIED carries session" });
1185
1183
  }
1186
1184
  const allowed = FUN_AUTH_TRANSITIONS_BY_PHASE[phase];
1187
1185
  response.transitions.forEach((transition, index) => {
1188
1186
  if (!allowed.includes(transition.id)) {
1189
- context.addIssue({
1187
+ context2.addIssue({
1190
1188
  code: "custom",
1191
1189
  path: ["transitions", index, "id"],
1192
1190
  message: `FUN_AUTH phase ${phase} offers ${allowed.join(" or ") || "no transitions"}, not "${transition.id}"`
@@ -2534,13 +2532,10 @@ var $checkout = obj2({
2534
2532
  var MoonPayCheckoutSchema = $checkout;
2535
2533
  var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
2536
2534
  var MoonPaySdkCredentialsSchema = $credentials;
2537
- var $path = z2.literal("guest_checkout");
2538
- var MoonPayPathSchema = $path;
2539
2535
  var $context = {
2540
2536
  checkout: $checkout,
2541
2537
  credentials: $credentials.optional(),
2542
- destinationAsset: DestinationAssetSchema.optional(),
2543
- path: $path.optional()
2538
+ destinationAsset: DestinationAssetSchema.optional()
2544
2539
  };
2545
2540
  var $requestContext = obj2($context);
2546
2541
  var MoonPayRequestContextSchema = $requestContext;
@@ -2559,6 +2554,9 @@ var $consentFields = {
2559
2554
  };
2560
2555
  var $sessionFields = { action: z2.literal("session") };
2561
2556
  var $connectFields = { action: z2.literal("connect"), customerId: $nonEmpty, accessToken: $nonEmpty };
2557
+ var $phoneNumberFields = { action: z2.literal("phone"), phoneNumber: z2.string().regex(/^\+[1-9]\d{1,14}$/) };
2558
+ var $phoneResendFields = { action: z2.literal("phone"), resend: $nonEmpty };
2559
+ var $phoneCodeFields = { action: z2.literal("phoneCode"), verificationRef: $nonEmpty, otpCode: z2.string().regex(/^\d{6}$/) };
2562
2560
  var $guestDeclineReason = z2.enum(["NOT_OFFERED", "MISMATCH", "OVER_LIMIT"]);
2563
2561
  var MoonPayGuestDeclineReasonSchema = $guestDeclineReason;
2564
2562
  var $declineFields = { action: z2.literal("decline"), reason: $guestDeclineReason };
@@ -2574,6 +2572,8 @@ var $observeRequest = obj2({ ...$context, ...$observeFields });
2574
2572
  var $consentRequest = obj2({ ...$context, ...$consentFields });
2575
2573
  var $sessionRequest = obj2({ ...$context, ...$sessionFields });
2576
2574
  var $connectRequest = obj2({ ...$context, ...$connectFields });
2575
+ var $phoneRequest = z2.union([obj2({ ...$context, ...$phoneNumberFields }), obj2({ ...$context, ...$phoneResendFields })]);
2576
+ var $phoneCodeRequest = obj2({ ...$context, ...$phoneCodeFields });
2577
2577
  var $declineRequest = obj2({ ...$context, ...$declineFields });
2578
2578
  var $kycRequest = obj2({ ...$context, ...$kycFields });
2579
2579
  var $prepareCaptureRequest = obj2({ ...$context, ...$prepareCaptureFields });
@@ -2583,30 +2583,30 @@ var MoonPayObserveRequestSchema = $observeRequest;
2583
2583
  var MoonPayConsentRequestSchema = $consentRequest;
2584
2584
  var MoonPaySessionRequestSchema = $sessionRequest;
2585
2585
  var MoonPayConnectRequestSchema = $connectRequest;
2586
+ var MoonPayPhoneRequestSchema = $phoneRequest;
2587
+ var MoonPayPhoneCodeRequestSchema = $phoneCodeRequest;
2586
2588
  var MoonPayDeclineRequestSchema = $declineRequest;
2587
2589
  var MoonPayKycRequestSchema = $kycRequest;
2588
2590
  var MoonPayPrepareCaptureRequestSchema = $prepareCaptureRequest;
2589
2591
  var MoonPayCaptureRequestSchema = $captureRequest;
2590
2592
  var MoonPayOrderRequestSchema = $orderRequest;
2591
- var $request = z2.discriminatedUnion("action", [
2593
+ var $request = z2.union([
2592
2594
  $observeRequest,
2593
2595
  $consentRequest,
2594
2596
  $sessionRequest,
2595
2597
  $connectRequest,
2596
- $declineRequest,
2597
2598
  $kycRequest,
2598
2599
  $prepareCaptureRequest,
2599
2600
  $captureRequest,
2600
2601
  $orderRequest
2601
2602
  ]);
2602
2603
  var MoonPayRequestSchema = $request;
2603
- var $envelope = { provider: z2.literal("MOONPAY"), geo: FiatGeoSchema, ...$context };
2604
- var $nextRequest2 = z2.discriminatedUnion("action", [
2604
+ var $envelope = { provider: z2.literal("MOONPAY"), geo: FiatGeoSchema, depositAddress: $nonEmpty.optional(), ...$context };
2605
+ var $nextRequest2 = z2.union([
2605
2606
  obj2({ ...$envelope, ...$observeFields }),
2606
2607
  obj2({ ...$envelope, ...$consentFields }),
2607
2608
  obj2({ ...$envelope, ...$sessionFields }),
2608
2609
  obj2({ ...$envelope, ...$connectFields }),
2609
- obj2({ ...$envelope, ...$declineFields }),
2610
2610
  obj2({ ...$envelope, ...$kycFields }),
2611
2611
  obj2({ ...$envelope, ...$prepareCaptureFields }),
2612
2612
  obj2({ ...$envelope, ...$captureFields }),
@@ -2623,6 +2623,13 @@ var $connectNextAction = obj2({
2623
2623
  quoteInput: $quoteInput,
2624
2624
  resetConnection: z2.literal(true).optional()
2625
2625
  });
2626
+ var $phoneNextAction = obj2({ next: z2.literal("phone"), error: z2.literal("CODE_EXPIRED").nullable() });
2627
+ var $phoneCodeNextAction = obj2({
2628
+ next: z2.literal("phoneCode"),
2629
+ verificationRef: $nonEmpty,
2630
+ expiresAt: z2.string().datetime({ offset: true }),
2631
+ error: z2.literal("CODE_INVALID").nullable()
2632
+ });
2626
2633
  var $payNextAction = obj2({ next: z2.literal("pay"), sessionToken: $nonEmpty, orderId: $nonEmpty, quoteInput: $quoteInput });
2627
2634
  var CAPTURE_DOCUMENTS = ["IDENTITY_DOCUMENT", "SELFIE", "PROOF_OF_ADDRESS", "PROOF_OF_INCOME"];
2628
2635
  var $captureDocument = z2.enum(CAPTURE_DOCUMENTS);
@@ -2654,35 +2661,37 @@ var $orderPendingNextAction = obj2({
2654
2661
  retryAfterMs: z2.number().int().positive().max(6e4),
2655
2662
  order: FiatStepResponseSchema.nullable()
2656
2663
  });
2657
- var checkConsent = (nextAction, context) => {
2664
+ var checkConsent = (nextAction, context2) => {
2658
2665
  if (!hasUniqueIds2(nextAction.documents.map((document) => document.id))) {
2659
- context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2666
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2660
2667
  }
2661
2668
  };
2662
- var checkKyc = (nextAction, context) => {
2669
+ var checkKyc = (nextAction, context2) => {
2663
2670
  const fieldIds = nextAction.fields.map((field) => field.id);
2664
2671
  if (!hasUniqueIds2(fieldIds)) {
2665
- context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2672
+ context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2666
2673
  }
2667
2674
  if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2668
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2675
+ context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2669
2676
  }
2670
2677
  if (nextAction.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
2671
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2678
+ context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
2672
2679
  }
2673
2680
  if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
2674
- context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2681
+ context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2675
2682
  }
2676
2683
  };
2677
2684
  var isCaptureDocument = (requirement) => CAPTURE_DOCUMENTS.includes(requirement);
2678
- var checkCapture = (nextAction, context) => {
2685
+ var checkCapture = (nextAction, context2) => {
2679
2686
  if (nextAction.reask?.requirements.some((requirement) => !isCaptureDocument(requirement))) {
2680
- context.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
2687
+ context2.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
2681
2688
  }
2682
2689
  };
2683
2690
  var MoonPayConsentNextActionSchema = $consentShape.superRefine(checkConsent);
2684
2691
  var MoonPaySessionNextActionSchema = $sessionNextAction;
2685
2692
  var MoonPayConnectNextActionSchema = $connectNextAction;
2693
+ var MoonPayPhoneNextActionSchema = $phoneNextAction;
2694
+ var MoonPayPhoneCodeNextActionSchema = $phoneCodeNextAction;
2686
2695
  var MoonPayPayNextActionSchema = $payNextAction;
2687
2696
  var MoonPayKycNextActionSchema = $kycShape.superRefine(checkKyc);
2688
2697
  var MoonPayPrepareCaptureNextActionSchema = $prepareCaptureNextAction;
@@ -2694,16 +2703,15 @@ var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
2694
2703
  var MoonPayWaitNextActionSchema = $waitNextAction;
2695
2704
  var MoonPayOrderNextActionSchema = $orderNextAction;
2696
2705
  var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
2697
- var checkNextAction = (response, context) => {
2698
- if (response.next === "consent") checkConsent(response, context);
2699
- if (response.next === "kyc") checkKyc(response, context);
2700
- if (response.next === "capture") checkCapture(response, context);
2706
+ var checkNextAction = (response, context2) => {
2707
+ if (response.next === "consent") checkConsent(response, context2);
2708
+ if (response.next === "kyc") checkKyc(response, context2);
2709
+ if (response.next === "capture") checkCapture(response, context2);
2701
2710
  };
2702
2711
  var $nextActionOptions = [
2703
2712
  $consentShape,
2704
2713
  $sessionNextAction,
2705
2714
  $connectNextAction,
2706
- $payNextAction,
2707
2715
  $kycShape,
2708
2716
  $prepareCaptureNextAction,
2709
2717
  $captureShape,
@@ -2733,7 +2741,6 @@ var MoonPayResponseSchemaFor = {
2733
2741
  consent: MoonPayStepResponseSchema,
2734
2742
  session: MoonPayStepResponseSchema,
2735
2743
  connect: MoonPayStepResponseSchema,
2736
- decline: MoonPayStepResponseSchema,
2737
2744
  kyc: MoonPayStepResponseSchema,
2738
2745
  prepareCapture: MoonPayStepResponseSchema,
2739
2746
  capture: MoonPayStepResponseSchema,
@@ -2800,7 +2807,7 @@ var CoinbasePlaceOrderRequestSchema = $placeOrderRequest;
2800
2807
  var CoinbaseOrderRequestSchema = $orderRequest2;
2801
2808
  var $request2 = z3.union([$observeRequest2, $consentRequest2, $sessionRequest2, $otpRequest, $kycRequest2, $placeOrderRequest, $orderRequest2]);
2802
2809
  var CoinbaseRequestSchema = $request2;
2803
- var envelope = { provider: z3.literal("COINBASE"), geo: FiatGeoSchema, ...contextFields };
2810
+ var envelope = { provider: z3.literal("COINBASE"), geo: FiatGeoSchema, depositAddress: $nonEmpty2.optional(), ...contextFields };
2804
2811
  var $nextRequest3 = z3.union([
2805
2812
  obj3({ ...envelope, ...observeFields }),
2806
2813
  obj3({ ...envelope, ...consentFields }),
@@ -2849,21 +2856,21 @@ var $orderPendingNextAction2 = obj3({
2849
2856
  retryAfterMs: $retryAfterMs,
2850
2857
  order: FiatStepResponseSchema.nullable()
2851
2858
  });
2852
- var checkConsent2 = (nextAction, context) => {
2859
+ var checkConsent2 = (nextAction, context2) => {
2853
2860
  if (!hasUniqueIds3(nextAction.documents.map((document) => document.id))) {
2854
- context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2861
+ context2.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
2855
2862
  }
2856
2863
  };
2857
- var checkKyc2 = (nextAction, context) => {
2864
+ var checkKyc2 = (nextAction, context2) => {
2858
2865
  const fieldIds = nextAction.fields.map((field) => field.id);
2859
2866
  if (!hasUniqueIds3(fieldIds)) {
2860
- context.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2867
+ context2.addIssue({ code: "custom", path: ["fields"], message: "field ids must be unique" });
2861
2868
  }
2862
2869
  if (nextAction.fieldErrors?.some((error) => !fieldIds.includes(error.fieldId))) {
2863
- context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2870
+ context2.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error must name a field in this next action" });
2864
2871
  }
2865
2872
  if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
2866
- context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2873
+ context2.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
2867
2874
  }
2868
2875
  };
2869
2876
  var CoinbaseConsentNextActionSchema = $consentShape2.superRefine(checkConsent2);
@@ -2874,9 +2881,9 @@ var CoinbaseWaitNextActionSchema = $waitNextAction2;
2874
2881
  var CoinbasePlaceOrderNextActionSchema = $placeOrderNextAction;
2875
2882
  var CoinbasePayNextActionSchema = $payNextAction2;
2876
2883
  var CoinbaseOrderPendingNextActionSchema = $orderPendingNextAction2;
2877
- var checkNextAction2 = (response, context) => {
2878
- if (response.next === "consent") checkConsent2(response, context);
2879
- if (response.next === "kyc") checkKyc2(response, context);
2884
+ var checkNextAction2 = (response, context2) => {
2885
+ if (response.next === "consent") checkConsent2(response, context2);
2886
+ if (response.next === "kyc") checkKyc2(response, context2);
2880
2887
  };
2881
2888
  var $nextActionOptions2 = [
2882
2889
  $consentShape2,
@@ -2933,6 +2940,60 @@ var $errorBody2 = obj3({
2933
2940
  retryAfterSeconds: z3.number().int().positive().optional()
2934
2941
  });
2935
2942
  var CoinbaseErrorBodySchema = $errorBody2;
2943
+
2944
+ // src/providers/moonpay-guest.schemas.ts
2945
+ import { z as z4 } from "zod";
2946
+ var context = { checkout: MoonPayCheckoutSchema, destinationAsset: DestinationAssetSchema.optional() };
2947
+ var obj4 = (shape) => z4.object(shape).strict();
2948
+ var nonEmpty = z4.string().refine((value) => value.trim().length > 0, "must not be blank");
2949
+ var actions = [
2950
+ { action: z4.literal("observe") },
2951
+ { action: z4.literal("session") },
2952
+ { 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") },
2953
+ { action: z4.literal("order"), orderId: nonEmpty, quotedAmount: FiatAmountSchema, transactionId: nonEmpty.optional() },
2954
+ { action: z4.literal("phone"), phoneNumber: z4.string().regex(/^\+[1-9]\d{1,14}$/) },
2955
+ { action: z4.literal("phone"), resend: nonEmpty },
2956
+ { action: z4.literal("phoneCode"), verificationRef: nonEmpty, otpCode: z4.string().regex(/^\d{6}$/) },
2957
+ { action: z4.literal("decline"), reason: MoonPayGuestDeclineReasonSchema }
2958
+ ];
2959
+ var MoonPayGuestObserveRequestSchema = obj4({ ...context, ...actions[0] });
2960
+ var MoonPayGuestSessionRequestSchema = obj4({ ...context, ...actions[1] });
2961
+ var MoonPayGuestConsentRequestSchema = obj4({ ...context, ...actions[2] });
2962
+ var MoonPayGuestOrderRequestSchema = obj4({ ...context, ...actions[3] });
2963
+ var MoonPayGuestPhoneNumberRequestSchema = obj4({ ...context, ...actions[4] });
2964
+ var MoonPayGuestPhoneResendRequestSchema = obj4({ ...context, ...actions[5] });
2965
+ var MoonPayGuestPhoneCodeRequestSchema = obj4({ ...context, ...actions[6] });
2966
+ var MoonPayGuestDeclineRequestSchema = obj4({ ...context, ...actions[7] });
2967
+ var MoonPayGuestPhoneRequestSchema = z4.union([MoonPayGuestPhoneNumberRequestSchema, MoonPayGuestPhoneResendRequestSchema]);
2968
+ var MoonPayGuestRequestSchema = z4.union([
2969
+ MoonPayGuestObserveRequestSchema,
2970
+ MoonPayGuestSessionRequestSchema,
2971
+ MoonPayGuestConsentRequestSchema,
2972
+ MoonPayGuestOrderRequestSchema,
2973
+ MoonPayGuestPhoneNumberRequestSchema,
2974
+ MoonPayGuestPhoneResendRequestSchema,
2975
+ MoonPayGuestPhoneCodeRequestSchema,
2976
+ MoonPayGuestDeclineRequestSchema
2977
+ ]);
2978
+ var MoonPayGuestNextRequestSchema = z4.union([
2979
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[0] }),
2980
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[1] }),
2981
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[2] }),
2982
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[3] }),
2983
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[4] }),
2984
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[5] }),
2985
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[6] }),
2986
+ obj4({ provider: z4.literal("MOONPAY_GUEST"), geo: FiatGeoSchema, depositAddress: nonEmpty.optional(), ...context, ...actions[7] })
2987
+ ]);
2988
+ var MoonPayGuestStepResponseSchema = z4.union([
2989
+ MoonPayConsentNextActionSchema,
2990
+ MoonPaySessionNextActionSchema,
2991
+ MoonPayPhoneNextActionSchema,
2992
+ MoonPayPhoneCodeNextActionSchema,
2993
+ MoonPayPayNextActionSchema,
2994
+ obj4({ next: z4.literal("refused"), reason: z4.enum(["NOT_ELIGIBLE", "FINAL_REJECTION"]), recovery: z4.enum(["REQUOTE", "NONE"]) })
2995
+ ]);
2996
+ var MoonPayGuestResponseSchema = z4.union([MoonPayGuestStepResponseSchema, MoonPayOrderResponseSchema]);
2936
2997
  export {
2937
2998
  BlockedReasonSchema,
2938
2999
  BlockedStateSchema,
@@ -2995,7 +3056,6 @@ export {
2995
3056
  FiatCurrencyCode,
2996
3057
  FiatEndpointSchema,
2997
3058
  FiatGeoSchema,
2998
- FiatHandoffPathSchema,
2999
3059
  FiatNextRequestSchema,
3000
3060
  FiatProviderSchema,
3001
3061
  FiatRoutingQuoteErrorBodySchema,
@@ -3041,7 +3101,20 @@ export {
3041
3101
  MoonPayDoneSchema,
3042
3102
  MoonPayErrorBodySchema,
3043
3103
  MoonPayFaultSchema,
3104
+ MoonPayGuestConsentRequestSchema,
3044
3105
  MoonPayGuestDeclineReasonSchema,
3106
+ MoonPayGuestDeclineRequestSchema,
3107
+ MoonPayGuestNextRequestSchema,
3108
+ MoonPayGuestObserveRequestSchema,
3109
+ MoonPayGuestOrderRequestSchema,
3110
+ MoonPayGuestPhoneCodeRequestSchema,
3111
+ MoonPayGuestPhoneNumberRequestSchema,
3112
+ MoonPayGuestPhoneRequestSchema,
3113
+ MoonPayGuestPhoneResendRequestSchema,
3114
+ MoonPayGuestRequestSchema,
3115
+ MoonPayGuestResponseSchema,
3116
+ MoonPayGuestSessionRequestSchema,
3117
+ MoonPayGuestStepResponseSchema,
3045
3118
  MoonPayKycNextActionSchema,
3046
3119
  MoonPayKycRequestSchema,
3047
3120
  MoonPayNextActionSchema,
@@ -3051,8 +3124,11 @@ export {
3051
3124
  MoonPayOrderPendingNextActionSchema,
3052
3125
  MoonPayOrderRequestSchema,
3053
3126
  MoonPayOrderResponseSchema,
3054
- MoonPayPathSchema,
3055
3127
  MoonPayPayNextActionSchema,
3128
+ MoonPayPhoneCodeNextActionSchema,
3129
+ MoonPayPhoneCodeRequestSchema,
3130
+ MoonPayPhoneNextActionSchema,
3131
+ MoonPayPhoneRequestSchema,
3056
3132
  MoonPayPrepareCaptureNextActionSchema,
3057
3133
  MoonPayPrepareCaptureRequestSchema,
3058
3134
  MoonPayQuoteInputSchema,
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * A response names the next action in `next`; the client's request names it in `action`. `observe` answers the
5
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.
6
+ * Identity comes from the verified partner assertion or the Fun session; the deposit wallet from the assertion or,
7
+ * for a mode-2 partner, from the body's `depositAddress` (see `FiatNextRequest`).
7
8
  *
8
9
  * A retry sends the same request and gets the current response. A fault is a 4xx/5xx whose body is
9
10
  * `CoinbaseErrorBody`; anything the buyer can act on is a 200.
@@ -157,10 +158,14 @@ export type CoinbaseRequest = CoinbaseRequestContext & (CoinbaseObserveRequest |
157
158
  * `wait` is a next action the client answers by sending `observe` again, never a request action.
158
159
  */
159
160
  export type CoinbaseAction = CoinbaseRequest['action'];
160
- /** The wire body. The orchestrator reads `provider` and `geo`; Coinbase's action schemas read the rest. */
161
+ /**
162
+ * The wire body. The orchestrator reads `provider`, `geo` and `depositAddress` (as on every
163
+ * `FiatNextRequest`); Coinbase's action schemas read the rest.
164
+ */
161
165
  export type CoinbaseNextRequest = {
162
166
  provider: 'COINBASE';
163
167
  geo: FiatGeo;
168
+ depositAddress?: string;
164
169
  } & CoinbaseRequest;
165
170
  export type CoinbaseNextAction = CoinbaseConsentNextAction | CoinbaseSessionNextAction | CoinbaseOtpNextAction | CoinbaseKycNextAction | CoinbaseWaitNextAction | CoinbasePlaceOrderNextAction | CoinbasePayNextAction | CoinbaseOrderPendingNextAction;
166
171
  /** The order is terminal. `order` is its body, which the shared order screen renders. */
@@ -0,0 +1,12 @@
1
+ /** MoonPay guest checkout is a separate provider; it never connects a MoonPay customer. */
2
+ import type { FiatGeo } from '../types';
3
+ import type { MoonPayRequestContext, MoonPayObserveRequest, MoonPayConsentRequest, MoonPaySessionRequest, MoonPayPhoneRequest, MoonPayPhoneCodeRequest, MoonPayDeclineRequest, MoonPayOrderRequest, MoonPayConsentNextAction, MoonPaySessionNextAction, MoonPayPhoneNextAction, MoonPayPhoneCodeNextAction, MoonPayPayNextAction, MoonPayRefused, MoonPayOrderResponse } from './moonpay';
4
+ export type MoonPayGuestRequestContext = Omit<MoonPayRequestContext, 'credentials'>;
5
+ export type MoonPayGuestRequest = MoonPayGuestRequestContext & (MoonPayObserveRequest | MoonPayConsentRequest | MoonPaySessionRequest | MoonPayPhoneRequest | MoonPayPhoneCodeRequest | MoonPayDeclineRequest | MoonPayOrderRequest);
6
+ export type MoonPayGuestNextRequest = {
7
+ provider: 'MOONPAY_GUEST';
8
+ geo: FiatGeo;
9
+ depositAddress?: string;
10
+ } & MoonPayGuestRequest;
11
+ export type MoonPayGuestStepResponse = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayPhoneNextAction | MoonPayPhoneCodeNextAction | MoonPayPayNextAction | MoonPayRefused<'NOT_ELIGIBLE' | 'FINAL_REJECTION', 'REQUOTE' | 'NONE'>;
12
+ export type MoonPayGuestResponse = MoonPayGuestStepResponse | MoonPayOrderResponse;
@@ -0,0 +1,18 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/providers/moonpay-guest.ts
17
+ var moonpay_guest_exports = {};
18
+ module.exports = __toCommonJS(moonpay_guest_exports);
@@ -0,0 +1 @@
1
+ import "../chunk-LTJWGDSA.mjs";
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ import type { MoonPayGuestRequest, MoonPayGuestNextRequest } from './moonpay-guest';
3
+ export declare const MoonPayGuestObserveRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
4
+ action: "observe";
5
+ }>>;
6
+ export declare const MoonPayGuestSessionRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
7
+ action: "session";
8
+ }>>;
9
+ export declare const MoonPayGuestConsentRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
10
+ action: "consent";
11
+ }>>;
12
+ export declare const MoonPayGuestOrderRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
13
+ action: "order";
14
+ }>>;
15
+ export declare const MoonPayGuestPhoneNumberRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
16
+ action: "phone";
17
+ phoneNumber: string;
18
+ }>>;
19
+ export declare const MoonPayGuestPhoneResendRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
20
+ action: "phone";
21
+ resend: string;
22
+ }>>;
23
+ export declare const MoonPayGuestPhoneCodeRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
24
+ action: "phoneCode";
25
+ }>>;
26
+ export declare const MoonPayGuestDeclineRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
27
+ action: "decline";
28
+ }>>;
29
+ export declare const MoonPayGuestPhoneRequestSchema: z.ZodType<Extract<MoonPayGuestRequest, {
30
+ action: "phone";
31
+ }>>;
32
+ export declare const MoonPayGuestRequestSchema: z.ZodType<MoonPayGuestRequest>;
33
+ export declare const MoonPayGuestNextRequestSchema: z.ZodType<MoonPayGuestNextRequest>;
34
+ import type { MoonPayGuestStepResponse, MoonPayGuestResponse } from './moonpay-guest';
35
+ export declare const MoonPayGuestStepResponseSchema: z.ZodType<MoonPayGuestStepResponse>;
36
+ export declare const MoonPayGuestResponseSchema: z.ZodType<MoonPayGuestResponse>;