@neus/sdk 1.1.0 → 1.1.2

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,18 +8,35 @@ 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,
15
15
  campaignTitle,
16
- campaignMessage
16
+ campaignMessage,
17
+ appId,
18
+ billingWallet,
19
+ gateId
17
20
  }) {
18
21
  const checkoutUrl = new URL(hostedCheckoutUrl);
19
- checkoutUrl.searchParams.set("verifiers", verifierList.join(","));
20
22
  checkoutUrl.searchParams.set("mode", "popup");
21
23
  checkoutUrl.searchParams.set("returnUrl", returnUrl);
22
24
  checkoutUrl.searchParams.set("origin", origin);
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
+ }
39
+ }
23
40
  if (typeof oauthProvider === "string" && oauthProvider.trim()) {
24
41
  checkoutUrl.searchParams.set("oauthProvider", oauthProvider.trim());
25
42
  }
@@ -37,16 +54,17 @@ function buildHostedCheckoutRedirectUrl(popupCheckoutUrl) {
37
54
  return checkoutUrl.toString();
38
55
  }
39
56
 
40
- // widgets/verify-gate/mergeCreateProofOptions.js
41
- function mergeVerifyGateCreateProofOptions(proofOptions, verifierOptions) {
42
- return {
43
- privacyLevel: "private",
44
- publicDisplay: false,
45
- storeOriginalContent: true,
46
- ...proofOptions && typeof proofOptions === "object" ? proofOptions : {},
47
- ...verifierOptions ? { verifierOptions } : {}
48
- };
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}`;
49
65
  }
66
+ var NEUS_DEFAULT_MARK_URL = withBrandPackVersion("favicon.svg");
67
+ var NEUS_DEFAULT_OG_IMAGE_URL = withBrandPackVersion("og-default-1200x630-neus.png");
50
68
 
51
69
  // widgets/verify-gate/VerifyGate.jsx
52
70
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -74,37 +92,6 @@ if (typeof document !== "undefined") {
74
92
  document.head.appendChild(el);
75
93
  }
76
94
  }
77
- var DEFAULT_MAX_AGE_MS_BY_VERIFIER = {
78
- "ownership-dns-txt": 60 * 60 * 1e3,
79
- "contract-ownership": 60 * 60 * 1e3,
80
- "nft-ownership": 60 * 60 * 1e3,
81
- "token-holding": 60 * 60 * 1e3,
82
- "wallet-risk": 60 * 60 * 1e3,
83
- "agent-delegation": 7 * 24 * 60 * 60 * 1e3
84
- };
85
- var maxAgeMsForVerifier = (verifierId, overrideMs) => {
86
- if (typeof overrideMs === "number") return overrideMs;
87
- return DEFAULT_MAX_AGE_MS_BY_VERIFIER[verifierId];
88
- };
89
- var CREATABLE_VERIFIERS = /* @__PURE__ */ new Set([
90
- "ownership-basic",
91
- "ownership-pseudonym",
92
- "ownership-dns-txt",
93
- "contract-ownership",
94
- "nft-ownership",
95
- "token-holding",
96
- "wallet-link",
97
- "wallet-risk",
98
- "agent-identity",
99
- "agent-delegation",
100
- "ai-content-moderation"
101
- ]);
102
- var INTERACTIVE_VERIFIERS = /* @__PURE__ */ new Set([
103
- "ownership-social",
104
- "ownership-org-oauth",
105
- "proof-of-human"
106
- ]);
107
- var HOSTED_WHEN_INCOMPLETE = /* @__PURE__ */ new Set(["wallet-link"]);
108
95
  var DEFAULT_HOSTED_CHECKOUT_URL = "https://neus.network/verify";
109
96
  var VERIFY_GATE_DEFAULT_ERROR = "Something went wrong. Please try again.";
110
97
  function getVerifyGateUserError(err) {
@@ -159,42 +146,40 @@ function VerifyGateInlineSpinner({ size = 16 }) {
159
146
  }
160
147
  );
161
148
  }
162
- function NeusLogo({ size = 16, onPrimaryFill = false }) {
149
+ function NeusLogo({ size = 16 }) {
163
150
  return /* @__PURE__ */ jsx(
164
- "span",
151
+ "img",
165
152
  {
153
+ src: NEUS_DEFAULT_MARK_URL,
154
+ alt: "",
166
155
  "aria-hidden": "true",
156
+ width: size,
157
+ height: size,
167
158
  style: {
168
- display: "inline-flex",
169
- alignItems: "center",
170
- justifyContent: "center",
171
- width: `${size}px`,
172
- height: `${size}px`,
173
- borderRadius: "4px",
174
- border: `1px solid ${onPrimaryFill ? "rgba(10, 10, 10, 0.35)" : "currentColor"}`,
175
- color: onPrimaryFill ? "#0a0a0a" : "currentColor",
176
- fontSize: `${Math.max(9, Math.round(size * 0.55))}px`,
177
- fontWeight: 700,
178
- lineHeight: 1
179
- },
180
- children: "N"
159
+ width: size,
160
+ height: size,
161
+ display: "block",
162
+ borderRadius: 4,
163
+ flexShrink: 0,
164
+ objectFit: "contain",
165
+ background: "transparent"
166
+ }
181
167
  }
182
168
  );
183
169
  }
184
170
  function VerifyGate({
171
+ gateId = void 0,
185
172
  requiredVerifiers = ["ownership-basic"],
186
173
  onVerified = void 0,
187
174
  apiUrl = void 0,
188
175
  appId = void 0,
176
+ billingWallet = void 0,
189
177
  paymentSignature = void 0,
190
178
  extraHeaders = void 0,
191
179
  hostedCheckoutUrl = void 0,
192
180
  oauthProvider = void 0,
193
181
  style = void 0,
194
182
  children = void 0,
195
- verifierOptions = void 0,
196
- verifierData = void 0,
197
- proofOptions = void 0,
198
183
  showBrand = false,
199
184
  disabled = false,
200
185
  buttonText = void 0,
@@ -202,7 +187,6 @@ function VerifyGate({
202
187
  qHash: qHashProp = null,
203
188
  strategy = "reuse-or-create",
204
189
  checkExisting = true,
205
- maxProofAgeMs = void 0,
206
190
  allowPrivateReuse = true,
207
191
  campaignTitle = void 0,
208
192
  campaignMessage = void 0,
@@ -219,27 +203,18 @@ function VerifyGate({
219
203
  const [walletAddress, setWalletAddress] = useState(null);
220
204
  const [existingProofs, setExistingProofs] = useState(null);
221
205
  const [operation, setOperation] = useState("verify");
206
+ const resolvedGateId = typeof gateId === "string" ? gateId.trim() : "";
222
207
  const client = useMemo(
223
- () => new NeusClient({ apiUrl, appId, paymentSignature, extraHeaders }),
224
- [apiUrl, appId, 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]
225
210
  );
226
211
  const verifierList = useMemo(() => {
212
+ if (resolvedGateId) return [];
227
213
  return Array.isArray(requiredVerifiers) && requiredVerifiers.length > 0 ? requiredVerifiers : ["ownership-basic"];
228
- }, [requiredVerifiers]);
214
+ }, [requiredVerifiers, resolvedGateId]);
229
215
  const primaryVerifier = verifierList[0];
230
216
  const qHash = qHashProp || null;
231
217
  const resolvedQHash = qHash;
232
- const hasInteractiveVerifier = useMemo(
233
- () => verifierList.some((verifierId) => {
234
- if (INTERACTIVE_VERIFIERS.has(verifierId)) return true;
235
- if (HOSTED_WHEN_INCOMPLETE.has(verifierId)) {
236
- const data = verifierData && verifierData[verifierId];
237
- if (!data || !data.secondaryWalletAddress || !data.signature) return true;
238
- }
239
- return false;
240
- }),
241
- [verifierList, verifierData]
242
- );
243
218
  const resolvedHostedCheckoutUrl = useMemo(() => {
244
219
  if (typeof hostedCheckoutUrl === "string" && hostedCheckoutUrl.trim()) {
245
220
  return hostedCheckoutUrl.trim();
@@ -253,7 +228,7 @@ function VerifyGate({
253
228
  }
254
229
  return DEFAULT_HOSTED_CHECKOUT_URL;
255
230
  }, [apiUrl, hostedCheckoutUrl]);
256
- const shouldCheckExisting = checkExisting && strategy !== "fresh";
231
+ const shouldCheckExisting = !resolvedGateId && checkExisting && strategy !== "fresh";
257
232
  const inferChainFromAddress = useCallback((address) => {
258
233
  const raw = String(address || "").trim();
259
234
  if (!raw) return void 0;
@@ -262,11 +237,8 @@ function VerifyGate({
262
237
  return "solana:mainnet";
263
238
  }, [chain]);
264
239
  const buildGateRequirements = useCallback(() => {
265
- return verifierList.map((verifierId) => ({
266
- verifierId,
267
- ...maxAgeMsForVerifier(verifierId, maxProofAgeMs) && { maxAgeMs: maxAgeMsForVerifier(verifierId, maxProofAgeMs) }
268
- }));
269
- }, [verifierList, maxProofAgeMs]);
240
+ return verifierList.map((verifierId) => ({ verifierId }));
241
+ }, [verifierList]);
270
242
  const applySatisfiedGateResult = useCallback((gateResult, address) => {
271
243
  if (!gateResult?.satisfied) return false;
272
244
  setNotice(null);
@@ -397,7 +369,10 @@ function VerifyGate({
397
369
  origin,
398
370
  oauthProvider,
399
371
  campaignTitle,
400
- campaignMessage
372
+ campaignMessage,
373
+ gateId: resolvedGateId || void 0,
374
+ appId: resolvedGateId ? void 0 : appId,
375
+ billingWallet: resolvedGateId ? void 0 : billingWallet
401
376
  });
402
377
  let expectedOrigin = null;
403
378
  try {
@@ -451,7 +426,7 @@ function VerifyGate({
451
426
  };
452
427
  window.addEventListener("message", onMessage);
453
428
  });
454
- }, [resolvedHostedCheckoutUrl, verifierList, oauthProvider, campaignTitle, campaignMessage]);
429
+ }, [resolvedHostedCheckoutUrl, verifierList, oauthProvider, campaignTitle, campaignMessage, appId, billingWallet, resolvedGateId]);
455
430
  useEffect(() => {
456
431
  onStateChange?.(state);
457
432
  }, [state, onStateChange]);
@@ -538,118 +513,25 @@ function VerifyGate({
538
513
  setState("idle");
539
514
  setNotice("No matching proof was found. Create a proof to continue.");
540
515
  } else {
541
- if (hasInteractiveVerifier) {
542
- setOperation("verify");
543
- setIsProcessing(true);
544
- setState("interactive-checkout");
545
- onStateChange?.("interactive-checkout");
546
- const checkoutResult = await launchHostedCheckout();
547
- const checkoutQHash = checkoutResult?.qHash || null;
548
- const handoffWallet = typeof checkoutResult?.walletAddress === "string" && checkoutResult.walletAddress.trim() || walletAddress && String(walletAddress).trim() || "";
549
- setState("verified");
550
- dispatchNeusProofCreatedForHost({
551
- qHash: checkoutQHash,
552
- walletAddress: handoffWallet
553
- });
554
- onVerified?.({
555
- qHash: checkoutQHash,
556
- verifierIds: verifierList,
557
- existing: false,
558
- mode: "create",
559
- eligible: checkoutResult?.eligible !== false,
560
- proofUrl: checkoutResult?.proofUrl || (checkoutQHash ? `${apiUrl || "https://api.neus.network"}/api/v1/proofs/${checkoutQHash}` : null)
561
- });
562
- return;
563
- }
564
516
  setOperation("verify");
565
517
  setIsProcessing(true);
566
- setState("signing");
567
- const resolvedProofOptions = mergeVerifyGateCreateProofOptions(
568
- proofOptions,
569
- verifierOptions
570
- );
571
- const buildDataForVerifier = (verifierId) => {
572
- if (!CREATABLE_VERIFIERS.has(verifierId)) {
573
- throw new Error(
574
- "This check requires the hosted verifier."
575
- );
576
- }
577
- const explicit = verifierData && verifierData[verifierId];
578
- if (explicit && typeof explicit === "object") return explicit;
579
- if (verifierId === "ownership-basic") {
580
- return null;
581
- }
582
- if (verifierId === "wallet-risk") {
583
- return {};
584
- }
585
- if (verifierId === "wallet-link") {
586
- if (!explicit?.secondaryWalletAddress || !explicit?.signature || !explicit?.chain || !explicit?.signatureMethod) {
587
- throw new Error(
588
- "Missing required wallet details."
589
- );
590
- }
591
- return explicit;
592
- }
593
- throw new Error("Missing required verification details.");
594
- };
595
- const verifyOne = async (verifierId) => {
596
- const dataForVerifier = buildDataForVerifier(verifierId);
597
- const params = verifierId === "ownership-basic" && dataForVerifier === null ? {
598
- verifier: "ownership-basic",
599
- content: (typeof verifierData?.["ownership-basic"] === "string" ? verifierData["ownership-basic"] : verifierData?.["ownership-basic"]?.content) || `NEUS verification (${verifierId})`,
600
- options: resolvedProofOptions
601
- } : {
602
- verifier: verifierId,
603
- data: dataForVerifier,
604
- options: resolvedProofOptions
605
- };
606
- setState("signing");
607
- const created = await client.verify({
608
- ...params,
609
- wallet: wallet || (typeof window !== "undefined" ? window.ethereum : void 0)
610
- });
611
- setState("verifying");
612
- const qHashToCheck = created.qHash || created?.data?.qHash;
613
- const final = await client.pollProofStatus(qHashToCheck, { interval: 3e3, timeout: 6e4 });
614
- const verifiedVerifiers = final?.data?.verifiedVerifiers || [];
615
- const verifierResult = verifiedVerifiers.find((v) => v.verifierId === verifierId);
616
- if (!verifierResult || verifierResult.verified !== true) {
617
- throw new Error("Verification could not be completed.");
618
- }
619
- const hubTx = final?.data?.hubTransaction || {};
620
- const crosschain = final?.data?.crosschain || {};
621
- const txHash = hubTx?.txHash || crosschain?.hubTxHash || null;
622
- const finalQHash = final?.qHash || qHashToCheck;
623
- return {
624
- verifierId,
625
- qHash: finalQHash,
626
- address: final?.data?.walletAddress,
627
- txHash,
628
- verifiedVerifiers,
629
- proofUrl: final?.proofUrl
630
- };
631
- };
632
- const results = [];
633
- for (const verifierId of verifierList) {
634
- results.push(await verifyOne(verifierId));
635
- }
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() || "";
636
523
  setState("verified");
637
- const last = results[results.length - 1];
638
- const lastQHash = last?.qHash || null;
639
- const handoffAddr = last?.address && String(last.address).trim() || walletAddress && String(walletAddress).trim() || "";
640
524
  dispatchNeusProofCreatedForHost({
641
- qHash: lastQHash,
642
- walletAddress: handoffAddr
525
+ qHash: checkoutQHash,
526
+ walletAddress: handoffWallet
643
527
  });
644
528
  onVerified?.({
645
- qHash: lastQHash,
646
- qHashes: results.map((r) => r.qHash).filter(Boolean),
647
- address: last?.address,
648
- txHash: last?.txHash,
529
+ qHash: checkoutQHash,
649
530
  verifierIds: verifierList,
650
- verifiedVerifiers: last?.verifiedVerifiers,
651
- proofUrl: last?.proofUrl,
652
- 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)
653
535
  });
654
536
  }
655
537
  } catch (err) {
@@ -667,12 +549,8 @@ function VerifyGate({
667
549
  mode,
668
550
  resolvedQHash,
669
551
  verifierList,
670
- hasInteractiveVerifier,
671
552
  client,
672
553
  apiUrl,
673
- verifierOptions,
674
- verifierData,
675
- proofOptions,
676
554
  launchHostedCheckout,
677
555
  onVerified,
678
556
  onError,
@@ -814,7 +692,7 @@ function VerifyGate({
814
692
  style: getButtonStyle(),
815
693
  children: [
816
694
  (state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
817
- showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
695
+ showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16 }),
818
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" }) }),
819
697
  /* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() })
820
698
  ]
@@ -871,7 +749,7 @@ function VerifyGate({
871
749
  disabled: disabled || isProcessing,
872
750
  children: [
873
751
  (state === "signing" || state === "verifying" || state === "interactive-checkout") && /* @__PURE__ */ jsx(VerifyGateInlineSpinner, { size: 16 }),
874
- showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16, onPrimaryFill: true }),
752
+ showBrand && state === "idle" && /* @__PURE__ */ jsx(NeusLogo, { size: 16 }),
875
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" }) }),
876
754
  /* @__PURE__ */ jsx("span", { className: "neus-vg__label", style: { color: "inherit" }, children: getLabel() }),
877
755
  error && /* @__PURE__ */ jsxs("span", { style: { opacity: 0.8, marginLeft: "8px" }, children: [
package/CHANGELOG.md DELETED
@@ -1,3 +0,0 @@
1
- # Changelog
2
-
3
- Release notes: [github.com/neus/network/blob/main/CHANGELOG.md](https://github.com/neus/network/blob/main/CHANGELOG.md)