@fun-xyz/fiat-contract 0.16.0 → 0.18.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/README.md +24 -2
- package/dist/{chunk-PEJOU52N.mjs → chunk-7KI7DJZ2.mjs} +2 -2
- package/dist/chunk-YWKS7MMT.mjs +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +136 -2
- package/dist/index.mjs +131 -2
- package/dist/providers/moonpay.d.ts +131 -0
- package/dist/providers/moonpay.js +32 -0
- package/dist/providers/moonpay.mjs +7 -0
- package/dist/providers/moonpay.schemas.d.ts +18 -0
- package/dist/schemas.d.ts +3 -1
- package/dist/table.js +1 -1
- package/dist/table.mjs +1 -1
- package/dist/types.d.ts +29 -0
- package/moonpay.d.ts +1 -0
- package/moonpay.js +2 -0
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -13,12 +13,13 @@ Four things, zero runtime logic beyond validation:
|
|
|
13
13
|
| `src/table.ts` | the transition table **as data**: per state, its legal transition set, the states any call from it may return, and `terminal: boolean` |
|
|
14
14
|
| `src/assert.ts` + `src/fixtures/` | `assertFiatStepResponse` · `assertLegalEmission` · `assertLegalReturn` · `walkTable` · fixture loader + 18 recorded step responses (inlined as data — no filesystem, so React Native can bundle it) |
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Four entry points — production vs test-time
|
|
17
17
|
|
|
18
18
|
| Import | Weight | Contains | Used by |
|
|
19
19
|
| --- | --- | --- | --- |
|
|
20
20
|
| `@fun-xyz/fiat-contract/types` | **0.1 KB** (types erase) | every type; no runtime values | production, both repos |
|
|
21
21
|
| `@fun-xyz/fiat-contract/table` | **13.8 KB**, zero deps | `TRANSITION_TABLE`, `stateKey`, `tableEntry`, `isTerminal`, `walkTable`, `TABLE_VERSION`, `TERMINAL_ORDER_STATUSES`, `DOCUMENTED_ENDPOINTS`, `UNOFFERED_ENDPOINTS`, `UNREACHABLE_STATES`, `unofferedEndpoints`, `unreachableStates` | **production frontend** + backend |
|
|
22
|
+
| `@fun-xyz/fiat-contract/moonpay` | zero deps | the MoonPay provider-owned flow: request, response, standing and fault types, and `MOONPAY_ENDPOINTS` | **production frontend** (MoonPay adapter) + backend |
|
|
22
23
|
| `@fun-xyz/fiat-contract` | 47.6 KB, needs zod | the above + 46 zod schemas + assertions + 18 fixtures | tests, and backend dev/test guards |
|
|
23
24
|
|
|
24
25
|
`./table` is not a micro-optimisation. Terminality is table data a **shipped** client must read
|
|
@@ -88,6 +89,27 @@ this package is [ENG-5268](https://linear.app/funxyz/issue/ENG-5268).
|
|
|
88
89
|
16. **Correction text never decides retry.** A correctable provider rejection returns
|
|
89
90
|
`KYC{CAPTURE}` and may carry `correctionReason` for display. Clients decide that retry is allowed
|
|
90
91
|
from the state and its transitions; provider-authored text is never a branch key.
|
|
92
|
+
17. **Prepared payment is inert until promotion.** `FiatStepResponse.preparedPayment` may warm a
|
|
93
|
+
provider-owned payment surface while auth or KYC continues, but its `CLIENT_SURFACE` transition
|
|
94
|
+
is not active yet. A client exposes it only after a later response makes the same `quoteRef`
|
|
95
|
+
executable; the prepared surface provider must match the response provider.
|
|
96
|
+
|
|
97
|
+
## Provider-owned flows
|
|
98
|
+
|
|
99
|
+
A provider can run its own flow instead of the shared step machine. `POST /fiat/quote` still routes
|
|
100
|
+
and prices. When the request's `handoffs` lists the winning provider, the response carries
|
|
101
|
+
`handoff: { provider }` and no transitions, and the client calls that provider's routes under
|
|
102
|
+
`POST /fiat/providers/{provider}/…`. The schema refuses a handoff to a provider other than the
|
|
103
|
+
response's own, and a handoff that still offers transitions.
|
|
104
|
+
|
|
105
|
+
MoonPay is the first (`./moonpay`). Its routes are `start`, `intent`, `kyc`, and `complete`, in
|
|
106
|
+
`MOONPAY_ENDPOINTS`. Only `intent` decides: it answers with a `MoonPayStanding` (`READY`, `KYC`,
|
|
107
|
+
`PENDING`, or `REFUSED`). `kyc` answers `{ status: 'ACCEPTED' }`, and the client then calls `intent`.
|
|
108
|
+
`complete` answers with the same step response as `GET /fiat/orders/:orderId`. A fault is a 4xx or
|
|
109
|
+
5xx with a `MoonPayErrorBody`: the shared `errorCode`, `errorMsg` and `reqId`, plus `reason`,
|
|
110
|
+
`recovery`, and `fields` on a rejected KYC value. `recovery` is `RETRY` (send the same request),
|
|
111
|
+
`REFRESH` (call `intent` for a new standing, as after a stale form), `REQUOTE`, or `NONE`. The zod
|
|
112
|
+
schemas (`MoonPay*Schema`) are exported from the root only. A handoff appears only on a `QUOTE`.
|
|
91
113
|
|
|
92
114
|
## KYC SDK hints, results, and client delivery
|
|
93
115
|
|
|
@@ -440,7 +462,7 @@ Dual CJS + ESM, same shape as `@funkit/fun-relay`, because the two consumers loa
|
|
|
440
462
|
| `require()` must work | `fun-backend/apps/api-server` compiles `module: commonjs` and runs plain node — no bundler | esbuild emits `dist/index.js` (CJS) + `dist/index.mjs` (ESM); `exports` maps `require`/`import`; no `"type": "module"` |
|
|
441
463
|
| Zero Node builtins | `connect-core` is React Native — Metro cannot resolve `node:fs` | fixtures are inlined as generated TS data (`src/fixtures/data.ts`), so nothing touches the filesystem; `platform: browser`, every bare import external |
|
|
442
464
|
| Subpath imports must resolve without `exports` support | Metro only reads `package.json#exports` from RN 0.79 on, and `@funkit/connect-rn` accepts `react-native: >=0.74` | root compat stubs `table.js` / `types.js` (+ `.d.ts`) that re-export `dist/`. Without them Metro fails with *"Unable to resolve module"* — verified, not theorised. Resolvers that do read `exports` never see the stubs |
|
|
443
|
-
| Production code must not pull zod or fixtures | `connect-core` ships to React Native, where Metro does not tree-shake unused exports by default |
|
|
465
|
+
| Production code must not pull zod or fixtures | `connect-core` ships to React Native, where Metro does not tree-shake unused exports by default | four entry points: `./types` (erased), `./table` (13.8 KB, zero deps), `./moonpay` (zero deps), root (schemas + fixtures, test-time). CI asserts `require('.../table')` and `require('.../moonpay')` never load zod |
|
|
444
466
|
| `.d.ts` must not lock a zod major | Both repos run `skipLibCheck: true`, which turns a broken declaration into a silent `any` | every exported schema is annotated `z.ZodType<T>`, so declarations name only `z.ZodType`; the structural drift checks stay module-private |
|
|
445
467
|
|
|
446
468
|
Declarations come from `tsc --emitDeclarationOnly`; esbuild only emits JS. The fixture `.json` files
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.18.0";
|
|
3
3
|
|
|
4
4
|
// src/table.ts
|
|
5
5
|
var TABLE_VERSION = version;
|
|
@@ -514,4 +514,4 @@ export {
|
|
|
514
514
|
tableEntry,
|
|
515
515
|
isTerminal
|
|
516
516
|
};
|
|
517
|
-
//# sourceMappingURL=chunk-
|
|
517
|
+
//# sourceMappingURL=chunk-7KI7DJZ2.mjs.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/providers/moonpay.ts
|
|
2
|
+
var MOONPAY_ENDPOINTS = {
|
|
3
|
+
start: "POST /fiat/providers/moonpay/start",
|
|
4
|
+
intent: "POST /fiat/providers/moonpay/intent",
|
|
5
|
+
kyc: "POST /fiat/providers/moonpay/kyc",
|
|
6
|
+
complete: "POST /fiat/providers/moonpay/complete"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
MOONPAY_ENDPOINTS
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-YWKS7MMT.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,7 @@ export * from './codes';
|
|
|
10
10
|
export * from './schemas';
|
|
11
11
|
export * from './table';
|
|
12
12
|
export * from './assert';
|
|
13
|
+
export * from './providers/moonpay';
|
|
14
|
+
export * from './providers/moonpay.schemas';
|
|
13
15
|
export { FIXTURES, FIXTURE_COVERAGE_GAPS, fixtureMeta, loadFixture, loadFixtures, type FixtureMeta, type FixtureSource, type LoadedFixture, } from './fixtures/index';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,18 @@ __export(index_exports, {
|
|
|
59
59
|
KycInputRequiredStateSchema: () => KycInputRequiredStateSchema,
|
|
60
60
|
KycNoActionRequiredStateSchema: () => KycNoActionRequiredStateSchema,
|
|
61
61
|
KycSdkResultReportSchema: () => KycSdkResultReportSchema,
|
|
62
|
+
MOONPAY_ENDPOINTS: () => MOONPAY_ENDPOINTS,
|
|
63
|
+
MoonPayCompleteRequestSchema: () => MoonPayCompleteRequestSchema,
|
|
64
|
+
MoonPayCompleteResponseSchema: () => MoonPayCompleteResponseSchema,
|
|
65
|
+
MoonPayErrorBodySchema: () => MoonPayErrorBodySchema,
|
|
66
|
+
MoonPayFaultSchema: () => MoonPayFaultSchema,
|
|
67
|
+
MoonPayIntentRequestSchema: () => MoonPayIntentRequestSchema,
|
|
68
|
+
MoonPayIntentResponseSchema: () => MoonPayIntentResponseSchema,
|
|
69
|
+
MoonPayKycRequestSchema: () => MoonPayKycRequestSchema,
|
|
70
|
+
MoonPayKycResponseSchema: () => MoonPayKycResponseSchema,
|
|
71
|
+
MoonPayStandingSchema: () => MoonPayStandingSchema,
|
|
72
|
+
MoonPayStartRequestSchema: () => MoonPayStartRequestSchema,
|
|
73
|
+
MoonPayStartResponseSchema: () => MoonPayStartResponseSchema,
|
|
62
74
|
OrderAwaitingConfirmationStateSchema: () => OrderAwaitingConfirmationStateSchema,
|
|
63
75
|
OrderCreatedStateSchema: () => OrderCreatedStateSchema,
|
|
64
76
|
OrderRefSchema: () => OrderRefSchema,
|
|
@@ -67,9 +79,11 @@ __export(index_exports, {
|
|
|
67
79
|
PAYMENT_METHOD_CATEGORIES: () => PAYMENT_METHOD_CATEGORIES,
|
|
68
80
|
PaymentCaptureStateSchema: () => PaymentCaptureStateSchema,
|
|
69
81
|
PaymentInstructStateSchema: () => PaymentInstructStateSchema,
|
|
82
|
+
PaymentSurfaceSchema: () => PaymentSurfaceSchema,
|
|
70
83
|
PendingOrderStateSchema: () => PendingOrderStateSchema,
|
|
71
84
|
PollSpecSchema: () => PollSpecSchema,
|
|
72
85
|
PreferredIdentityDocumentSchema: () => PreferredIdentityDocumentSchema,
|
|
86
|
+
PreparedPaymentSchema: () => PreparedPaymentSchema,
|
|
73
87
|
QuoteLimitRangeSchema: () => QuoteLimitRangeSchema,
|
|
74
88
|
QuoteLimitsSchema: () => QuoteLimitsSchema,
|
|
75
89
|
QuoteSchema: () => QuoteSchema,
|
|
@@ -671,6 +685,13 @@ var $surface = import_zod.z.union([
|
|
|
671
685
|
})
|
|
672
686
|
]);
|
|
673
687
|
var SurfaceSchema = $surface;
|
|
688
|
+
var $paymentSurface = obj({
|
|
689
|
+
...$surfaceBase,
|
|
690
|
+
kind: import_zod.z.enum(["URL_REDIRECT", "PCI_COMPONENT", "PAY_SHEET", "ACH_COMPONENT"]),
|
|
691
|
+
provider: $provider,
|
|
692
|
+
delivery: $clientExecutedDelivery.optional()
|
|
693
|
+
});
|
|
694
|
+
var PaymentSurfaceSchema = $paymentSurface;
|
|
674
695
|
var $instructionField = obj({
|
|
675
696
|
id: import_zod.z.string(),
|
|
676
697
|
labelFallback: import_zod.z.string(),
|
|
@@ -798,6 +819,11 @@ var $kycSdkResult = import_zod.z.union([
|
|
|
798
819
|
obj({ outcome: import_zod.z.literal("FAILED"), errorType: import_zod.z.string().trim().min(1) })
|
|
799
820
|
]);
|
|
800
821
|
var KycSdkResultReportSchema = $kycSdkResult;
|
|
822
|
+
var $clientSurfaceTransition = obj({
|
|
823
|
+
id: import_zod.z.string(),
|
|
824
|
+
mode: import_zod.z.literal("CLIENT_SURFACE"),
|
|
825
|
+
report: $reportSpec
|
|
826
|
+
});
|
|
801
827
|
var $transition = import_zod.z.union([
|
|
802
828
|
obj({
|
|
803
829
|
id: import_zod.z.string(),
|
|
@@ -808,9 +834,15 @@ var $transition = import_zod.z.union([
|
|
|
808
834
|
labelFallback: import_zod.z.string().optional()
|
|
809
835
|
}),
|
|
810
836
|
obj({ id: import_zod.z.string(), mode: import_zod.z.literal("AWAIT"), poll: $pollSpec }),
|
|
811
|
-
|
|
837
|
+
$clientSurfaceTransition
|
|
812
838
|
]);
|
|
813
839
|
var TransitionSchema = $transition;
|
|
840
|
+
var $preparedPayment = obj({
|
|
841
|
+
quoteRef: import_zod.z.string().trim().min(1),
|
|
842
|
+
surface: $paymentSurface,
|
|
843
|
+
transition: $clientSurfaceTransition
|
|
844
|
+
});
|
|
845
|
+
var PreparedPaymentSchema = $preparedPayment;
|
|
814
846
|
var $authChallenge = import_zod.z.record(import_zod.z.string(), JsonSchema);
|
|
815
847
|
var AuthChallengeSchema = $authChallenge;
|
|
816
848
|
var $quoteState = obj({
|
|
@@ -937,6 +969,8 @@ var $providerBoundStepResponse = obj({
|
|
|
937
969
|
state: $providerBoundFlowState,
|
|
938
970
|
provider: $provider,
|
|
939
971
|
transitions: import_zod.z.array($transition),
|
|
972
|
+
preparedPayment: $preparedPayment.optional(),
|
|
973
|
+
handoff: obj({ provider: $provider }).optional(),
|
|
940
974
|
routingSessionRef: import_zod.z.string().optional(),
|
|
941
975
|
providerAuthToken: obj({
|
|
942
976
|
clientSecret: import_zod.z.string(),
|
|
@@ -944,6 +978,35 @@ var $providerBoundStepResponse = obj({
|
|
|
944
978
|
}).optional(),
|
|
945
979
|
orderId: import_zod.z.string().optional(),
|
|
946
980
|
refreshLimits: import_zod.z.literal(true).optional()
|
|
981
|
+
}).superRefine((response, context) => {
|
|
982
|
+
if (response.preparedPayment !== void 0 && response.preparedPayment.surface.provider !== response.provider) {
|
|
983
|
+
context.addIssue({
|
|
984
|
+
code: "custom",
|
|
985
|
+
path: ["preparedPayment", "surface", "provider"],
|
|
986
|
+
message: "preparedPayment.surface.provider must match the response provider"
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
if (response.handoff !== void 0 && response.handoff.provider !== response.provider) {
|
|
990
|
+
context.addIssue({
|
|
991
|
+
code: "custom",
|
|
992
|
+
path: ["handoff", "provider"],
|
|
993
|
+
message: "handoff.provider must match the response provider"
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
if (response.handoff !== void 0 && response.state.kind !== "QUOTE") {
|
|
997
|
+
context.addIssue({
|
|
998
|
+
code: "custom",
|
|
999
|
+
path: ["handoff"],
|
|
1000
|
+
message: "only a QUOTE response hands off to a provider"
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
if (response.handoff !== void 0 && response.transitions.length > 0) {
|
|
1004
|
+
context.addIssue({
|
|
1005
|
+
code: "custom",
|
|
1006
|
+
path: ["transitions"],
|
|
1007
|
+
message: "a handoff response carries no transitions"
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
947
1010
|
});
|
|
948
1011
|
var $blockedStepResponse = obj({
|
|
949
1012
|
state: $blockedState,
|
|
@@ -961,7 +1024,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
|
|
|
961
1024
|
var FiatStepResponseSchema = $stepResponse;
|
|
962
1025
|
|
|
963
1026
|
// package.json
|
|
964
|
-
var version = "0.
|
|
1027
|
+
var version = "0.18.0";
|
|
965
1028
|
|
|
966
1029
|
// src/table.ts
|
|
967
1030
|
var TABLE_VERSION = version;
|
|
@@ -2526,4 +2589,75 @@ function assertFixture(id) {
|
|
|
2526
2589
|
function assertAllFixtures() {
|
|
2527
2590
|
return FIXTURES.map((meta) => assertFixture(meta.id));
|
|
2528
2591
|
}
|
|
2592
|
+
|
|
2593
|
+
// src/providers/moonpay.ts
|
|
2594
|
+
var MOONPAY_ENDPOINTS = {
|
|
2595
|
+
start: "POST /fiat/providers/moonpay/start",
|
|
2596
|
+
intent: "POST /fiat/providers/moonpay/intent",
|
|
2597
|
+
kyc: "POST /fiat/providers/moonpay/kyc",
|
|
2598
|
+
complete: "POST /fiat/providers/moonpay/complete"
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2601
|
+
// src/providers/moonpay.schemas.ts
|
|
2602
|
+
var import_zod2 = require("zod");
|
|
2603
|
+
var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
|
|
2604
|
+
var obj2 = (shape) => import_zod2.z.object(shape).strict();
|
|
2605
|
+
var $nonEmpty = import_zod2.z.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
2606
|
+
var $startRequest = obj2({
|
|
2607
|
+
amount: FiatAmountSchema,
|
|
2608
|
+
destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
|
|
2609
|
+
paymentMethod: import_zod2.z.literal("apple_pay"),
|
|
2610
|
+
geo: obj2({ alpha2: import_zod2.z.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() }),
|
|
2611
|
+
termsAcceptance: obj2({ version: $nonEmpty, acceptedAt: import_zod2.z.string().datetime({ offset: true }) })
|
|
2612
|
+
});
|
|
2613
|
+
var MoonPayStartRequestSchema = $startRequest;
|
|
2614
|
+
var $quoteInput = obj2({
|
|
2615
|
+
source: obj2({ asset: obj2({ code: import_zod2.z.enum(FIAT_CURRENCY_CODES2) }), amount: $nonEmpty }),
|
|
2616
|
+
destination: obj2({ asset: obj2({ code: $nonEmpty }) }),
|
|
2617
|
+
wallet: obj2({ address: $nonEmpty }),
|
|
2618
|
+
paymentMethod: obj2({ type: import_zod2.z.literal("apple_pay") }),
|
|
2619
|
+
feeBehavior: import_zod2.z.literal("inclusive")
|
|
2620
|
+
});
|
|
2621
|
+
var $startResponse = obj2({ sessionToken: $nonEmpty, quoteInput: $quoteInput });
|
|
2622
|
+
var MoonPayStartResponseSchema = $startResponse;
|
|
2623
|
+
var $intentRequest = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
2624
|
+
var MoonPayIntentRequestSchema = $intentRequest;
|
|
2625
|
+
var $refusal = import_zod2.z.enum(["DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
|
|
2626
|
+
var $standing = import_zod2.z.discriminatedUnion("status", [
|
|
2627
|
+
obj2({ status: import_zod2.z.literal("READY"), orderId: $nonEmpty }),
|
|
2628
|
+
obj2({ status: import_zod2.z.literal("KYC"), form: FormDescriptorSchema }),
|
|
2629
|
+
obj2({ status: import_zod2.z.literal("PENDING"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) }),
|
|
2630
|
+
obj2({ status: import_zod2.z.literal("REFUSED"), reason: $refusal, recovery: import_zod2.z.enum(["REQUOTE", "NONE"]) })
|
|
2631
|
+
]);
|
|
2632
|
+
var MoonPayStandingSchema = $standing;
|
|
2633
|
+
var MoonPayIntentResponseSchema = $standing;
|
|
2634
|
+
var $kycRequest = obj2({ formId: $nonEmpty, values: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string()) });
|
|
2635
|
+
var MoonPayKycRequestSchema = $kycRequest;
|
|
2636
|
+
var $kycResponse = obj2({ status: import_zod2.z.literal("ACCEPTED") });
|
|
2637
|
+
var MoonPayKycResponseSchema = $kycResponse;
|
|
2638
|
+
var $completeRequest = obj2({ orderId: $nonEmpty, transactionId: $nonEmpty });
|
|
2639
|
+
var MoonPayCompleteRequestSchema = $completeRequest;
|
|
2640
|
+
var MoonPayCompleteResponseSchema = FiatStepResponseSchema;
|
|
2641
|
+
var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
|
|
2642
|
+
var $faultFields = {
|
|
2643
|
+
reason: import_zod2.z.enum([
|
|
2644
|
+
"NOT_ELIGIBLE",
|
|
2645
|
+
"SESSION_BUDGET_SPENT",
|
|
2646
|
+
"PROVIDER_UNAVAILABLE",
|
|
2647
|
+
"INVALID_VALUE",
|
|
2648
|
+
"STALE_FORM",
|
|
2649
|
+
"TRANSACTION_NOT_VISIBLE",
|
|
2650
|
+
"WALLET_MISMATCH"
|
|
2651
|
+
]),
|
|
2652
|
+
recovery: import_zod2.z.enum(["RETRY", "REFRESH", "REQUOTE", "NONE"]),
|
|
2653
|
+
fields: import_zod2.z.array($fieldError).min(1).optional()
|
|
2654
|
+
};
|
|
2655
|
+
var fieldsOnlyOnInvalidValue = (fault) => fault.reason === "INVALID_VALUE" === (fault.fields !== void 0);
|
|
2656
|
+
var $fault = obj2($faultFields).refine(fieldsOnlyOnInvalidValue, "fields is present exactly when reason is INVALID_VALUE");
|
|
2657
|
+
var MoonPayFaultSchema = $fault;
|
|
2658
|
+
var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: import_zod2.z.string(), reqId: import_zod2.z.string().optional() }).refine(
|
|
2659
|
+
fieldsOnlyOnInvalidValue,
|
|
2660
|
+
"fields is present exactly when reason is INVALID_VALUE"
|
|
2661
|
+
);
|
|
2662
|
+
var MoonPayErrorBodySchema = $errorBody;
|
|
2529
2663
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,10 @@ import {
|
|
|
12
12
|
tableEntry,
|
|
13
13
|
unofferedEndpoints,
|
|
14
14
|
unreachableStates
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7KI7DJZ2.mjs";
|
|
16
|
+
import {
|
|
17
|
+
MOONPAY_ENDPOINTS
|
|
18
|
+
} from "./chunk-YWKS7MMT.mjs";
|
|
16
19
|
|
|
17
20
|
// src/codes.ts
|
|
18
21
|
var US_STATE_CODES = [
|
|
@@ -568,6 +571,13 @@ var $surface = z.union([
|
|
|
568
571
|
})
|
|
569
572
|
]);
|
|
570
573
|
var SurfaceSchema = $surface;
|
|
574
|
+
var $paymentSurface = obj({
|
|
575
|
+
...$surfaceBase,
|
|
576
|
+
kind: z.enum(["URL_REDIRECT", "PCI_COMPONENT", "PAY_SHEET", "ACH_COMPONENT"]),
|
|
577
|
+
provider: $provider,
|
|
578
|
+
delivery: $clientExecutedDelivery.optional()
|
|
579
|
+
});
|
|
580
|
+
var PaymentSurfaceSchema = $paymentSurface;
|
|
571
581
|
var $instructionField = obj({
|
|
572
582
|
id: z.string(),
|
|
573
583
|
labelFallback: z.string(),
|
|
@@ -695,6 +705,11 @@ var $kycSdkResult = z.union([
|
|
|
695
705
|
obj({ outcome: z.literal("FAILED"), errorType: z.string().trim().min(1) })
|
|
696
706
|
]);
|
|
697
707
|
var KycSdkResultReportSchema = $kycSdkResult;
|
|
708
|
+
var $clientSurfaceTransition = obj({
|
|
709
|
+
id: z.string(),
|
|
710
|
+
mode: z.literal("CLIENT_SURFACE"),
|
|
711
|
+
report: $reportSpec
|
|
712
|
+
});
|
|
698
713
|
var $transition = z.union([
|
|
699
714
|
obj({
|
|
700
715
|
id: z.string(),
|
|
@@ -705,9 +720,15 @@ var $transition = z.union([
|
|
|
705
720
|
labelFallback: z.string().optional()
|
|
706
721
|
}),
|
|
707
722
|
obj({ id: z.string(), mode: z.literal("AWAIT"), poll: $pollSpec }),
|
|
708
|
-
|
|
723
|
+
$clientSurfaceTransition
|
|
709
724
|
]);
|
|
710
725
|
var TransitionSchema = $transition;
|
|
726
|
+
var $preparedPayment = obj({
|
|
727
|
+
quoteRef: z.string().trim().min(1),
|
|
728
|
+
surface: $paymentSurface,
|
|
729
|
+
transition: $clientSurfaceTransition
|
|
730
|
+
});
|
|
731
|
+
var PreparedPaymentSchema = $preparedPayment;
|
|
711
732
|
var $authChallenge = z.record(z.string(), JsonSchema);
|
|
712
733
|
var AuthChallengeSchema = $authChallenge;
|
|
713
734
|
var $quoteState = obj({
|
|
@@ -834,6 +855,8 @@ var $providerBoundStepResponse = obj({
|
|
|
834
855
|
state: $providerBoundFlowState,
|
|
835
856
|
provider: $provider,
|
|
836
857
|
transitions: z.array($transition),
|
|
858
|
+
preparedPayment: $preparedPayment.optional(),
|
|
859
|
+
handoff: obj({ provider: $provider }).optional(),
|
|
837
860
|
routingSessionRef: z.string().optional(),
|
|
838
861
|
providerAuthToken: obj({
|
|
839
862
|
clientSecret: z.string(),
|
|
@@ -841,6 +864,35 @@ var $providerBoundStepResponse = obj({
|
|
|
841
864
|
}).optional(),
|
|
842
865
|
orderId: z.string().optional(),
|
|
843
866
|
refreshLimits: z.literal(true).optional()
|
|
867
|
+
}).superRefine((response, context) => {
|
|
868
|
+
if (response.preparedPayment !== void 0 && response.preparedPayment.surface.provider !== response.provider) {
|
|
869
|
+
context.addIssue({
|
|
870
|
+
code: "custom",
|
|
871
|
+
path: ["preparedPayment", "surface", "provider"],
|
|
872
|
+
message: "preparedPayment.surface.provider must match the response provider"
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
if (response.handoff !== void 0 && response.handoff.provider !== response.provider) {
|
|
876
|
+
context.addIssue({
|
|
877
|
+
code: "custom",
|
|
878
|
+
path: ["handoff", "provider"],
|
|
879
|
+
message: "handoff.provider must match the response provider"
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
if (response.handoff !== void 0 && response.state.kind !== "QUOTE") {
|
|
883
|
+
context.addIssue({
|
|
884
|
+
code: "custom",
|
|
885
|
+
path: ["handoff"],
|
|
886
|
+
message: "only a QUOTE response hands off to a provider"
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
if (response.handoff !== void 0 && response.transitions.length > 0) {
|
|
890
|
+
context.addIssue({
|
|
891
|
+
code: "custom",
|
|
892
|
+
path: ["transitions"],
|
|
893
|
+
message: "a handoff response carries no transitions"
|
|
894
|
+
});
|
|
895
|
+
}
|
|
844
896
|
});
|
|
845
897
|
var $blockedStepResponse = obj({
|
|
846
898
|
state: $blockedState,
|
|
@@ -1921,6 +1973,69 @@ function assertFixture(id) {
|
|
|
1921
1973
|
function assertAllFixtures() {
|
|
1922
1974
|
return FIXTURES.map((meta) => assertFixture(meta.id));
|
|
1923
1975
|
}
|
|
1976
|
+
|
|
1977
|
+
// src/providers/moonpay.schemas.ts
|
|
1978
|
+
import { z as z2 } from "zod";
|
|
1979
|
+
var FIAT_CURRENCY_CODES2 = Object.keys(FIAT_CURRENCY_NAMES);
|
|
1980
|
+
var obj2 = (shape) => z2.object(shape).strict();
|
|
1981
|
+
var $nonEmpty = z2.string().refine((value) => value.trim().length > 0, "must not be blank");
|
|
1982
|
+
var $startRequest = obj2({
|
|
1983
|
+
amount: FiatAmountSchema,
|
|
1984
|
+
destination: obj2({ asset: $nonEmpty, network: $nonEmpty }),
|
|
1985
|
+
paymentMethod: z2.literal("apple_pay"),
|
|
1986
|
+
geo: obj2({ alpha2: z2.string().regex(/^[A-Z]{2}$/), region: $nonEmpty.optional(), ip: $nonEmpty.optional() }),
|
|
1987
|
+
termsAcceptance: obj2({ version: $nonEmpty, acceptedAt: z2.string().datetime({ offset: true }) })
|
|
1988
|
+
});
|
|
1989
|
+
var MoonPayStartRequestSchema = $startRequest;
|
|
1990
|
+
var $quoteInput = obj2({
|
|
1991
|
+
source: obj2({ asset: obj2({ code: z2.enum(FIAT_CURRENCY_CODES2) }), amount: $nonEmpty }),
|
|
1992
|
+
destination: obj2({ asset: obj2({ code: $nonEmpty }) }),
|
|
1993
|
+
wallet: obj2({ address: $nonEmpty }),
|
|
1994
|
+
paymentMethod: obj2({ type: z2.literal("apple_pay") }),
|
|
1995
|
+
feeBehavior: z2.literal("inclusive")
|
|
1996
|
+
});
|
|
1997
|
+
var $startResponse = obj2({ sessionToken: $nonEmpty, quoteInput: $quoteInput });
|
|
1998
|
+
var MoonPayStartResponseSchema = $startResponse;
|
|
1999
|
+
var $intentRequest = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
2000
|
+
var MoonPayIntentRequestSchema = $intentRequest;
|
|
2001
|
+
var $refusal = z2.enum(["DOCUMENTS_REQUIRED", "FINAL_REJECTION", "CUSTOMER_MISMATCH"]);
|
|
2002
|
+
var $standing = z2.discriminatedUnion("status", [
|
|
2003
|
+
obj2({ status: z2.literal("READY"), orderId: $nonEmpty }),
|
|
2004
|
+
obj2({ status: z2.literal("KYC"), form: FormDescriptorSchema }),
|
|
2005
|
+
obj2({ status: z2.literal("PENDING"), retryAfterMs: z2.number().int().positive().max(6e4) }),
|
|
2006
|
+
obj2({ status: z2.literal("REFUSED"), reason: $refusal, recovery: z2.enum(["REQUOTE", "NONE"]) })
|
|
2007
|
+
]);
|
|
2008
|
+
var MoonPayStandingSchema = $standing;
|
|
2009
|
+
var MoonPayIntentResponseSchema = $standing;
|
|
2010
|
+
var $kycRequest = obj2({ formId: $nonEmpty, values: z2.record(z2.string(), z2.string()) });
|
|
2011
|
+
var MoonPayKycRequestSchema = $kycRequest;
|
|
2012
|
+
var $kycResponse = obj2({ status: z2.literal("ACCEPTED") });
|
|
2013
|
+
var MoonPayKycResponseSchema = $kycResponse;
|
|
2014
|
+
var $completeRequest = obj2({ orderId: $nonEmpty, transactionId: $nonEmpty });
|
|
2015
|
+
var MoonPayCompleteRequestSchema = $completeRequest;
|
|
2016
|
+
var MoonPayCompleteResponseSchema = FiatStepResponseSchema;
|
|
2017
|
+
var $fieldError = obj2({ fieldId: $nonEmpty, message: $nonEmpty });
|
|
2018
|
+
var $faultFields = {
|
|
2019
|
+
reason: z2.enum([
|
|
2020
|
+
"NOT_ELIGIBLE",
|
|
2021
|
+
"SESSION_BUDGET_SPENT",
|
|
2022
|
+
"PROVIDER_UNAVAILABLE",
|
|
2023
|
+
"INVALID_VALUE",
|
|
2024
|
+
"STALE_FORM",
|
|
2025
|
+
"TRANSACTION_NOT_VISIBLE",
|
|
2026
|
+
"WALLET_MISMATCH"
|
|
2027
|
+
]),
|
|
2028
|
+
recovery: z2.enum(["RETRY", "REFRESH", "REQUOTE", "NONE"]),
|
|
2029
|
+
fields: z2.array($fieldError).min(1).optional()
|
|
2030
|
+
};
|
|
2031
|
+
var fieldsOnlyOnInvalidValue = (fault) => fault.reason === "INVALID_VALUE" === (fault.fields !== void 0);
|
|
2032
|
+
var $fault = obj2($faultFields).refine(fieldsOnlyOnInvalidValue, "fields is present exactly when reason is INVALID_VALUE");
|
|
2033
|
+
var MoonPayFaultSchema = $fault;
|
|
2034
|
+
var $errorBody = obj2({ ...$faultFields, errorCode: $nonEmpty, errorMsg: z2.string(), reqId: z2.string().optional() }).refine(
|
|
2035
|
+
fieldsOnlyOnInvalidValue,
|
|
2036
|
+
"fields is present exactly when reason is INVALID_VALUE"
|
|
2037
|
+
);
|
|
2038
|
+
var MoonPayErrorBodySchema = $errorBody;
|
|
1924
2039
|
export {
|
|
1925
2040
|
AuthChallengeSchema,
|
|
1926
2041
|
BlockedReasonSchema,
|
|
@@ -1961,6 +2076,18 @@ export {
|
|
|
1961
2076
|
KycInputRequiredStateSchema,
|
|
1962
2077
|
KycNoActionRequiredStateSchema,
|
|
1963
2078
|
KycSdkResultReportSchema,
|
|
2079
|
+
MOONPAY_ENDPOINTS,
|
|
2080
|
+
MoonPayCompleteRequestSchema,
|
|
2081
|
+
MoonPayCompleteResponseSchema,
|
|
2082
|
+
MoonPayErrorBodySchema,
|
|
2083
|
+
MoonPayFaultSchema,
|
|
2084
|
+
MoonPayIntentRequestSchema,
|
|
2085
|
+
MoonPayIntentResponseSchema,
|
|
2086
|
+
MoonPayKycRequestSchema,
|
|
2087
|
+
MoonPayKycResponseSchema,
|
|
2088
|
+
MoonPayStandingSchema,
|
|
2089
|
+
MoonPayStartRequestSchema,
|
|
2090
|
+
MoonPayStartResponseSchema,
|
|
1964
2091
|
OrderAwaitingConfirmationStateSchema,
|
|
1965
2092
|
OrderCreatedStateSchema,
|
|
1966
2093
|
OrderRefSchema,
|
|
@@ -1969,9 +2096,11 @@ export {
|
|
|
1969
2096
|
PAYMENT_METHOD_CATEGORIES,
|
|
1970
2097
|
PaymentCaptureStateSchema,
|
|
1971
2098
|
PaymentInstructStateSchema,
|
|
2099
|
+
PaymentSurfaceSchema,
|
|
1972
2100
|
PendingOrderStateSchema,
|
|
1973
2101
|
PollSpecSchema,
|
|
1974
2102
|
PreferredIdentityDocumentSchema,
|
|
2103
|
+
PreparedPaymentSchema,
|
|
1975
2104
|
QuoteLimitRangeSchema,
|
|
1976
2105
|
QuoteLimitsSchema,
|
|
1977
2106
|
QuoteSchema,
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MoonPay provider-owned flow: `POST /fiat/providers/moonpay/{start,intent,kyc,complete}`.
|
|
3
|
+
*
|
|
4
|
+
* Only `intent` decides what happens next. `kyc` confirms a write or rejects it with field errors,
|
|
5
|
+
* and the client then calls `intent` again. Identity and the deposit wallet always come from the
|
|
6
|
+
* verified partner assertion, never from a request body.
|
|
7
|
+
*
|
|
8
|
+
* A fault is a 4xx/5xx whose body is the shared error body plus `MoonPayFault`. A decision the user
|
|
9
|
+
* can act on is a 200 `MoonPayStanding`.
|
|
10
|
+
*
|
|
11
|
+
* Zero runtime dependencies, so production React Native code can import it. The zod schemas are in
|
|
12
|
+
* `./moonpay.schemas`, exported from the package root.
|
|
13
|
+
*/
|
|
14
|
+
import type { FiatCurrencyCode } from '../codes';
|
|
15
|
+
import type { FiatAmount, FiatStepResponse, FormDescriptor, TermsAcceptance } from '../types';
|
|
16
|
+
export declare const MOONPAY_ENDPOINTS: {
|
|
17
|
+
readonly start: "POST /fiat/providers/moonpay/start";
|
|
18
|
+
readonly intent: "POST /fiat/providers/moonpay/intent";
|
|
19
|
+
readonly kyc: "POST /fiat/providers/moonpay/kyc";
|
|
20
|
+
readonly complete: "POST /fiat/providers/moonpay/complete";
|
|
21
|
+
};
|
|
22
|
+
export interface MoonPayStartRequest {
|
|
23
|
+
amount: FiatAmount;
|
|
24
|
+
/** The quote's `crypto.currency` and `crypto.network`, unchanged. */
|
|
25
|
+
destination: {
|
|
26
|
+
asset: string;
|
|
27
|
+
network: string;
|
|
28
|
+
};
|
|
29
|
+
paymentMethod: 'apple_pay';
|
|
30
|
+
/** The geo endpoint's response, as sent to `POST /fiat/quote`. `alpha2` is ISO 3166-1 alpha-2. */
|
|
31
|
+
geo: {
|
|
32
|
+
alpha2: string;
|
|
33
|
+
region?: string;
|
|
34
|
+
ip?: string;
|
|
35
|
+
};
|
|
36
|
+
/** The MoonPay terms notice on the amount screen; the tap is the acceptance. */
|
|
37
|
+
termsAcceptance: TermsAcceptance;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The parameters for the device `client.getQuote`, not a quote. The backend builds them because the
|
|
41
|
+
* wallet must be the verified one and MoonPay's currency codes differ by environment.
|
|
42
|
+
*/
|
|
43
|
+
export interface MoonPayQuoteInput {
|
|
44
|
+
source: {
|
|
45
|
+
asset: {
|
|
46
|
+
code: FiatCurrencyCode;
|
|
47
|
+
};
|
|
48
|
+
amount: string;
|
|
49
|
+
};
|
|
50
|
+
destination: {
|
|
51
|
+
asset: {
|
|
52
|
+
code: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
wallet: {
|
|
56
|
+
address: string;
|
|
57
|
+
};
|
|
58
|
+
paymentMethod: {
|
|
59
|
+
type: 'apple_pay';
|
|
60
|
+
};
|
|
61
|
+
feeBehavior: 'inclusive';
|
|
62
|
+
}
|
|
63
|
+
export interface MoonPayStartResponse {
|
|
64
|
+
/** The one SDK session, for the connection check, the auth frames, and the Apple Pay button. */
|
|
65
|
+
sessionToken: string;
|
|
66
|
+
quoteInput: MoonPayQuoteInput;
|
|
67
|
+
}
|
|
68
|
+
export interface MoonPayIntentRequest {
|
|
69
|
+
/** From the SDK's `active` connection. */
|
|
70
|
+
customerId: string;
|
|
71
|
+
/** From the SDK's `active` connection. A credential: the backend strips it from every log. */
|
|
72
|
+
accessToken: string;
|
|
73
|
+
}
|
|
74
|
+
export type MoonPayRefusal = 'DOCUMENTS_REQUIRED' | 'FINAL_REJECTION' | 'CUSTOMER_MISMATCH';
|
|
75
|
+
export type MoonPayStanding =
|
|
76
|
+
/** `orderId` is the `externalTransactionId` for the Apple Pay button. */
|
|
77
|
+
{
|
|
78
|
+
status: 'READY';
|
|
79
|
+
orderId: string;
|
|
80
|
+
} | {
|
|
81
|
+
status: 'KYC';
|
|
82
|
+
form: FormDescriptor;
|
|
83
|
+
} | {
|
|
84
|
+
status: 'PENDING';
|
|
85
|
+
retryAfterMs: number;
|
|
86
|
+
} | {
|
|
87
|
+
status: 'REFUSED';
|
|
88
|
+
reason: MoonPayRefusal;
|
|
89
|
+
recovery: 'REQUOTE' | 'NONE';
|
|
90
|
+
};
|
|
91
|
+
export type MoonPayIntentResponse = MoonPayStanding;
|
|
92
|
+
export interface MoonPayKycRequest {
|
|
93
|
+
/** From the `KYC` standing. A stale one is a 409 `STALE_FORM` with recovery `REFRESH`. */
|
|
94
|
+
formId: string;
|
|
95
|
+
/** One string per form field id. */
|
|
96
|
+
values: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
/** The write landed. The client calls `intent` next. */
|
|
99
|
+
export interface MoonPayKycResponse {
|
|
100
|
+
status: 'ACCEPTED';
|
|
101
|
+
}
|
|
102
|
+
export interface MoonPayCompleteRequest {
|
|
103
|
+
orderId: string;
|
|
104
|
+
/** From the Apple Pay completion event. */
|
|
105
|
+
transactionId: string;
|
|
106
|
+
}
|
|
107
|
+
/** The same response as `GET /fiat/orders/:orderId`, so the shared order screen renders it. */
|
|
108
|
+
export type MoonPayCompleteResponse = FiatStepResponse;
|
|
109
|
+
/**
|
|
110
|
+
* `RETRY` sends the same request again. `REFRESH` calls `intent` for a new standing. `REQUOTE` goes
|
|
111
|
+
* back to `POST /fiat/quote`. `NONE` ends the flow.
|
|
112
|
+
*/
|
|
113
|
+
export type MoonPayRecovery = 'RETRY' | 'REFRESH' | 'REQUOTE' | 'NONE';
|
|
114
|
+
export type MoonPayFaultReason = 'NOT_ELIGIBLE' | 'SESSION_BUDGET_SPENT' | 'PROVIDER_UNAVAILABLE' | 'INVALID_VALUE' | 'STALE_FORM' | 'TRANSACTION_NOT_VISIBLE' | 'WALLET_MISMATCH';
|
|
115
|
+
export interface MoonPayFieldError {
|
|
116
|
+
fieldId: string;
|
|
117
|
+
message: string;
|
|
118
|
+
}
|
|
119
|
+
/** The fields a MoonPay route adds to the shared error body. `fields` is only on `INVALID_VALUE`. */
|
|
120
|
+
export interface MoonPayFault {
|
|
121
|
+
reason: MoonPayFaultReason;
|
|
122
|
+
recovery: MoonPayRecovery;
|
|
123
|
+
fields?: MoonPayFieldError[];
|
|
124
|
+
}
|
|
125
|
+
/** A MoonPay route's 4xx/5xx body: the shared error body plus `MoonPayFault`. */
|
|
126
|
+
export type MoonPayErrorBody = MoonPayFault & {
|
|
127
|
+
errorCode: string;
|
|
128
|
+
errorMsg: string;
|
|
129
|
+
reqId?: string;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=moonpay.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
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/moonpay.ts
|
|
21
|
+
var moonpay_exports = {};
|
|
22
|
+
__export(moonpay_exports, {
|
|
23
|
+
MOONPAY_ENDPOINTS: () => MOONPAY_ENDPOINTS
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(moonpay_exports);
|
|
26
|
+
var MOONPAY_ENDPOINTS = {
|
|
27
|
+
start: "POST /fiat/providers/moonpay/start",
|
|
28
|
+
intent: "POST /fiat/providers/moonpay/intent",
|
|
29
|
+
kyc: "POST /fiat/providers/moonpay/kyc",
|
|
30
|
+
complete: "POST /fiat/providers/moonpay/complete"
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=moonpay.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zod schemas for the MoonPay provider-owned flow. Test-time and backend-boundary only: exported from
|
|
3
|
+
* the package root, never from `./moonpay`, so the production entry stays free of zod.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { MoonPayCompleteRequest, MoonPayCompleteResponse, MoonPayErrorBody, MoonPayFault, MoonPayIntentRequest, MoonPayIntentResponse, MoonPayKycRequest, MoonPayKycResponse, MoonPayStanding, MoonPayStartRequest, MoonPayStartResponse } from './moonpay';
|
|
7
|
+
export declare const MoonPayStartRequestSchema: z.ZodType<MoonPayStartRequest>;
|
|
8
|
+
export declare const MoonPayStartResponseSchema: z.ZodType<MoonPayStartResponse>;
|
|
9
|
+
export declare const MoonPayIntentRequestSchema: z.ZodType<MoonPayIntentRequest>;
|
|
10
|
+
export declare const MoonPayStandingSchema: z.ZodType<MoonPayStanding>;
|
|
11
|
+
export declare const MoonPayIntentResponseSchema: z.ZodType<MoonPayIntentResponse>;
|
|
12
|
+
export declare const MoonPayKycRequestSchema: z.ZodType<MoonPayKycRequest>;
|
|
13
|
+
export declare const MoonPayKycResponseSchema: z.ZodType<MoonPayKycResponse>;
|
|
14
|
+
export declare const MoonPayCompleteRequestSchema: z.ZodType<MoonPayCompleteRequest>;
|
|
15
|
+
export declare const MoonPayCompleteResponseSchema: z.ZodType<MoonPayCompleteResponse>;
|
|
16
|
+
export declare const MoonPayFaultSchema: z.ZodType<MoonPayFault>;
|
|
17
|
+
export declare const MoonPayErrorBodySchema: z.ZodType<MoonPayErrorBody>;
|
|
18
|
+
//# sourceMappingURL=moonpay.schemas.d.ts.map
|
package/dist/schemas.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { z } from 'zod';
|
|
30
30
|
import type { UsStateCode } from './codes';
|
|
31
|
-
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
|
|
31
|
+
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx } from './types';
|
|
32
32
|
export declare const JsonSchema: z.ZodType<JsonValue>;
|
|
33
33
|
export declare const HTTP_VERBS: readonly ["GET", "POST"];
|
|
34
34
|
/** `"POST /fiat/session/verify"`, `"GET /fiat/orders/o_31c"` — the verb rides the string. */
|
|
@@ -59,6 +59,7 @@ export declare const STANDARD_KYC_FIELD_IDS: readonly ["LEGAL_FIRST_NAME", "LEGA
|
|
|
59
59
|
export declare const KYC_ACKNOWLEDGEMENT_FIELD_IDS: readonly ["RISK_ACKNOWLEDGEMENT", "COOLING_OFF_ACKNOWLEDGEMENT", "TERMS_ACCEPTANCE"];
|
|
60
60
|
export declare const ClientExecutedDeliverySchema: z.ZodType<ClientExecutedDelivery>;
|
|
61
61
|
export declare const SurfaceSchema: z.ZodType<Surface>;
|
|
62
|
+
export declare const PaymentSurfaceSchema: z.ZodType<PaymentSurface>;
|
|
62
63
|
export declare const InstructionFieldSchema: z.ZodType<InstructionField>;
|
|
63
64
|
export declare const InstructionsSchema: z.ZodType<Instructions>;
|
|
64
65
|
export declare const SelectOptionSchema: z.ZodType<SelectOption>;
|
|
@@ -80,6 +81,7 @@ export declare const PollSpecSchema: z.ZodType<PollSpec>;
|
|
|
80
81
|
export declare const ReportSpecSchema: z.ZodType<ReportSpec>;
|
|
81
82
|
export declare const KycSdkResultReportSchema: z.ZodType<KycSdkResultReport>;
|
|
82
83
|
export declare const TransitionSchema: z.ZodType<Transition>;
|
|
84
|
+
export declare const PreparedPaymentSchema: z.ZodType<PreparedPayment>;
|
|
83
85
|
export declare const AuthChallengeSchema: z.ZodType<Record<string, JsonValue>>;
|
|
84
86
|
/** `Extract` keeps each per-state export pinned to the union member it validates. */
|
|
85
87
|
type State<K extends FlowState['kind'], P = never> = [P] extends [never] ? Extract<FlowState, {
|
package/dist/table.js
CHANGED
package/dist/table.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -293,6 +293,12 @@ export type Surface = (SurfaceBase & {
|
|
|
293
293
|
/** Adapter-owned submission mechanics; the shared contract declares only the safe source. */
|
|
294
294
|
delivery?: ClientExecutedDelivery;
|
|
295
295
|
});
|
|
296
|
+
/** Provider-owned surfaces that can execute a payment after the quote becomes executable. */
|
|
297
|
+
export type PaymentSurfaceKind = 'URL_REDIRECT' | 'PCI_COMPONENT' | 'PAY_SHEET' | 'ACH_COMPONENT';
|
|
298
|
+
export type PaymentSurface = Surface & {
|
|
299
|
+
kind: PaymentSurfaceKind;
|
|
300
|
+
provider: FiatProvider;
|
|
301
|
+
};
|
|
296
302
|
export interface InstructionField {
|
|
297
303
|
id: string;
|
|
298
304
|
labelFallback: string;
|
|
@@ -506,6 +512,20 @@ export type Transition = {
|
|
|
506
512
|
mode: 'CLIENT_SURFACE';
|
|
507
513
|
report: ReportSpec;
|
|
508
514
|
};
|
|
515
|
+
/**
|
|
516
|
+
* A payment surface prepared ahead of the flow state that may execute it.
|
|
517
|
+
*
|
|
518
|
+
* This is inert response metadata, not an active transition. A client may warm the surface while
|
|
519
|
+
* completing auth or KYC, but must expose or report it only after a later response makes the same
|
|
520
|
+
* quote executable. `quoteRef` is explicit so that promotion never relies on provider-owned params.
|
|
521
|
+
*/
|
|
522
|
+
export interface PreparedPayment {
|
|
523
|
+
quoteRef: string;
|
|
524
|
+
surface: PaymentSurface;
|
|
525
|
+
transition: Extract<Transition, {
|
|
526
|
+
mode: 'CLIENT_SURFACE';
|
|
527
|
+
}>;
|
|
528
|
+
}
|
|
509
529
|
/**
|
|
510
530
|
* TODO(open-decision): shape owned by the auth spike (contract §Auth & ref binding, item 5).
|
|
511
531
|
* `FUN_AUTH` never renders in fomo (identity is ambient), so nothing in either doc constrains
|
|
@@ -692,6 +712,15 @@ export type FiatStepResponse = (FiatStepResponseBase & {
|
|
|
692
712
|
kind: 'BLOCKED';
|
|
693
713
|
}>;
|
|
694
714
|
provider: FiatProvider;
|
|
715
|
+
/** Optional future payment artifact; never one of this response's currently active transitions. */
|
|
716
|
+
preparedPayment?: PreparedPayment;
|
|
717
|
+
/**
|
|
718
|
+
* The provider runs its own flow from here (`POST /fiat/providers/{provider}/…`). Present only
|
|
719
|
+
* when the request's `handoffs` named this provider; the response then carries no transitions.
|
|
720
|
+
*/
|
|
721
|
+
handoff?: {
|
|
722
|
+
provider: FiatProvider;
|
|
723
|
+
};
|
|
695
724
|
});
|
|
696
725
|
export {};
|
|
697
726
|
//# sourceMappingURL=types.d.ts.map
|
package/moonpay.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/providers/moonpay';
|
package/moonpay.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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": {
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"import": "./dist/table.mjs",
|
|
29
29
|
"require": "./dist/table.js"
|
|
30
30
|
},
|
|
31
|
+
"./moonpay": {
|
|
32
|
+
"types": "./dist/providers/moonpay.d.ts",
|
|
33
|
+
"import": "./dist/providers/moonpay.mjs",
|
|
34
|
+
"require": "./dist/providers/moonpay.js"
|
|
35
|
+
},
|
|
31
36
|
"./package.json": "./package.json"
|
|
32
37
|
},
|
|
33
38
|
"files": [
|
|
@@ -36,6 +41,8 @@
|
|
|
36
41
|
"table.d.ts",
|
|
37
42
|
"types.js",
|
|
38
43
|
"types.d.ts",
|
|
44
|
+
"moonpay.js",
|
|
45
|
+
"moonpay.d.ts",
|
|
39
46
|
"README.md",
|
|
40
47
|
"!dist/**/*.map"
|
|
41
48
|
],
|
|
@@ -75,6 +82,9 @@
|
|
|
75
82
|
],
|
|
76
83
|
"table": [
|
|
77
84
|
"./dist/table.d.ts"
|
|
85
|
+
],
|
|
86
|
+
"moonpay": [
|
|
87
|
+
"./dist/providers/moonpay.d.ts"
|
|
78
88
|
]
|
|
79
89
|
}
|
|
80
90
|
}
|