@neus/sdk 1.0.7 → 1.0.9
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 +23 -26
- package/SECURITY.md +38 -38
- package/cjs/client.cjs +40 -44
- package/cjs/index.cjs +40 -44
- package/client.js +1820 -1837
- package/package.json +135 -136
- package/types.d.ts +904 -915
- package/widgets/README.md +45 -45
- package/widgets/verify-gate/dist/ProofBadge.js +41 -37
- package/widgets/verify-gate/dist/VerifyGate.js +142 -70
|
@@ -4,6 +4,39 @@
|
|
|
4
4
|
import { useCallback, useMemo, useState, useEffect } from "react";
|
|
5
5
|
import { NeusClient } from "@neus/sdk/client";
|
|
6
6
|
|
|
7
|
+
// widgets/verify-gate/hostedCheckout.js
|
|
8
|
+
var HOSTED_CHECKOUT_MESSAGE_TYPE = "neus_checkout_done";
|
|
9
|
+
function buildHostedCheckoutUrl({
|
|
10
|
+
hostedCheckoutUrl,
|
|
11
|
+
verifierList,
|
|
12
|
+
returnUrl,
|
|
13
|
+
origin,
|
|
14
|
+
oauthProvider,
|
|
15
|
+
campaignTitle,
|
|
16
|
+
campaignMessage
|
|
17
|
+
}) {
|
|
18
|
+
const checkoutUrl = new URL(hostedCheckoutUrl);
|
|
19
|
+
checkoutUrl.searchParams.set("verifiers", verifierList.join(","));
|
|
20
|
+
checkoutUrl.searchParams.set("mode", "popup");
|
|
21
|
+
checkoutUrl.searchParams.set("returnUrl", returnUrl);
|
|
22
|
+
checkoutUrl.searchParams.set("origin", origin);
|
|
23
|
+
if (typeof oauthProvider === "string" && oauthProvider.trim()) {
|
|
24
|
+
checkoutUrl.searchParams.set("oauthProvider", oauthProvider.trim());
|
|
25
|
+
}
|
|
26
|
+
if (typeof campaignTitle === "string" && campaignTitle.trim()) {
|
|
27
|
+
checkoutUrl.searchParams.set("presetLabel", campaignTitle.trim().slice(0, 200));
|
|
28
|
+
}
|
|
29
|
+
if (typeof campaignMessage === "string" && campaignMessage.trim()) {
|
|
30
|
+
checkoutUrl.searchParams.set("message", campaignMessage.trim().slice(0, 200));
|
|
31
|
+
}
|
|
32
|
+
return checkoutUrl.toString();
|
|
33
|
+
}
|
|
34
|
+
function buildHostedCheckoutRedirectUrl(popupCheckoutUrl) {
|
|
35
|
+
const checkoutUrl = new URL(popupCheckoutUrl);
|
|
36
|
+
checkoutUrl.searchParams.delete("mode");
|
|
37
|
+
return checkoutUrl.toString();
|
|
38
|
+
}
|
|
39
|
+
|
|
7
40
|
// widgets/verify-gate/mergeCreateProofOptions.js
|
|
8
41
|
function mergeVerifyGateCreateProofOptions(proofOptions, verifierOptions) {
|
|
9
42
|
return {
|
|
@@ -37,7 +70,7 @@ if (typeof document !== "undefined") {
|
|
|
37
70
|
if (!document.getElementById(sid)) {
|
|
38
71
|
const el = document.createElement("style");
|
|
39
72
|
el.id = sid;
|
|
40
|
-
el.textContent = "button.neus-vg__primary{ color: #0a0a0a !important; -webkit-text-fill-color: #0a0a0a; }button.neus-vg__primary .neus-vg__label,button.neus-vg__primary span.neus-vg__label{ color: inherit !important; -webkit-text-fill-color: inherit; }";
|
|
73
|
+
el.textContent = "@keyframes neus-vg-spin{to{transform:rotate(360deg)}}button.neus-vg__primary{ color: #0a0a0a !important; -webkit-text-fill-color: #0a0a0a; }button.neus-vg__primary .neus-vg__label,button.neus-vg__primary span.neus-vg__label{ color: inherit !important; -webkit-text-fill-color: inherit; }";
|
|
41
74
|
document.head.appendChild(el);
|
|
42
75
|
}
|
|
43
76
|
}
|
|
@@ -73,7 +106,6 @@ var INTERACTIVE_VERIFIERS = /* @__PURE__ */ new Set([
|
|
|
73
106
|
]);
|
|
74
107
|
var HOSTED_WHEN_INCOMPLETE = /* @__PURE__ */ new Set(["wallet-link"]);
|
|
75
108
|
var DEFAULT_HOSTED_CHECKOUT_URL = "https://neus.network/verify";
|
|
76
|
-
var HOSTED_CHECKOUT_MESSAGE_TYPE = "neus_checkout_done";
|
|
77
109
|
var VERIFY_GATE_DEFAULT_ERROR = "Something went wrong. Please try again.";
|
|
78
110
|
function getVerifyGateUserError(err) {
|
|
79
111
|
const c = err && err.code;
|
|
@@ -92,10 +124,11 @@ function getVerifyGateUserError(err) {
|
|
|
92
124
|
}
|
|
93
125
|
return null;
|
|
94
126
|
}
|
|
95
|
-
function dispatchNeusProofCreatedForHost({ qHash,
|
|
127
|
+
function dispatchNeusProofCreatedForHost({ qHash, walletAddress, ...legacyInput }) {
|
|
96
128
|
try {
|
|
97
129
|
if (typeof window === "undefined") return;
|
|
98
|
-
const raw = typeof qHash === "string" && qHash.trim() || typeof proofId === "string" && proofId.trim() ||
|
|
130
|
+
const raw = typeof qHash === "string" && qHash.trim() || typeof legacyInput.proofId === "string" && legacyInput.proofId.trim() || // Legacy input compatibility only. Do not expose or store proofId.
|
|
131
|
+
"";
|
|
99
132
|
if (!raw) return;
|
|
100
133
|
const w = typeof walletAddress === "string" ? walletAddress.trim() : "";
|
|
101
134
|
const normalizedWallet = w && /^0x[a-fA-F0-9]{40}$/.test(w) ? w.toLowerCase() : w;
|
|
@@ -111,6 +144,44 @@ function dispatchNeusProofCreatedForHost({ qHash, proofId, walletAddress }) {
|
|
|
111
144
|
} catch (_err) {
|
|
112
145
|
}
|
|
113
146
|
}
|
|
147
|
+
function VerifyGateInlineSpinner({ size = 16 }) {
|
|
148
|
+
return /* @__PURE__ */ jsxs(
|
|
149
|
+
"svg",
|
|
150
|
+
{
|
|
151
|
+
width: size,
|
|
152
|
+
height: size,
|
|
153
|
+
viewBox: "0 0 24 24",
|
|
154
|
+
"aria-hidden": "true",
|
|
155
|
+
style: { animation: "neus-vg-spin 0.8s linear infinite" },
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", fill: "none", stroke: "currentColor", strokeWidth: "3", opacity: "0.25" }),
|
|
158
|
+
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round" })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function NeusLogo({ size = 16, onPrimaryFill = false }) {
|
|
164
|
+
return /* @__PURE__ */ jsx(
|
|
165
|
+
"span",
|
|
166
|
+
{
|
|
167
|
+
"aria-hidden": "true",
|
|
168
|
+
style: {
|
|
169
|
+
display: "inline-flex",
|
|
170
|
+
alignItems: "center",
|
|
171
|
+
justifyContent: "center",
|
|
172
|
+
width: `${size}px`,
|
|
173
|
+
height: `${size}px`,
|
|
174
|
+
borderRadius: "4px",
|
|
175
|
+
border: `1px solid ${onPrimaryFill ? "rgba(10, 10, 10, 0.35)" : "currentColor"}`,
|
|
176
|
+
color: onPrimaryFill ? "#0a0a0a" : "currentColor",
|
|
177
|
+
fontSize: `${Math.max(9, Math.round(size * 0.55))}px`,
|
|
178
|
+
fontWeight: 700,
|
|
179
|
+
lineHeight: 1
|
|
180
|
+
},
|
|
181
|
+
children: "N"
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
114
185
|
function VerifyGate({
|
|
115
186
|
requiredVerifiers = ["ownership-basic"],
|
|
116
187
|
onVerified = void 0,
|
|
@@ -129,8 +200,7 @@ function VerifyGate({
|
|
|
129
200
|
disabled = false,
|
|
130
201
|
buttonText = void 0,
|
|
131
202
|
mode = "create",
|
|
132
|
-
|
|
133
|
-
qHash = null,
|
|
203
|
+
qHash: qHashProp = null,
|
|
134
204
|
strategy = "reuse-or-create",
|
|
135
205
|
checkExisting = true,
|
|
136
206
|
maxProofAgeMs = void 0,
|
|
@@ -141,7 +211,8 @@ function VerifyGate({
|
|
|
141
211
|
onError = void 0,
|
|
142
212
|
wallet = void 0,
|
|
143
213
|
chain = void 0,
|
|
144
|
-
signatureMethod = void 0
|
|
214
|
+
signatureMethod = void 0,
|
|
215
|
+
...legacyProps
|
|
145
216
|
}) {
|
|
146
217
|
const [state, setState] = useState("idle");
|
|
147
218
|
const [error, setError] = useState(null);
|
|
@@ -158,7 +229,8 @@ function VerifyGate({
|
|
|
158
229
|
return Array.isArray(requiredVerifiers) && requiredVerifiers.length > 0 ? requiredVerifiers : ["ownership-basic"];
|
|
159
230
|
}, [requiredVerifiers]);
|
|
160
231
|
const primaryVerifier = verifierList[0];
|
|
161
|
-
const
|
|
232
|
+
const qHash = qHashProp || legacyProps.proofId || null;
|
|
233
|
+
const resolvedQHash = qHash;
|
|
162
234
|
const hasInteractiveVerifier = useMemo(
|
|
163
235
|
() => verifierList.some((verifierId) => {
|
|
164
236
|
if (INTERACTIVE_VERIFIERS.has(verifierId)) return true;
|
|
@@ -205,16 +277,15 @@ function VerifyGate({
|
|
|
205
277
|
setExistingProofs(gateResult);
|
|
206
278
|
const existingProof = gateResult.existing?.[primaryVerifier];
|
|
207
279
|
if (existingProof && onVerified) {
|
|
208
|
-
const
|
|
280
|
+
const existingQHash = existingProof.qHash || existingProof.proofId || null;
|
|
209
281
|
onVerified({
|
|
210
|
-
|
|
211
|
-
qHash: proofId2,
|
|
282
|
+
qHash: existingQHash,
|
|
212
283
|
address: existingProof.walletAddress || address,
|
|
213
284
|
verifierIds: verifierList,
|
|
214
285
|
verifiedVerifiers: existingProof.verifiedVerifiers || [],
|
|
215
286
|
existing: true,
|
|
216
287
|
proofsByVerifierId: gateResult.existing || {},
|
|
217
|
-
proofUrl:
|
|
288
|
+
proofUrl: existingQHash ? `${apiUrl || "https://api.neus.network"}/api/v1/proofs/${existingQHash}` : null
|
|
218
289
|
});
|
|
219
290
|
}
|
|
220
291
|
return true;
|
|
@@ -300,7 +371,6 @@ function VerifyGate({
|
|
|
300
371
|
}
|
|
301
372
|
if (result.qHash) {
|
|
302
373
|
existing[result.verifierId] = {
|
|
303
|
-
proofId: result.qHash,
|
|
304
374
|
qHash: result.qHash,
|
|
305
375
|
walletAddress: address,
|
|
306
376
|
verifiedVerifiers: [{ verifierId: result.verifierId, verified: true }]
|
|
@@ -322,35 +392,30 @@ function VerifyGate({
|
|
|
322
392
|
}
|
|
323
393
|
const origin = window.location.origin;
|
|
324
394
|
const returnUrl = window.location.href;
|
|
325
|
-
const checkoutUrl =
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
if (typeof campaignMessage === "string" && campaignMessage.trim()) {
|
|
337
|
-
checkoutUrl.searchParams.set("message", campaignMessage.trim().slice(0, 200));
|
|
338
|
-
}
|
|
339
|
-
let expectedOrigin = "*";
|
|
395
|
+
const checkoutUrl = buildHostedCheckoutUrl({
|
|
396
|
+
hostedCheckoutUrl: resolvedHostedCheckoutUrl,
|
|
397
|
+
verifierList,
|
|
398
|
+
returnUrl,
|
|
399
|
+
origin,
|
|
400
|
+
oauthProvider,
|
|
401
|
+
campaignTitle,
|
|
402
|
+
campaignMessage
|
|
403
|
+
});
|
|
404
|
+
let expectedOrigin = null;
|
|
340
405
|
try {
|
|
341
406
|
expectedOrigin = new URL(resolvedHostedCheckoutUrl).origin;
|
|
342
407
|
} catch (_err) {
|
|
343
|
-
expectedOrigin =
|
|
408
|
+
expectedOrigin = null;
|
|
344
409
|
}
|
|
345
|
-
return
|
|
346
|
-
const url = checkoutUrl
|
|
410
|
+
return new Promise((resolve, reject) => {
|
|
411
|
+
const url = checkoutUrl;
|
|
347
412
|
const popup = window.open(
|
|
348
413
|
url,
|
|
349
414
|
"neus_checkout",
|
|
350
415
|
"width=600,height=700,scrollbars=yes,resizable=yes"
|
|
351
416
|
);
|
|
352
417
|
if (!popup) {
|
|
353
|
-
window.location.assign(url);
|
|
418
|
+
window.location.assign(buildHostedCheckoutRedirectUrl(url));
|
|
354
419
|
return;
|
|
355
420
|
}
|
|
356
421
|
let completed = false;
|
|
@@ -375,7 +440,7 @@ function VerifyGate({
|
|
|
375
440
|
}
|
|
376
441
|
};
|
|
377
442
|
const onMessage = (event) => {
|
|
378
|
-
if (expectedOrigin
|
|
443
|
+
if (!expectedOrigin || event.origin !== expectedOrigin) return;
|
|
379
444
|
const payload = event?.data;
|
|
380
445
|
if (!payload || payload.type !== HOSTED_CHECKOUT_MESSAGE_TYPE) return;
|
|
381
446
|
completed = true;
|
|
@@ -388,7 +453,7 @@ function VerifyGate({
|
|
|
388
453
|
};
|
|
389
454
|
window.addEventListener("message", onMessage);
|
|
390
455
|
});
|
|
391
|
-
}, [resolvedHostedCheckoutUrl, verifierList, oauthProvider]);
|
|
456
|
+
}, [resolvedHostedCheckoutUrl, verifierList, oauthProvider, campaignTitle, campaignMessage]);
|
|
392
457
|
useEffect(() => {
|
|
393
458
|
onStateChange?.(state);
|
|
394
459
|
}, [state, onStateChange]);
|
|
@@ -408,7 +473,7 @@ function VerifyGate({
|
|
|
408
473
|
});
|
|
409
474
|
setExistingProofs(gateResult);
|
|
410
475
|
applySatisfiedGateResult(gateResult, address);
|
|
411
|
-
} catch (
|
|
476
|
+
} catch (_err) {
|
|
412
477
|
}
|
|
413
478
|
};
|
|
414
479
|
checkExistingProofs();
|
|
@@ -438,7 +503,7 @@ function VerifyGate({
|
|
|
438
503
|
requirements: buildGateRequirements()
|
|
439
504
|
});
|
|
440
505
|
if (applySatisfiedGateResult(gateResult, walletAddress)) return;
|
|
441
|
-
} catch (
|
|
506
|
+
} catch (_err) {
|
|
442
507
|
}
|
|
443
508
|
}
|
|
444
509
|
try {
|
|
@@ -446,18 +511,17 @@ function VerifyGate({
|
|
|
446
511
|
setOperation("access");
|
|
447
512
|
setIsProcessing(true);
|
|
448
513
|
setState("signing");
|
|
449
|
-
if (!
|
|
450
|
-
throw new Error("
|
|
514
|
+
if (!resolvedQHash) {
|
|
515
|
+
throw new Error("qHash is required for access mode");
|
|
451
516
|
}
|
|
452
517
|
setState("verifying");
|
|
453
518
|
const privateData = await client.getPrivateProof(
|
|
454
|
-
|
|
519
|
+
resolvedQHash,
|
|
455
520
|
wallet || (typeof window !== "undefined" ? window.ethereum : null)
|
|
456
521
|
);
|
|
457
522
|
setState("verified");
|
|
458
523
|
onVerified?.({
|
|
459
|
-
|
|
460
|
-
qHash: resolvedProofId,
|
|
524
|
+
qHash: resolvedQHash,
|
|
461
525
|
data: privateData.data,
|
|
462
526
|
mode: "access",
|
|
463
527
|
proofUrl: privateData.proofUrl
|
|
@@ -480,23 +544,22 @@ function VerifyGate({
|
|
|
480
544
|
setOperation("verify");
|
|
481
545
|
setIsProcessing(true);
|
|
482
546
|
setState("interactive-checkout");
|
|
547
|
+
onStateChange?.("interactive-checkout");
|
|
483
548
|
const checkoutResult = await launchHostedCheckout();
|
|
484
|
-
const
|
|
549
|
+
const checkoutQHash = checkoutResult?.qHash || checkoutResult?.proofId || null;
|
|
485
550
|
const handoffWallet = typeof checkoutResult?.walletAddress === "string" && checkoutResult.walletAddress.trim() || walletAddress && String(walletAddress).trim() || "";
|
|
486
551
|
setState("verified");
|
|
487
552
|
dispatchNeusProofCreatedForHost({
|
|
488
|
-
qHash:
|
|
489
|
-
proofId: checkoutProofId,
|
|
553
|
+
qHash: checkoutQHash,
|
|
490
554
|
walletAddress: handoffWallet
|
|
491
555
|
});
|
|
492
556
|
onVerified?.({
|
|
493
|
-
|
|
494
|
-
qHash: checkoutProofId,
|
|
557
|
+
qHash: checkoutQHash,
|
|
495
558
|
verifierIds: verifierList,
|
|
496
559
|
existing: false,
|
|
497
560
|
mode: "create",
|
|
498
561
|
eligible: checkoutResult?.eligible !== false,
|
|
499
|
-
proofUrl: checkoutResult?.proofUrl || (
|
|
562
|
+
proofUrl: checkoutResult?.proofUrl || (checkoutQHash ? `${apiUrl || "https://api.neus.network"}/api/v1/proofs/${checkoutQHash}` : null)
|
|
500
563
|
});
|
|
501
564
|
return;
|
|
502
565
|
}
|
|
@@ -509,7 +572,9 @@ function VerifyGate({
|
|
|
509
572
|
);
|
|
510
573
|
const buildDataForVerifier = (verifierId) => {
|
|
511
574
|
if (!CREATABLE_VERIFIERS.has(verifierId)) {
|
|
512
|
-
throw new Error(
|
|
575
|
+
throw new Error(
|
|
576
|
+
`${verifierId} cannot be created via the wallet flow. It requires hosted checkout or a server integration.`
|
|
577
|
+
);
|
|
513
578
|
}
|
|
514
579
|
const explicit = verifierData && verifierData[verifierId];
|
|
515
580
|
if (explicit && typeof explicit === "object") return explicit;
|
|
@@ -546,8 +611,8 @@ function VerifyGate({
|
|
|
546
611
|
wallet: wallet || (typeof window !== "undefined" ? window.ethereum : void 0)
|
|
547
612
|
});
|
|
548
613
|
setState("verifying");
|
|
549
|
-
const
|
|
550
|
-
const final = await client.pollProofStatus(
|
|
614
|
+
const qHashToCheck = created.qHash || created.proofId || created?.data?.qHash || created?.data?.proofId;
|
|
615
|
+
const final = await client.pollProofStatus(qHashToCheck, { interval: 3e3, timeout: 6e4 });
|
|
551
616
|
const verifiedVerifiers = final?.data?.verifiedVerifiers || [];
|
|
552
617
|
const verifierResult = verifiedVerifiers.find((v) => v.verifierId === verifierId);
|
|
553
618
|
if (!verifierResult || verifierResult.verified !== true) {
|
|
@@ -556,11 +621,10 @@ function VerifyGate({
|
|
|
556
621
|
const hubTx = final?.data?.hubTransaction || {};
|
|
557
622
|
const crosschain = final?.data?.crosschain || {};
|
|
558
623
|
const txHash = hubTx?.txHash || crosschain?.hubTxHash || null;
|
|
559
|
-
const
|
|
624
|
+
const finalQHash = final?.qHash || final?.proofId || qHashToCheck;
|
|
560
625
|
return {
|
|
561
626
|
verifierId,
|
|
562
|
-
|
|
563
|
-
qHash: finalProofId,
|
|
627
|
+
qHash: finalQHash,
|
|
564
628
|
address: final?.data?.walletAddress,
|
|
565
629
|
txHash,
|
|
566
630
|
verifiedVerifiers,
|
|
@@ -573,18 +637,15 @@ function VerifyGate({
|
|
|
573
637
|
}
|
|
574
638
|
setState("verified");
|
|
575
639
|
const last = results[results.length - 1];
|
|
576
|
-
const
|
|
640
|
+
const lastQHash = last?.qHash || null;
|
|
577
641
|
const handoffAddr = last?.address && String(last.address).trim() || walletAddress && String(walletAddress).trim() || "";
|
|
578
642
|
dispatchNeusProofCreatedForHost({
|
|
579
|
-
qHash:
|
|
580
|
-
proofId: lastProofId,
|
|
643
|
+
qHash: lastQHash,
|
|
581
644
|
walletAddress: handoffAddr
|
|
582
645
|
});
|
|
583
646
|
onVerified?.({
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
proofIds: results.map((r) => r.proofId || r.qHash).filter(Boolean),
|
|
587
|
-
qHashes: results.map((r) => r.proofId || r.qHash).filter(Boolean),
|
|
647
|
+
qHash: lastQHash,
|
|
648
|
+
qHashes: results.map((r) => r.qHash).filter(Boolean),
|
|
588
649
|
address: last?.address,
|
|
589
650
|
txHash: last?.txHash,
|
|
590
651
|
verifierIds: verifierList,
|
|
@@ -596,7 +657,7 @@ function VerifyGate({
|
|
|
596
657
|
} catch (err) {
|
|
597
658
|
const userMsg = getVerifyGateUserError(err);
|
|
598
659
|
const fallback = mode === "access" ? "Access failed" : VERIFY_GATE_DEFAULT_ERROR;
|
|
599
|
-
setError(userMsg
|
|
660
|
+
setError(userMsg !== null ? userMsg : fallback);
|
|
600
661
|
setState("error");
|
|
601
662
|
onError?.(err);
|
|
602
663
|
} finally {
|
|
@@ -606,7 +667,7 @@ function VerifyGate({
|
|
|
606
667
|
disabled,
|
|
607
668
|
isProcessing,
|
|
608
669
|
mode,
|
|
609
|
-
|
|
670
|
+
resolvedQHash,
|
|
610
671
|
verifierList,
|
|
611
672
|
hasInteractiveVerifier,
|
|
612
673
|
client,
|
|
@@ -617,6 +678,7 @@ function VerifyGate({
|
|
|
617
678
|
launchHostedCheckout,
|
|
618
679
|
onVerified,
|
|
619
680
|
onError,
|
|
681
|
+
onStateChange,
|
|
620
682
|
shouldCheckExisting,
|
|
621
683
|
walletAddress,
|
|
622
684
|
existingProofs,
|
|
@@ -645,13 +707,23 @@ function VerifyGate({
|
|
|
645
707
|
setNotice("No matching proof was found. Verify to create a proof.");
|
|
646
708
|
} catch (err) {
|
|
647
709
|
const userMsg = getVerifyGateUserError(err);
|
|
648
|
-
setError(userMsg
|
|
710
|
+
setError(userMsg !== null ? userMsg : "Unable to access private proofs");
|
|
649
711
|
setState("error");
|
|
650
712
|
onError?.(err);
|
|
651
713
|
} finally {
|
|
652
714
|
setIsProcessing(false);
|
|
653
715
|
}
|
|
654
|
-
}, [
|
|
716
|
+
}, [
|
|
717
|
+
disabled,
|
|
718
|
+
isProcessing,
|
|
719
|
+
mode,
|
|
720
|
+
allowPrivateReuse,
|
|
721
|
+
walletAddress,
|
|
722
|
+
getOrRequestWalletAddress,
|
|
723
|
+
tryPrivateReuse,
|
|
724
|
+
applySatisfiedGateResult,
|
|
725
|
+
onError
|
|
726
|
+
]);
|
|
655
727
|
const primaryCtaClass = state === "idle" || state === "interactive-checkout" ? "neus-vg__primary" : "";
|
|
656
728
|
const getLabel = () => {
|
|
657
729
|
if (buttonText && state === "idle") return buttonText;
|
|
@@ -708,17 +780,17 @@ function VerifyGate({
|
|
|
708
780
|
if (state === "error") {
|
|
709
781
|
return {
|
|
710
782
|
...buttonBaseStyle,
|
|
711
|
-
background:
|
|
783
|
+
background: "rgba(239, 68, 68, 0.15)",
|
|
712
784
|
color: THEME.error,
|
|
713
|
-
border:
|
|
785
|
+
border: "1px solid rgba(239, 68, 68, 0.3)"
|
|
714
786
|
};
|
|
715
787
|
}
|
|
716
788
|
if (state === "signing" || state === "verifying") {
|
|
717
789
|
return {
|
|
718
790
|
...buttonBaseStyle,
|
|
719
|
-
background:
|
|
791
|
+
background: "rgba(61, 114, 201, 0.15)",
|
|
720
792
|
color: "var(--neus-accent, #98C0EF)",
|
|
721
|
-
border:
|
|
793
|
+
border: "1px solid rgba(61, 114, 201, 0.3)"
|
|
722
794
|
};
|
|
723
795
|
}
|
|
724
796
|
return {
|
|
@@ -743,7 +815,7 @@ function VerifyGate({
|
|
|
743
815
|
className: primaryCtaClass,
|
|
744
816
|
style: getButtonStyle(),
|
|
745
817
|
children: [
|
|
746
|
-
(state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(
|
|
818
|
+
(state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
|
|
747
819
|
showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
|
|
748
820
|
state === "verified" && /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }),
|
|
749
821
|
/* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() })
|
|
@@ -800,7 +872,7 @@ function VerifyGate({
|
|
|
800
872
|
style: { ...getButtonStyle(), ...style },
|
|
801
873
|
disabled: disabled || isProcessing,
|
|
802
874
|
children: [
|
|
803
|
-
(state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(
|
|
875
|
+
(state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
|
|
804
876
|
showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
|
|
805
877
|
state === "verified" && /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }),
|
|
806
878
|
/* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() }),
|