@vapi-network/core 0.2.3 → 0.5.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.
Files changed (74) hide show
  1. package/README.md +18 -5
  2. package/dist/accounts.d.ts.map +1 -1
  3. package/dist/agent-guard.d.ts +40 -0
  4. package/dist/agent-guard.d.ts.map +1 -0
  5. package/dist/agent-link.d.ts +98 -0
  6. package/dist/agent-link.d.ts.map +1 -0
  7. package/dist/agent-link.js +1715 -0
  8. package/dist/agent-link.js.map +6 -0
  9. package/dist/agent-profile.d.ts +27 -0
  10. package/dist/agent-profile.d.ts.map +1 -0
  11. package/dist/api-key.d.ts +99 -0
  12. package/dist/api-key.d.ts.map +1 -0
  13. package/dist/api-key.js +20084 -0
  14. package/dist/api-key.js.map +6 -0
  15. package/dist/audit.d.ts +44 -0
  16. package/dist/audit.d.ts.map +1 -0
  17. package/dist/authorization-state.d.ts +58 -0
  18. package/dist/authorization-state.d.ts.map +1 -0
  19. package/dist/call-contracts-wire.d.ts +151 -11
  20. package/dist/call-contracts-wire.d.ts.map +1 -1
  21. package/dist/config.d.ts +10 -1
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/discovery.d.ts +20 -2
  24. package/dist/discovery.d.ts.map +1 -1
  25. package/dist/hd.d.ts +33 -0
  26. package/dist/hd.d.ts.map +1 -0
  27. package/dist/index.d.ts +14 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +25354 -954
  30. package/dist/index.js.map +3 -3
  31. package/dist/keystore.d.ts +94 -4
  32. package/dist/keystore.d.ts.map +1 -1
  33. package/dist/marketplace-contracts.d.ts +448 -15
  34. package/dist/marketplace-contracts.d.ts.map +1 -1
  35. package/dist/networks.d.ts +16 -2
  36. package/dist/networks.d.ts.map +1 -1
  37. package/dist/onramp.d.ts +12 -28
  38. package/dist/onramp.d.ts.map +1 -1
  39. package/dist/passphrase.d.ts +47 -0
  40. package/dist/passphrase.d.ts.map +1 -0
  41. package/dist/policy.d.ts +6 -0
  42. package/dist/policy.d.ts.map +1 -1
  43. package/dist/receipts.d.ts +40 -4
  44. package/dist/receipts.d.ts.map +1 -1
  45. package/dist/router-client.d.ts +117 -0
  46. package/dist/router-client.d.ts.map +1 -0
  47. package/dist/router-client.js +27421 -0
  48. package/dist/router-client.js.map +6 -0
  49. package/dist/secret-store.d.ts +60 -0
  50. package/dist/secret-store.d.ts.map +1 -0
  51. package/dist/secrets.d.ts +14 -0
  52. package/dist/secrets.d.ts.map +1 -0
  53. package/dist/secrets.js +47238 -0
  54. package/dist/secrets.js.map +6 -0
  55. package/dist/spend-policy.d.ts +13 -1
  56. package/dist/spend-policy.d.ts.map +1 -1
  57. package/dist/stats.d.ts +3 -2
  58. package/dist/stats.d.ts.map +1 -1
  59. package/dist/support-report.d.ts +1 -1
  60. package/dist/sweep.d.ts +4 -0
  61. package/dist/sweep.d.ts.map +1 -1
  62. package/dist/wallet-name.d.ts +18 -0
  63. package/dist/wallet-name.d.ts.map +1 -0
  64. package/dist/wallet-store.d.ts +220 -0
  65. package/dist/wallet-store.d.ts.map +1 -0
  66. package/dist/wallet.d.ts +0 -5
  67. package/dist/wallet.d.ts.map +1 -1
  68. package/dist/x402-networks.d.ts +6 -9
  69. package/dist/x402-networks.d.ts.map +1 -1
  70. package/dist/x402-pay.d.ts +131 -0
  71. package/dist/x402-pay.d.ts.map +1 -0
  72. package/dist/x402.d.ts +20 -1
  73. package/dist/x402.d.ts.map +1 -1
  74. package/package.json +17 -1
