@zkp2p/pay-shared 0.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.
@@ -0,0 +1,370 @@
1
+ export declare const PaymentPlatform: {
2
+ readonly VENMO: "venmo";
3
+ readonly CASHAPP: "cashapp";
4
+ readonly REVOLUT: "revolut";
5
+ readonly WISE: "wise";
6
+ readonly ZELLE: "zelle";
7
+ readonly PAYPAL: "paypal";
8
+ readonly MONZO: "monzo";
9
+ readonly N26: "n26";
10
+ };
11
+ export type PaymentPlatformType = typeof PaymentPlatform[keyof typeof PaymentPlatform];
12
+ export declare const SupportedChains: Record<number, string>;
13
+ export type SupportedChainId = keyof typeof SupportedChains;
14
+ export declare const CheckoutMode: {
15
+ readonly EXACT_TOKEN: "exact-token";
16
+ readonly EXACT_FIAT: "exact-fiat";
17
+ };
18
+ export type CheckoutModeType = typeof CheckoutMode[keyof typeof CheckoutMode];
19
+ export declare const OrderStatus: {
20
+ readonly SIGNAL_SUBMITTED: "SIGNAL_SUBMITTED";
21
+ readonly SIGNAL_MINED: "SIGNAL_MINED";
22
+ readonly PAYMENT_SENT: "PAYMENT_SENT";
23
+ readonly PROOF_VERIFIED: "PROOF_VERIFIED";
24
+ readonly FULFILL_SUBMITTED: "FULFILL_SUBMITTED";
25
+ readonly FULFILLED: "FULFILLED";
26
+ readonly CANCELLED: "CANCELLED";
27
+ readonly EXPIRED: "EXPIRED";
28
+ readonly FAILED: "FAILED";
29
+ };
30
+ export type OrderStatusType = typeof OrderStatus[keyof typeof OrderStatus];
31
+ export declare const ProofAttemptStatus: {
32
+ readonly PENDING: "PENDING";
33
+ readonly VERIFYING: "VERIFYING";
34
+ readonly VERIFIED: "VERIFIED";
35
+ readonly REJECTED: "REJECTED";
36
+ };
37
+ export type ProofAttemptStatusType = typeof ProofAttemptStatus[keyof typeof ProofAttemptStatus];
38
+ export declare const SessionStatus: {
39
+ readonly CREATED: "CREATED";
40
+ readonly ACTIVE: "ACTIVE";
41
+ readonly COMPLETED: "COMPLETED";
42
+ readonly EXPIRED: "EXPIRED";
43
+ readonly CANCELLED: "CANCELLED";
44
+ };
45
+ export type SessionStatusType = typeof SessionStatus[keyof typeof SessionStatus];
46
+ export declare const OrderErrorCode: {
47
+ readonly PROOF_INVALID: "PROOF_INVALID";
48
+ readonly PROOF_EXPIRED: "PROOF_EXPIRED";
49
+ readonly PROOF_AMOUNT_MISMATCH: "PROOF_AMOUNT_MISMATCH";
50
+ readonly PROOF_RECIPIENT_MISMATCH: "PROOF_RECIPIENT_MISMATCH";
51
+ readonly FULFILL_TIMEOUT: "FULFILL_TIMEOUT";
52
+ readonly FULFILL_REVERTED: "FULFILL_REVERTED";
53
+ readonly SIGNAL_TIMEOUT: "SIGNAL_TIMEOUT";
54
+ readonly SIGNAL_REVERTED: "SIGNAL_REVERTED";
55
+ readonly RPC_ERROR: "RPC_ERROR";
56
+ readonly RELAYER_ERROR: "RELAYER_ERROR";
57
+ readonly ATTESTATION_ERROR: "ATTESTATION_ERROR";
58
+ readonly BRIDGE_QUOTE_ERROR: "BRIDGE_QUOTE_ERROR";
59
+ readonly BRIDGE_TIMEOUT: "BRIDGE_TIMEOUT";
60
+ readonly FEE_THRESHOLD_EXCEEDED: "FEE_THRESHOLD_EXCEEDED";
61
+ readonly SDK_ERROR: "SDK_ERROR";
62
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
63
+ };
64
+ export type OrderErrorCodeType = typeof OrderErrorCode[keyof typeof OrderErrorCode];
65
+ export declare const MerchantEnvironment: {
66
+ readonly LIVE: "LIVE";
67
+ readonly SANDBOX: "SANDBOX";
68
+ };
69
+ export type MerchantEnvironmentType = typeof MerchantEnvironment[keyof typeof MerchantEnvironment];
70
+ export type Merchant = {
71
+ id: string;
72
+ name: string;
73
+ logoUrl?: string | null;
74
+ disableBranding?: boolean;
75
+ apiKey: string;
76
+ environment?: MerchantEnvironmentType;
77
+ sandboxMerchantId?: string | null;
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ defaultChainId?: number | null;
81
+ defaultCheckoutMode?: 'exact-token' | 'exact-fiat' | null;
82
+ defaultFiatCurrency?: string | null;
83
+ defaultMaxFeePercentage?: number | null;
84
+ enabledPaymentPlatforms?: PaymentPlatformType[] | null;
85
+ };
86
+ export type CreateMerchantRequest = {
87
+ name: string;
88
+ logoUrl?: string;
89
+ };
90
+ export type CheckoutSession = {
91
+ id: string;
92
+ merchantId: string;
93
+ amountUsdc: string;
94
+ netAmountUsdc?: string | null;
95
+ destinationChainId: number;
96
+ destinationToken: string;
97
+ recipientAddress: string;
98
+ status: SessionStatusType;
99
+ selectedPaymentPlatform?: PaymentPlatformType | null;
100
+ selectedFiatCurrency?: string | null;
101
+ successUrl?: string | null;
102
+ cancelUrl?: string | null;
103
+ metadata?: Record<string, string> | null;
104
+ expiresAt?: string | null;
105
+ activeOrderId?: string | null;
106
+ checkoutMode?: CheckoutModeType;
107
+ fiatAmount?: string | null;
108
+ fiatCurrency?: string | null;
109
+ maxFeePercentage?: number | null;
110
+ requiresBridge?: boolean;
111
+ enabledPaymentPlatforms?: PaymentPlatformType[] | null;
112
+ createdAt: string;
113
+ updatedAt: string;
114
+ merchant?: {
115
+ id: string;
116
+ name: string;
117
+ logoUrl?: string | null;
118
+ environment?: MerchantEnvironmentType;
119
+ disableBranding?: boolean;
120
+ } | null;
121
+ activeOrder?: Order | null;
122
+ };
123
+ export type QuoteIntent = {
124
+ depositId: string;
125
+ processorName: string;
126
+ amount: string;
127
+ toAddress: string;
128
+ payeeDetails: string;
129
+ processorIntentData: Record<string, unknown>;
130
+ fiatCurrencyCode: string;
131
+ chainId: string;
132
+ };
133
+ export type Quote = {
134
+ fiatAmount: string;
135
+ fiatAmountFormatted: string;
136
+ tokenAmount: string;
137
+ tokenAmountFormatted: string;
138
+ paymentMethod: string;
139
+ payeeAddress: string;
140
+ conversionRate: string;
141
+ intent: QuoteIntent;
142
+ payeeData?: Record<string, string>;
143
+ };
144
+ export type Order = {
145
+ id: string;
146
+ sessionId: string;
147
+ merchantId: string;
148
+ status: OrderStatusType;
149
+ intentHash?: string | null;
150
+ signalTx?: string | null;
151
+ fulfillTx?: string | null;
152
+ paymentPlatform?: PaymentPlatformType | null;
153
+ fiatCurrency?: string | null;
154
+ amountUsdc?: string | null;
155
+ netAmountUsdc?: string | null;
156
+ conversionRate?: string | null;
157
+ recipient?: string | null;
158
+ quote?: Quote | null;
159
+ expiresAt?: string | null;
160
+ bridgeCommitmentData?: string | null;
161
+ bridgeFulfillData?: string | null;
162
+ bridgeDepositTxHash?: string | null;
163
+ bridgeStatus?: 'pending' | 'filled' | 'expired' | null;
164
+ bridgeFilledAt?: string | null;
165
+ bridgeFilledTxHash?: string | null;
166
+ bridgeInfo?: OrderBridgeInfo | null;
167
+ currentProofId?: string | null;
168
+ cancelTx?: string | null;
169
+ cancelledAt?: string | null;
170
+ cancelReason?: string | null;
171
+ errorCode?: string | null;
172
+ errorMessage?: string | null;
173
+ errorDetails?: Record<string, unknown> | null;
174
+ failedAt?: string | null;
175
+ createdAt: string;
176
+ updatedAt: string;
177
+ };
178
+ export type ProofAttempt = {
179
+ id: string;
180
+ orderId: string;
181
+ intentHash: string;
182
+ proof: Record<string, unknown>;
183
+ submittedAt: string;
184
+ status: ProofAttemptStatusType;
185
+ verifiedAt?: string | null;
186
+ attestationResponse?: Record<string, unknown> | null;
187
+ verificationError?: string | null;
188
+ verificationMessage?: string | null;
189
+ txHash?: string | null;
190
+ txSubmittedAt?: string | null;
191
+ txConfirmedAt?: string | null;
192
+ txError?: string | null;
193
+ };
194
+ type CreateSessionBaseRequest = {
195
+ merchantId: string;
196
+ destinationChainId: number;
197
+ destinationToken: string;
198
+ recipientAddress: string;
199
+ successUrl?: string;
200
+ cancelUrl?: string;
201
+ metadata?: Record<string, string>;
202
+ enabledPaymentPlatforms?: PaymentPlatformType[];
203
+ };
204
+ type CreateSessionExactTokenRequest = CreateSessionBaseRequest & {
205
+ checkoutMode?: 'exact-token';
206
+ amountUsdc: string;
207
+ fiatAmount?: never;
208
+ fiatCurrency?: never;
209
+ maxFeePercentage?: never;
210
+ };
211
+ type CreateSessionExactFiatRequest = CreateSessionBaseRequest & {
212
+ checkoutMode: 'exact-fiat';
213
+ amountUsdc?: never;
214
+ fiatAmount: string;
215
+ fiatCurrency?: string;
216
+ maxFeePercentage?: number;
217
+ };
218
+ export type CreateSessionRequest = CreateSessionExactTokenRequest | CreateSessionExactFiatRequest;
219
+ /**
220
+ * Bridge information returned when session requires cross-chain bridging.
221
+ * Amounts are in raw units (6 decimals for USDC).
222
+ */
223
+ export type BridgeInfo = {
224
+ required: boolean;
225
+ inputAmount?: string | null;
226
+ outputAmount?: string | null;
227
+ feeAmount?: string | null;
228
+ minOutputAmount?: string | null;
229
+ estimatedTimeSeconds?: number | null;
230
+ };
231
+ export type CreateSessionResponse = {
232
+ session: CheckoutSession;
233
+ sessionToken: string;
234
+ checkoutUrl: string;
235
+ bridge?: BridgeInfo;
236
+ };
237
+ export type StartSessionRequest = {
238
+ paymentPlatform?: PaymentPlatformType;
239
+ fiatCurrency?: string;
240
+ };
241
+ export type StartSessionResponse = {
242
+ session: CheckoutSession;
243
+ order: Order;
244
+ quote: Quote;
245
+ intentHash: string;
246
+ expiresAt?: string | null;
247
+ };
248
+ export type MarkPaymentSentResponse = {
249
+ order: Order;
250
+ };
251
+ export type FulfillIntentRequest = {
252
+ intentHash: string;
253
+ proof: Record<string, unknown> | string;
254
+ };
255
+ export type FulfillIntentResponse = {
256
+ order: Order;
257
+ proofAttemptId: string;
258
+ txHash: string;
259
+ };
260
+ export type FulfillIntentError = {
261
+ proofAttemptId: string;
262
+ errorCode?: string;
263
+ errorMessage: string;
264
+ canRetry: boolean;
265
+ };
266
+ export type ProofAttemptsResponse = {
267
+ proofAttempts: ProofAttempt[];
268
+ };
269
+ export interface BridgeStatusResponse {
270
+ status: 'pending' | 'filled' | 'expired' | 'not_applicable';
271
+ destinationChainId?: string;
272
+ outputAmountUsdc?: string;
273
+ fillTxHash?: string;
274
+ depositTxHash?: string;
275
+ acrossTrackingUrl?: string;
276
+ estimatedFillTime?: number;
277
+ }
278
+ /**
279
+ * Bridge information included in order responses.
280
+ * Tracks the status of cross-chain bridging via Across Protocol.
281
+ */
282
+ export interface OrderBridgeInfo {
283
+ status: 'PENDING' | 'DEPOSITED' | 'FILLED' | 'EXPIRED';
284
+ destinationChainId: string;
285
+ outputAmountUsdc?: string;
286
+ estimatedOutputAmountUsdc?: string;
287
+ minOutputAmountUsdc?: string;
288
+ fillTxHash?: string | null;
289
+ estimatedFillTime?: number | null;
290
+ }
291
+ export declare const WebhookEventType: {
292
+ readonly ORDER_CREATED: "order.created";
293
+ readonly ORDER_PAYMENT_SENT: "order.payment_sent";
294
+ readonly ORDER_FULFILLED: "order.fulfilled";
295
+ readonly ORDER_FAILED: "order.failed";
296
+ readonly ORDER_EXPIRED: "order.expired";
297
+ readonly SESSION_STARTED: "session.started";
298
+ readonly SESSION_COMPLETED: "session.completed";
299
+ readonly SESSION_ABANDONED: "session.abandoned";
300
+ };
301
+ export type WebhookEventTypeValue = typeof WebhookEventType[keyof typeof WebhookEventType];
302
+ export declare const WebhookDeliveryStatus: {
303
+ readonly PENDING: "PENDING";
304
+ readonly DELIVERED: "DELIVERED";
305
+ readonly FAILED: "FAILED";
306
+ };
307
+ export type WebhookDeliveryStatusType = typeof WebhookDeliveryStatus[keyof typeof WebhookDeliveryStatus];
308
+ export type Webhook = {
309
+ id: string;
310
+ merchantId: string;
311
+ url: string;
312
+ events: WebhookEventTypeValue[];
313
+ active: boolean;
314
+ createdAt: string;
315
+ updatedAt: string;
316
+ };
317
+ export type WebhookWithSecret = Webhook & {
318
+ secret: string;
319
+ };
320
+ export type WebhookDelivery = {
321
+ id: string;
322
+ webhookId: string;
323
+ eventType: WebhookEventTypeValue;
324
+ eventId: string;
325
+ status: WebhookDeliveryStatusType;
326
+ attempts: number;
327
+ lastAttemptAt?: string | null;
328
+ nextRetryAt?: string | null;
329
+ responseCode?: number | null;
330
+ createdAt: string;
331
+ };
332
+ export type WebhookPayload = {
333
+ id: string;
334
+ type: WebhookEventTypeValue;
335
+ timestamp: string;
336
+ environment: MerchantEnvironmentType;
337
+ data: {
338
+ session: CheckoutSession;
339
+ order?: Order | null;
340
+ txHash?: string | null;
341
+ error?: {
342
+ code: string;
343
+ message: string;
344
+ } | null;
345
+ };
346
+ };
347
+ export type CreateWebhookRequest = {
348
+ url: string;
349
+ events?: WebhookEventTypeValue[];
350
+ };
351
+ export type CreateWebhookResponse = WebhookWithSecret;
352
+ export type UpdateWebhookRequest = {
353
+ url?: string;
354
+ events?: WebhookEventTypeValue[];
355
+ active?: boolean;
356
+ };
357
+ export type ListWebhooksResponse = {
358
+ webhooks: Webhook[];
359
+ };
360
+ export type ListWebhookDeliveriesResponse = {
361
+ deliveries: WebhookDelivery[];
362
+ };
363
+ export type TestWebhookResponse = {
364
+ success: boolean;
365
+ deliveryId: string;
366
+ responseCode?: number | null;
367
+ error?: string | null;
368
+ };
369
+ export {};
370
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;CASlB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAKvF,eAAO,MAAM,eAAe,wBAAqB,CAAC;AAElD,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,eAAe,CAAC;AAG5D,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE9E,eAAO,MAAM,WAAW;;;;;;;;;;CAUd,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE3E,eAAO,MAAM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;YACN,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,GAAG,IAAI,CAAC;KACV,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,90 @@
1
+ export const PaymentPlatform = {
2
+ VENMO: 'venmo',
3
+ CASHAPP: 'cashapp',
4
+ REVOLUT: 'revolut',
5
+ WISE: 'wise',
6
+ ZELLE: 'zelle',
7
+ PAYPAL: 'paypal',
8
+ MONZO: 'monzo',
9
+ N26: 'n26',
10
+ };
11
+ // Supported chains for USDC destination
12
+ // Re-exported from chains.ts for backward compatibility
13
+ import { SupportedChainsMap } from './chains.js';
14
+ export const SupportedChains = SupportedChainsMap;
15
+ // Checkout mode determines how amounts are specified
16
+ export const CheckoutMode = {
17
+ EXACT_TOKEN: 'exact-token', // Merchant specifies USDC amount, customer pays variable fiat
18
+ EXACT_FIAT: 'exact-fiat', // Merchant specifies fiat amount, customer pays fixed fiat, merchant receives variable USDC
19
+ };
20
+ export const OrderStatus = {
21
+ SIGNAL_SUBMITTED: 'SIGNAL_SUBMITTED', // Intent tx submitted, awaiting confirmation
22
+ SIGNAL_MINED: 'SIGNAL_MINED', // Intent tx confirmed, intentHash available
23
+ PAYMENT_SENT: 'PAYMENT_SENT', // User marked fiat payment as sent
24
+ PROOF_VERIFIED: 'PROOF_VERIFIED', // ZKP proof verified by attestation service
25
+ FULFILL_SUBMITTED: 'FULFILL_SUBMITTED', // Fulfill tx submitted, awaiting confirmation
26
+ FULFILLED: 'FULFILLED', // Fulfill tx confirmed, payment complete
27
+ CANCELLED: 'CANCELLED', // Order cancelled
28
+ EXPIRED: 'EXPIRED', // Order expired
29
+ FAILED: 'FAILED', // Order failed due to error
30
+ };
31
+ export const ProofAttemptStatus = {
32
+ PENDING: 'PENDING', // Proof received, awaiting verification
33
+ VERIFYING: 'VERIFYING', // Being verified by attestation service
34
+ VERIFIED: 'VERIFIED', // Proof valid, fulfillment can proceed (Order tracks tx status)
35
+ REJECTED: 'REJECTED', // Proof failed verification (can retry with new proof)
36
+ };
37
+ export const SessionStatus = {
38
+ CREATED: 'CREATED',
39
+ ACTIVE: 'ACTIVE',
40
+ COMPLETED: 'COMPLETED',
41
+ EXPIRED: 'EXPIRED',
42
+ CANCELLED: 'CANCELLED',
43
+ };
44
+ // Structured error codes for Order failures
45
+ export const OrderErrorCode = {
46
+ // Proof verification errors
47
+ PROOF_INVALID: 'PROOF_INVALID', // Proof data failed attestation verification
48
+ PROOF_EXPIRED: 'PROOF_EXPIRED', // Proof timestamp too old
49
+ PROOF_AMOUNT_MISMATCH: 'PROOF_AMOUNT_MISMATCH', // Payment amount doesn't match intent
50
+ PROOF_RECIPIENT_MISMATCH: 'PROOF_RECIPIENT_MISMATCH', // Payment recipient doesn't match
51
+ // Transaction errors
52
+ FULFILL_TIMEOUT: 'FULFILL_TIMEOUT', // On-chain tx timed out
53
+ FULFILL_REVERTED: 'FULFILL_REVERTED', // On-chain tx reverted
54
+ SIGNAL_TIMEOUT: 'SIGNAL_TIMEOUT', // Signal intent tx timed out
55
+ SIGNAL_REVERTED: 'SIGNAL_REVERTED', // Signal intent tx reverted
56
+ // Infrastructure errors
57
+ RPC_ERROR: 'RPC_ERROR', // RPC node connection/timeout
58
+ RELAYER_ERROR: 'RELAYER_ERROR', // Relayer submission failed
59
+ ATTESTATION_ERROR: 'ATTESTATION_ERROR', // Attestation service unavailable
60
+ // Bridge errors (cross-chain)
61
+ BRIDGE_QUOTE_ERROR: 'BRIDGE_QUOTE_ERROR', // Failed to get bridge quote
62
+ BRIDGE_TIMEOUT: 'BRIDGE_TIMEOUT', // Bridge fill timed out
63
+ // Fee threshold errors (exact-fiat mode)
64
+ FEE_THRESHOLD_EXCEEDED: 'FEE_THRESHOLD_EXCEEDED', // Quote fee exceeds merchant's max
65
+ // Generic
66
+ SDK_ERROR: 'SDK_ERROR', // Unknown SDK error
67
+ UNKNOWN_ERROR: 'UNKNOWN_ERROR', // Uncategorized error
68
+ };
69
+ export const MerchantEnvironment = {
70
+ LIVE: 'LIVE',
71
+ SANDBOX: 'SANDBOX',
72
+ };
73
+ // ============ Webhook Types ============
74
+ export const WebhookEventType = {
75
+ // Order lifecycle events
76
+ ORDER_CREATED: 'order.created',
77
+ ORDER_PAYMENT_SENT: 'order.payment_sent',
78
+ ORDER_FULFILLED: 'order.fulfilled',
79
+ ORDER_FAILED: 'order.failed',
80
+ ORDER_EXPIRED: 'order.expired',
81
+ // Session lifecycle events
82
+ SESSION_STARTED: 'session.started',
83
+ SESSION_COMPLETED: 'session.completed',
84
+ SESSION_ABANDONED: 'session.abandoned',
85
+ };
86
+ export const WebhookDeliveryStatus = {
87
+ PENDING: 'PENDING',
88
+ DELIVERED: 'DELIVERED',
89
+ FAILED: 'FAILED',
90
+ };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@zkp2p/pay-shared",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "src"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json",
19
+ "lint": "eslint . --ext .ts,.tsx"
20
+ }
21
+ }