@p2pdotme/sdk 1.0.5 → 1.1.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.
Files changed (66) hide show
  1. package/README.md +103 -41
  2. package/dist/country.cjs +9 -2
  3. package/dist/country.cjs.map +1 -1
  4. package/dist/country.d.cts +35 -10
  5. package/dist/country.d.ts +35 -10
  6. package/dist/country.mjs +6 -2
  7. package/dist/country.mjs.map +1 -1
  8. package/dist/fraud-engine.cjs +52 -48
  9. package/dist/fraud-engine.cjs.map +1 -1
  10. package/dist/fraud-engine.mjs +46 -42
  11. package/dist/fraud-engine.mjs.map +1 -1
  12. package/dist/index.cjs +4 -14
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +41 -36
  15. package/dist/index.d.ts +41 -36
  16. package/dist/index.mjs +4 -12
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/orders.cjs +5961 -0
  19. package/dist/orders.cjs.map +1 -0
  20. package/dist/orders.d.cts +620 -0
  21. package/dist/orders.d.ts +620 -0
  22. package/dist/orders.mjs +5911 -0
  23. package/dist/orders.mjs.map +1 -0
  24. package/dist/prices.cjs +1432 -0
  25. package/dist/prices.cjs.map +1 -0
  26. package/dist/prices.d.cts +109 -0
  27. package/dist/prices.d.ts +109 -0
  28. package/dist/prices.mjs +1404 -0
  29. package/dist/prices.mjs.map +1 -0
  30. package/dist/profile.cjs +899 -69
  31. package/dist/profile.cjs.map +1 -1
  32. package/dist/profile.d.cts +39 -27
  33. package/dist/profile.d.ts +39 -27
  34. package/dist/profile.mjs +892 -62
  35. package/dist/profile.mjs.map +1 -1
  36. package/dist/qr-parsers.cjs +88 -7
  37. package/dist/qr-parsers.cjs.map +1 -1
  38. package/dist/qr-parsers.d.cts +38 -16
  39. package/dist/qr-parsers.d.ts +38 -16
  40. package/dist/qr-parsers.mjs +88 -7
  41. package/dist/qr-parsers.mjs.map +1 -1
  42. package/dist/react.cjs +2955 -1105
  43. package/dist/react.cjs.map +1 -1
  44. package/dist/react.d.cts +384 -104
  45. package/dist/react.d.ts +384 -104
  46. package/dist/react.mjs +2841 -992
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/zkkyc.cjs +405 -24
  49. package/dist/zkkyc.cjs.map +1 -1
  50. package/dist/zkkyc.d.cts +14 -9
  51. package/dist/zkkyc.d.ts +14 -9
  52. package/dist/zkkyc.mjs +405 -24
  53. package/dist/zkkyc.mjs.map +1 -1
  54. package/package.json +12 -12
  55. package/dist/order-routing.cjs +0 -888
  56. package/dist/order-routing.cjs.map +0 -1
  57. package/dist/order-routing.d.cts +0 -68
  58. package/dist/order-routing.d.ts +0 -68
  59. package/dist/order-routing.mjs +0 -860
  60. package/dist/order-routing.mjs.map +0 -1
  61. package/dist/payload.cjs +0 -3168
  62. package/dist/payload.cjs.map +0 -1
  63. package/dist/payload.d.cts +0 -147
  64. package/dist/payload.d.ts +0 -147
  65. package/dist/payload.mjs +0 -3124
  66. package/dist/payload.mjs.map +0 -1
