@p2pdotme/sdk 1.0.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 +155 -0
- package/dist/fraud-engine.cjs +598 -0
- package/dist/fraud-engine.cjs.map +1 -0
- package/dist/fraud-engine.d.cts +194 -0
- package/dist/fraud-engine.d.ts +194 -0
- package/dist/fraud-engine.mjs +549 -0
- package/dist/fraud-engine.mjs.map +1 -0
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/order-routing.cjs +882 -0
- package/dist/order-routing.cjs.map +1 -0
- package/dist/order-routing.d.cts +68 -0
- package/dist/order-routing.d.ts +68 -0
- package/dist/order-routing.mjs +854 -0
- package/dist/order-routing.mjs.map +1 -0
- package/dist/payload.cjs +3164 -0
- package/dist/payload.cjs.map +1 -0
- package/dist/payload.d.cts +162 -0
- package/dist/payload.d.ts +162 -0
- package/dist/payload.mjs +3120 -0
- package/dist/payload.mjs.map +1 -0
- package/dist/profile.cjs +695 -0
- package/dist/profile.cjs.map +1 -0
- package/dist/profile.d.cts +133 -0
- package/dist/profile.d.ts +133 -0
- package/dist/profile.mjs +667 -0
- package/dist/profile.mjs.map +1 -0
- package/dist/qr-parsers.cjs +366 -0
- package/dist/qr-parsers.cjs.map +1 -0
- package/dist/qr-parsers.d.cts +41 -0
- package/dist/qr-parsers.d.ts +41 -0
- package/dist/qr-parsers.mjs +338 -0
- package/dist/qr-parsers.mjs.map +1 -0
- package/dist/react.cjs +4803 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +511 -0
- package/dist/react.d.ts +511 -0
- package/dist/react.mjs +4759 -0
- package/dist/react.mjs.map +1 -0
- package/dist/zkkyc.cjs +868 -0
- package/dist/zkkyc.cjs.map +1 -0
- package/dist/zkkyc.d.cts +230 -0
- package/dist/zkkyc.d.ts +230 -0
- package/dist/zkkyc.mjs +824 -0
- package/dist/zkkyc.mjs.map +1 -0
- package/package.json +130 -0
package/dist/zkkyc.cjs
ADDED
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/zkkyc/index.ts
|
|
31
|
+
var zkkyc_exports = {};
|
|
32
|
+
__export(zkkyc_exports, {
|
|
33
|
+
DEFAULT_RECLAIM_PROVIDER_IDS: () => DEFAULT_RECLAIM_PROVIDER_IDS,
|
|
34
|
+
RECLAIM_APP_LINKS: () => RECLAIM_APP_LINKS,
|
|
35
|
+
SOCIAL_PLATFORM_NAMES: () => SOCIAL_PLATFORM_NAMES,
|
|
36
|
+
ZK_PASSPORT_APP_LINKS: () => ZK_PASSPORT_APP_LINKS,
|
|
37
|
+
ZkkycError: () => ZkkycError,
|
|
38
|
+
createReclaimFlow: () => createReclaimFlow,
|
|
39
|
+
createZkPassportFlow: () => createZkPassportFlow,
|
|
40
|
+
createZkkyc: () => createZkkyc
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(zkkyc_exports);
|
|
43
|
+
|
|
44
|
+
// src/contracts/reputation-manager/writes.ts
|
|
45
|
+
var import_neverthrow2 = require("neverthrow");
|
|
46
|
+
var import_viem3 = require("viem");
|
|
47
|
+
|
|
48
|
+
// src/validation/errors.ts
|
|
49
|
+
var SdkError = class extends Error {
|
|
50
|
+
code;
|
|
51
|
+
cause;
|
|
52
|
+
context;
|
|
53
|
+
constructor(message, options) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = "SdkError";
|
|
56
|
+
this.code = options.code;
|
|
57
|
+
this.cause = options.cause;
|
|
58
|
+
this.context = options.context;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/validation/schemas.ts
|
|
63
|
+
var import_neverthrow = require("neverthrow");
|
|
64
|
+
var import_viem = require("viem");
|
|
65
|
+
var import_zod = require("zod");
|
|
66
|
+
var ZodAddressSchema = import_zod.z.string().refine((s) => (0, import_viem.isAddress)(s), { message: "Invalid Ethereum address" });
|
|
67
|
+
var ZodCurrencySchema = import_zod.z.enum([
|
|
68
|
+
"IDR",
|
|
69
|
+
"INR",
|
|
70
|
+
"BRL",
|
|
71
|
+
"ARS",
|
|
72
|
+
"MEX",
|
|
73
|
+
"VEN",
|
|
74
|
+
"EUR",
|
|
75
|
+
"NGN",
|
|
76
|
+
"USD"
|
|
77
|
+
]);
|
|
78
|
+
function validate(schema, data, toError) {
|
|
79
|
+
const result = schema.safeParse(data);
|
|
80
|
+
if (result.success) {
|
|
81
|
+
return (0, import_neverthrow.ok)(result.data);
|
|
82
|
+
}
|
|
83
|
+
return (0, import_neverthrow.err)(toError(import_zod.z.prettifyError(result.error), result.error, data));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/zkkyc/errors.ts
|
|
87
|
+
var ZkkycError = class extends SdkError {
|
|
88
|
+
constructor(message, options) {
|
|
89
|
+
super(message, options);
|
|
90
|
+
this.name = "ZkkycError";
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/zkkyc/validation.ts
|
|
95
|
+
var import_zod2 = require("zod");
|
|
96
|
+
var ZodAnonAadharProofParamsSchema = import_zod2.z.object({
|
|
97
|
+
nullifierSeed: import_zod2.z.bigint(),
|
|
98
|
+
nullifier: import_zod2.z.bigint(),
|
|
99
|
+
timestamp: import_zod2.z.bigint(),
|
|
100
|
+
signal: import_zod2.z.bigint(),
|
|
101
|
+
revealArray: import_zod2.z.tuple([import_zod2.z.bigint(), import_zod2.z.bigint(), import_zod2.z.bigint(), import_zod2.z.bigint()]),
|
|
102
|
+
packedGroth16Proof: import_zod2.z.tuple([
|
|
103
|
+
import_zod2.z.bigint(),
|
|
104
|
+
import_zod2.z.bigint(),
|
|
105
|
+
import_zod2.z.bigint(),
|
|
106
|
+
import_zod2.z.bigint(),
|
|
107
|
+
import_zod2.z.bigint(),
|
|
108
|
+
import_zod2.z.bigint(),
|
|
109
|
+
import_zod2.z.bigint(),
|
|
110
|
+
import_zod2.z.bigint()
|
|
111
|
+
])
|
|
112
|
+
});
|
|
113
|
+
var ZodSocialVerifyParamsSchema = import_zod2.z.object({
|
|
114
|
+
_socialName: import_zod2.z.string(),
|
|
115
|
+
proofs: import_zod2.z.array(
|
|
116
|
+
import_zod2.z.object({
|
|
117
|
+
claimInfo: import_zod2.z.object({
|
|
118
|
+
provider: import_zod2.z.string(),
|
|
119
|
+
parameters: import_zod2.z.string(),
|
|
120
|
+
context: import_zod2.z.string()
|
|
121
|
+
}),
|
|
122
|
+
signedClaim: import_zod2.z.object({
|
|
123
|
+
claim: import_zod2.z.object({
|
|
124
|
+
identifier: import_zod2.z.string(),
|
|
125
|
+
owner: ZodAddressSchema,
|
|
126
|
+
timestampS: import_zod2.z.number(),
|
|
127
|
+
epoch: import_zod2.z.number()
|
|
128
|
+
}),
|
|
129
|
+
signatures: import_zod2.z.array(import_zod2.z.string())
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
)
|
|
133
|
+
});
|
|
134
|
+
var ZodSolidityVerifierParametersSchema = import_zod2.z.object({
|
|
135
|
+
version: import_zod2.z.string().refine((val) => val.startsWith("0x"), {
|
|
136
|
+
message: "Version must be a hex string"
|
|
137
|
+
}),
|
|
138
|
+
proofVerificationData: import_zod2.z.object({
|
|
139
|
+
vkeyHash: import_zod2.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
140
|
+
message: "Invalid bytes32 hex string"
|
|
141
|
+
}),
|
|
142
|
+
proof: import_zod2.z.string().refine((val) => val.startsWith("0x"), {
|
|
143
|
+
message: "Proof must be a hex string"
|
|
144
|
+
}),
|
|
145
|
+
publicInputs: import_zod2.z.array(
|
|
146
|
+
import_zod2.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
147
|
+
message: "Each public input must be a valid bytes32 hex string"
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
}),
|
|
151
|
+
committedInputs: import_zod2.z.string().refine((val) => val.startsWith("0x"), {
|
|
152
|
+
message: "Committed inputs must be a hex string"
|
|
153
|
+
}),
|
|
154
|
+
serviceConfig: import_zod2.z.object({
|
|
155
|
+
validityPeriodInSeconds: import_zod2.z.number().int().nonnegative(),
|
|
156
|
+
domain: import_zod2.z.string(),
|
|
157
|
+
scope: import_zod2.z.string(),
|
|
158
|
+
devMode: import_zod2.z.boolean()
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
var ZodZkPassportRegisterParamsSchema = import_zod2.z.object({
|
|
162
|
+
params: ZodSolidityVerifierParametersSchema,
|
|
163
|
+
isIDCard: import_zod2.z.boolean()
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// src/contracts/abis/index.ts
|
|
167
|
+
var import_viem2 = require("viem");
|
|
168
|
+
|
|
169
|
+
// src/contracts/abis/order-flow-facet.ts
|
|
170
|
+
var orderFlowFacetAbi = [
|
|
171
|
+
{
|
|
172
|
+
inputs: [
|
|
173
|
+
{ internalType: "uint256", name: "circleId", type: "uint256" },
|
|
174
|
+
{ internalType: "uint256", name: "assignUpto", type: "uint256" },
|
|
175
|
+
{ internalType: "bytes32", name: "currency", type: "bytes32" },
|
|
176
|
+
{ internalType: "address", name: "user", type: "address" },
|
|
177
|
+
{ internalType: "uint256", name: "usdtAmount", type: "uint256" },
|
|
178
|
+
{ internalType: "uint256", name: "fiatAmount", type: "uint256" },
|
|
179
|
+
{ internalType: "int256", name: "orderType", type: "int256" },
|
|
180
|
+
{ internalType: "uint256", name: "preferredPCConfigId", type: "uint256" }
|
|
181
|
+
],
|
|
182
|
+
name: "getAssignableMerchantsFromCircle",
|
|
183
|
+
outputs: [{ internalType: "address[]", name: "", type: "address[]" }],
|
|
184
|
+
stateMutability: "view",
|
|
185
|
+
type: "function"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
inputs: [
|
|
189
|
+
{ internalType: "address", name: "_user", type: "address" },
|
|
190
|
+
{ internalType: "bytes32", name: "_nativeCurrency", type: "bytes32" }
|
|
191
|
+
],
|
|
192
|
+
name: "userTxLimit",
|
|
193
|
+
outputs: [
|
|
194
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
195
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
196
|
+
],
|
|
197
|
+
stateMutability: "view",
|
|
198
|
+
type: "function"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
// src/contracts/abis/p2p-config-facet.ts
|
|
203
|
+
var p2pConfigFacetAbi = [
|
|
204
|
+
{
|
|
205
|
+
inputs: [
|
|
206
|
+
{
|
|
207
|
+
internalType: "bytes32",
|
|
208
|
+
name: "_currency",
|
|
209
|
+
type: "bytes32"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
name: "getPriceConfig",
|
|
213
|
+
outputs: [
|
|
214
|
+
{
|
|
215
|
+
components: [
|
|
216
|
+
{
|
|
217
|
+
internalType: "uint256",
|
|
218
|
+
name: "buyPrice",
|
|
219
|
+
type: "uint256"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
internalType: "uint256",
|
|
223
|
+
name: "sellPrice",
|
|
224
|
+
type: "uint256"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
internalType: "int256",
|
|
228
|
+
name: "buyPriceOffset",
|
|
229
|
+
type: "int256"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
internalType: "uint256",
|
|
233
|
+
name: "baseSpread",
|
|
234
|
+
type: "uint256"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
internalType: "struct P2pConfigStorage.PriceConfig",
|
|
238
|
+
name: "",
|
|
239
|
+
type: "tuple"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
stateMutability: "view",
|
|
243
|
+
type: "function"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
inputs: [
|
|
247
|
+
{
|
|
248
|
+
internalType: "bytes32",
|
|
249
|
+
name: "_nativeCurrency",
|
|
250
|
+
type: "bytes32"
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
name: "getRpPerUsdtLimitRational",
|
|
254
|
+
outputs: [
|
|
255
|
+
{
|
|
256
|
+
internalType: "uint256",
|
|
257
|
+
name: "numerator",
|
|
258
|
+
type: "uint256"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
internalType: "uint256",
|
|
262
|
+
name: "denominator",
|
|
263
|
+
type: "uint256"
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
stateMutability: "view",
|
|
267
|
+
type: "function"
|
|
268
|
+
}
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
// src/contracts/abis/reputation-manager.ts
|
|
272
|
+
var reputationManagerAbi = [
|
|
273
|
+
{
|
|
274
|
+
inputs: [
|
|
275
|
+
{
|
|
276
|
+
internalType: "string",
|
|
277
|
+
name: "_socialName",
|
|
278
|
+
type: "string"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
components: [
|
|
282
|
+
{
|
|
283
|
+
components: [
|
|
284
|
+
{
|
|
285
|
+
internalType: "string",
|
|
286
|
+
name: "provider",
|
|
287
|
+
type: "string"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
internalType: "string",
|
|
291
|
+
name: "parameters",
|
|
292
|
+
type: "string"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
internalType: "string",
|
|
296
|
+
name: "context",
|
|
297
|
+
type: "string"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
internalType: "struct IReclaimSDK.ClaimInfo",
|
|
301
|
+
name: "claimInfo",
|
|
302
|
+
type: "tuple"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
components: [
|
|
306
|
+
{
|
|
307
|
+
components: [
|
|
308
|
+
{
|
|
309
|
+
internalType: "bytes32",
|
|
310
|
+
name: "identifier",
|
|
311
|
+
type: "bytes32"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
internalType: "address",
|
|
315
|
+
name: "owner",
|
|
316
|
+
type: "address"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
internalType: "uint32",
|
|
320
|
+
name: "timestampS",
|
|
321
|
+
type: "uint32"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
internalType: "uint32",
|
|
325
|
+
name: "epoch",
|
|
326
|
+
type: "uint32"
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
internalType: "struct IReclaimSDK.CompleteClaimData",
|
|
330
|
+
name: "claim",
|
|
331
|
+
type: "tuple"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
internalType: "bytes[]",
|
|
335
|
+
name: "signatures",
|
|
336
|
+
type: "bytes[]"
|
|
337
|
+
}
|
|
338
|
+
],
|
|
339
|
+
internalType: "struct IReclaimSDK.SignedClaim",
|
|
340
|
+
name: "signedClaim",
|
|
341
|
+
type: "tuple"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
internalType: "struct IReclaimSDK.Proof[]",
|
|
345
|
+
name: "proofs",
|
|
346
|
+
type: "tuple[]"
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
name: "socialVerify",
|
|
350
|
+
outputs: [],
|
|
351
|
+
stateMutability: "nonpayable",
|
|
352
|
+
type: "function"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
inputs: [
|
|
356
|
+
{
|
|
357
|
+
internalType: "uint256",
|
|
358
|
+
name: "nullifierSeed",
|
|
359
|
+
type: "uint256"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
internalType: "uint256",
|
|
363
|
+
name: "nullifier",
|
|
364
|
+
type: "uint256"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
internalType: "uint256",
|
|
368
|
+
name: "timestamp",
|
|
369
|
+
type: "uint256"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
internalType: "uint256",
|
|
373
|
+
name: "signal",
|
|
374
|
+
type: "uint256"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
internalType: "uint256[4]",
|
|
378
|
+
name: "revealArray",
|
|
379
|
+
type: "uint256[4]"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
internalType: "uint256[8]",
|
|
383
|
+
name: "groth16Proof",
|
|
384
|
+
type: "uint256[8]"
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
name: "submitAnonAadharProof",
|
|
388
|
+
outputs: [],
|
|
389
|
+
stateMutability: "nonpayable",
|
|
390
|
+
type: "function"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
inputs: [
|
|
394
|
+
{
|
|
395
|
+
components: [
|
|
396
|
+
{
|
|
397
|
+
internalType: "bytes32",
|
|
398
|
+
name: "version",
|
|
399
|
+
type: "bytes32"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
components: [
|
|
403
|
+
{
|
|
404
|
+
internalType: "bytes32",
|
|
405
|
+
name: "vkeyHash",
|
|
406
|
+
type: "bytes32"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
internalType: "bytes",
|
|
410
|
+
name: "proof",
|
|
411
|
+
type: "bytes"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
internalType: "bytes32[]",
|
|
415
|
+
name: "publicInputs",
|
|
416
|
+
type: "bytes32[]"
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
internalType: "struct ProofVerificationData",
|
|
420
|
+
name: "proofVerificationData",
|
|
421
|
+
type: "tuple"
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
internalType: "bytes",
|
|
425
|
+
name: "committedInputs",
|
|
426
|
+
type: "bytes"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
components: [
|
|
430
|
+
{
|
|
431
|
+
internalType: "uint256",
|
|
432
|
+
name: "validityPeriodInSeconds",
|
|
433
|
+
type: "uint256"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
internalType: "string",
|
|
437
|
+
name: "domain",
|
|
438
|
+
type: "string"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
internalType: "string",
|
|
442
|
+
name: "scope",
|
|
443
|
+
type: "string"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
internalType: "bool",
|
|
447
|
+
name: "devMode",
|
|
448
|
+
type: "bool"
|
|
449
|
+
}
|
|
450
|
+
],
|
|
451
|
+
internalType: "struct ServiceConfig",
|
|
452
|
+
name: "serviceConfig",
|
|
453
|
+
type: "tuple"
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
internalType: "struct ProofVerificationParams",
|
|
457
|
+
name: "params",
|
|
458
|
+
type: "tuple"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
internalType: "bool",
|
|
462
|
+
name: "isIDCard",
|
|
463
|
+
type: "bool"
|
|
464
|
+
}
|
|
465
|
+
],
|
|
466
|
+
name: "zkPassportRegister",
|
|
467
|
+
outputs: [],
|
|
468
|
+
stateMutability: "nonpayable",
|
|
469
|
+
type: "function"
|
|
470
|
+
}
|
|
471
|
+
];
|
|
472
|
+
|
|
473
|
+
// src/contracts/abis/index.ts
|
|
474
|
+
var DIAMOND_ABI = [...orderFlowFacetAbi, ...p2pConfigFacetAbi];
|
|
475
|
+
var ABIS = {
|
|
476
|
+
DIAMOND: DIAMOND_ABI,
|
|
477
|
+
FACETS: {
|
|
478
|
+
ORDER_FLOW: orderFlowFacetAbi,
|
|
479
|
+
CONFIG: p2pConfigFacetAbi
|
|
480
|
+
},
|
|
481
|
+
EXTERNAL: {
|
|
482
|
+
USDC: import_viem2.erc20Abi,
|
|
483
|
+
REPUTATION_MANAGER: reputationManagerAbi
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/contracts/reputation-manager/writes.ts
|
|
488
|
+
function prepareSocialVerify(reputationManagerAddress, params) {
|
|
489
|
+
return validate(
|
|
490
|
+
ZodSocialVerifyParamsSchema,
|
|
491
|
+
params,
|
|
492
|
+
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
493
|
+
).andThen(
|
|
494
|
+
(validated) => import_neverthrow2.Result.fromThrowable(
|
|
495
|
+
() => ({
|
|
496
|
+
to: reputationManagerAddress,
|
|
497
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
498
|
+
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
499
|
+
functionName: "socialVerify",
|
|
500
|
+
args: [
|
|
501
|
+
validated._socialName,
|
|
502
|
+
validated.proofs.map((proof) => ({
|
|
503
|
+
...proof,
|
|
504
|
+
signedClaim: {
|
|
505
|
+
...proof.signedClaim,
|
|
506
|
+
claim: {
|
|
507
|
+
...proof.signedClaim.claim,
|
|
508
|
+
identifier: proof.signedClaim.claim.identifier
|
|
509
|
+
},
|
|
510
|
+
signatures: proof.signedClaim.signatures
|
|
511
|
+
}
|
|
512
|
+
}))
|
|
513
|
+
]
|
|
514
|
+
})
|
|
515
|
+
}),
|
|
516
|
+
(error) => new ZkkycError("Failed to encode socialVerify", {
|
|
517
|
+
code: "ENCODE_ERROR",
|
|
518
|
+
cause: error
|
|
519
|
+
})
|
|
520
|
+
)()
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
function prepareSubmitAnonAadharProof(reputationManagerAddress, params) {
|
|
524
|
+
return validate(
|
|
525
|
+
ZodAnonAadharProofParamsSchema,
|
|
526
|
+
params,
|
|
527
|
+
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
528
|
+
).andThen(
|
|
529
|
+
(validated) => import_neverthrow2.Result.fromThrowable(
|
|
530
|
+
() => ({
|
|
531
|
+
to: reputationManagerAddress,
|
|
532
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
533
|
+
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
534
|
+
functionName: "submitAnonAadharProof",
|
|
535
|
+
args: [
|
|
536
|
+
validated.nullifierSeed,
|
|
537
|
+
validated.nullifier,
|
|
538
|
+
validated.timestamp,
|
|
539
|
+
validated.signal,
|
|
540
|
+
validated.revealArray,
|
|
541
|
+
validated.packedGroth16Proof
|
|
542
|
+
]
|
|
543
|
+
})
|
|
544
|
+
}),
|
|
545
|
+
(error) => new ZkkycError("Failed to encode submitAnonAadharProof", {
|
|
546
|
+
code: "ENCODE_ERROR",
|
|
547
|
+
cause: error
|
|
548
|
+
})
|
|
549
|
+
)()
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
function prepareZkPassportRegister(reputationManagerAddress, params) {
|
|
553
|
+
return validate(
|
|
554
|
+
ZodZkPassportRegisterParamsSchema,
|
|
555
|
+
params,
|
|
556
|
+
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
557
|
+
).andThen(
|
|
558
|
+
(validated) => import_neverthrow2.Result.fromThrowable(
|
|
559
|
+
() => {
|
|
560
|
+
const { proofVerificationData, serviceConfig, committedInputs, version } = validated.params;
|
|
561
|
+
const proofVerificationParams = {
|
|
562
|
+
version,
|
|
563
|
+
proofVerificationData: {
|
|
564
|
+
vkeyHash: proofVerificationData.vkeyHash,
|
|
565
|
+
proof: proofVerificationData.proof,
|
|
566
|
+
publicInputs: proofVerificationData.publicInputs
|
|
567
|
+
},
|
|
568
|
+
committedInputs,
|
|
569
|
+
serviceConfig: {
|
|
570
|
+
validityPeriodInSeconds: BigInt(serviceConfig.validityPeriodInSeconds),
|
|
571
|
+
domain: serviceConfig.domain,
|
|
572
|
+
scope: serviceConfig.scope,
|
|
573
|
+
devMode: serviceConfig.devMode
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
return {
|
|
577
|
+
to: reputationManagerAddress,
|
|
578
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
579
|
+
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
580
|
+
functionName: "zkPassportRegister",
|
|
581
|
+
args: [proofVerificationParams, validated.isIDCard]
|
|
582
|
+
})
|
|
583
|
+
};
|
|
584
|
+
},
|
|
585
|
+
(error) => new ZkkycError("Failed to encode zkPassportRegister", {
|
|
586
|
+
code: "ENCODE_ERROR",
|
|
587
|
+
cause: error
|
|
588
|
+
})
|
|
589
|
+
)()
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// src/zkkyc/client.ts
|
|
594
|
+
function createZkkyc(config) {
|
|
595
|
+
const { reputationManagerAddress } = config;
|
|
596
|
+
return {
|
|
597
|
+
prepareSocialVerify: (params) => prepareSocialVerify(reputationManagerAddress, params),
|
|
598
|
+
prepareSubmitAnonAadharProof: (params) => prepareSubmitAnonAadharProof(reputationManagerAddress, params),
|
|
599
|
+
prepareZkPassportRegister: (params) => prepareZkPassportRegister(reputationManagerAddress, params)
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// src/zkkyc/orchestrators/constants.ts
|
|
604
|
+
var DEFAULT_RECLAIM_PROVIDER_IDS = {
|
|
605
|
+
linkedin: "6a86edbe-a0fe-420b-8db2-3155220cc949",
|
|
606
|
+
github: "033f0c06-2eb3-48c8-894c-5599c3356d1c",
|
|
607
|
+
x: "aad95818-f726-4a34-be97-8d1f47631b03",
|
|
608
|
+
instagram: "7e5b59a9-56c5-490c-a169-82a443f9b507",
|
|
609
|
+
facebook: "2701510b-c835-4820-84f0-d9e74569656b"
|
|
610
|
+
};
|
|
611
|
+
var ZK_PASSPORT_APP_LINKS = {
|
|
612
|
+
IOS: "https://apps.apple.com/us/app/zkpassport/id6477371975",
|
|
613
|
+
ANDROID: "https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport"
|
|
614
|
+
};
|
|
615
|
+
var RECLAIM_APP_LINKS = {
|
|
616
|
+
ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app"
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/zkkyc/orchestrators/reclaim.ts
|
|
620
|
+
var import_neverthrow3 = require("neverthrow");
|
|
621
|
+
|
|
622
|
+
// src/zkkyc/orchestrators/types.ts
|
|
623
|
+
var SOCIAL_PLATFORM_NAMES = {
|
|
624
|
+
linkedin: "LinkedIn",
|
|
625
|
+
github: "GitHub",
|
|
626
|
+
x: "X",
|
|
627
|
+
instagram: "Instagram",
|
|
628
|
+
facebook: "Facebook"
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// src/zkkyc/orchestrators/reclaim.ts
|
|
632
|
+
var RECLAIM_SESSION_API = "https://api.reclaimprotocol.org/api/sdk/session";
|
|
633
|
+
function createReclaimFlow(config, options) {
|
|
634
|
+
return import_neverthrow3.ResultAsync.fromPromise(
|
|
635
|
+
(async () => {
|
|
636
|
+
const mod = await import("@reclaimprotocol/js-sdk").catch(() => {
|
|
637
|
+
throw new ZkkycError(
|
|
638
|
+
"Missing peer dependency: @reclaimprotocol/js-sdk. Install it with: npm install @reclaimprotocol/js-sdk",
|
|
639
|
+
{ code: "PEER_DEPENDENCY_MISSING" }
|
|
640
|
+
);
|
|
641
|
+
});
|
|
642
|
+
const { ReclaimProofRequest, transformForOnchain } = mod;
|
|
643
|
+
const {
|
|
644
|
+
platform,
|
|
645
|
+
walletAddress,
|
|
646
|
+
redirectUrl,
|
|
647
|
+
sessionId: existingSessionId,
|
|
648
|
+
contextDescription,
|
|
649
|
+
onStatus,
|
|
650
|
+
signal,
|
|
651
|
+
pollingIntervalMs = 5e3
|
|
652
|
+
} = options;
|
|
653
|
+
const socialName = SOCIAL_PLATFORM_NAMES[platform];
|
|
654
|
+
const providerId = config.providerIds[platform];
|
|
655
|
+
let sessionId;
|
|
656
|
+
if (existingSessionId) {
|
|
657
|
+
sessionId = existingSessionId;
|
|
658
|
+
} else {
|
|
659
|
+
const reclaimProofRequest = await ReclaimProofRequest.init(
|
|
660
|
+
config.appId,
|
|
661
|
+
config.appSecret,
|
|
662
|
+
providerId,
|
|
663
|
+
{ launchOptions: { canUseDeferredDeepLinksFlow: true } }
|
|
664
|
+
);
|
|
665
|
+
const statusUrl = reclaimProofRequest.getStatusUrl();
|
|
666
|
+
sessionId = statusUrl.split("/").pop() || "";
|
|
667
|
+
if (redirectUrl) {
|
|
668
|
+
const separator = redirectUrl.includes("?") ? "&" : "?";
|
|
669
|
+
reclaimProofRequest.setRedirectUrl(
|
|
670
|
+
`${redirectUrl}${separator}sessionId=${sessionId}&socialPlatform=${socialName}`
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
reclaimProofRequest.addContext(
|
|
674
|
+
walletAddress,
|
|
675
|
+
contextDescription ?? `Social verification for ${socialName}`
|
|
676
|
+
);
|
|
677
|
+
const requestUrl = await reclaimProofRequest.getRequestUrl();
|
|
678
|
+
onStatus?.({ type: "session_created", sessionId, requestUrl });
|
|
679
|
+
if (typeof window !== "undefined") {
|
|
680
|
+
reclaimProofRequest.triggerReclaimFlow();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
onStatus?.({ type: "polling_started", sessionId });
|
|
684
|
+
while (true) {
|
|
685
|
+
if (signal?.aborted) {
|
|
686
|
+
throw new ZkkycError("Reclaim polling aborted", {
|
|
687
|
+
code: "RECLAIM_POLLING_ABORTED"
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
const response = await fetch(`${RECLAIM_SESSION_API}/${sessionId}`);
|
|
691
|
+
const data = await response.json();
|
|
692
|
+
if (data?.session?.proofs?.length > 0) {
|
|
693
|
+
const proofs = data.session.proofs;
|
|
694
|
+
onStatus?.({ type: "proof_received" });
|
|
695
|
+
if (platform === "github" && proofs.length > 0) {
|
|
696
|
+
const first = proofs[0];
|
|
697
|
+
if (first?.publicData && Object.keys(first.publicData).length === 0) {
|
|
698
|
+
throw new ZkkycError("GitHub verification eligibility criteria not met", {
|
|
699
|
+
code: "RECLAIM_PROOF_INVALID"
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const transformedProofs = proofs.map((proof) => transformForOnchain(proof));
|
|
704
|
+
onStatus?.({ type: "proof_transformed" });
|
|
705
|
+
return {
|
|
706
|
+
_socialName: socialName,
|
|
707
|
+
proofs: transformedProofs,
|
|
708
|
+
sessionId
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
if (data?.message?.includes("Session not found")) {
|
|
712
|
+
throw new ZkkycError("Reclaim session not found", {
|
|
713
|
+
code: "RECLAIM_SESSION_NOT_FOUND",
|
|
714
|
+
context: { sessionId }
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
if (data?.session?.statusV2 === "PROOF_GENERATION_FAILED") {
|
|
718
|
+
throw new ZkkycError("Reclaim proof generation failed", {
|
|
719
|
+
code: "RECLAIM_PROOF_GENERATION_FAILED",
|
|
720
|
+
context: { sessionId }
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
await new Promise((resolve) => setTimeout(resolve, pollingIntervalMs));
|
|
724
|
+
}
|
|
725
|
+
})(),
|
|
726
|
+
(error) => {
|
|
727
|
+
if (error instanceof ZkkycError) return error;
|
|
728
|
+
return new ZkkycError("Reclaim verification flow failed", {
|
|
729
|
+
code: "RECLAIM_INIT_FAILED",
|
|
730
|
+
cause: error
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// src/zkkyc/orchestrators/zk-passport.ts
|
|
737
|
+
var import_neverthrow4 = require("neverthrow");
|
|
738
|
+
function createZkPassportFlow(config, options) {
|
|
739
|
+
return import_neverthrow4.ResultAsync.fromPromise(
|
|
740
|
+
(async () => {
|
|
741
|
+
const mod = await import("@zkpassport/sdk").catch(() => {
|
|
742
|
+
throw new ZkkycError(
|
|
743
|
+
"Missing peer dependency: @zkpassport/sdk. Install it with: npm install @zkpassport/sdk",
|
|
744
|
+
{ code: "PEER_DEPENDENCY_MISSING" }
|
|
745
|
+
);
|
|
746
|
+
});
|
|
747
|
+
const { ZKPassport } = mod;
|
|
748
|
+
const zkPassport = new ZKPassport(config.domain ?? "app.p2p.me");
|
|
749
|
+
const queryBuilder = await zkPassport.request({
|
|
750
|
+
name: config.name ?? "ZKPassport",
|
|
751
|
+
logo: config.logo ?? "https://app.p2p.lol/favicon.svg",
|
|
752
|
+
purpose: config.purpose ?? "Prove your personhood",
|
|
753
|
+
scope: "personhood",
|
|
754
|
+
mode: "compressed-evm"
|
|
755
|
+
});
|
|
756
|
+
const {
|
|
757
|
+
url,
|
|
758
|
+
onRequestReceived,
|
|
759
|
+
onGeneratingProof,
|
|
760
|
+
onProofGenerated,
|
|
761
|
+
onResult,
|
|
762
|
+
onReject,
|
|
763
|
+
onError
|
|
764
|
+
} = queryBuilder.gte("age", 18).disclose("document_type").disclose("nationality").bind("user_address", options.walletAddress).done();
|
|
765
|
+
options.onStatus?.({ type: "request_created", url });
|
|
766
|
+
let aborted = false;
|
|
767
|
+
const resultPromise = new Promise((resolve, reject) => {
|
|
768
|
+
let proof = null;
|
|
769
|
+
onRequestReceived(() => {
|
|
770
|
+
if (aborted) return;
|
|
771
|
+
options.onStatus?.({ type: "request_received" });
|
|
772
|
+
});
|
|
773
|
+
onGeneratingProof(() => {
|
|
774
|
+
if (aborted) return;
|
|
775
|
+
options.onStatus?.({ type: "generating_proof" });
|
|
776
|
+
});
|
|
777
|
+
onProofGenerated(async (result) => {
|
|
778
|
+
if (aborted) return;
|
|
779
|
+
options.onStatus?.({ type: "proof_generated" });
|
|
780
|
+
proof = result;
|
|
781
|
+
});
|
|
782
|
+
onResult(
|
|
783
|
+
async ({
|
|
784
|
+
result,
|
|
785
|
+
uniqueIdentifier,
|
|
786
|
+
verified
|
|
787
|
+
}) => {
|
|
788
|
+
if (aborted) return;
|
|
789
|
+
options.onStatus?.({ type: "result_received" });
|
|
790
|
+
if (!verified || !proof || !uniqueIdentifier) {
|
|
791
|
+
reject(
|
|
792
|
+
new ZkkycError("ZK Passport verification failed", {
|
|
793
|
+
code: "ZK_PASSPORT_VERIFICATION_FAILED"
|
|
794
|
+
})
|
|
795
|
+
);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
try {
|
|
799
|
+
const verifierParams = zkPassport.getSolidityVerifierParameters({
|
|
800
|
+
proof,
|
|
801
|
+
scope: "personhood",
|
|
802
|
+
devMode: false
|
|
803
|
+
});
|
|
804
|
+
const isIDCard = result.document_type?.disclose?.result !== "passport";
|
|
805
|
+
resolve({ params: verifierParams, isIDCard });
|
|
806
|
+
} catch (error) {
|
|
807
|
+
reject(
|
|
808
|
+
new ZkkycError("Failed to extract ZK Passport verifier parameters", {
|
|
809
|
+
code: "ZK_PASSPORT_VERIFICATION_FAILED",
|
|
810
|
+
cause: error
|
|
811
|
+
})
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
onReject(() => {
|
|
817
|
+
options.onStatus?.({ type: "rejected" });
|
|
818
|
+
reject(
|
|
819
|
+
new ZkkycError("User rejected ZK Passport verification", {
|
|
820
|
+
code: "ZK_PASSPORT_REJECTED"
|
|
821
|
+
})
|
|
822
|
+
);
|
|
823
|
+
});
|
|
824
|
+
onError((error) => {
|
|
825
|
+
reject(
|
|
826
|
+
new ZkkycError(typeof error === "string" ? error : "ZK Passport verification error", {
|
|
827
|
+
code: "ZK_PASSPORT_VERIFICATION_FAILED",
|
|
828
|
+
cause: error
|
|
829
|
+
})
|
|
830
|
+
);
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
const session = {
|
|
834
|
+
url,
|
|
835
|
+
result: import_neverthrow4.ResultAsync.fromPromise(resultPromise, (error) => {
|
|
836
|
+
if (error instanceof ZkkycError) return error;
|
|
837
|
+
return new ZkkycError("ZK Passport flow failed", {
|
|
838
|
+
code: "ZK_PASSPORT_VERIFICATION_FAILED",
|
|
839
|
+
cause: error
|
|
840
|
+
});
|
|
841
|
+
}),
|
|
842
|
+
abort: () => {
|
|
843
|
+
aborted = true;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
return session;
|
|
847
|
+
})(),
|
|
848
|
+
(error) => {
|
|
849
|
+
if (error instanceof ZkkycError) return error;
|
|
850
|
+
return new ZkkycError("Failed to initialize ZK Passport", {
|
|
851
|
+
code: "ZK_PASSPORT_INIT_FAILED",
|
|
852
|
+
cause: error
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
858
|
+
0 && (module.exports = {
|
|
859
|
+
DEFAULT_RECLAIM_PROVIDER_IDS,
|
|
860
|
+
RECLAIM_APP_LINKS,
|
|
861
|
+
SOCIAL_PLATFORM_NAMES,
|
|
862
|
+
ZK_PASSPORT_APP_LINKS,
|
|
863
|
+
ZkkycError,
|
|
864
|
+
createReclaimFlow,
|
|
865
|
+
createZkPassportFlow,
|
|
866
|
+
createZkkyc
|
|
867
|
+
});
|
|
868
|
+
//# sourceMappingURL=zkkyc.cjs.map
|