@t2000/sdk 8.0.0 → 8.0.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.
package/dist/index.cjs CHANGED
@@ -13,6 +13,7 @@ var cryptography = require('@mysten/sui/cryptography');
13
13
  var promises = require('fs/promises');
14
14
  var path = require('path');
15
15
  var os = require('os');
16
+ var ed25519$1 = require('@noble/curves/ed25519');
16
17
  var secp256k1 = require('@noble/curves/secp256k1');
17
18
  var sha256 = require('@noble/hashes/sha256');
18
19
  var utils$1 = require('@noble/hashes/utils');
@@ -1902,7 +1903,7 @@ function resolveApiKey(apiKey) {
1902
1903
  if (!key) {
1903
1904
  throw new exports.T2000Error(
1904
1905
  "INVALID_KEY",
1905
- "No Private API key. Pass `apiKey` or set T2000_API_KEY. Generate one at agents.t2000.ai/manage (Pro/Max)."
1906
+ "No Private Inference key. Pass `apiKey` or set T2000_API_KEY. Generate one at agents.t2000.ai/manage."
1906
1907
  );
1907
1908
  }
1908
1909
  return key;
@@ -2080,7 +2081,24 @@ function jcs(value) {
2080
2081
  function verifyReceiptSignature(receipt, signingKeyHex) {
2081
2082
  try {
2082
2083
  const sig = receipt.signature;
2083
- if (sig?.algo !== "ecdsa-secp256k1" || !sig.value) {
2084
+ if (!sig?.value) {
2085
+ return false;
2086
+ }
2087
+ const endorsed = utils$1.hexToBytes(signingKeyHex.replace(/^0x/, ""));
2088
+ const sigBytes = utils$1.hexToBytes(sig.value);
2089
+ if (sig.algo === "ed25519") {
2090
+ if (sigBytes.length !== 64 || endorsed.length !== 32) {
2091
+ return false;
2092
+ }
2093
+ const { value: _omitted, ...sigRest } = sig;
2094
+ const canonical2 = {
2095
+ ...receipt,
2096
+ signature: sigRest
2097
+ };
2098
+ const msg = new TextEncoder().encode(jcs(canonical2));
2099
+ return ed25519$1.ed25519.verify(sigBytes, msg, endorsed);
2100
+ }
2101
+ if (sig.algo !== "ecdsa-secp256k1") {
2084
2102
  return false;
2085
2103
  }
2086
2104
  const canonical = {
@@ -2096,7 +2114,6 @@ function verifyReceiptSignature(receipt, signingKeyHex) {
2096
2114
  signature: { algo: sig.algo, key_id: sig.key_id ?? "" }
2097
2115
  };
2098
2116
  const prehash = sha256.sha256(new TextEncoder().encode(jcs(canonical)));
2099
- const sigBytes = utils$1.hexToBytes(sig.value);
2100
2117
  if (sigBytes.length !== 65) {
2101
2118
  return false;
2102
2119
  }
@@ -2108,8 +2125,7 @@ function verifyReceiptSignature(receipt, signingKeyHex) {
2108
2125
  return false;
2109
2126
  }
2110
2127
  const recovered = secp256k1.secp256k1.Signature.fromCompact(sigBytes.slice(0, 64)).addRecoveryBit(v).recoverPublicKey(prehash).toHex(false);
2111
- const endorsed = utils$1.bytesToHex(utils$1.hexToBytes(signingKeyHex.replace(/^0x/, "")));
2112
- return recovered.toLowerCase() === endorsed.toLowerCase();
2128
+ return recovered.toLowerCase() === utils$1.bytesToHex(endorsed).toLowerCase();
2113
2129
  } catch {
2114
2130
  return false;
2115
2131
  }
@@ -2613,9 +2629,9 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2613
2629
  //
2614
2630
  // Inference as a wallet verb — the agent's brain + wallet in one package.
2615
2631
  // Key-based today (`apiKey` / `T2000_API_KEY`); the x402 no-key pay-per-call
2616
- // path is a later add. The model runs on the t2000 Private API (ZDR; a
2632
+ // path is a later add. The model runs on t2000 Private Inference (ZDR; a
2617
2633
  // `phala/*` confidential tier runs in a GPU-TEE).
2618
- /** Non-streaming chat completion against the Private API. */
2634
+ /** Non-streaming chat completion against Private Inference. */
2619
2635
  async chat(params) {
2620
2636
  return chatCompletion(params);
2621
2637
  }
@@ -2624,7 +2640,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
2624
2640
  chatStream(params) {
2625
2641
  return chatCompletionStream(params);
2626
2642
  }
2627
- /** The Private API model catalog (`GET /v1/models`). */
2643
+ /** The Private Inference model catalog (`GET /v1/models`). */
2628
2644
  async models(opts) {
2629
2645
  return listModels(opts);
2630
2646
  }