@p2pdotme/sdk 1.2.11 → 1.2.13
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/dist/country.cjs +1 -1
- package/dist/country.cjs.map +1 -1
- package/dist/country.mjs +1 -1
- package/dist/country.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/orders.cjs +47 -0
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.mjs +47 -0
- package/dist/orders.mjs.map +1 -1
- package/dist/prices.cjs +47 -0
- package/dist/prices.cjs.map +1 -1
- package/dist/prices.mjs +47 -0
- package/dist/prices.mjs.map +1 -1
- package/dist/profile.cjs +47 -0
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.mjs +47 -0
- package/dist/profile.mjs.map +1 -1
- package/dist/qr-parsers.cjs +50 -1
- package/dist/qr-parsers.cjs.map +1 -1
- package/dist/qr-parsers.d.cts +1 -1
- package/dist/qr-parsers.d.ts +1 -1
- package/dist/qr-parsers.mjs +50 -1
- package/dist/qr-parsers.mjs.map +1 -1
- package/dist/react.cjs +76 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +12 -1
- package/dist/react.d.ts +12 -1
- package/dist/react.mjs +76 -1
- package/dist/react.mjs.map +1 -1
- package/dist/stake.cjs +33 -0
- package/dist/stake.cjs.map +1 -1
- package/dist/stake.mjs +33 -0
- package/dist/stake.mjs.map +1 -1
- package/dist/zkkyc.cjs +190 -29
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.d.cts +107 -10
- package/dist/zkkyc.d.ts +107 -10
- package/dist/zkkyc.mjs +187 -29
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +1 -1
package/dist/zkkyc.cjs
CHANGED
|
@@ -32,16 +32,19 @@ var zkkyc_exports = {};
|
|
|
32
32
|
__export(zkkyc_exports, {
|
|
33
33
|
BVN_OTP_METHODS: () => BVN_OTP_METHODS,
|
|
34
34
|
DEFAULT_RECLAIM_PROVIDER_IDS: () => DEFAULT_RECLAIM_PROVIDER_IDS,
|
|
35
|
+
LIVENESS_DEFAULT_TENANT: () => LIVENESS_DEFAULT_TENANT,
|
|
35
36
|
RECLAIM_APP_LINKS: () => RECLAIM_APP_LINKS,
|
|
36
37
|
SIMPLE_KYC_DEFAULT_TENANT: () => SIMPLE_KYC_DEFAULT_TENANT,
|
|
37
38
|
SOCIAL_PLATFORM_NAMES: () => SOCIAL_PLATFORM_NAMES,
|
|
38
39
|
ZK_PASSPORT_APP_LINKS: () => ZK_PASSPORT_APP_LINKS,
|
|
39
40
|
ZkkycError: () => ZkkycError,
|
|
40
41
|
createBvnFlow: () => createBvnFlow,
|
|
42
|
+
createLivenessFlow: () => createLivenessFlow,
|
|
41
43
|
createReclaimFlow: () => createReclaimFlow,
|
|
42
44
|
createSimpleKycFlow: () => createSimpleKycFlow,
|
|
43
45
|
createZkPassportFlow: () => createZkPassportFlow,
|
|
44
46
|
createZkkyc: () => createZkkyc,
|
|
47
|
+
resumeLivenessFlow: () => resumeLivenessFlow,
|
|
45
48
|
resumeSimpleKycFlow: () => resumeSimpleKycFlow
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(zkkyc_exports);
|
|
@@ -206,6 +209,20 @@ var ZodBvnSubmitParamsSchema = import_zod2.z.object({
|
|
|
206
209
|
message: "signature must be a hex string"
|
|
207
210
|
})
|
|
208
211
|
});
|
|
212
|
+
var ZodLivenessSubmitParamsSchema = import_zod2.z.object({
|
|
213
|
+
/** Per-(tenant, identity) Sybil nullifier (bytes32 hex). */
|
|
214
|
+
nullifier: import_zod2.z.string().refine((v) => /^0x[a-fA-F0-9]{64}$/.test(v), {
|
|
215
|
+
message: "nullifier must be a bytes32 hex string"
|
|
216
|
+
}),
|
|
217
|
+
/** Remaining limit in micro-USDC (part of the signed struct). */
|
|
218
|
+
limit: import_zod2.z.bigint(),
|
|
219
|
+
/** Attestation expiry (unix seconds). */
|
|
220
|
+
expiry: import_zod2.z.bigint(),
|
|
221
|
+
/** 65-byte secp256k1 signature (hex). */
|
|
222
|
+
signature: import_zod2.z.string().refine((v) => /^0x[a-fA-F0-9]+$/.test(v), {
|
|
223
|
+
message: "signature must be a hex string"
|
|
224
|
+
})
|
|
225
|
+
});
|
|
209
226
|
|
|
210
227
|
// src/contracts/abis/index.ts
|
|
211
228
|
var import_viem2 = require("viem");
|
|
@@ -1042,6 +1059,39 @@ var reputationManagerAbi = [
|
|
|
1042
1059
|
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
1043
1060
|
stateMutability: "view",
|
|
1044
1061
|
type: "function"
|
|
1062
|
+
},
|
|
1063
|
+
// ── Liveness (face-only, no document) attestation ───────────────────────
|
|
1064
|
+
{ inputs: [], name: "LivenessSignerNotSet", type: "error" },
|
|
1065
|
+
{ inputs: [], name: "LivenessAttestationExpired", type: "error" },
|
|
1066
|
+
{ inputs: [], name: "LivenessNullifierZero", type: "error" },
|
|
1067
|
+
{ inputs: [], name: "LivenessNullifierAlreadySpent", type: "error" },
|
|
1068
|
+
{ inputs: [], name: "LivenessAlreadyVerified", type: "error" },
|
|
1069
|
+
{ inputs: [], name: "LivenessInvalidSignature", type: "error" },
|
|
1070
|
+
{
|
|
1071
|
+
inputs: [
|
|
1072
|
+
{ internalType: "bytes32", name: "nullifier", type: "bytes32" },
|
|
1073
|
+
{ internalType: "uint256", name: "limit", type: "uint256" },
|
|
1074
|
+
{ internalType: "uint256", name: "expiry", type: "uint256" },
|
|
1075
|
+
{ internalType: "bytes", name: "signature", type: "bytes" }
|
|
1076
|
+
],
|
|
1077
|
+
name: "submitLivenessAttestation",
|
|
1078
|
+
outputs: [],
|
|
1079
|
+
stateMutability: "nonpayable",
|
|
1080
|
+
type: "function"
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
inputs: [],
|
|
1084
|
+
name: "livenessRp",
|
|
1085
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
1086
|
+
stateMutability: "view",
|
|
1087
|
+
type: "function"
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
1091
|
+
name: "livenessVerified",
|
|
1092
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
1093
|
+
stateMutability: "view",
|
|
1094
|
+
type: "function"
|
|
1045
1095
|
}
|
|
1046
1096
|
];
|
|
1047
1097
|
|
|
@@ -1185,6 +1235,33 @@ function prepareSubmitBvnAttestation(reputationManagerAddress, params) {
|
|
|
1185
1235
|
)()
|
|
1186
1236
|
);
|
|
1187
1237
|
}
|
|
1238
|
+
function prepareSubmitLivenessAttestation(reputationManagerAddress, params) {
|
|
1239
|
+
return validate(
|
|
1240
|
+
ZodLivenessSubmitParamsSchema,
|
|
1241
|
+
params,
|
|
1242
|
+
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
1243
|
+
).andThen(
|
|
1244
|
+
(validated) => import_neverthrow2.Result.fromThrowable(
|
|
1245
|
+
() => ({
|
|
1246
|
+
to: reputationManagerAddress,
|
|
1247
|
+
data: (0, import_viem3.encodeFunctionData)({
|
|
1248
|
+
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
1249
|
+
functionName: "submitLivenessAttestation",
|
|
1250
|
+
args: [
|
|
1251
|
+
validated.nullifier,
|
|
1252
|
+
validated.limit,
|
|
1253
|
+
validated.expiry,
|
|
1254
|
+
validated.signature
|
|
1255
|
+
]
|
|
1256
|
+
})
|
|
1257
|
+
}),
|
|
1258
|
+
(error) => new ZkkycError("Failed to encode submitLivenessAttestation", {
|
|
1259
|
+
code: "ENCODE_ERROR",
|
|
1260
|
+
cause: error
|
|
1261
|
+
})
|
|
1262
|
+
)()
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1188
1265
|
function prepareZkPassportRegister(reputationManagerAddress, params) {
|
|
1189
1266
|
return validate(
|
|
1190
1267
|
ZodZkPassportRegisterParamsSchema,
|
|
@@ -1234,29 +1311,11 @@ function createZkkyc(config) {
|
|
|
1234
1311
|
prepareSubmitAnonAadharProof: (params) => prepareSubmitAnonAadharProof(reputationManagerAddress, params),
|
|
1235
1312
|
prepareZkPassportRegister: (params) => prepareZkPassportRegister(reputationManagerAddress, params),
|
|
1236
1313
|
prepareSubmitKycAttestation: (params) => prepareSubmitKycAttestation(reputationManagerAddress, params),
|
|
1237
|
-
prepareSubmitBvnAttestation: (params) => prepareSubmitBvnAttestation(reputationManagerAddress, params)
|
|
1314
|
+
prepareSubmitBvnAttestation: (params) => prepareSubmitBvnAttestation(reputationManagerAddress, params),
|
|
1315
|
+
prepareSubmitLivenessAttestation: (params) => prepareSubmitLivenessAttestation(reputationManagerAddress, params)
|
|
1238
1316
|
};
|
|
1239
1317
|
}
|
|
1240
1318
|
|
|
1241
|
-
// src/zkkyc/orchestrators/constants.ts
|
|
1242
|
-
var DEFAULT_RECLAIM_PROVIDER_IDS = {
|
|
1243
|
-
linkedin: "6a86edbe-a0fe-420b-8db2-3155220cc949",
|
|
1244
|
-
github: "033f0c06-2eb3-48c8-894c-5599c3356d1c",
|
|
1245
|
-
x: "aad95818-f726-4a34-be97-8d1f47631b03",
|
|
1246
|
-
instagram: "7e5b59a9-56c5-490c-a169-82a443f9b507",
|
|
1247
|
-
facebook: "2701510b-c835-4820-84f0-d9e74569656b",
|
|
1248
|
-
binance: "7e40c007-f432-4d47-ac00-3e0762f8a7a0"
|
|
1249
|
-
};
|
|
1250
|
-
var ZK_PASSPORT_APP_LINKS = {
|
|
1251
|
-
IOS: "https://apps.apple.com/us/app/zkpassport/id6477371975",
|
|
1252
|
-
ANDROID: "https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport"
|
|
1253
|
-
};
|
|
1254
|
-
var RECLAIM_APP_LINKS = {
|
|
1255
|
-
ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app"
|
|
1256
|
-
};
|
|
1257
|
-
var SIMPLE_KYC_DEFAULT_TENANT = "p2p-reputation";
|
|
1258
|
-
var BVN_OTP_METHODS = ["email", "phone", "phone_1", "alternate_phone"];
|
|
1259
|
-
|
|
1260
1319
|
// src/zkkyc/orchestrators/bvn.ts
|
|
1261
1320
|
var import_neverthrow3 = require("neverthrow");
|
|
1262
1321
|
function createBvnFlow(config) {
|
|
@@ -1396,8 +1455,107 @@ function createBvnFlow(config) {
|
|
|
1396
1455
|
};
|
|
1397
1456
|
}
|
|
1398
1457
|
|
|
1399
|
-
// src/zkkyc/orchestrators/
|
|
1458
|
+
// src/zkkyc/orchestrators/constants.ts
|
|
1459
|
+
var DEFAULT_RECLAIM_PROVIDER_IDS = {
|
|
1460
|
+
linkedin: "6a86edbe-a0fe-420b-8db2-3155220cc949",
|
|
1461
|
+
github: "033f0c06-2eb3-48c8-894c-5599c3356d1c",
|
|
1462
|
+
x: "aad95818-f726-4a34-be97-8d1f47631b03",
|
|
1463
|
+
instagram: "7e5b59a9-56c5-490c-a169-82a443f9b507",
|
|
1464
|
+
facebook: "2701510b-c835-4820-84f0-d9e74569656b",
|
|
1465
|
+
binance: "7e40c007-f432-4d47-ac00-3e0762f8a7a0"
|
|
1466
|
+
};
|
|
1467
|
+
var ZK_PASSPORT_APP_LINKS = {
|
|
1468
|
+
IOS: "https://apps.apple.com/us/app/zkpassport/id6477371975",
|
|
1469
|
+
ANDROID: "https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport"
|
|
1470
|
+
};
|
|
1471
|
+
var RECLAIM_APP_LINKS = {
|
|
1472
|
+
ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app"
|
|
1473
|
+
};
|
|
1474
|
+
var SIMPLE_KYC_DEFAULT_TENANT = "p2p-reputation";
|
|
1475
|
+
var LIVENESS_DEFAULT_TENANT = "p2p-reputation-liveness";
|
|
1476
|
+
var BVN_OTP_METHODS = ["email", "phone", "phone_1", "alternate_phone"];
|
|
1477
|
+
|
|
1478
|
+
// src/zkkyc/orchestrators/liveness.ts
|
|
1400
1479
|
var import_neverthrow4 = require("neverthrow");
|
|
1480
|
+
function createLivenessFlow(params) {
|
|
1481
|
+
const { baseUrl, walletAddress, tenant, redirectUrl, state, onStatus } = params;
|
|
1482
|
+
return import_neverthrow4.ResultAsync.fromPromise(
|
|
1483
|
+
(async () => {
|
|
1484
|
+
const res = await fetch(`${baseUrl}/v1/widget/public-sessions`, {
|
|
1485
|
+
method: "POST",
|
|
1486
|
+
headers: { "Content-Type": "application/json" },
|
|
1487
|
+
body: JSON.stringify({
|
|
1488
|
+
wallet_pubkey: walletAddress,
|
|
1489
|
+
redirect_uri: redirectUrl,
|
|
1490
|
+
tenant,
|
|
1491
|
+
state
|
|
1492
|
+
})
|
|
1493
|
+
});
|
|
1494
|
+
if (!res.ok) {
|
|
1495
|
+
const body = await res.text();
|
|
1496
|
+
throw new ZkkycError(`liveness session creation failed: ${res.status} ${body}`, {
|
|
1497
|
+
code: "LIVENESS_SESSION_FAILED",
|
|
1498
|
+
context: { status: res.status }
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
const data = await res.json();
|
|
1502
|
+
const widgetUrl = data.widget_url;
|
|
1503
|
+
onStatus?.({ type: "session_created", widgetUrl });
|
|
1504
|
+
return {
|
|
1505
|
+
widgetUrl,
|
|
1506
|
+
redirect: () => {
|
|
1507
|
+
if (typeof window !== "undefined") {
|
|
1508
|
+
onStatus?.({ type: "redirecting", widgetUrl });
|
|
1509
|
+
window.location.href = widgetUrl;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
})(),
|
|
1514
|
+
(error) => {
|
|
1515
|
+
if (error instanceof ZkkycError) return error;
|
|
1516
|
+
return new ZkkycError("liveness flow failed to start", {
|
|
1517
|
+
code: "LIVENESS_SESSION_FAILED",
|
|
1518
|
+
cause: error
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
function resumeLivenessFlow(args) {
|
|
1524
|
+
return import_neverthrow4.ResultAsync.fromPromise(
|
|
1525
|
+
(async () => {
|
|
1526
|
+
const res = await fetch(`${args.baseUrl}/v1/widget/attestation`, {
|
|
1527
|
+
method: "POST",
|
|
1528
|
+
headers: { "Content-Type": "application/json" },
|
|
1529
|
+
body: JSON.stringify({ code: args.code })
|
|
1530
|
+
});
|
|
1531
|
+
if (!res.ok) {
|
|
1532
|
+
const body = await res.text();
|
|
1533
|
+
throw new ZkkycError(`liveness attestation redemption failed: ${res.status} ${body}`, {
|
|
1534
|
+
code: "LIVENESS_REDEEM_FAILED",
|
|
1535
|
+
context: { status: res.status }
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
const d = await res.json();
|
|
1539
|
+
return {
|
|
1540
|
+
nullifier: d.nullifier,
|
|
1541
|
+
limit: BigInt(d.limit),
|
|
1542
|
+
expiry: BigInt(d.expiry),
|
|
1543
|
+
signature: d.signature,
|
|
1544
|
+
identityHash: d.identity_hash
|
|
1545
|
+
};
|
|
1546
|
+
})(),
|
|
1547
|
+
(error) => {
|
|
1548
|
+
if (error instanceof ZkkycError) return error;
|
|
1549
|
+
return new ZkkycError("liveness attestation redemption failed", {
|
|
1550
|
+
code: "LIVENESS_REDEEM_FAILED",
|
|
1551
|
+
cause: error
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// src/zkkyc/orchestrators/reclaim.ts
|
|
1558
|
+
var import_neverthrow5 = require("neverthrow");
|
|
1401
1559
|
|
|
1402
1560
|
// src/zkkyc/orchestrators/types.ts
|
|
1403
1561
|
var SOCIAL_PLATFORM_NAMES = {
|
|
@@ -1412,7 +1570,7 @@ var SOCIAL_PLATFORM_NAMES = {
|
|
|
1412
1570
|
// src/zkkyc/orchestrators/reclaim.ts
|
|
1413
1571
|
var RECLAIM_SESSION_API = "https://api.reclaimprotocol.org/api/sdk/session";
|
|
1414
1572
|
function createReclaimFlow(params) {
|
|
1415
|
-
return
|
|
1573
|
+
return import_neverthrow5.ResultAsync.fromPromise(
|
|
1416
1574
|
(async () => {
|
|
1417
1575
|
const mod = await import("@reclaimprotocol/js-sdk").catch(() => {
|
|
1418
1576
|
throw new ZkkycError(
|
|
@@ -1516,7 +1674,7 @@ function createReclaimFlow(params) {
|
|
|
1516
1674
|
const session = {
|
|
1517
1675
|
sessionId,
|
|
1518
1676
|
requestUrl,
|
|
1519
|
-
start: () =>
|
|
1677
|
+
start: () => import_neverthrow5.ResultAsync.fromPromise(pollForProof(), (error) => {
|
|
1520
1678
|
if (error instanceof ZkkycError) return error;
|
|
1521
1679
|
return new ZkkycError("Reclaim verification flow failed", {
|
|
1522
1680
|
code: "RECLAIM_INIT_FAILED",
|
|
@@ -1540,10 +1698,10 @@ function createReclaimFlow(params) {
|
|
|
1540
1698
|
}
|
|
1541
1699
|
|
|
1542
1700
|
// src/zkkyc/orchestrators/simple-kyc.ts
|
|
1543
|
-
var
|
|
1701
|
+
var import_neverthrow6 = require("neverthrow");
|
|
1544
1702
|
function createSimpleKycFlow(params) {
|
|
1545
1703
|
const { baseUrl, walletAddress, tenant, redirectUrl, country, state, onStatus } = params;
|
|
1546
|
-
return
|
|
1704
|
+
return import_neverthrow6.ResultAsync.fromPromise(
|
|
1547
1705
|
(async () => {
|
|
1548
1706
|
const res = await fetch(`${baseUrl}/v1/widget/public-sessions`, {
|
|
1549
1707
|
method: "POST",
|
|
@@ -1586,7 +1744,7 @@ function createSimpleKycFlow(params) {
|
|
|
1586
1744
|
);
|
|
1587
1745
|
}
|
|
1588
1746
|
function resumeSimpleKycFlow(args) {
|
|
1589
|
-
return
|
|
1747
|
+
return import_neverthrow6.ResultAsync.fromPromise(
|
|
1590
1748
|
(async () => {
|
|
1591
1749
|
const res = await fetch(`${args.baseUrl}/v1/widget/attestation`, {
|
|
1592
1750
|
method: "POST",
|
|
@@ -1620,9 +1778,9 @@ function resumeSimpleKycFlow(args) {
|
|
|
1620
1778
|
}
|
|
1621
1779
|
|
|
1622
1780
|
// src/zkkyc/orchestrators/zk-passport.ts
|
|
1623
|
-
var
|
|
1781
|
+
var import_neverthrow7 = require("neverthrow");
|
|
1624
1782
|
function createZkPassportFlow(params) {
|
|
1625
|
-
return
|
|
1783
|
+
return import_neverthrow7.ResultAsync.fromPromise(
|
|
1626
1784
|
(async () => {
|
|
1627
1785
|
const mod = await import("@zkpassport/sdk").catch(() => {
|
|
1628
1786
|
throw new ZkkycError(
|
|
@@ -1718,7 +1876,7 @@ function createZkPassportFlow(params) {
|
|
|
1718
1876
|
});
|
|
1719
1877
|
const session = {
|
|
1720
1878
|
url,
|
|
1721
|
-
result:
|
|
1879
|
+
result: import_neverthrow7.ResultAsync.fromPromise(resultPromise, (error) => {
|
|
1722
1880
|
if (error instanceof ZkkycError) return error;
|
|
1723
1881
|
return new ZkkycError("ZK Passport flow failed", {
|
|
1724
1882
|
code: "ZK_PASSPORT_VERIFICATION_FAILED",
|
|
@@ -1744,16 +1902,19 @@ function createZkPassportFlow(params) {
|
|
|
1744
1902
|
0 && (module.exports = {
|
|
1745
1903
|
BVN_OTP_METHODS,
|
|
1746
1904
|
DEFAULT_RECLAIM_PROVIDER_IDS,
|
|
1905
|
+
LIVENESS_DEFAULT_TENANT,
|
|
1747
1906
|
RECLAIM_APP_LINKS,
|
|
1748
1907
|
SIMPLE_KYC_DEFAULT_TENANT,
|
|
1749
1908
|
SOCIAL_PLATFORM_NAMES,
|
|
1750
1909
|
ZK_PASSPORT_APP_LINKS,
|
|
1751
1910
|
ZkkycError,
|
|
1752
1911
|
createBvnFlow,
|
|
1912
|
+
createLivenessFlow,
|
|
1753
1913
|
createReclaimFlow,
|
|
1754
1914
|
createSimpleKycFlow,
|
|
1755
1915
|
createZkPassportFlow,
|
|
1756
1916
|
createZkkyc,
|
|
1917
|
+
resumeLivenessFlow,
|
|
1757
1918
|
resumeSimpleKycFlow
|
|
1758
1919
|
});
|
|
1759
1920
|
//# sourceMappingURL=zkkyc.cjs.map
|