@neus/sdk 1.0.3 → 1.0.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/utils.cjs CHANGED
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // utils.js
31
31
  var utils_exports = {};
32
32
  __export(utils_exports, {
33
+ DEFAULT_HOSTED_VERIFY_URL: () => DEFAULT_HOSTED_VERIFY_URL,
33
34
  NEUS_CONSTANTS: () => NEUS_CONSTANTS,
35
+ PORTABLE_PROOF_SIGNER_HEADER: () => PORTABLE_PROOF_SIGNER_HEADER,
34
36
  StatusPoller: () => StatusPoller,
35
37
  buildVerificationRequest: () => buildVerificationRequest,
36
38
  computeContentHash: () => computeContentHash,
@@ -40,6 +42,7 @@ __export(utils_exports, {
40
42
  deriveDid: () => deriveDid,
41
43
  formatTimestamp: () => formatTimestamp,
42
44
  formatVerificationStatus: () => formatVerificationStatus,
45
+ getHostedCheckoutUrl: () => getHostedCheckoutUrl,
43
46
  isFailureStatus: () => isFailureStatus,
44
47
  isSuccessStatus: () => isSuccessStatus,
45
48
  isSupportedChain: () => isSupportedChain,
@@ -49,6 +52,7 @@ __export(utils_exports, {
49
52
  resolveZkPassportConfig: () => resolveZkPassportConfig,
50
53
  signMessage: () => signMessage,
51
54
  standardizeVerificationRequest: () => standardizeVerificationRequest,
55
+ toAgentDelegationMaxSpend: () => toAgentDelegationMaxSpend,
52
56
  toHexUtf8: () => toHexUtf8,
53
57
  validateQHash: () => validateQHash,
54
58
  validateSignatureComponents: () => validateSignatureComponents,
@@ -127,6 +131,7 @@ var ValidationError = class extends SDKError {
127
131
  };
128
132
 
129
133
  // utils.js
134
+ var PORTABLE_PROOF_SIGNER_HEADER = "Portable Proof Verification Request";
130
135
  var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
131
136
  function encodeBase58Bytes(input) {
132
137
  let source;
@@ -141,8 +146,7 @@ function encodeBase58Bytes(input) {
141
146
  } else {
142
147
  throw new SDKError("Unsupported non-EVM signature byte format", "INVALID_SIGNATURE_FORMAT");
143
148
  }
144
- if (source.length === 0)
145
- return "";
149
+ if (source.length === 0) return "";
146
150
  let zeroes = 0;
147
151
  while (zeroes < source.length && source[zeroes] === 0) {
148
152
  zeroes++;
@@ -176,16 +180,28 @@ function deterministicStringify(obj) {
176
180
  return JSON.stringify(obj);
177
181
  }
178
182
  if (typeof obj !== "object") {
183
+ if (typeof obj === "string") return JSON.stringify(obj.normalize("NFC"));
179
184
  return JSON.stringify(obj);
180
185
  }
181
186
  if (Array.isArray(obj)) {
182
- return "[" + obj.map((item) => deterministicStringify(item)).join(",") + "]";
187
+ return `[${obj.map((item) => item === void 0 ? "null" : deterministicStringify(item)).join(",")}]`;
183
188
  }
184
- const sortedKeys = Object.keys(obj).sort();
189
+ const sortedKeys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
185
190
  const pairs = sortedKeys.map(
186
- (key) => JSON.stringify(key) + ":" + deterministicStringify(obj[key])
191
+ (key) => `${JSON.stringify(key)}:${deterministicStringify(obj[key])}`
187
192
  );
188
- return "{" + pairs.join(",") + "}";
193
+ return `{${pairs.join(",")}}`;
194
+ }
195
+ function chainLineForPortableProofSigner(chain, chainId) {
196
+ if (typeof chain === "string" && chain.length > 0) {
197
+ const m = chain.match(/^eip155:(\d+)$/);
198
+ if (m) return Number(m[1]);
199
+ return chain;
200
+ }
201
+ if (typeof chainId === "number" && Number.isFinite(chainId) && chainId > 0) {
202
+ return chainId;
203
+ }
204
+ throw new SDKError("chainId is required (or provide chain for universal mode)", "INVALID_CHAIN_CONTEXT");
189
205
  }
190
206
  function constructVerificationMessage({ walletAddress, signedTimestamp, data, verifierIds, chainId, chain }) {
191
207
  if (!walletAddress || typeof walletAddress !== "string") {
@@ -200,28 +216,28 @@ function constructVerificationMessage({ walletAddress, signedTimestamp, data, ve
200
216
  if (!Array.isArray(verifierIds) || verifierIds.length === 0) {
201
217
  throw new SDKError("verifierIds is required and must be a non-empty array", "INVALID_VERIFIER_IDS");
202
218
  }
203
- const chainContext = typeof chain === "string" && chain.length > 0 ? chain : chainId;
204
- if (!chainContext) {
219
+ if ((typeof chain !== "string" || !chain.length) && !(typeof chainId === "number" && chainId > 0)) {
205
220
  throw new SDKError("chainId is required (or provide chain for universal mode)", "INVALID_CHAIN_CONTEXT");
206
221
  }
207
- if (chainContext === chainId && typeof chainId !== "number") {
208
- throw new SDKError("chainId must be a number when provided", "INVALID_CHAIN_ID");
209
- }
210
- if (chainContext === chain && (typeof chain !== "string" || !chain.includes(":"))) {
222
+ if (typeof chain === "string" && chain.length > 0 && !chain.includes(":")) {
211
223
  throw new SDKError('chain must be a "namespace:reference" string', "INVALID_CHAIN");
212
224
  }
225
+ if ((!chain || !chain.length) && typeof chainId !== "number") {
226
+ throw new SDKError("chainId must be a number when provided", "INVALID_CHAIN_ID");
227
+ }
228
+ const chainLine = chainLineForPortableProofSigner(chain, chainId);
213
229
  const namespace = typeof chain === "string" && chain.includes(":") ? chain.split(":")[0] : "eip155";
214
230
  const normalizedWalletAddress = namespace === "eip155" ? walletAddress.toLowerCase() : walletAddress;
215
231
  const dataString = deterministicStringify(data);
216
232
  const messageComponents = [
217
- "NEUS Verification Request",
233
+ PORTABLE_PROOF_SIGNER_HEADER,
218
234
  `Wallet: ${normalizedWalletAddress}`,
219
- `Chain: ${chainContext}`,
235
+ `Chain: ${chainLine}`,
220
236
  `Verifiers: ${verifierIds.join(",")}`,
221
237
  `Data: ${dataString}`,
222
238
  `Timestamp: ${signedTimestamp}`
223
239
  ];
224
- return messageComponents.join("\n");
240
+ return messageComponents.join("\n").normalize("NFC");
225
241
  }
226
242
  function validateWalletAddress(address) {
227
243
  if (!address || typeof address !== "string") {
@@ -230,17 +246,13 @@ function validateWalletAddress(address) {
230
246
  return /^0x[a-fA-F0-9]{40}$/.test(address);
231
247
  }
232
248
  function validateUniversalAddress(address, chain) {
233
- if (!address || typeof address !== "string")
234
- return false;
249
+ if (!address || typeof address !== "string") return false;
235
250
  const value = address.trim();
236
- if (!value)
237
- return false;
251
+ if (!value) return false;
238
252
  const chainRef = typeof chain === "string" ? chain.trim().toLowerCase() : "";
239
253
  const namespace = chainRef.includes(":") ? chainRef.split(":")[0] : "";
240
- if (validateWalletAddress(value))
241
- return true;
242
- if (namespace === "eip155")
243
- return false;
254
+ if (validateWalletAddress(value)) return true;
255
+ if (namespace === "eip155") return false;
244
256
  if (namespace === "solana") {
245
257
  return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(value);
246
258
  }
@@ -302,16 +314,12 @@ async function resolveDID(params, options = {}) {
302
314
  const endpointPath = options.endpoint || "/api/v1/profile/did/resolve";
303
315
  const apiUrl = typeof options.apiUrl === "string" ? options.apiUrl.trim() : "";
304
316
  const resolveEndpoint = (path) => {
305
- if (!path || typeof path !== "string")
306
- return null;
317
+ if (!path || typeof path !== "string") return null;
307
318
  const trimmedPath = path.trim();
308
- if (!trimmedPath)
309
- return null;
310
- if (/^https?:\/\//i.test(trimmedPath))
311
- return trimmedPath;
319
+ if (!trimmedPath) return null;
320
+ if (/^https?:\/\//i.test(trimmedPath)) return trimmedPath;
312
321
  if (trimmedPath.startsWith("/")) {
313
- if (!apiUrl)
314
- return trimmedPath;
322
+ if (!apiUrl) return trimmedPath;
315
323
  try {
316
324
  return new URL(trimmedPath, apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`).toString();
317
325
  } catch {
@@ -319,8 +327,7 @@ async function resolveDID(params, options = {}) {
319
327
  }
320
328
  }
321
329
  const base = apiUrl || NEUS_CONSTANTS.API_BASE_URL;
322
- if (!base || typeof base !== "string")
323
- return null;
330
+ if (!base || typeof base !== "string") return null;
324
331
  try {
325
332
  return new URL(trimmedPath, base.endsWith("/") ? base : `${base}/`).toString();
326
333
  } catch {
@@ -360,8 +367,7 @@ async function resolveDID(params, options = {}) {
360
367
  }
361
368
  return { did, data: json?.data || null, raw: json };
362
369
  } catch (error) {
363
- if (error instanceof SDKError)
364
- throw error;
370
+ if (error instanceof SDKError) throw error;
365
371
  throw new SDKError(`DID resolution failed: ${error?.message || error}`, "DID_RESOLVE_FAILED");
366
372
  }
367
373
  }
@@ -369,16 +375,12 @@ async function standardizeVerificationRequest(params, options = {}) {
369
375
  const endpointPath = options.endpoint || "/api/v1/verification/standardize";
370
376
  const apiUrl = typeof options.apiUrl === "string" ? options.apiUrl.trim() : "";
371
377
  const resolveEndpoint = (path) => {
372
- if (!path || typeof path !== "string")
373
- return null;
378
+ if (!path || typeof path !== "string") return null;
374
379
  const trimmedPath = path.trim();
375
- if (!trimmedPath)
376
- return null;
377
- if (/^https?:\/\//i.test(trimmedPath))
378
- return trimmedPath;
380
+ if (!trimmedPath) return null;
381
+ if (/^https?:\/\//i.test(trimmedPath)) return trimmedPath;
379
382
  if (trimmedPath.startsWith("/")) {
380
- if (!apiUrl)
381
- return trimmedPath;
383
+ if (!apiUrl) return trimmedPath;
382
384
  try {
383
385
  return new URL(trimmedPath, apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`).toString();
384
386
  } catch {
@@ -386,8 +388,7 @@ async function standardizeVerificationRequest(params, options = {}) {
386
388
  }
387
389
  }
388
390
  const base = apiUrl || NEUS_CONSTANTS.API_BASE_URL;
389
- if (!base || typeof base !== "string")
390
- return null;
391
+ if (!base || typeof base !== "string") return null;
391
392
  try {
392
393
  return new URL(trimmedPath, base.endsWith("/") ? base : `${base}/`).toString();
393
394
  } catch {
@@ -418,8 +419,7 @@ async function standardizeVerificationRequest(params, options = {}) {
418
419
  }
419
420
  return json?.data || json;
420
421
  } catch (error) {
421
- if (error instanceof SDKError)
422
- throw error;
422
+ if (error instanceof SDKError) throw error;
423
423
  throw new SDKError(`Standardize request failed: ${error?.message || error}`, "STANDARDIZE_FAILED");
424
424
  }
425
425
  }
@@ -453,34 +453,27 @@ async function signMessage({ provider, message, walletAddress, chain } = {}) {
453
453
  const chainStr = typeof chain === "string" && chain.trim().length > 0 ? chain.trim() : "eip155";
454
454
  const namespace = chainStr.includes(":") ? chainStr.split(":")[0] || "eip155" : "eip155";
455
455
  const resolveAddress = async () => {
456
- if (typeof walletAddress === "string" && walletAddress.trim().length > 0)
457
- return walletAddress;
456
+ if (typeof walletAddress === "string" && walletAddress.trim().length > 0) return walletAddress;
458
457
  if (namespace === "solana") {
459
458
  if (resolvedProvider?.publicKey && typeof resolvedProvider.publicKey.toBase58 === "function") {
460
459
  const pk = resolvedProvider.publicKey.toBase58();
461
- if (typeof pk === "string" && pk)
462
- return pk;
460
+ if (typeof pk === "string" && pk) return pk;
463
461
  }
464
462
  if (typeof resolvedProvider.getAddress === "function") {
465
463
  const addr = await resolvedProvider.getAddress().catch(() => null);
466
- if (typeof addr === "string" && addr)
467
- return addr;
464
+ if (typeof addr === "string" && addr) return addr;
468
465
  }
469
- if (typeof resolvedProvider.address === "string" && resolvedProvider.address)
470
- return resolvedProvider.address;
466
+ if (typeof resolvedProvider.address === "string" && resolvedProvider.address) return resolvedProvider.address;
471
467
  return null;
472
468
  }
473
- if (typeof resolvedProvider.address === "string" && resolvedProvider.address)
474
- return resolvedProvider.address;
475
- if (typeof resolvedProvider.getAddress === "function")
476
- return await resolvedProvider.getAddress();
469
+ if (typeof resolvedProvider.address === "string" && resolvedProvider.address) return resolvedProvider.address;
470
+ if (typeof resolvedProvider.getAddress === "function") return resolvedProvider.getAddress();
477
471
  if (typeof resolvedProvider.request === "function") {
478
472
  let accounts = await resolvedProvider.request({ method: "eth_accounts" }).catch(() => []);
479
473
  if (!Array.isArray(accounts) || accounts.length === 0) {
480
474
  accounts = await resolvedProvider.request({ method: "eth_requestAccounts" }).catch(() => []);
481
475
  }
482
- if (Array.isArray(accounts) && accounts[0])
483
- return accounts[0];
476
+ if (Array.isArray(accounts) && accounts[0]) return accounts[0];
484
477
  }
485
478
  return null;
486
479
  };
@@ -488,16 +481,11 @@ async function signMessage({ provider, message, walletAddress, chain } = {}) {
488
481
  if (typeof resolvedProvider.signMessage === "function") {
489
482
  const encoded = typeof msg === "string" ? new TextEncoder().encode(msg) : msg;
490
483
  const result = await resolvedProvider.signMessage(encoded);
491
- if (typeof result === "string" && result)
492
- return result;
493
- if (result instanceof Uint8Array)
494
- return encodeBase58Bytes(result);
495
- if (result instanceof ArrayBuffer)
496
- return encodeBase58Bytes(new Uint8Array(result));
497
- if (ArrayBuffer.isView(result))
498
- return encodeBase58Bytes(result);
499
- if (typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(result))
500
- return encodeBase58Bytes(result);
484
+ if (typeof result === "string" && result) return result;
485
+ if (result instanceof Uint8Array) return encodeBase58Bytes(result);
486
+ if (result instanceof ArrayBuffer) return encodeBase58Bytes(new Uint8Array(result));
487
+ if (ArrayBuffer.isView(result)) return encodeBase58Bytes(result);
488
+ if (typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(result)) return encodeBase58Bytes(result);
501
489
  }
502
490
  throw new SDKError("Non-EVM signing requires provider.signMessage", "SIGNER_UNAVAILABLE");
503
491
  }
@@ -506,16 +494,14 @@ async function signMessage({ provider, message, walletAddress, chain } = {}) {
506
494
  let firstPersonalSignError = null;
507
495
  try {
508
496
  const sig = await resolvedProvider.request({ method: "personal_sign", params: [msg, address] });
509
- if (typeof sig === "string" && sig)
510
- return sig;
497
+ if (typeof sig === "string" && sig) return sig;
511
498
  } catch (error) {
512
499
  firstPersonalSignError = error;
513
500
  }
514
501
  let secondPersonalSignError = null;
515
502
  try {
516
503
  const sig = await resolvedProvider.request({ method: "personal_sign", params: [address, msg] });
517
- if (typeof sig === "string" && sig)
518
- return sig;
504
+ if (typeof sig === "string" && sig) return sig;
519
505
  } catch (error) {
520
506
  secondPersonalSignError = error;
521
507
  const signatureErrorMessage = String(
@@ -526,16 +512,14 @@ async function signMessage({ provider, message, walletAddress, chain } = {}) {
526
512
  try {
527
513
  const hexMsg = toHexUtf8(msg);
528
514
  const sig = await resolvedProvider.request({ method: "personal_sign", params: [hexMsg, address] });
529
- if (typeof sig === "string" && sig)
530
- return sig;
515
+ if (typeof sig === "string" && sig) return sig;
531
516
  } catch {
532
517
  }
533
518
  }
534
519
  }
535
520
  try {
536
521
  const sig = await resolvedProvider.request({ method: "eth_sign", params: [address, msg] });
537
- if (typeof sig === "string" && sig)
538
- return sig;
522
+ if (typeof sig === "string" && sig) return sig;
539
523
  } catch {
540
524
  }
541
525
  if (secondPersonalSignError || firstPersonalSignError) {
@@ -548,14 +532,12 @@ async function signMessage({ provider, message, walletAddress, chain } = {}) {
548
532
  }
549
533
  if (typeof resolvedProvider.signMessage === "function") {
550
534
  const result = await resolvedProvider.signMessage(msg);
551
- if (typeof result === "string" && result)
552
- return result;
535
+ if (typeof result === "string" && result) return result;
553
536
  }
554
537
  throw new SDKError("Unable to sign message with provided wallet/provider", "SIGNER_UNAVAILABLE");
555
538
  }
556
539
  function isTerminalStatus(status) {
557
- if (!status || typeof status !== "string")
558
- return false;
540
+ if (!status || typeof status !== "string") return false;
559
541
  const successStates = [
560
542
  "verified",
561
543
  "verified_no_verifiers",
@@ -576,8 +558,7 @@ function isTerminalStatus(status) {
576
558
  return successStates.includes(status) || failureStates.includes(status);
577
559
  }
578
560
  function isSuccessStatus(status) {
579
- if (!status || typeof status !== "string")
580
- return false;
561
+ if (!status || typeof status !== "string") return false;
581
562
  const successStates = [
582
563
  "verified",
583
564
  "verified_no_verifiers",
@@ -588,8 +569,7 @@ function isSuccessStatus(status) {
588
569
  return successStates.includes(status);
589
570
  }
590
571
  function isFailureStatus(status) {
591
- if (!status || typeof status !== "string")
592
- return false;
572
+ if (!status || typeof status !== "string") return false;
593
573
  const failureStates = [
594
574
  "rejected",
595
575
  "rejected_verifier_failure",
@@ -736,7 +716,7 @@ var StatusPoller = class {
736
716
  const pollAttempt = async () => {
737
717
  try {
738
718
  this.attempt++;
739
- const response = await this.client.getStatus(this.qHash);
719
+ const response = await this.client.getProof(this.qHash);
740
720
  if (isTerminalStatus(response.status)) {
741
721
  resolve(response);
742
722
  return;
@@ -781,7 +761,7 @@ var StatusPoller = class {
781
761
  }
782
762
  };
783
763
  var NEUS_CONSTANTS = {
784
- // Hub chain (where all verifications occur)
764
+ /** Default EVM chain id for NEUS protocol signing context (`HUB_CHAIN_ID` name kept for compatibility). */
785
765
  HUB_CHAIN_ID: 84532,
786
766
  // Supported target chains for cross-chain propagation
787
767
  TESTNET_CHAINS: [
@@ -835,23 +815,20 @@ function validateVerifierPayload(verifierId, data) {
835
815
  const id = verifierId.replace(/@\d+$/, "");
836
816
  if (id === "nft-ownership") {
837
817
  ["contractAddress", "tokenId", "chainId"].forEach((key) => {
838
- if (!(key in data))
839
- result.missing.push(key);
818
+ if (!(key in data)) result.missing.push(key);
840
819
  });
841
820
  if (!("ownerAddress" in data)) {
842
821
  result.warnings.push("ownerAddress omitted (defaults to the signed walletAddress)");
843
822
  }
844
823
  } else if (id === "token-holding") {
845
824
  ["contractAddress", "minBalance", "chainId"].forEach((key) => {
846
- if (!(key in data))
847
- result.missing.push(key);
825
+ if (!(key in data)) result.missing.push(key);
848
826
  });
849
827
  if (!("ownerAddress" in data)) {
850
828
  result.warnings.push("ownerAddress omitted (defaults to the signed walletAddress)");
851
829
  }
852
830
  } else if (id === "ownership-basic") {
853
- if (!("owner" in data))
854
- result.missing.push("owner");
831
+ if (!("owner" in data)) result.missing.push("owner");
855
832
  const hasContent = typeof data.content === "string" && data.content.length > 0;
856
833
  const hasContentHash = typeof data.contentHash === "string" && data.contentHash.length > 0;
857
834
  const hasRefId = typeof data.reference?.id === "string" && data.reference.id.length > 0;
@@ -915,8 +892,7 @@ async function withRetry(fn, options = {}) {
915
892
  return await fn();
916
893
  } catch (error) {
917
894
  lastError = error;
918
- if (attempt === maxAttempts)
919
- break;
895
+ if (attempt === maxAttempts) break;
920
896
  const delayMs = Math.min(
921
897
  baseDelay * Math.pow(backoffFactor, attempt - 1),
922
898
  maxDelay
@@ -984,9 +960,72 @@ function validateSignatureComponents({ walletAddress, signature, signedTimestamp
984
960
  }
985
961
  return result;
986
962
  }
963
+ function toAgentDelegationMaxSpend(humanAmount, decimals) {
964
+ if (humanAmount === void 0 || humanAmount === null) {
965
+ throw new ValidationError("humanAmount is required", "humanAmount", humanAmount);
966
+ }
967
+ const s0 = String(humanAmount).trim();
968
+ if (!s0) {
969
+ throw new ValidationError("humanAmount must be non-empty", "humanAmount", humanAmount);
970
+ }
971
+ if (s0.startsWith("-") || s0.startsWith("+")) {
972
+ throw new ValidationError("humanAmount must be non-negative", "humanAmount", humanAmount);
973
+ }
974
+ const d = Number(decimals);
975
+ if (!Number.isInteger(d) || d < 0 || d > 78) {
976
+ throw new ValidationError("decimalPlaces must be an integer from 0 to 78", "decimals", decimals);
977
+ }
978
+ if (!/^(?:\d+\.?\d*|\.\d+)$/.test(s0)) {
979
+ throw new ValidationError(
980
+ 'humanAmount must be a decimal string (e.g. "100" or "100.50")',
981
+ "humanAmount",
982
+ humanAmount
983
+ );
984
+ }
985
+ const dot = s0.indexOf(".");
986
+ const intPart = dot === -1 ? s0 : s0.slice(0, dot);
987
+ const fracRaw = dot === -1 ? "" : s0.slice(dot + 1);
988
+ const intNormalized = intPart === "" ? "0" : (() => {
989
+ const s = intPart.replace(/^0+/, "");
990
+ return s === "" ? "0" : s;
991
+ })();
992
+ if (!/^\d+$/.test(intNormalized)) {
993
+ throw new ValidationError("humanAmount has an invalid integer part", "humanAmount", humanAmount);
994
+ }
995
+ if (fracRaw && !/^\d*$/.test(fracRaw)) {
996
+ throw new ValidationError("humanAmount has an invalid fractional part", "humanAmount", humanAmount);
997
+ }
998
+ const fracPadded = `${fracRaw}${"0".repeat(d)}`.slice(0, d);
999
+ const base = BigInt(10) ** BigInt(d);
1000
+ const value = BigInt(intNormalized) * base + BigInt(fracPadded || "0");
1001
+ const out = value.toString();
1002
+ if (out.length > 78) {
1003
+ throw new ValidationError("maxSpend exceeds 78-digit limit after conversion", "humanAmount", humanAmount);
1004
+ }
1005
+ return out;
1006
+ }
1007
+ var DEFAULT_HOSTED_VERIFY_URL = "https://neus.network/verify";
1008
+ function getHostedCheckoutUrl(opts = {}) {
1009
+ const base = typeof opts.baseUrl === "string" && opts.baseUrl.trim() ? opts.baseUrl.replace(/\/+$/, "") : DEFAULT_HOSTED_VERIFY_URL;
1010
+ const params = new URLSearchParams();
1011
+ if (opts.gateId) params.set("gateId", String(opts.gateId));
1012
+ if (opts.returnUrl) params.set("returnUrl", String(opts.returnUrl));
1013
+ if (Array.isArray(opts.verifiers) && opts.verifiers.length > 0) {
1014
+ params.set("verifiers", opts.verifiers.filter(Boolean).join(","));
1015
+ }
1016
+ if (opts.preset) params.set("preset", String(opts.preset));
1017
+ if (opts.mode) params.set("mode", String(opts.mode));
1018
+ if (opts.intent) params.set("intent", String(opts.intent));
1019
+ if (opts.origin) params.set("origin", String(opts.origin));
1020
+ if (opts.oauthProvider) params.set("oauthProvider", String(opts.oauthProvider));
1021
+ const qs = params.toString();
1022
+ return qs ? `${base}?${qs}` : base;
1023
+ }
987
1024
  // Annotate the CommonJS export names for ESM import in node:
988
1025
  0 && (module.exports = {
1026
+ DEFAULT_HOSTED_VERIFY_URL,
989
1027
  NEUS_CONSTANTS,
1028
+ PORTABLE_PROOF_SIGNER_HEADER,
990
1029
  StatusPoller,
991
1030
  buildVerificationRequest,
992
1031
  computeContentHash,
@@ -996,6 +1035,7 @@ function validateSignatureComponents({ walletAddress, signature, signedTimestamp
996
1035
  deriveDid,
997
1036
  formatTimestamp,
998
1037
  formatVerificationStatus,
1038
+ getHostedCheckoutUrl,
999
1039
  isFailureStatus,
1000
1040
  isSuccessStatus,
1001
1041
  isSupportedChain,
@@ -1005,6 +1045,7 @@ function validateSignatureComponents({ walletAddress, signature, signedTimestamp
1005
1045
  resolveZkPassportConfig,
1006
1046
  signMessage,
1007
1047
  standardizeVerificationRequest,
1048
+ toAgentDelegationMaxSpend,
1008
1049
  toHexUtf8,
1009
1050
  validateQHash,
1010
1051
  validateSignatureComponents,
package/cli/neus.mjs ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ const argv = process.argv.slice(2);
3
+ const sub = argv[0];
4
+
5
+ function usage() {
6
+ process.stderr.write("Usage: neus init\n");
7
+ process.stderr.write("Prints hosted MCP config and doc URLs. Does not write files.\n");
8
+ process.exit(sub && sub !== "help" && sub !== "--help" && sub !== "-h" ? 1 : 0);
9
+ }
10
+
11
+ function printInit() {
12
+ const mcpBlock = {
13
+ mcpServers: {
14
+ neus: {
15
+ type: "streamableHttp",
16
+ url: "https://mcp.neus.network/mcp",
17
+ },
18
+ },
19
+ };
20
+
21
+ const lines = [
22
+ "# NEUS",
23
+ "",
24
+ "## MCP",
25
+ JSON.stringify(mcpBlock, null, 2),
26
+ "",
27
+ "## URLs",
28
+ "MCP: https://mcp.neus.network/mcp",
29
+ "Verify: https://neus.network/verify",
30
+ "Explorer: https://neus.network/hub",
31
+ "",
32
+ "## Docs",
33
+ "MCP setup: https://docs.neus.network/mcp/setup",
34
+ "LLM / assistants: https://docs.neus.network/platform/llm-docs",
35
+ "Agents: https://docs.neus.network/agents/overview",
36
+ "Agent identity: https://docs.neus.network/agents/agent-identity",
37
+ "Agent delegation: https://docs.neus.network/agents/agent-delegation",
38
+ "Integration: https://docs.neus.network/integration",
39
+ "Quickstart: https://docs.neus.network/quickstart",
40
+ "Machine route map: https://neus.network/llms.txt",
41
+ "",
42
+ "This command only prints to stdout; it does not modify files or create accounts.",
43
+ "Use Authorization: Bearer <access key> when a tool returns auth_required (see MCP auth).",
44
+ ];
45
+
46
+ process.stdout.write(`${lines.join("\n")}\n`);
47
+ }
48
+
49
+ if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
50
+ usage();
51
+ }
52
+
53
+ if (sub === "init") {
54
+ printInit();
55
+ process.exit(0);
56
+ }
57
+
58
+ usage();