@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.
package/cjs/index.cjs CHANGED
@@ -2089,21 +2089,20 @@ var init_client = __esm({
2089
2089
  return hex;
2090
2090
  }
2091
2091
  };
2092
- const isFarcasterWallet = (() => {
2092
+ const isBaseMiniAppWallet = (() => {
2093
2093
  if (typeof window === "undefined") return false;
2094
2094
  try {
2095
2095
  const w = window;
2096
- const fc = w.farcaster;
2097
- if (!fc || !fc.context) return false;
2098
- const fcProvider = fc.provider || fc.walletProvider || fc.context && fc.context.walletProvider;
2099
- if (fcProvider === provider) return true;
2100
- if (w.mini && w.mini.wallet === provider && fc && fc.context) return true;
2101
- if (w.ethereum === provider && fc && fc.context) return true;
2096
+ const mini = w.mini;
2097
+ if (!mini) return false;
2098
+ const miniProvider = mini.wallet || mini.provider;
2099
+ if (miniProvider === provider) return true;
2100
+ if (w.ethereum === provider && mini) return true;
2102
2101
  } catch {
2103
2102
  }
2104
2103
  return false;
2105
2104
  })();
2106
- if (isFarcasterWallet) {
2105
+ if (isBaseMiniAppWallet) {
2107
2106
  try {
2108
2107
  const hexMsg = toHexUtf82(message);
2109
2108
  signature2 = await provider.request({ method: "personal_sign", params: [hexMsg, walletAddress2] });
@@ -2452,7 +2451,9 @@ ${bytes.length}`;
2452
2451
  const pathId = /^0x[a-fA-F0-9]{40}$/i.test(id) ? id.toLowerCase() : id;
2453
2452
  const qs = [];
2454
2453
  if (options.limit) qs.push(`limit=${encodeURIComponent(String(options.limit))}`);
2455
- if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
2454
+ const cursorRaw = options.cursor !== null && options.cursor !== void 0 ? String(options.cursor).trim() : "";
2455
+ if (cursorRaw) qs.push(`cursor=${encodeURIComponent(cursorRaw)}`);
2456
+ else if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
2456
2457
  if (options.qHash) qs.push(`qHash=${encodeURIComponent(options.qHash.toLowerCase())}`);
2457
2458
  const query = qs.length ? `?${qs.join("&")}` : "";
2458
2459
  const response = await this._makeRequest(
@@ -2468,7 +2469,8 @@ ${bytes.length}`;
2468
2469
  proofs: Array.isArray(proofs) ? proofs : [],
2469
2470
  totalCount: response.data?.totalCount ?? proofs.length,
2470
2471
  hasMore: Boolean(response.data?.hasMore),
2471
- nextOffset: response.data?.nextOffset ?? null
2472
+ nextOffset: response.data?.nextOffset ?? null,
2473
+ nextCursor: typeof response.data?.nextCursor === "string" && response.data.nextCursor.trim() ? response.data.nextCursor.trim() : null
2472
2474
  };
2473
2475
  }
2474
2476
  async getPrivateProofsByWallet(walletAddress, options = {}, wallet = null) {
@@ -2520,7 +2522,9 @@ ${bytes.length}`;
2520
2522
  }
2521
2523
  const qs = [];
2522
2524
  if (options.limit) qs.push(`limit=${encodeURIComponent(String(options.limit))}`);
2523
- if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
2525
+ const cursorRaw = options.cursor !== null && options.cursor !== void 0 ? String(options.cursor).trim() : "";
2526
+ if (cursorRaw) qs.push(`cursor=${encodeURIComponent(cursorRaw)}`);
2527
+ else if (options.offset) qs.push(`offset=${encodeURIComponent(String(options.offset))}`);
2524
2528
  if (options.qHash) qs.push(`qHash=${encodeURIComponent(options.qHash.toLowerCase())}`);
2525
2529
  const query = qs.length ? `?${qs.join("&")}` : "";
2526
2530
  const response = await this._makeRequest("GET", `/api/v1/proofs/by-wallet/${encodeURIComponent(pathId)}${query}`, null, {
@@ -2538,7 +2542,8 @@ ${bytes.length}`;
2538
2542
  proofs: Array.isArray(proofs) ? proofs : [],
2539
2543
  totalCount: response.data?.totalCount ?? proofs.length,
2540
2544
  hasMore: Boolean(response.data?.hasMore),
2541
- nextOffset: response.data?.nextOffset ?? null
2545
+ nextOffset: response.data?.nextOffset ?? null,
2546
+ nextCursor: typeof response.data?.nextCursor === "string" && response.data.nextCursor.trim() ? response.data.nextCursor.trim() : null
2542
2547
  };
2543
2548
  }
2544
2549
  async gateCheck(params = {}) {
@@ -2546,6 +2551,8 @@ ${bytes.length}`;
2546
2551
  if (!validateUniversalAddress(address, params.chain)) {
2547
2552
  throw new ValidationError("Valid address is required");
2548
2553
  }
2554
+ const gateIdParam = typeof params.gateId === "string" ? params.gateId.trim() : "";
2555
+ const verifierIds = gateIdParam ? void 0 : params.verifierIds;
2549
2556
  const qs = new URLSearchParams();
2550
2557
  qs.set("address", address);
2551
2558
  const setIfPresent = (key, value) => {
@@ -2567,7 +2574,8 @@ ${bytes.length}`;
2567
2574
  }
2568
2575
  setIfPresent(key, value);
2569
2576
  };
2570
- setCsvIfPresent("verifierIds", params.verifierIds);
2577
+ setIfPresent("gateId", gateIdParam);
2578
+ setCsvIfPresent("verifierIds", verifierIds);
2571
2579
  setBoolIfPresent("requireAll", params.requireAll);
2572
2580
  setIfPresent("minCount", params.minCount);
2573
2581
  setIfPresent("sinceDays", params.sinceDays);
@@ -2631,10 +2639,10 @@ ${bytes.length}`;
2631
2639
  }
2632
2640
  }
2633
2641
  let mergedHeaders = headersOverride;
2634
- if (!mergedHeaders) {
2642
+ if (!mergedHeaders && !gateIdParam) {
2635
2643
  try {
2636
2644
  const sponsorHeaders = await this._resolveSponsorGrantHeaders(
2637
- Array.isArray(params.verifierIds) ? params.verifierIds : params.verifierIds ? [params.verifierIds] : []
2645
+ Array.isArray(verifierIds) ? verifierIds : verifierIds ? [verifierIds] : []
2638
2646
  );
2639
2647
  if (sponsorHeaders && Object.keys(sponsorHeaders).length > 0) {
2640
2648
  mergedHeaders = sponsorHeaders;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // mcp-hosts.js
21
+ var mcp_hosts_exports = {};
22
+ __export(mcp_hosts_exports, {
23
+ IDE_HOST_BRAND_LOGOS: () => IDE_HOST_BRAND_LOGOS,
24
+ IDE_HOST_LABELS: () => IDE_HOST_LABELS,
25
+ MCP_INSTALL_CLIENTS: () => MCP_INSTALL_CLIENTS,
26
+ MCP_INSTALL_HOSTS: () => MCP_INSTALL_HOSTS,
27
+ NEUS_AUTH_CLI: () => NEUS_AUTH_CLI,
28
+ NEUS_MCP_SERVER_NAME: () => NEUS_MCP_SERVER_NAME,
29
+ NEUS_MCP_SETUP_DOCS_URL: () => NEUS_MCP_SETUP_DOCS_URL,
30
+ NEUS_MCP_URL: () => NEUS_MCP_URL,
31
+ NEUS_SETUP_CLI: () => NEUS_SETUP_CLI,
32
+ buildAuthCommandForClient: () => buildAuthCommandForClient,
33
+ buildCursorMcpInstallUrl: () => buildCursorMcpInstallUrl,
34
+ buildNeusMcpHttpConfig: () => buildNeusMcpHttpConfig,
35
+ buildSetupCommandForClient: () => buildSetupCommandForClient,
36
+ buildSetupCommandForHost: () => buildSetupCommandForHost,
37
+ buildVsCodeMcpInstallUrl: () => buildVsCodeMcpInstallUrl,
38
+ supportsMcpInstallDeeplink: () => supportsMcpInstallDeeplink
39
+ });
40
+ module.exports = __toCommonJS(mcp_hosts_exports);
41
+ var NEUS_MCP_SERVER_NAME = "neus";
42
+ var NEUS_MCP_URL = "https://mcp.neus.network/mcp";
43
+ var NEUS_SETUP_CLI = "npx -y -p @neus/sdk neus setup";
44
+ var NEUS_AUTH_CLI = "npx -y -p @neus/sdk neus auth";
45
+ var NEUS_MCP_SETUP_DOCS_URL = "https://docs.neus.network/mcp/ide-plugin";
46
+ var MCP_INSTALL_CLIENTS = ["claude", "codex", "cursor", "vscode"];
47
+ var MCP_INSTALL_HOSTS = ["cursor", "claude", "codex"];
48
+ var IDE_HOST_LABELS = {
49
+ cursor: "Cursor",
50
+ claude: "Claude Code",
51
+ codex: "Codex"
52
+ };
53
+ var IDE_HOST_BRAND_LOGOS = {
54
+ cursor: "/images/brandLogos/cursor.svg",
55
+ claude: "/images/brandLogos/anthropic.svg",
56
+ codex: "/images/brandLogos/openai.svg"
57
+ };
58
+ function buildNeusMcpHttpConfig(accessKey) {
59
+ const key = String(accessKey || "").trim();
60
+ return {
61
+ type: "http",
62
+ url: NEUS_MCP_URL,
63
+ ...key ? { headers: { Authorization: `Bearer ${key}` } } : {}
64
+ };
65
+ }
66
+ function encodeBase64Json(value) {
67
+ const json = JSON.stringify(value);
68
+ if (typeof globalThis.btoa === "function") {
69
+ return globalThis.btoa(json);
70
+ }
71
+ return Buffer.from(json, "utf8").toString("base64");
72
+ }
73
+ function buildCursorMcpInstallUrl(accessKey) {
74
+ const config = buildNeusMcpHttpConfig(accessKey);
75
+ const encoded = encodeBase64Json(config);
76
+ return `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(NEUS_MCP_SERVER_NAME)}&config=${encodeURIComponent(encoded)}`;
77
+ }
78
+ function buildVsCodeMcpInstallUrl(accessKey) {
79
+ const payload = {
80
+ name: NEUS_MCP_SERVER_NAME,
81
+ ...buildNeusMcpHttpConfig(accessKey)
82
+ };
83
+ return `vscode:mcp/install?${encodeURIComponent(JSON.stringify(payload))}`;
84
+ }
85
+ function buildAuthCommandForClient(client) {
86
+ if (client === "codex") {
87
+ return `${NEUS_AUTH_CLI} --client codex`;
88
+ }
89
+ return NEUS_AUTH_CLI;
90
+ }
91
+ function buildSetupCommandForClient(client, accessKey) {
92
+ const key = String(accessKey || "").trim();
93
+ const setup = key ? `${NEUS_SETUP_CLI} --client ${client} --access-key ${key}` : `${NEUS_SETUP_CLI} --client ${client}`;
94
+ if (key) return setup;
95
+ return `${setup}
96
+ ${buildAuthCommandForClient(client)}`;
97
+ }
98
+ function buildSetupCommandForHost(host, accessKey) {
99
+ return buildSetupCommandForClient(host, accessKey);
100
+ }
101
+ function supportsMcpInstallDeeplink(host) {
102
+ if (host !== "cursor") return false;
103
+ if (typeof navigator === "undefined") return false;
104
+ const ua = navigator.userAgent || "";
105
+ return !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ IDE_HOST_BRAND_LOGOS,
110
+ IDE_HOST_LABELS,
111
+ MCP_INSTALL_CLIENTS,
112
+ MCP_INSTALL_HOSTS,
113
+ NEUS_AUTH_CLI,
114
+ NEUS_MCP_SERVER_NAME,
115
+ NEUS_MCP_SETUP_DOCS_URL,
116
+ NEUS_MCP_URL,
117
+ NEUS_SETUP_CLI,
118
+ buildAuthCommandForClient,
119
+ buildCursorMcpInstallUrl,
120
+ buildNeusMcpHttpConfig,
121
+ buildSetupCommandForClient,
122
+ buildSetupCommandForHost,
123
+ buildVsCodeMcpInstallUrl,
124
+ supportsMcpInstallDeeplink
125
+ });