@neus/sdk 1.1.1 → 1.1.4

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.
@@ -8,7 +8,7 @@ import { NeusClient } from "@neus/sdk/client";
8
8
  var HOSTED_CHECKOUT_MESSAGE_TYPE = "neus_checkout_done";
9
9
  function buildHostedCheckoutUrl({
10
10
  hostedCheckoutUrl,
11
- verifierList,
11
+ verifierList = [],
12
12
  returnUrl,
13
13
  origin,
14
14
  oauthProvider,
@@ -19,18 +19,23 @@ function buildHostedCheckoutUrl({
19
19
  gateId
20
20
  }) {
21
21
  const checkoutUrl = new URL(hostedCheckoutUrl);
22
- checkoutUrl.searchParams.set("verifiers", verifierList.join(","));
23
22
  checkoutUrl.searchParams.set("mode", "popup");
24
23
  checkoutUrl.searchParams.set("returnUrl", returnUrl);
25
24
  checkoutUrl.searchParams.set("origin", origin);
26
- if (typeof appId === "string" && appId.trim()) {
27
- checkoutUrl.searchParams.set("appId", appId.trim());
28
- }
29
- if (typeof billingWallet === "string" && billingWallet.trim()) {
30
- checkoutUrl.searchParams.set("billingWallet", billingWallet.trim().toLowerCase());
31
- }
32
- if (typeof gateId === "string" && gateId.trim()) {
33
- checkoutUrl.searchParams.set("gateId", gateId.trim());
25
+ const gateIdTrimmed = typeof gateId === "string" ? gateId.trim() : "";
26
+ if (gateIdTrimmed) {
27
+ checkoutUrl.searchParams.set("gateId", gateIdTrimmed);
28
+ } else {
29
+ const verifiers = Array.isArray(verifierList) ? verifierList.filter(Boolean) : [];
30
+ if (verifiers.length > 0) {
31
+ checkoutUrl.searchParams.set("verifiers", verifiers.join(","));
32
+ }
33
+ if (typeof appId === "string" && appId.trim()) {
34
+ checkoutUrl.searchParams.set("appId", appId.trim());
35
+ }
36
+ if (typeof billingWallet === "string" && billingWallet.trim()) {
37
+ checkoutUrl.searchParams.set("billingWallet", billingWallet.trim().toLowerCase());
38
+ }
34
39
  }
35
40
  if (typeof oauthProvider === "string" && oauthProvider.trim()) {
36
41
  checkoutUrl.searchParams.set("oauthProvider", oauthProvider.trim());
@@ -49,16 +54,17 @@ function buildHostedCheckoutRedirectUrl(popupCheckoutUrl) {
49
54
  return checkoutUrl.toString();
50
55
  }
51
56
 
52
- // widgets/verify-gate/mergeCreateProofOptions.js
53
- function mergeVerifyGateCreateProofOptions(proofOptions, verifierOptions) {
54
- return {
55
- privacyLevel: "private",
56
- publicDisplay: false,
57
- storeOriginalContent: true,
58
- ...proofOptions && typeof proofOptions === "object" ? proofOptions : {},
59
- ...verifierOptions ? { verifierOptions } : {}
60
- };
57
+ // brand-mark.js
58
+ var NEUS_BRAND_PACK_VERSION = "2026-06-03-mark-og-finalize-v1";
59
+ var NEUS_MARK_CDN_ORIGIN = "https://neus.network";
60
+ var PACK_BASE = `${NEUS_MARK_CDN_ORIGIN}/images/neus-brand-pack`;
61
+ var v = encodeURIComponent(NEUS_BRAND_PACK_VERSION);
62
+ function withBrandPackVersion(file) {
63
+ const name = file.replace(/^\//, "");
64
+ return `${PACK_BASE}/${name}?v=${v}`;
61
65
  }
66
+ var NEUS_DEFAULT_MARK_URL = withBrandPackVersion("favicon.svg");
67
+ var NEUS_DEFAULT_OG_IMAGE_URL = withBrandPackVersion("og-default-1200x630-neus.png");
62
68
 
63
69
  // widgets/verify-gate/VerifyGate.jsx
64
70
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -86,37 +92,6 @@ if (typeof document !== "undefined") {
86
92
  document.head.appendChild(el);
87
93
  }
88
94
  }
89
- var DEFAULT_MAX_AGE_MS_BY_VERIFIER = {
90
- "ownership-dns-txt": 60 * 60 * 1e3,
91
- "contract-ownership": 60 * 60 * 1e3,
92
- "nft-ownership": 60 * 60 * 1e3,
93
- "token-holding": 60 * 60 * 1e3,
94
- "wallet-risk": 60 * 60 * 1e3,
95
- "agent-delegation": 7 * 24 * 60 * 60 * 1e3
96
- };
97
- var maxAgeMsForVerifier = (verifierId, overrideMs) => {
98
- if (typeof overrideMs === "number") return overrideMs;
99
- return DEFAULT_MAX_AGE_MS_BY_VERIFIER[verifierId];
100
- };
101
- var CREATABLE_VERIFIERS = /* @__PURE__ */ new Set([
102
- "ownership-basic",
103
- "ownership-pseudonym",
104
- "ownership-dns-txt",
105
- "contract-ownership",
106
- "nft-ownership",
107
- "token-holding",
108
- "wallet-link",
109
- "wallet-risk",
110
- "agent-identity",
111
- "agent-delegation",
112
- "ai-content-moderation"
113
- ]);
114
- var INTERACTIVE_VERIFIERS = /* @__PURE__ */ new Set([
115
- "ownership-social",
116
- "ownership-org-oauth",
117
- "proof-of-human"
118
- ]);
119
- var HOSTED_WHEN_INCOMPLETE = /* @__PURE__ */ new Set(["wallet-link"]);
120
95
  var DEFAULT_HOSTED_CHECKOUT_URL = "https://neus.network/verify";
121
96
  var VERIFY_GATE_DEFAULT_ERROR = "Something went wrong. Please try again.";
122
97
  function getVerifyGateUserError(err) {
@@ -171,29 +146,29 @@ function VerifyGateInlineSpinner({ size = 16 }) {
171
146
  }
172
147
  );
173
148
  }
174
- function NeusLogo({ size = 16, onPrimaryFill = false }) {
149
+ function NeusLogo({ size = 16 }) {
175
150
  return /* @__PURE__ */ jsx(
176
- "span",
151
+ "img",
177
152
  {
153
+ src: NEUS_DEFAULT_MARK_URL,
154
+ alt: "",
178
155
  "aria-hidden": "true",
156
+ width: size,
157
+ height: size,
179
158
  style: {
180
- display: "inline-flex",
181
- alignItems: "center",
182
- justifyContent: "center",
183
- width: `${size}px`,
184
- height: `${size}px`,
185
- borderRadius: "4px",
186
- border: `1px solid ${onPrimaryFill ? "rgba(10, 10, 10, 0.35)" : "currentColor"}`,
187
- color: onPrimaryFill ? "#0a0a0a" : "currentColor",
188
- fontSize: `${Math.max(9, Math.round(size * 0.55))}px`,
189
- fontWeight: 700,
190
- lineHeight: 1
191
- },
192
- children: "N"
159
+ width: size,
160
+ height: size,
161
+ display: "block",
162
+ borderRadius: 4,
163
+ flexShrink: 0,
164
+ objectFit: "contain",
165
+ background: "transparent"
166
+ }
193
167
  }
194
168
  );
195
169
  }
196
170
  function VerifyGate({
171
+ gateId = void 0,
197
172
  requiredVerifiers = ["ownership-basic"],
198
173
  onVerified = void 0,
199
174
  apiUrl = void 0,
@@ -205,9 +180,6 @@ function VerifyGate({
205
180
  oauthProvider = void 0,
206
181
  style = void 0,
207
182
  children = void 0,
208
- verifierOptions = void 0,
209
- verifierData = void 0,
210
- proofOptions = void 0,
211
183
  showBrand = false,
212
184
  disabled = false,
213
185
  buttonText = void 0,
@@ -215,7 +187,6 @@ function VerifyGate({
215
187
  qHash: qHashProp = null,
216
188
  strategy = "reuse-or-create",
217
189
  checkExisting = true,
218
- maxProofAgeMs = void 0,
219
190
  allowPrivateReuse = true,
220
191
  campaignTitle = void 0,
221
192
  campaignMessage = void 0,
@@ -232,27 +203,18 @@ function VerifyGate({
232
203
  const [walletAddress, setWalletAddress] = useState(null);
233
204
  const [existingProofs, setExistingProofs] = useState(null);
234
205
  const [operation, setOperation] = useState("verify");
206
+ const resolvedGateId = typeof gateId === "string" ? gateId.trim() : "";
235
207
  const client = useMemo(
236
- () => new NeusClient({ apiUrl, appId, billingWallet, paymentSignature, extraHeaders }),
237
- [apiUrl, appId, billingWallet, paymentSignature, extraHeaders]
208
+ () => new NeusClient({ apiUrl, appId: resolvedGateId ? void 0 : appId, billingWallet: resolvedGateId ? void 0 : billingWallet, paymentSignature, extraHeaders }),
209
+ [apiUrl, appId, billingWallet, paymentSignature, extraHeaders, resolvedGateId]
238
210
  );
239
211
  const verifierList = useMemo(() => {
212
+ if (resolvedGateId) return [];
240
213
  return Array.isArray(requiredVerifiers) && requiredVerifiers.length > 0 ? requiredVerifiers : ["ownership-basic"];
241
- }, [requiredVerifiers]);
214
+ }, [requiredVerifiers, resolvedGateId]);
242
215
  const primaryVerifier = verifierList[0];
243
216
  const qHash = qHashProp || null;
244
217
  const resolvedQHash = qHash;
245
- const hasInteractiveVerifier = useMemo(
246
- () => verifierList.some((verifierId) => {
247
- if (INTERACTIVE_VERIFIERS.has(verifierId)) return true;
248
- if (HOSTED_WHEN_INCOMPLETE.has(verifierId)) {
249
- const data = verifierData && verifierData[verifierId];
250
- if (!data || !data.secondaryWalletAddress || !data.signature) return true;
251
- }
252
- return false;
253
- }),
254
- [verifierList, verifierData]
255
- );
256
218
  const resolvedHostedCheckoutUrl = useMemo(() => {
257
219
  if (typeof hostedCheckoutUrl === "string" && hostedCheckoutUrl.trim()) {
258
220
  return hostedCheckoutUrl.trim();
@@ -266,7 +228,7 @@ function VerifyGate({
266
228
  }
267
229
  return DEFAULT_HOSTED_CHECKOUT_URL;
268
230
  }, [apiUrl, hostedCheckoutUrl]);
269
- const shouldCheckExisting = checkExisting && strategy !== "fresh";
231
+ const shouldCheckExisting = !resolvedGateId && checkExisting && strategy !== "fresh";
270
232
  const inferChainFromAddress = useCallback((address) => {
271
233
  const raw = String(address || "").trim();
272
234
  if (!raw) return void 0;
@@ -275,11 +237,8 @@ function VerifyGate({
275
237
  return "solana:mainnet";
276
238
  }, [chain]);
277
239
  const buildGateRequirements = useCallback(() => {
278
- return verifierList.map((verifierId) => ({
279
- verifierId,
280
- ...maxAgeMsForVerifier(verifierId, maxProofAgeMs) && { maxAgeMs: maxAgeMsForVerifier(verifierId, maxProofAgeMs) }
281
- }));
282
- }, [verifierList, maxProofAgeMs]);
240
+ return verifierList.map((verifierId) => ({ verifierId }));
241
+ }, [verifierList]);
283
242
  const applySatisfiedGateResult = useCallback((gateResult, address) => {
284
243
  if (!gateResult?.satisfied) return false;
285
244
  setNotice(null);
@@ -411,8 +370,9 @@ function VerifyGate({
411
370
  oauthProvider,
412
371
  campaignTitle,
413
372
  campaignMessage,
414
- appId,
415
- billingWallet
373
+ gateId: resolvedGateId || void 0,
374
+ appId: resolvedGateId ? void 0 : appId,
375
+ billingWallet: resolvedGateId ? void 0 : billingWallet
416
376
  });
417
377
  let expectedOrigin = null;
418
378
  try {
@@ -466,7 +426,7 @@ function VerifyGate({
466
426
  };
467
427
  window.addEventListener("message", onMessage);
468
428
  });
469
- }, [resolvedHostedCheckoutUrl, verifierList, oauthProvider, campaignTitle, campaignMessage, appId, billingWallet]);
429
+ }, [resolvedHostedCheckoutUrl, verifierList, oauthProvider, campaignTitle, campaignMessage, appId, billingWallet, resolvedGateId]);
470
430
  useEffect(() => {
471
431
  onStateChange?.(state);
472
432
  }, [state, onStateChange]);
@@ -553,118 +513,25 @@ function VerifyGate({
553
513
  setState("idle");
554
514
  setNotice("No matching proof was found. Create a proof to continue.");
555
515
  } else {
556
- if (hasInteractiveVerifier) {
557
- setOperation("verify");
558
- setIsProcessing(true);
559
- setState("interactive-checkout");
560
- onStateChange?.("interactive-checkout");
561
- const checkoutResult = await launchHostedCheckout();
562
- const checkoutQHash = checkoutResult?.qHash || null;
563
- const handoffWallet = typeof checkoutResult?.walletAddress === "string" && checkoutResult.walletAddress.trim() || walletAddress && String(walletAddress).trim() || "";
564
- setState("verified");
565
- dispatchNeusProofCreatedForHost({
566
- qHash: checkoutQHash,
567
- walletAddress: handoffWallet
568
- });
569
- onVerified?.({
570
- qHash: checkoutQHash,
571
- verifierIds: verifierList,
572
- existing: false,
573
- mode: "create",
574
- eligible: checkoutResult?.eligible !== false,
575
- proofUrl: checkoutResult?.proofUrl || (checkoutQHash ? `${apiUrl || "https://api.neus.network"}/api/v1/proofs/${checkoutQHash}` : null)
576
- });
577
- return;
578
- }
579
516
  setOperation("verify");
580
517
  setIsProcessing(true);
581
- setState("signing");
582
- const resolvedProofOptions = mergeVerifyGateCreateProofOptions(
583
- proofOptions,
584
- verifierOptions
585
- );
586
- const buildDataForVerifier = (verifierId) => {
587
- if (!CREATABLE_VERIFIERS.has(verifierId)) {
588
- throw new Error(
589
- "This check requires the hosted verifier."
590
- );
591
- }
592
- const explicit = verifierData && verifierData[verifierId];
593
- if (explicit && typeof explicit === "object") return explicit;
594
- if (verifierId === "ownership-basic") {
595
- return null;
596
- }
597
- if (verifierId === "wallet-risk") {
598
- return {};
599
- }
600
- if (verifierId === "wallet-link") {
601
- if (!explicit?.secondaryWalletAddress || !explicit?.signature || !explicit?.chain || !explicit?.signatureMethod) {
602
- throw new Error(
603
- "Missing required wallet details."
604
- );
605
- }
606
- return explicit;
607
- }
608
- throw new Error("Missing required verification details.");
609
- };
610
- const verifyOne = async (verifierId) => {
611
- const dataForVerifier = buildDataForVerifier(verifierId);
612
- const params = verifierId === "ownership-basic" && dataForVerifier === null ? {
613
- verifier: "ownership-basic",
614
- content: (typeof verifierData?.["ownership-basic"] === "string" ? verifierData["ownership-basic"] : verifierData?.["ownership-basic"]?.content) || `NEUS verification (${verifierId})`,
615
- options: resolvedProofOptions
616
- } : {
617
- verifier: verifierId,
618
- data: dataForVerifier,
619
- options: resolvedProofOptions
620
- };
621
- setState("signing");
622
- const created = await client.verify({
623
- ...params,
624
- wallet: wallet || (typeof window !== "undefined" ? window.ethereum : void 0)
625
- });
626
- setState("verifying");
627
- const qHashToCheck = created.qHash || created?.data?.qHash;
628
- const final = await client.pollProofStatus(qHashToCheck, { interval: 3e3, timeout: 6e4 });
629
- const verifiedVerifiers = final?.data?.verifiedVerifiers || [];
630
- const verifierResult = verifiedVerifiers.find((v) => v.verifierId === verifierId);
631
- if (!verifierResult || verifierResult.verified !== true) {
632
- throw new Error("Verification could not be completed.");
633
- }
634
- const hubTx = final?.data?.hubTransaction || {};
635
- const crosschain = final?.data?.crosschain || {};
636
- const txHash = hubTx?.txHash || crosschain?.hubTxHash || null;
637
- const finalQHash = final?.qHash || qHashToCheck;
638
- return {
639
- verifierId,
640
- qHash: finalQHash,
641
- address: final?.data?.walletAddress,
642
- txHash,
643
- verifiedVerifiers,
644
- proofUrl: final?.proofUrl
645
- };
646
- };
647
- const results = [];
648
- for (const verifierId of verifierList) {
649
- results.push(await verifyOne(verifierId));
650
- }
518
+ setState("interactive-checkout");
519
+ onStateChange?.("interactive-checkout");
520
+ const checkoutResult = await launchHostedCheckout();
521
+ const checkoutQHash = checkoutResult?.qHash || null;
522
+ const handoffWallet = typeof checkoutResult?.walletAddress === "string" && checkoutResult.walletAddress.trim() || walletAddress && String(walletAddress).trim() || "";
651
523
  setState("verified");
652
- const last = results[results.length - 1];
653
- const lastQHash = last?.qHash || null;
654
- const handoffAddr = last?.address && String(last.address).trim() || walletAddress && String(walletAddress).trim() || "";
655
524
  dispatchNeusProofCreatedForHost({
656
- qHash: lastQHash,
657
- walletAddress: handoffAddr
525
+ qHash: checkoutQHash,
526
+ walletAddress: handoffWallet
658
527
  });
659
528
  onVerified?.({
660
- qHash: lastQHash,
661
- qHashes: results.map((r) => r.qHash).filter(Boolean),
662
- address: last?.address,
663
- txHash: last?.txHash,
529
+ qHash: checkoutQHash,
664
530
  verifierIds: verifierList,
665
- verifiedVerifiers: last?.verifiedVerifiers,
666
- proofUrl: last?.proofUrl,
667
- results
531
+ existing: false,
532
+ mode: "create",
533
+ eligible: checkoutResult?.eligible !== false,
534
+ proofUrl: checkoutResult?.proofUrl || (checkoutQHash ? `${apiUrl || "https://api.neus.network"}/api/v1/proofs/${checkoutQHash}` : null)
668
535
  });
669
536
  }
670
537
  } catch (err) {
@@ -682,12 +549,8 @@ function VerifyGate({
682
549
  mode,
683
550
  resolvedQHash,
684
551
  verifierList,
685
- hasInteractiveVerifier,
686
552
  client,
687
553
  apiUrl,
688
- verifierOptions,
689
- verifierData,
690
- proofOptions,
691
554
  launchHostedCheckout,
692
555
  onVerified,
693
556
  onError,
@@ -829,7 +692,7 @@ function VerifyGate({
829
692
  style: getButtonStyle(),
830
693
  children: [
831
694
  (state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
832
- showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
695
+ showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16 }),
833
696
  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" }) }),
834
697
  /* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() })
835
698
  ]
@@ -886,7 +749,7 @@ function VerifyGate({
886
749
  disabled: disabled || isProcessing,
887
750
  children: [
888
751
  (state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
889
- showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
752
+ showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16 }),
890
753
  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" }) }),
891
754
  /* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() }),
892
755
  error && /* @__PURE__ */ jsxs("span", { style: { opacity: 0.8, marginLeft: "8px" }, children: [