@@ -48,21 +48,86 @@ declare const keystoreSchema: z.ZodObject<{
48
48
  }, z.core.$strip>;
49
49
  }, z.core.$strip>;
50
50
  }, z.core.$strip>;
51
+ declare const keystoreV3Schema: z.ZodObject<{
52
+ version: z.ZodLiteral<3>;
53
+ address: z.ZodString;
54
+ keys: z.ZodObject<{
55
+ evm: z.ZodObject<{
56
+ type: z.ZodLiteral<"secp256k1">;
57
+ address: z.ZodString;
58
+ path: z.ZodString;
59
+ }, z.core.$strip>;
60
+ solana: z.ZodOptional<z.ZodObject<{
61
+ type: z.ZodLiteral<"ed25519">;
62
+ address: z.ZodString;
63
+ path: z.ZodString;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>;
66
+ crypto: z.ZodObject<{
67
+ cipher: z.ZodLiteral<"aes-256-gcm">;
68
+ ciphertext: z.ZodString;
69
+ iv: z.ZodString;
70
+ authTag: z.ZodString;
71
+ kdf: z.ZodLiteral<"scrypt">;
72
+ salt: z.ZodString;
73
+ kdfParams: z.ZodObject<{
74
+ n: z.ZodLiteral<number>;
75
+ r: z.ZodLiteral<8>;
76
+ p: z.ZodLiteral<1>;
77
+ dkLen: z.ZodLiteral<32>;
78
+ }, z.core.$strip>;
79
+ }, z.core.$strip>;
80
+ }, z.core.$strip>;
51
81
  export type VapiKeystore = z.infer<typeof keystoreSchema>;
82
+ /** Keystore version 3: one BIP-39 recovery phrase behind both accounts. */
83
+ export type VapiKeystoreV3 = z.infer<typeof keystoreV3Schema>;
52
84
  export type LegacyVapiKeystore = z.infer<typeof legacyKeystoreSchema>;
53
85
  /** @deprecated Use VapiKeystore. */
54
86
  export type AgentCashKeystore = VapiKeystore;
55
87
  export type VapiPaymentAccount = ReturnType<typeof privateKeyToAccount> & {
56
88
  readonly solana?: KeyPairSigner;
57
89
  };
90
+ export type CreateKeystoreOptions = {
91
+ enableSolana?: boolean;
92
+ /** Restore an existing wallet instead of generating a new phrase. */
93
+ phrase?: string;
94
+ };
58
95
  export declare class KeystoreError extends Error {
59
96
  constructor(message: string, options?: ErrorOptions);
60
97
  }
61
98
  export declare function encryptPrivateKey(privateKey: Hex, passphrase: string): Promise<VapiKeystore>;
62
- export declare function decryptPrivateKey(keystore: VapiKeystore, passphrase: string): Promise<Hex>;
63
- export declare function createKeystore(passphrase: string, path?: string, options?: {
64
- enableSolana?: boolean;
99
+ /** Published only through `@vapi-network/core/secrets`. */
100
+ export declare function decryptPrivateKey(keystore: VapiKeystore | VapiKeystoreV3, passphrase: string): Promise<Hex>;
101
+ /**
102
+ * Creates a version 3 keystore: both accounts come from one BIP-39 recovery
103
+ * phrase, so the wallet can be restored in MetaMask, Rabby or Phantom from the
104
+ * words alone. The phrase is returned once and never written anywhere.
105
+ *
106
+ * Published only through `@vapi-network/core/secrets`.
107
+ */
108
+ export declare function createKeystoreWithPhrase(passphrase: string, path?: string, options?: CreateKeystoreOptions): Promise<{
109
+ account: VapiPaymentAccount;
110
+ recoveryPhrase: string;
111
+ }>;
112
+ /**
113
+ * Wraps a private key the user already holds in a version 2 keystore, for
114
+ * `vapi import --key`. Such a wallet has no recovery phrase, so `vapi backup`
115
+ * keeps pointing at `vapi export-key` for it.
116
+ */
117
+ export declare function createKeystoreFromPrivateKey(passphrase: string, path: string | undefined, options: {
118
+ privateKey: string;
65
119
  }): Promise<VapiPaymentAccount>;
120
+ /** The shape every wallet import accepts: 0x and 32 bytes of hexadecimal. */
121
+ export declare function validatePrivateKey(value: string): Hex;
122
+ /**
123
+ * Re-seals the keystore under a new passphrase: fresh salt and IV, the same
124
+ * keys, the same addresses, and the same atomic write as every other keystore
125
+ * change. A version 1 file becomes version 2, the upgrade `unlockKeystore`
126
+ * already performs.
127
+ */
128
+ export declare function changeKeystorePassphrase(oldPassphrase: string, newPassphrase: string, path?: string): Promise<VapiPaymentAccount>;
129
+ /** `createKeystoreWithPhrase` for callers that do not show the phrase. */
130
+ export declare function createKeystore(passphrase: string, path?: string, options?: CreateKeystoreOptions): Promise<VapiPaymentAccount>;
66
131
  export declare function unlockKeystore(passphrase: string, path?: string): Promise<VapiPaymentAccount>;
67
132
  /**
68
133
  * The stored address, read without the passphrase. Only the encrypted key
@@ -70,6 +135,12 @@ export declare function unlockKeystore(passphrase: string, path?: string): Promi
70
135
  * to replace. Returns undefined for a missing or unreadable keystore.
71
136
  */
72
137
  export declare function readKeystoreAddress(path?: string): Promise<string | undefined>;
138
+ /**
139
+ * The stored format version, read without the passphrase, so a command can say
140
+ * why a version 1 or 2 wallet has no recovery phrase. Undefined for a missing
141
+ * or unreadable keystore.
142
+ */
143
+ export declare function readKeystoreVersion(path?: string): Promise<number | undefined>;
73
144
  export type ExportedVapiKeys = {
74
145
  evm: {
75
146
  address: string;
@@ -85,12 +156,31 @@ export type ExportedVapiKeys = {
85
156
  * for the EVM key, and the base58 64-byte Ed25519 secret key for Solana. Only
86
157
  * `vapi export-key` may call this, and it must never write the result anywhere
87
158
  * but the caller's stdout.
159
+ *
160
+ * Published only through `@vapi-network/core/secrets`.
88
161
  */
89
162
  export declare function exportKeystoreKeys(passphrase: string, path?: string): Promise<ExportedVapiKeys>;
90
- /** Lazily adds a locally generated Ed25519 seed without replacing the EVM key. */
163
+ /**
164
+ * Adds the Solana account. A version 3 wallet derives it from the recovery
165
+ * phrase it already has; older files get a locally generated Ed25519 seed,
166
+ * which the EVM key never replaces.
167
+ */
91
168
  export declare function enableSolanaKey(passphrase: string, path?: string): Promise<VapiPaymentAccount>;
169
+ /**
170
+ * The 12 or 24 words behind a version 3 wallet, for `vapi backup`. Callers must
171
+ * print it to the user and nowhere else. Older keystores have no phrase.
172
+ *
173
+ * Published only through `@vapi-network/core/secrets`.
174
+ */
175
+ export declare function exportRecoveryPhrase(passphrase: string, path?: string): Promise<string>;
92
176
  export declare function getKeystorePassphrase(options?: {
93
177
  confirm?: boolean;
94
178
  }): Promise<string>;
179
+ /**
180
+ * Reads one line from the terminal without echoing it, for passphrases,
181
+ * recovery phrases, and private keys. The prompt goes to stderr so stdout stays
182
+ * a clean channel, and the secret never reaches the terminal's scrollback.
183
+ */
184
+ export declare function promptForSecret(prompt: string, noTerminalHint?: string): Promise<string>;
95
185
  export {};
96
186
  //# sourceMappingURL=keystore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keystore.d.ts","sourceRoot":"","sources":["../src/keystore.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAsB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC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