@0to1pay/fulfillment-sdk 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +20 -2
- package/dist/contracts/openapi.yaml +3862 -0
- package/dist/packages/domain/contract.d.ts +27 -0
- package/dist/packages/domain/contract.js +19 -0
- package/dist/packages/domain/shared.js +45 -0
- package/dist/packages/fulfillment-sdk/inbox.sql +59 -0
- package/dist/packages/fulfillment-sdk/index.d.ts +4 -0
- package/dist/packages/fulfillment-sdk/index.js +2 -0
- package/dist/packages/fulfillment-sdk/postgres.d.ts +69 -0
- package/dist/packages/fulfillment-sdk/postgres.js +247 -0
- package/dist/packages/fulfillment-sdk/signature.d.ts +37 -0
- package/dist/packages/fulfillment-sdk/signature.js +150 -0
- package/dist/packages/server-sdk/index.d.ts +184 -0
- package/dist/packages/server-sdk/recipient-proof.d.ts +10 -0
- package/dist/packages/server-sdk/schema.d.ts +2712 -0
- package/dist/packages/server-sdk/solana-recipient-proof.d.ts +3 -0
- package/dist/packages/server-sdk/tron-recipient-proof.d.ts +3 -0
- package/package.json +37 -4
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { components, operations } from './schema.js';
|
|
2
|
+
export type { components, operations, paths } from './schema.js';
|
|
3
|
+
export type Schema<K extends keyof components['schemas']> = components['schemas'][K];
|
|
4
|
+
type PrivateOperation = 'ingestProviderWebhook' | 'receiveStablePayEvent';
|
|
5
|
+
type OperationName = Exclude<keyof operations, PrivateOperation>;
|
|
6
|
+
type JsonContent<T> = T extends {
|
|
7
|
+
content: {
|
|
8
|
+
'application/json': infer V;
|
|
9
|
+
};
|
|
10
|
+
} ? V : never;
|
|
11
|
+
type ParametersOf<K extends OperationName> = operations[K]['parameters'];
|
|
12
|
+
type RequiredPath<K extends OperationName> = ParametersOf<K> extends {
|
|
13
|
+
path: infer V;
|
|
14
|
+
} ? {
|
|
15
|
+
path: V;
|
|
16
|
+
} : {
|
|
17
|
+
path?: never;
|
|
18
|
+
};
|
|
19
|
+
type Body<K extends OperationName> = operations[K] extends {
|
|
20
|
+
requestBody: infer V;
|
|
21
|
+
} ? {
|
|
22
|
+
body: JsonContent<V>;
|
|
23
|
+
} : {
|
|
24
|
+
body?: never;
|
|
25
|
+
};
|
|
26
|
+
type Idempotency<K extends OperationName> = ParametersOf<K> extends {
|
|
27
|
+
header: {
|
|
28
|
+
'Idempotency-Key': string;
|
|
29
|
+
};
|
|
30
|
+
} ? {
|
|
31
|
+
idempotencyKey: string;
|
|
32
|
+
} : {
|
|
33
|
+
idempotencyKey?: never;
|
|
34
|
+
};
|
|
35
|
+
type ResponseOf<K extends OperationName> = JsonContent<operations[K]['responses'][Extract<keyof operations[K]['responses'], 200 | 201 | 202>]>;
|
|
36
|
+
type OperationInput<K extends OperationName> = RequiredPath<K> & Body<K> & Idempotency<K> & {
|
|
37
|
+
query?: ParametersOf<K>['query'];
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
};
|
|
40
|
+
export declare class ZeroToOnePayError extends Error {
|
|
41
|
+
readonly status: number;
|
|
42
|
+
readonly code: string;
|
|
43
|
+
readonly requestId?: string | undefined;
|
|
44
|
+
readonly source = "stablepay";
|
|
45
|
+
constructor(status: number, code: string, requestId?: string | undefined);
|
|
46
|
+
}
|
|
47
|
+
export declare class ZeroToOnePayContractError extends Error {
|
|
48
|
+
readonly code: 'REQUEST_SCHEMA' | 'RESPONSE_SCHEMA' | 'UNRECOGNIZED_OPERATION';
|
|
49
|
+
constructor(code: 'REQUEST_SCHEMA' | 'RESPONSE_SCHEMA' | 'UNRECOGNIZED_OPERATION', detail: string);
|
|
50
|
+
}
|
|
51
|
+
export interface ZeroToOnePayClientOptions {
|
|
52
|
+
origin: string;
|
|
53
|
+
apiKey: string;
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
fetch?: typeof globalThis.fetch;
|
|
56
|
+
}
|
|
57
|
+
export declare class ZeroToOnePayClient {
|
|
58
|
+
private readonly options;
|
|
59
|
+
private readonly origin;
|
|
60
|
+
private readonly request;
|
|
61
|
+
constructor(options: ZeroToOnePayClientOptions);
|
|
62
|
+
call<K extends OperationName>(operation: K, input: OperationInput<K>): Promise<ResponseOf<K>>;
|
|
63
|
+
createPayment(body: Schema<'CreatePayment'>, idempotencyKey: string): Promise<{
|
|
64
|
+
merchant_id: string;
|
|
65
|
+
project_id: string;
|
|
66
|
+
environment: components["schemas"]["Environment"];
|
|
67
|
+
payment_id: string;
|
|
68
|
+
order_ref: string;
|
|
69
|
+
order_revision: number;
|
|
70
|
+
customer_ref: string;
|
|
71
|
+
price: components["schemas"]["Money"];
|
|
72
|
+
allowed_connections: string[];
|
|
73
|
+
policy_ref: string;
|
|
74
|
+
lifecycle: "open" | "expired" | "canceled" | "closed";
|
|
75
|
+
funding_status: "unfunded" | "partial" | "funded" | "excess";
|
|
76
|
+
verification: components["schemas"]["Verification"];
|
|
77
|
+
decision: components["schemas"]["Decision"];
|
|
78
|
+
fulfillment: components["schemas"]["FulfillmentSummary"];
|
|
79
|
+
fulfillment_spec: components["schemas"]["FulfillmentSpec"];
|
|
80
|
+
adjustments: components["schemas"]["Adjustment"][];
|
|
81
|
+
expires_at: string;
|
|
82
|
+
created_at: string;
|
|
83
|
+
updated_at: string;
|
|
84
|
+
resource_version: number;
|
|
85
|
+
}>;
|
|
86
|
+
getPayment(payment_id: string): Promise<{
|
|
87
|
+
merchant_id: string;
|
|
88
|
+
project_id: string;
|
|
89
|
+
environment: components["schemas"]["Environment"];
|
|
90
|
+
payment_id: string;
|
|
91
|
+
order_ref: string;
|
|
92
|
+
order_revision: number;
|
|
93
|
+
customer_ref: string;
|
|
94
|
+
price: components["schemas"]["Money"];
|
|
95
|
+
allowed_connections: string[];
|
|
96
|
+
policy_ref: string;
|
|
97
|
+
lifecycle: "open" | "expired" | "canceled" | "closed";
|
|
98
|
+
funding_status: "unfunded" | "partial" | "funded" | "excess";
|
|
99
|
+
verification: components["schemas"]["Verification"];
|
|
100
|
+
decision: components["schemas"]["Decision"];
|
|
101
|
+
fulfillment: components["schemas"]["FulfillmentSummary"];
|
|
102
|
+
fulfillment_spec: components["schemas"]["FulfillmentSpec"];
|
|
103
|
+
adjustments: components["schemas"]["Adjustment"][];
|
|
104
|
+
expires_at: string;
|
|
105
|
+
created_at: string;
|
|
106
|
+
updated_at: string;
|
|
107
|
+
resource_version: number;
|
|
108
|
+
}>;
|
|
109
|
+
createQuote(payment_id: string, body: Schema<'CreateQuote'>, idempotencyKey: string): Promise<{
|
|
110
|
+
merchant_id: string;
|
|
111
|
+
project_id: string;
|
|
112
|
+
environment: components["schemas"]["Environment"];
|
|
113
|
+
quote_id: string;
|
|
114
|
+
payment_id: string;
|
|
115
|
+
connection_id: string;
|
|
116
|
+
pricing_revision: number;
|
|
117
|
+
payable: components["schemas"]["Money"];
|
|
118
|
+
chain?: components["schemas"]["ChainQuoteTerms"];
|
|
119
|
+
recipient_account: string;
|
|
120
|
+
pricing_terms_hash: string;
|
|
121
|
+
expires_at: string;
|
|
122
|
+
created_at: string;
|
|
123
|
+
}>;
|
|
124
|
+
createAttempt(payment_id: string, body: Schema<'CreateAttempt'>, idempotencyKey: string): Promise<{
|
|
125
|
+
attempt: components["schemas"]["Attempt"];
|
|
126
|
+
operation: components["schemas"]["Operation"] | null;
|
|
127
|
+
}>;
|
|
128
|
+
attachExternalAttempt(payment_id: string, body: Schema<'AttachExternalAttempt'>, idempotencyKey: string): Promise<{
|
|
129
|
+
merchant_id: string;
|
|
130
|
+
project_id: string;
|
|
131
|
+
environment: components["schemas"]["Environment"];
|
|
132
|
+
attempt_id: string;
|
|
133
|
+
payment_id: string;
|
|
134
|
+
quote_id: string;
|
|
135
|
+
connection_id: string;
|
|
136
|
+
mode: "managed" | "external";
|
|
137
|
+
execution_status: "created" | "requires_action" | "processing" | "unknown" | "succeeded" | "failed" | "canceled";
|
|
138
|
+
operation_id: string | null;
|
|
139
|
+
external_resources: components["schemas"]["ExternalResource"][];
|
|
140
|
+
binding: components["schemas"]["Binding"];
|
|
141
|
+
next_action: components["schemas"]["NextAction"];
|
|
142
|
+
created_at: string;
|
|
143
|
+
updated_at: string;
|
|
144
|
+
resource_version: number;
|
|
145
|
+
}>;
|
|
146
|
+
claimFulfillment(command_id: string, body: Schema<'ClaimRequest'>, idempotencyKey: string): Promise<{
|
|
147
|
+
claim_id: string;
|
|
148
|
+
command_id: string;
|
|
149
|
+
execution_id: string;
|
|
150
|
+
decision: "execute" | "superseded" | "blocked" | "review_required" | "expired";
|
|
151
|
+
valid: boolean;
|
|
152
|
+
generation: number;
|
|
153
|
+
decision_version: number;
|
|
154
|
+
desired_version: number;
|
|
155
|
+
issued_at: string;
|
|
156
|
+
expires_at: string;
|
|
157
|
+
reason_codes: string[];
|
|
158
|
+
}>;
|
|
159
|
+
reportFulfillmentResult(command_id: string, body: Schema<'FulfillmentResultInput'>, idempotencyKey: string): Promise<{
|
|
160
|
+
result_id: string;
|
|
161
|
+
command_id: string;
|
|
162
|
+
execution_id: string;
|
|
163
|
+
result: "applied" | "noop" | "failed" | "unknown";
|
|
164
|
+
reason_code: string | null;
|
|
165
|
+
applied_version: number | null;
|
|
166
|
+
effect_reference: string | null;
|
|
167
|
+
applied_at: string | null;
|
|
168
|
+
received_at: string;
|
|
169
|
+
review_required: boolean;
|
|
170
|
+
reason_codes: string[];
|
|
171
|
+
} & ({
|
|
172
|
+
applied_version?: null;
|
|
173
|
+
effect_reference?: null;
|
|
174
|
+
applied_at?: null;
|
|
175
|
+
} | {
|
|
176
|
+
applied_version?: number;
|
|
177
|
+
effect_reference?: string;
|
|
178
|
+
applied_at?: string;
|
|
179
|
+
})>;
|
|
180
|
+
}
|
|
181
|
+
export { recipientProofMessage, type RecipientProof } from './recipient-proof.js';
|
|
182
|
+
export { solanaRecipientProofMessage } from './solana-recipient-proof.js';
|
|
183
|
+
export { tronRecipientProofMessage } from './tron-recipient-proof.js';
|
|
184
|
+
export { ZeroToOnePayClient as PaymentToFulfillmentClient, ZeroToOnePayContractError as PaymentToFulfillmentContractError, ZeroToOnePayError as PaymentToFulfillmentError, type ZeroToOnePayClientOptions as PaymentToFulfillmentClientOptions, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RecipientProof {
|
|
2
|
+
origin: string;
|
|
3
|
+
merchant_id: string;
|
|
4
|
+
project_id: string;
|
|
5
|
+
environment: 'test' | 'live';
|
|
6
|
+
connection_id: string;
|
|
7
|
+
chain_id: number;
|
|
8
|
+
address: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function recipientProofMessage(input: RecipientProof): string;
|