@@ -1,147 +0,0 @@
1
- import { ResultAsync, Result } from 'neverthrow';
2
- import { Address } from 'viem';
3
- import z$1, { z } from 'zod';
4
-
5
- declare class SdkError<TCode extends string = string> extends Error {
6
- readonly code: TCode;
7
- readonly cause?: unknown;
8
- readonly context?: Record<string, unknown>;
9
- constructor(message: string, options: {
10
- code: TCode;
11
- cause?: unknown;
12
- context?: Record<string, unknown>;
13
- });
14
- }
15
-
16
- declare const ZodCurrencySchema: z.ZodEnum<{
17
- [x: string]: string;
18
- }>;
19
-
20
- type PayloadErrorCode = "VALIDATION_ERROR" | "CIRCLE_SELECTION_ERROR" | "ENCRYPTION_ERROR" | "DECRYPTION_ERROR";
21
- declare class PayloadError extends SdkError<PayloadErrorCode> {
22
- constructor(message: string, options: {
23
- code: PayloadErrorCode;
24
- cause?: unknown;
25
- context?: Record<string, unknown>;
26
- });
27
- }
28
-
29
- type OrderRoutingErrorCode = "NO_ELIGIBLE_CIRCLES" | "SUBGRAPH_ERROR" | "SUBGRAPH_NOT_CONFIGURED" | "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
30
- declare class OrderRoutingError extends SdkError<OrderRoutingErrorCode> {
31
- constructor(message: string, options: {
32
- code: OrderRoutingErrorCode;
33
- cause?: unknown;
34
- context?: Record<string, unknown>;
35
- });
36
- }
37
-
38
- type CurrencyType = z$1.infer<typeof ZodCurrencySchema>;
39
-
40
- interface SelectCircleParams {
41
- readonly currency: string;
42
- readonly user: Address;
43
- readonly usdtAmount: bigint;
44
- readonly fiatAmount: bigint;
45
- readonly orderType: bigint;
46
- readonly preferredPCConfigId: bigint;
47
- }
48
-
49
- interface OrderRouter {
50
- /**
51
- * Full flow: fetch circles from subgraph → epsilon-greedy selection →
52
- * on-chain eligibility validation → return circleId.
53
- */
54
- selectCircle(params: SelectCircleParams): ResultAsync<bigint, OrderRoutingError>;
55
- }
56
-
57
- interface PayloadGeneratorConfig {
58
- readonly orderRouter: OrderRouter;
59
- }
60
- interface PlaceOrderPayload {
61
- readonly pubKey: string;
62
- readonly amount: bigint;
63
- readonly recipientAddr: `0x${string}`;
64
- readonly orderType: number;
65
- readonly userUpi: string;
66
- readonly userPubKey: string;
67
- readonly currency: CurrencyType;
68
- readonly preferredPaymentChannelConfigId: bigint;
69
- readonly fiatAmountLimit: bigint;
70
- readonly circleId: bigint;
71
- }
72
- interface SetSellOrderUpiPayload {
73
- readonly orderId: number;
74
- readonly userEncUpi: string;
75
- readonly updatedAmount: bigint;
76
- }
77
-
78
- declare const ZodPlaceOrderParamsSchema: z.ZodObject<{
79
- amount: z.ZodBigInt;
80
- recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
81
- orderType: z.ZodNumber;
82
- currency: z.ZodEnum<{
83
- [x: string]: string;
84
- }>;
85
- fiatAmount: z.ZodBigInt;
86
- user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
87
- pubKey: z.ZodOptional<z.ZodString>;
88
- preferredPaymentChannelConfigId: z.ZodOptional<z.ZodBigInt>;
89
- fiatAmountLimit: z.ZodDefault<z.ZodOptional<z.ZodBigInt>>;
90
- }, z.core.$strip>;
91
- type PlaceOrderParams = z.input<typeof ZodPlaceOrderParamsSchema>;
92
- declare const ZodSetSellOrderUpiParamsSchema: z.ZodObject<{
93
- orderId: z.ZodNumber;
94
- paymentAddress: z.ZodString;
95
- merchantPublicKey: z.ZodString;
96
- updatedAmount: z.ZodBigInt;
97
- }, z.core.$strip>;
98
- type SetSellOrderUpiParams = z.infer<typeof ZodSetSellOrderUpiParamsSchema>;
99
-
100
- interface PayloadGenerator {
101
- placeOrder(params: PlaceOrderParams): ResultAsync<PlaceOrderPayload, PayloadError>;
102
- setSellOrderUpi(params: SetSellOrderUpiParams): ResultAsync<SetSellOrderUpiPayload, PayloadError>;
103
- }
104
- declare function createPayloadGenerator(config: PayloadGeneratorConfig): PayloadGenerator;
105
-
106
- /**
107
- * Signs and encrypts a payment address using the relay identity's private key
108
- * and the recipient's public key, producing a hex-encoded ECIES ciphertext.
109
- */
110
- declare function encryptPaymentAddress(paymentAddress: string, encryptionPublicKey: string): ResultAsync<string, PayloadError>;
111
- /**
112
- * Decrypts an encrypted payment address using the relay identity's private key.
113
- */
114
- declare function decryptPaymentAddress(encryptedPaymentAddress: string): ResultAsync<string, PayloadError>;
115
-
116
- interface Encrypted {
117
- readonly iv: string;
118
- readonly ephemPublicKey: string;
119
- readonly ciphertext: string;
120
- readonly mac: string;
121
- }
122
- /**
123
- * Serializes an Encrypted object to a compact hex string.
124
- * Format: IV (16 bytes) || compressed ephemPublicKey (33 bytes) || MAC (32 bytes) || ciphertext.
125
- */
126
- declare function cipherStringify(encrypted: Encrypted): string;
127
- /**
128
- * Parses a compact hex string back into an Encrypted object.
129
- * Inverse of cipherStringify.
130
- */
131
- declare function cipherParse(str: string): Encrypted;
132
-
133
- interface RelayIdentity {
134
- readonly address: string;
135
- readonly publicKey: string;
136
- readonly privateKey: string;
137
- }
138
- /**
139
- * Generates a new relay identity keypair via viem and persists it to localStorage.
140
- */
141
- declare function createRelayIdentity(): RelayIdentity;
142
- /**
143
- * Retrieves the relay identity from localStorage, or creates a new one if absent/invalid.
144
- */
145
- declare function getRelayIdentity(): Result<RelayIdentity, PayloadError>;
146
-
147
- export { PayloadError, type PayloadErrorCode, type PayloadGenerator, type PayloadGeneratorConfig, type PlaceOrderParams, type PlaceOrderPayload, type RelayIdentity, type SetSellOrderUpiParams, type SetSellOrderUpiPayload, cipherParse, cipherStringify, createPayloadGenerator, createRelayIdentity, decryptPaymentAddress, encryptPaymentAddress, getRelayIdentity };
package/dist/payload.d.ts DELETED
@@ -1,147 +0,0 @@
1
- import { ResultAsync, Result } from 'neverthrow';
2
- import { Address } from 'viem';
3
- import z$1, { z } from 'zod';
4
-
5
- declare class SdkError<TCode extends string = string> extends Error {
6
- readonly code: TCode;
7
- readonly cause?: unknown;
8
- readonly context?: Record<string, unknown>;
9
- constructor(message: string, options: {
10
- code: TCode;
11
- cause?: unknown;
12
- context?: Record<string, unknown>;
13
- });
14
- }
15
-
16
- declare const ZodCurrencySchema: z.ZodEnum<{
17
- [x: string]: string;
18
- }>;
19
-
20
- type PayloadErrorCode = "VALIDATION_ERROR" | "CIRCLE_SELECTION_ERROR" | "ENCRYPTION_ERROR" | "DECRYPTION_ERROR";
21
- declare class PayloadError extends SdkError<PayloadErrorCode> {
22
- constructor(message: string, options: {
23
- code: PayloadErrorCode;
24
- cause?: unknown;
25
- context?: Record<string, unknown>;
26
- });
27
- }
28
-
29
- type OrderRoutingErrorCode = "NO_ELIGIBLE_CIRCLES" | "SUBGRAPH_ERROR" | "SUBGRAPH_NOT_CONFIGURED" | "VALIDATION_ERROR" | "CONTRACT_READ_ERROR";
30
- declare class OrderRoutingError extends SdkError<OrderRoutingErrorCode> {
31
- constructor(message: string, options: {
32
- code: OrderRoutingErrorCode;
33
- cause?: unknown;
34
- context?: Record<string, unknown>;
35
- });
36
- }
37
-
38
- type CurrencyType = z$1.infer<typeof ZodCurrencySchema>;
39
-
40
- interface SelectCircleParams {
41
- readonly currency: string;
42
- readonly user: Address;
43
- readonly usdtAmount: bigint;
44
- readonly fiatAmount: bigint;
45
- readonly orderType: bigint;
46
- readonly preferredPCConfigId: bigint;
47
- }
48
-
49
- interface OrderRouter {
50
- /**
51
- * Full flow: fetch circles from subgraph → epsilon-greedy selection →
52
- * on-chain eligibility validation → return circleId.
53
- */
54
- selectCircle(params: SelectCircleParams): ResultAsync<bigint, OrderRoutingError>;
55
- }
56
-
57
- interface PayloadGeneratorConfig {
58
- readonly orderRouter: OrderRouter;
59
- }
60
- interface PlaceOrderPayload {
61
- readonly pubKey: string;
62
- readonly amount: bigint;
63
- readonly recipientAddr: `0x${string}`;
64
- readonly orderType: number;
65
- readonly userUpi: string;
66
- readonly userPubKey: string;
67
- readonly currency: CurrencyType;
68
- readonly preferredPaymentChannelConfigId: bigint;
69
- readonly fiatAmountLimit: bigint;
70
- readonly circleId: bigint;
71
- }
72
- interface SetSellOrderUpiPayload {
73
- readonly orderId: number;
74
- readonly userEncUpi: string;
75
- readonly updatedAmount: bigint;
76
- }
77
-
78
- declare const ZodPlaceOrderParamsSchema: z.ZodObject<{
79
- amount: z.ZodBigInt;
80
- recipientAddr: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
81
- orderType: z.ZodNumber;
82
- currency: z.ZodEnum<{
83
- [x: string]: string;
84
- }>;
85
- fiatAmount: z.ZodBigInt;
86
- user: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
87
- pubKey: z.ZodOptional<z.ZodString>;
88
- preferredPaymentChannelConfigId: z.ZodOptional<z.ZodBigInt>;
89
- fiatAmountLimit: z.ZodDefault<z.ZodOptional<z.ZodBigInt>>;
90
- }, z.core.$strip>;
91
- type PlaceOrderParams = z.input<typeof ZodPlaceOrderParamsSchema>;
92
- declare const ZodSetSellOrderUpiParamsSchema: z.ZodObject<{
93
- orderId: z.ZodNumber;
94
- paymentAddress: z.ZodString;
95
- merchantPublicKey: z.ZodString;
96
- updatedAmount: z.ZodBigInt;
97
- }, z.core.$strip>;
98
- type SetSellOrderUpiParams = z.infer<typeof ZodSetSellOrderUpiParamsSchema>;
99
-
100
- interface PayloadGenerator {
101
- placeOrder(params: PlaceOrderParams): ResultAsync<PlaceOrderPayload, PayloadError>;
102
- setSellOrderUpi(params: SetSellOrderUpiParams): ResultAsync<SetSellOrderUpiPayload, PayloadError>;
103
- }
104
- declare function createPayloadGenerator(config: PayloadGeneratorConfig): PayloadGenerator;
105
-
106
- /**
107
- * Signs and encrypts a payment address using the relay identity's private key
108
- * and the recipient's public key, producing a hex-encoded ECIES ciphertext.
109
- */
110
- declare function encryptPaymentAddress(paymentAddress: string, encryptionPublicKey: string): ResultAsync<string, PayloadError>;
111
- /**
112
- * Decrypts an encrypted payment address using the relay identity's private key.
113
- */
114
- declare function decryptPaymentAddress(encryptedPaymentAddress: string): ResultAsync<string, PayloadError>;
115
-
116
- interface Encrypted {
117
- readonly iv: string;
118
- readonly ephemPublicKey: string;
119
- readonly ciphertext: string;
120
- readonly mac: string;
121
- }
122
- /**
123
- * Serializes an Encrypted object to a compact hex string.
124
- * Format: IV (16 bytes) || compressed ephemPublicKey (33 bytes) || MAC (32 bytes) || ciphertext.
125
- */
126
- declare function cipherStringify(encrypted: Encrypted): string;
127
- /**
128
- * Parses a compact hex string back into an Encrypted object.
129
- * Inverse of cipherStringify.
130
- */
131
- declare function cipherParse(str: string): Encrypted;
132
-
133
- interface RelayIdentity {
134
- readonly address: string;
135
- readonly publicKey: string;
136
- readonly privateKey: string;
137
- }
138
- /**
139
- * Generates a new relay identity keypair via viem and persists it to localStorage.
140
- */
141
- declare function createRelayIdentity(): RelayIdentity;
142
- /**
143
- * Retrieves the relay identity from localStorage, or creates a new one if absent/invalid.
144
- */
145
- declare function getRelayIdentity(): Result<RelayIdentity, PayloadError>;
146
-
147
- export { PayloadError, type PayloadErrorCode, type PayloadGenerator, type PayloadGeneratorConfig, type PlaceOrderParams, type PlaceOrderPayload, type RelayIdentity, type SetSellOrderUpiParams, type SetSellOrderUpiPayload, cipherParse, cipherStringify, createPayloadGenerator, createRelayIdentity, decryptPaymentAddress, encryptPaymentAddress, getRelayIdentity };