@vapi-network/core 0.11.0 → 0.12.0

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.d.ts CHANGED
@@ -37,6 +37,7 @@ export * from "./run-budget.js";
37
37
  export * from "./searches.js";
38
38
  export * from "./secret-store.js";
39
39
  export * from "./siblings.js";
40
+ export * from "./link-state.js";
40
41
  export * from "./stats.js";
41
42
  export * from "./spend-policy.js";
42
43
  export * from "./spend-cap-exceeded.js";
@@ -49,10 +50,12 @@ export * from "./transfer.js";
49
50
  export * from "./siwx.js";
50
51
  export * from "./svm.js";
51
52
  export * from "./vault-key.js";
53
+ export * from "./vault-setup.js";
52
54
  export { readVaultFileUnlocked, VaultError, type StoredVaultFile, type VaultAccount, type VaultErrorCode, } from "./vault.js";
53
55
  export * from "./wallet.js";
54
56
  export * from "./wallet-store.js";
55
57
  export * from "./x402.js";
58
+ export * from "./remote-account.js";
56
59
  export * from "./x402-pay.js";
57
60
  export { ARC_MAINNET_CAIP2, BROWSER_ENABLED_X402_NETWORK_CONFIG, CANONICAL_X402_USDC_NETWORKS, getCanonicalX402Usdc, SOLANA_DEVNET_CAIP2, type CanonicalX402UsdcIdentity, type CanonicalX402UsdcNetwork, type X402NetworkConfig, type X402TokenDomain, } from "./x402-networks.js";
58
61
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,cAAc,EACd,6BAA6B,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB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Ae,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,mCAAmC,EACnC,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -69738,7 +69738,7 @@ var POWERSHELL_MISSING = [
69738
69738
  ].join(" ");
