@neus/sdk 1.0.10 → 1.1.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/CHANGELOG.md +3 -0
- package/README.md +55 -26
- package/SECURITY.md +1 -1
- package/cjs/client.cjs +117 -27
- package/cjs/index.cjs +117 -27
- package/cli/neus.mjs +1288 -92
- package/client.js +139 -26
- package/errors.js +1 -1
- package/package.json +11 -3
- package/types.d.ts +79 -14
- package/widgets/README.md +1 -1
- package/widgets/verify-gate/dist/ProofBadge.js +8 -16
- package/widgets/verify-gate/dist/VerifyGate.js +17 -19
|
@@ -124,11 +124,10 @@ function getVerifyGateUserError(err) {
|
|
|
124
124
|
}
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
-
function dispatchNeusProofCreatedForHost({ qHash, walletAddress
|
|
127
|
+
function dispatchNeusProofCreatedForHost({ qHash, walletAddress }) {
|
|
128
128
|
try {
|
|
129
129
|
if (typeof window === "undefined") return;
|
|
130
|
-
const raw = typeof qHash === "string"
|
|
131
|
-
"";
|
|
130
|
+
const raw = typeof qHash === "string" ? qHash.trim() : "";
|
|
132
131
|
if (!raw) return;
|
|
133
132
|
const w = typeof walletAddress === "string" ? walletAddress.trim() : "";
|
|
134
133
|
const normalizedWallet = w && /^0x[a-fA-F0-9]{40}$/.test(w) ? w.toLowerCase() : w;
|
|
@@ -211,8 +210,7 @@ function VerifyGate({
|
|
|
211
210
|
onError = void 0,
|
|
212
211
|
wallet = void 0,
|
|
213
212
|
chain = void 0,
|
|
214
|
-
signatureMethod = void 0
|
|
215
|
-
...legacyProps
|
|
213
|
+
signatureMethod = void 0
|
|
216
214
|
}) {
|
|
217
215
|
const [state, setState] = useState("idle");
|
|
218
216
|
const [error, setError] = useState(null);
|
|
@@ -229,7 +227,7 @@ function VerifyGate({
|
|
|
229
227
|
return Array.isArray(requiredVerifiers) && requiredVerifiers.length > 0 ? requiredVerifiers : ["ownership-basic"];
|
|
230
228
|
}, [requiredVerifiers]);
|
|
231
229
|
const primaryVerifier = verifierList[0];
|
|
232
|
-
const qHash = qHashProp ||
|
|
230
|
+
const qHash = qHashProp || null;
|
|
233
231
|
const resolvedQHash = qHash;
|
|
234
232
|
const hasInteractiveVerifier = useMemo(
|
|
235
233
|
() => verifierList.some((verifierId) => {
|
|
@@ -277,7 +275,7 @@ function VerifyGate({
|
|
|
277
275
|
setExistingProofs(gateResult);
|
|
278
276
|
const existingProof = gateResult.existing?.[primaryVerifier];
|
|
279
277
|
if (existingProof && onVerified) {
|
|
280
|
-
const existingQHash = existingProof.qHash ||
|
|
278
|
+
const existingQHash = existingProof.qHash || null;
|
|
281
279
|
onVerified({
|
|
282
280
|
qHash: existingQHash,
|
|
283
281
|
address: existingProof.walletAddress || address,
|
|
@@ -307,7 +305,7 @@ function VerifyGate({
|
|
|
307
305
|
return provider.address;
|
|
308
306
|
}
|
|
309
307
|
if (typeof provider.request !== "function") {
|
|
310
|
-
throw new Error("
|
|
308
|
+
throw new Error("Connect a wallet and try again.");
|
|
311
309
|
}
|
|
312
310
|
let accounts = await provider.request({ method: "eth_accounts" });
|
|
313
311
|
if (!accounts || accounts.length === 0) {
|
|
@@ -315,7 +313,7 @@ function VerifyGate({
|
|
|
315
313
|
accounts = await provider.request({ method: "eth_accounts" });
|
|
316
314
|
}
|
|
317
315
|
if (!accounts || accounts.length === 0) {
|
|
318
|
-
throw new Error("
|
|
316
|
+
throw new Error("Connect a wallet and try again.");
|
|
319
317
|
}
|
|
320
318
|
return accounts[0];
|
|
321
319
|
}, [wallet]);
|
|
@@ -388,7 +386,7 @@ function VerifyGate({
|
|
|
388
386
|
}, [client, buildGateRequirements, wallet, inferChainFromAddress, signatureMethod]);
|
|
389
387
|
const launchHostedCheckout = useCallback(async () => {
|
|
390
388
|
if (typeof window === "undefined") {
|
|
391
|
-
throw new Error("
|
|
389
|
+
throw new Error("Open this in a browser to verify.");
|
|
392
390
|
}
|
|
393
391
|
const origin = window.location.origin;
|
|
394
392
|
const returnUrl = window.location.href;
|
|
@@ -446,7 +444,7 @@ function VerifyGate({
|
|
|
446
444
|
completed = true;
|
|
447
445
|
cleanup();
|
|
448
446
|
if (payload?.eligible === false) {
|
|
449
|
-
reject(new Error("
|
|
447
|
+
reject(new Error("Verification could not be completed."));
|
|
450
448
|
return;
|
|
451
449
|
}
|
|
452
450
|
resolve(payload);
|
|
@@ -546,7 +544,7 @@ function VerifyGate({
|
|
|
546
544
|
setState("interactive-checkout");
|
|
547
545
|
onStateChange?.("interactive-checkout");
|
|
548
546
|
const checkoutResult = await launchHostedCheckout();
|
|
549
|
-
const checkoutQHash = checkoutResult?.qHash ||
|
|
547
|
+
const checkoutQHash = checkoutResult?.qHash || null;
|
|
550
548
|
const handoffWallet = typeof checkoutResult?.walletAddress === "string" && checkoutResult.walletAddress.trim() || walletAddress && String(walletAddress).trim() || "";
|
|
551
549
|
setState("verified");
|
|
552
550
|
dispatchNeusProofCreatedForHost({
|
|
@@ -573,7 +571,7 @@ function VerifyGate({
|
|
|
573
571
|
const buildDataForVerifier = (verifierId) => {
|
|
574
572
|
if (!CREATABLE_VERIFIERS.has(verifierId)) {
|
|
575
573
|
throw new Error(
|
|
576
|
-
|
|
574
|
+
"This check requires the hosted verifier."
|
|
577
575
|
);
|
|
578
576
|
}
|
|
579
577
|
const explicit = verifierData && verifierData[verifierId];
|
|
@@ -587,12 +585,12 @@ function VerifyGate({
|
|
|
587
585
|
if (verifierId === "wallet-link") {
|
|
588
586
|
if (!explicit?.secondaryWalletAddress || !explicit?.signature || !explicit?.chain || !explicit?.signatureMethod) {
|
|
589
587
|
throw new Error(
|
|
590
|
-
"
|
|
588
|
+
"Missing required wallet details."
|
|
591
589
|
);
|
|
592
590
|
}
|
|
593
591
|
return explicit;
|
|
594
592
|
}
|
|
595
|
-
throw new Error(
|
|
593
|
+
throw new Error("Missing required verification details.");
|
|
596
594
|
};
|
|
597
595
|
const verifyOne = async (verifierId) => {
|
|
598
596
|
const dataForVerifier = buildDataForVerifier(verifierId);
|
|
@@ -611,17 +609,17 @@ function VerifyGate({
|
|
|
611
609
|
wallet: wallet || (typeof window !== "undefined" ? window.ethereum : void 0)
|
|
612
610
|
});
|
|
613
611
|
setState("verifying");
|
|
614
|
-
const qHashToCheck = created.qHash || created
|
|
612
|
+
const qHashToCheck = created.qHash || created?.data?.qHash;
|
|
615
613
|
const final = await client.pollProofStatus(qHashToCheck, { interval: 3e3, timeout: 6e4 });
|
|
616
614
|
const verifiedVerifiers = final?.data?.verifiedVerifiers || [];
|
|
617
615
|
const verifierResult = verifiedVerifiers.find((v) => v.verifierId === verifierId);
|
|
618
616
|
if (!verifierResult || verifierResult.verified !== true) {
|
|
619
|
-
throw new Error(
|
|
617
|
+
throw new Error("Verification could not be completed.");
|
|
620
618
|
}
|
|
621
619
|
const hubTx = final?.data?.hubTransaction || {};
|
|
622
620
|
const crosschain = final?.data?.crosschain || {};
|
|
623
621
|
const txHash = hubTx?.txHash || crosschain?.hubTxHash || null;
|
|
624
|
-
const finalQHash = final?.qHash ||
|
|
622
|
+
const finalQHash = final?.qHash || qHashToCheck;
|
|
625
623
|
return {
|
|
626
624
|
verifierId,
|
|
627
625
|
qHash: finalQHash,
|
|
@@ -849,7 +847,7 @@ function VerifyGate({
|
|
|
849
847
|
textUnderlineOffset: "2px",
|
|
850
848
|
opacity: disabled || isProcessing ? 0.6 : 0.9
|
|
851
849
|
},
|
|
852
|
-
children: "Already verified?
|
|
850
|
+
children: "Already verified? Reuse your proof."
|
|
853
851
|
}
|
|
854
852
|
),
|
|
855
853
|
error && /* @__PURE__ */ jsx("div", { style: {
|