69739
69739
  function secretStore(options = {}) {
69740
69740
  const platform2 = options.platform ?? process.platform;
69741
- const run = options.run ?? spawnRunner;
69741
+ const run = options.run ?? (async (file2, args, input2) => await spawnRunner(platform2, file2, args, input2));
69742
69742
  const env = options.env ?? process.env;
69743
69743
  const installed = options.installed ?? ((file2) => binaryInstalled(file2, env));
69744
69744
  if (platform2 === "darwin") return keychainStore(platform2, run);
@@ -69932,6 +69932,7 @@ function windowsDataProtectionStore(platform2, run, env, installed) {
69932
69932
  ].join("\n");
69933
69933
  const execute = async (script2) => {
69934
69934
  const result = await run(powershell, WINDOWS_POWERSHELL_ARGS, `${script2}
69935
+
69935
69936
  `);
69936
69937
  requirePowerShell(result);
69937
69938
  return result;
@@ -70104,7 +70105,7 @@ function requireSuccess(result, what) {
70104
70105
  function withoutTrailingNewline(value) {
70105
70106
  return value.replace(/\r?\n$/u, "");
70106
70107
  }
70107
- var spawnRunner = async (file2, args, input2) => await new Promise((resolve2) => {
70108
+ var spawnRunner = async (platform2, file2, args, input2) => await new Promise((resolve2) => {
70108
70109
  let stdout = "";
70109
70110
  let stderr2 = "";
70110
70111
  let settled = false;
@@ -70114,7 +70115,7 @@ var spawnRunner = async (file2, args, input2) => await new Promise((resolve2) =>
70114
70115
  resolve2(outcome);
70115
70116
  };
70116
70117
  const child = spawn(file2, [...args], {
70117
- detached: true,
70118
+ detached: platform2 !== "win32",
70118
70119
  stdio: ["pipe", "pipe", "pipe"],
70119
70120
  windowsHide: true
70120
70121
  });
@@ -71689,6 +71690,17 @@ var WalletStore = class _WalletStore {
71689
71690
  );
71690
71691
  return account?.address ?? (await readKeystoreSummary(this.pathFor(target))).address;
71691
71692
  }
71693
+ /**
71694
+ * Creates the vault without deriving an account, for apps that create every
71695
+ * account by name. Refuses when a vault already exists in this home.
71696
+ */
71697
+ async createEmptyVault() {
71698
+ if (await this.readVaultUnlocked() !== void 0) {
71699
+ throw new KeystoreError("A vault already exists in this home.");
71700
+ }
71701
+ await this.openVault({ create: true });
71702
+ this.dropVaultCache();
71703
+ }
71692
71704
  async create(name, passphrase, options = {}) {
71693
71705
  void passphrase;
71694
71706
  void options.enableSolana;
@@ -77159,7 +77171,7 @@ function createRunBudget(args) {
77159
77171
  import { mkdir as mkdir15, writeFile as writeFile8 } from "node:fs/promises";
77160
77172
  import { arch, platform, release } from "node:os";
77161
77173
  import { join as join13 } from "node:path";
77162
- var VAPI_CLIENT_VERSION = "0.11.0";
77174
+ var VAPI_CLIENT_VERSION = "0.12.0";
77163
77175
  async function createSupportReport(options) {
77164
77176
  const message = options.message.trim();
77165
77177
  if (!message) throw new Error("Support report message must not be empty.");
@@ -79275,6 +79287,54 @@ var SpendPolicy = class {
79275
79287
  }
79276
79288
  };
79277
79289
 
79290
+ // src/link-state.ts
79291
+ async function linkStates(args) {
79292
+ const origin = new URL(args.apiBase).origin;
79293
+ await args.store.reload();
79294
+ const states = /* @__PURE__ */ new Map();
79295
+ const candidates = [];
79296
+ for (const name of args.store.names()) {
79297
+ const link2 = args.store.entry(name)?.link;
79298
+ const address2 = await args.store.readAddress(name);
79299
+ const hasTokens = args.secrets.available && await args.secrets.has(agentSecretAccounts(name).tokens).catch(() => false);
79300
+ if (link2 === void 0 || new URL(link2.apiBase).origin !== origin || address2 === void 0 || !hasTokens) {
79301
+ states.set(name, "not_linked");
79302
+ continue;
79303
+ }
79304
+ states.set(name, "linked");
79305
+ candidates.push({ name, owner: getAddress(link2.owner), address: getAddress(address2) });
79306
+ }
79307
+ for (const source of candidates) {
79308
+ let result;
79309
+ try {
79310
+ result = await fetchSiblings({
79311
+ apiBase: args.apiBase,
79312
+ account: source.name,
79313
+ secrets: args.secrets,
79314
+ wallets: args.store,
79315
+ ...args.fetchImpl === void 0 ? {} : { fetchImpl: args.fetchImpl },
79316
+ ...args.now === void 0 ? {} : { now: args.now }
79317
+ });
79318
+ } catch (error61) {
79319
+ if (error61 instanceof SiblingsError && error61.code === "not_linked") {
79320
+ states.set(source.name, "revoked");
79321
+ continue;
79322
+ }
79323
+ return states;
79324
+ }
79325
+ const owner = result.owner === null ? source.owner : getAddress(result.owner);
79326
+ for (const candidate of candidates) {
79327
+ if (candidate.owner !== owner) continue;
79328
+ const sibling = result.siblings.find(
79329
+ (entry) => getAddress(entry.address) === candidate.address
79330
+ );
79331
+ states.set(candidate.name, sibling?.status === "active" ? "linked" : "revoked");
79332
+ }
79333
+ return states;
79334
+ }
79335
+ return states;
79336
+ }
79337
+
79278
79338
  // src/stats.ts
79279
79339
  var STATS_RANGES = ["24h", "7d", "30d"];
79280
79340
  var OUTCOMES = [
@@ -81594,6 +81654,37 @@ function isRecord4(value) {
81594
81654
  return typeof value === "object" && value !== null && !Array.isArray(value);
81595
81655
  }
81596
81656
 
81657
+ // src/vault-setup.ts
81658
+ import { rm as rm2 } from "node:fs/promises";
81659
+ import { join as join16 } from "node:path";
81660
+ async function createVault2(home, options) {
81661
+ if (options.password === "") {
81662
+ throw new KeystoreError("A password cannot be empty.");
81663
+ }
81664
+ const store = await WalletStore.open(home, {
81665
+ secrets: options.secrets,
81666
+ ...options.now === void 0 ? {} : { now: options.now }
81667
+ });
81668
+ const hadDeviceKey = options.password !== void 0 && await options.secrets.has(VAULT_KEY_ACCOUNT);
81669
+ await store.createEmptyVault();
81670
+ if (options.password !== void 0) {
81671
+ const path = join16(home, "vault.json");
81672
+ try {
81673
+ await protectVault({
81674
+ path,
81675
+ secrets: options.secrets,
81676
+ password: options.password
81677
+ });
81678
+ } catch (error61) {
81679
+ await Promise.allSettled([
81680
+ rm2(path, { force: true }),
81681
+ ...hadDeviceKey ? [] : [options.secrets.remove(VAULT_KEY_ACCOUNT)]
81682
+ ]);
81683
+ throw error61;
81684
+ }
81685
+ }
81686
+ }
81687
+
81597
81688
  // src/wallet.ts
81598
81689
  var LocalWallet = class {
81599
81690
  constructor(account, policy) {
@@ -81620,6 +81711,44 @@ var LocalWallet = class {
81620
81711
  return await readUsdcBalance({ network, configured, address: address2 });
81621
81712
  }
81622
81713
  };
81714
+
81715
+ // src/remote-account.ts
81716
+ var RemoteAccountError = class extends Error {
81717
+ constructor(code, message) {
81718
+ super(message);
81719
+ this.code = code;
81720
+ this.name = "RemoteAccountError";
81721
+ }
81722
+ code;
81723
+ };
81724
+ var notPermitted = (what) => new RemoteAccountError("not_permitted", `${what} is not permitted through vAPI Desktop.`);
81725
+ function remotePaymentAccount(args) {
81726
+ const base = toAccount({
81727
+ address: args.address,
81728
+ async signMessage({ message }) {
81729
+ const text = typeof message === "string" ? message : JSON.stringify(message);
81730
+ return await args.request({ kind: "message", wallet: args.wallet, message: text });
81731
+ },
81732
+ async signTransaction() {
81733
+ throw notPermitted("Raw transaction signing");
81734
+ },
81735
+ async signTypedData(typedData) {
81736
+ return await args.request({ kind: "typedData", wallet: args.wallet, typedData });
81737
+ }
81738
+ });
81739
+ const account = {
81740
+ ...base,
81741
+ publicKey: args.publicKey,
81742
+ source: "privateKey",
81743
+ async sign() {
81744
+ throw notPermitted("Hash signing");
81745
+ },
81746
+ async signAuthorization() {
81747
+ throw notPermitted("EIP-7702 authorization");
81748
+ }
81749
+ };
81750
+ return account;
81751
+ }
81623
81752
  export {
81624
81753
  AGENT_GRANTS,
81625
81754
  AGENT_MARKER_VARIABLES,
@@ -81683,6 +81812,7 @@ export {
81683
81812
  RESTORE_GAP_LIMIT,
81684
81813
  ROUTER_TOPUP_TIERS,
81685
81814
  RUN_ID_PATTERN,
81815
+ RemoteAccountError,
81686
81816
  RunBudgetError,
81687
81817
  SECRET_STORE_SERVICE,
81688
81818
  SIBLINGS_DEFAULT_TIMEOUT_MS,
@@ -81769,6 +81899,7 @@ export {
81769
81899
  createRunId,
81770
81900
  createSIWxMessage,
81771
81901
  createSupportReport,
81902
+ createVault2 as createVault,
81772
81903
  decideFunding,
81773
81904
  decideRelease,
81774
81905
  decodePaymentRequiredHeader,
@@ -81830,6 +81961,7 @@ export {
81830
81961
  isWalletName,
81831
81962
  leaveSwarm,
81832
81963
  linkRouterAllowanceUsd,
81964
+ linkStates,
81833
81965
  listAccounts,
81834
81966
  listAgentProfiles,
81835
81967
  listServicesResponseSchema,
@@ -81906,6 +82038,7 @@ export {
81906
82038
  receiptWallet,
81907
82039
  receiptsToCsv,
81908
82040
  releaseSpend,
82041
+ remotePaymentAccount,
81909
82042
  removeAgentProfile,
81910
82043
  renameReceiptWallet,
81911
82044
  requireRpcUrl,