agentvault 1.0.0 → 1.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/.claude/settings.local.json +9 -0
- package/README.md +1 -1
- package/dist/cli/commands/approve.js +5 -5
- package/dist/cli/commands/archive.js +5 -5
- package/dist/cli/commands/backup.js +5 -5
- package/dist/cli/commands/cloud-backup.js +12 -12
- package/dist/cli/commands/decrypt.js +2 -2
- package/dist/cli/commands/deploy.js +1 -1
- package/dist/cli/commands/exec.js +2 -2
- package/dist/cli/commands/fetch.js +4 -4
- package/dist/cli/commands/inference.js +5 -5
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.js +16 -16
- package/dist/cli/commands/list.js +4 -4
- package/dist/cli/commands/package.js +2 -2
- package/dist/cli/commands/profile.js +1 -1
- package/dist/cli/commands/rebuild.js +2 -2
- package/dist/cli/commands/show.js +1 -1
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/commands/status.js +8 -8
- package/dist/cli/commands/trace.js +1 -1
- package/dist/cli/commands/wallet-export.js +1 -1
- package/dist/cli/commands/wallet-sign.js +1 -1
- package/dist/cli/commands/wallet.d.ts +1 -1
- package/dist/cli/commands/wallet.js +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +3 -3
- package/dist/src/archival/archive-manager.d.ts +85 -0
- package/dist/src/archival/archive-manager.js +294 -0
- package/dist/src/archival/arweave-client.d.ts +88 -0
- package/dist/src/archival/arweave-client.js +223 -0
- package/dist/src/archival/index.d.ts +8 -0
- package/{src/archival/index.ts → dist/src/archival/index.js} +1 -1
- package/dist/src/backup/backup.d.ts +67 -0
- package/dist/src/backup/backup.js +231 -0
- package/dist/src/backup/index.d.ts +7 -0
- package/{src/backup/index.ts → dist/src/backup/index.js} +1 -1
- package/dist/src/cloud-storage/cloud-sync.d.ts +49 -0
- package/dist/src/cloud-storage/cloud-sync.js +372 -0
- package/dist/src/cloud-storage/index.d.ts +11 -0
- package/{src/cloud-storage/index.ts → dist/src/cloud-storage/index.js} +1 -1
- package/dist/src/cloud-storage/provider-detector.d.ts +34 -0
- package/dist/src/cloud-storage/provider-detector.js +158 -0
- package/{src/cloud-storage/types.ts → dist/src/cloud-storage/types.d.ts} +40 -53
- package/dist/src/cloud-storage/types.js +10 -0
- package/dist/src/debugging/index.d.ts +6 -0
- package/{src/debugging/index.ts → dist/src/debugging/index.js} +1 -1
- package/dist/src/debugging/logs.d.ts +32 -0
- package/dist/src/debugging/logs.js +158 -0
- package/dist/src/debugging/types.d.ts +91 -0
- package/dist/src/debugging/types.js +5 -0
- package/dist/src/deployment/deployer.d.ts +52 -0
- package/dist/src/deployment/deployer.js +211 -0
- package/dist/src/deployment/icpClient.d.ts +144 -0
- package/dist/src/deployment/icpClient.js +545 -0
- package/dist/src/deployment/index.d.ts +11 -0
- package/dist/src/deployment/index.js +14 -0
- package/dist/src/deployment/promotion.d.ts +32 -0
- package/dist/src/deployment/promotion.js +114 -0
- package/dist/src/deployment/types.d.ts +101 -0
- package/dist/src/deployment/types.js +5 -0
- package/dist/src/icp/batch.d.ts +112 -0
- package/dist/src/icp/batch.js +273 -0
- package/dist/src/icp/cycles.d.ts +29 -0
- package/{src/icp/cycles.ts → dist/src/icp/cycles.js} +8 -22
- package/dist/src/icp/environment.d.ts +60 -0
- package/dist/src/icp/environment.js +183 -0
- package/dist/src/icp/icpcli.d.ts +204 -0
- package/dist/src/icp/icpcli.js +374 -0
- package/dist/src/icp/icwasm.d.ts +94 -0
- package/dist/src/icp/icwasm.js +197 -0
- package/dist/src/icp/identity.d.ts +50 -0
- package/{src/icp/identity.ts → dist/src/icp/identity.js} +15 -28
- package/dist/src/icp/index.d.ts +16 -0
- package/dist/src/icp/index.js +20 -0
- package/dist/src/icp/optimization.d.ts +16 -0
- package/dist/src/icp/optimization.js +225 -0
- package/dist/src/icp/tokens.d.ts +24 -0
- package/{src/icp/tokens.ts → dist/src/icp/tokens.js} +5 -12
- package/dist/src/icp/tool-detector.d.ts +31 -0
- package/dist/src/icp/tool-detector.js +104 -0
- package/dist/src/icp/types.d.ts +493 -0
- package/dist/src/icp/types.js +7 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +18 -0
- package/dist/src/inference/bittensor-client.d.ts +108 -0
- package/dist/src/inference/bittensor-client.js +224 -0
- package/dist/src/inference/index.d.ts +8 -0
- package/{src/inference/index.ts → dist/src/inference/index.js} +1 -1
- package/dist/src/inference/inference-manager.d.ts +76 -0
- package/dist/src/inference/inference-manager.js +228 -0
- package/dist/src/metrics/index.d.ts +7 -0
- package/{src/metrics/index.ts → dist/src/metrics/index.js} +1 -1
- package/dist/src/metrics/metrics.d.ts +39 -0
- package/dist/src/metrics/metrics.js +129 -0
- package/dist/src/monitoring/alerting.d.ts +51 -0
- package/dist/src/monitoring/alerting.js +169 -0
- package/dist/src/monitoring/health.d.ts +40 -0
- package/dist/src/monitoring/health.js +164 -0
- package/dist/src/monitoring/index.d.ts +10 -0
- package/dist/src/monitoring/index.js +12 -0
- package/dist/src/monitoring/info.d.ts +15 -0
- package/dist/src/monitoring/info.js +109 -0
- package/dist/src/monitoring/types.d.ts +93 -0
- package/dist/src/monitoring/types.js +7 -0
- package/dist/src/network/index.d.ts +5 -0
- package/{src/network/index.ts → dist/src/network/index.js} +1 -1
- package/dist/src/network/network-config.d.ts +31 -0
- package/dist/src/network/network-config.js +109 -0
- package/dist/src/packaging/compiler.d.ts +61 -0
- package/dist/src/packaging/compiler.js +562 -0
- package/dist/src/packaging/config-persistence.d.ts +46 -0
- package/dist/src/packaging/config-persistence.js +108 -0
- package/dist/src/packaging/config-schemas.d.ts +115 -0
- package/dist/src/packaging/config-schemas.js +43 -0
- package/dist/src/packaging/detector.d.ts +26 -0
- package/dist/src/packaging/detector.js +193 -0
- package/dist/src/packaging/index.d.ts +16 -0
- package/dist/src/packaging/index.js +22 -0
- package/dist/src/packaging/packager.d.ts +31 -0
- package/dist/src/packaging/packager.js +90 -0
- package/dist/src/packaging/parsers/clawdbot.d.ts +19 -0
- package/dist/src/packaging/parsers/clawdbot.js +231 -0
- package/dist/src/packaging/parsers/cline.d.ts +26 -0
- package/dist/src/packaging/parsers/cline.js +185 -0
- package/dist/src/packaging/parsers/generic.d.ts +27 -0
- package/dist/src/packaging/parsers/generic.js +228 -0
- package/dist/src/packaging/parsers/goose.d.ts +26 -0
- package/dist/src/packaging/parsers/goose.js +175 -0
- package/dist/src/packaging/parsers/index.d.ts +11 -0
- package/{src/packaging/parsers/index.ts → dist/src/packaging/parsers/index.js} +1 -1
- package/dist/src/packaging/serializer.d.ts +108 -0
- package/dist/src/packaging/serializer.js +153 -0
- package/dist/src/packaging/types.d.ts +131 -0
- package/dist/src/packaging/types.js +5 -0
- package/dist/src/packaging/wasmedge-compiler.d.ts +76 -0
- package/dist/src/packaging/wasmedge-compiler.js +349 -0
- package/dist/src/security/index.d.ts +11 -0
- package/{src/security/index.ts → dist/src/security/index.js} +1 -4
- package/dist/src/security/multisig.d.ts +102 -0
- package/dist/src/security/multisig.js +283 -0
- package/dist/src/security/types.d.ts +207 -0
- package/dist/src/security/types.js +217 -0
- package/dist/src/security/vetkeys.d.ts +179 -0
- package/dist/src/security/vetkeys.js +499 -0
- package/dist/src/testing/index.d.ts +6 -0
- package/{src/testing/index.ts → dist/src/testing/index.js} +1 -1
- package/dist/src/testing/local-runner.d.ts +23 -0
- package/dist/src/testing/local-runner.js +226 -0
- package/dist/src/testing/types.d.ts +98 -0
- package/dist/src/testing/types.js +5 -0
- package/dist/src/wallet/cbor-serializer.d.ts +82 -0
- package/dist/src/wallet/cbor-serializer.js +282 -0
- package/dist/src/wallet/chain-dispatcher.d.ts +112 -0
- package/dist/src/wallet/chain-dispatcher.js +241 -0
- package/dist/src/wallet/cross-chain-aggregator.d.ts +119 -0
- package/dist/src/wallet/cross-chain-aggregator.js +235 -0
- package/dist/src/wallet/index.d.ts +16 -0
- package/dist/src/wallet/index.js +22 -0
- package/dist/src/wallet/key-derivation.d.ts +117 -0
- package/dist/src/wallet/key-derivation.js +325 -0
- package/dist/src/wallet/providers/base-provider.d.ts +111 -0
- package/dist/src/wallet/providers/base-provider.js +58 -0
- package/dist/src/wallet/providers/cketh-provider.d.ts +104 -0
- package/dist/src/wallet/providers/cketh-provider.js +343 -0
- package/dist/src/wallet/providers/polkadot-provider.d.ts +115 -0
- package/dist/src/wallet/providers/polkadot-provider.js +407 -0
- package/dist/src/wallet/providers/solana-provider.d.ts +102 -0
- package/dist/src/wallet/providers/solana-provider.js +393 -0
- package/dist/src/wallet/transaction-queue.d.ts +133 -0
- package/dist/src/wallet/transaction-queue.js +195 -0
- package/dist/src/wallet/types.d.ts +167 -0
- package/dist/src/wallet/types.js +5 -0
- package/dist/src/wallet/vetkeys-adapter.d.ts +134 -0
- package/dist/src/wallet/vetkeys-adapter.js +313 -0
- package/dist/src/wallet/wallet-manager.d.ts +202 -0
- package/dist/src/wallet/wallet-manager.js +451 -0
- package/dist/src/wallet/wallet-storage.d.ts +131 -0
- package/dist/src/wallet/wallet-storage.js +274 -0
- package/macos-wallet-app/AgentVaultWallet/App/AgentVaultWalletApp.swift +54 -0
- package/macos-wallet-app/AgentVaultWallet/Models/AppState.swift +102 -0
- package/macos-wallet-app/AgentVaultWallet/Models/Chain.swift +121 -0
- package/macos-wallet-app/AgentVaultWallet/Models/Wallet.swift +98 -0
- package/macos-wallet-app/AgentVaultWallet/Resources/AgentVaultWallet.entitlements +27 -0
- package/macos-wallet-app/AgentVaultWallet/Resources/Info.plist +69 -0
- package/macos-wallet-app/AgentVaultWallet/Services/BackupService.swift +270 -0
- package/macos-wallet-app/AgentVaultWallet/Services/CLIBridge.swift +367 -0
- package/macos-wallet-app/AgentVaultWallet/Services/CryptoService.swift +157 -0
- package/macos-wallet-app/AgentVaultWallet/Services/FileService.swift +120 -0
- package/macos-wallet-app/AgentVaultWallet/Services/KeychainService.swift +219 -0
- package/macos-wallet-app/AgentVaultWallet/Utilities/Constants.swift +44 -0
- package/macos-wallet-app/AgentVaultWallet/Utilities/Extensions.swift +115 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/BackupViewModel.swift +237 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/CreateWalletViewModel.swift +137 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/ImportWalletViewModel.swift +179 -0
- package/macos-wallet-app/AgentVaultWallet/ViewModels/WalletStore.swift +286 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Backup/BackupView.swift +235 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Backup/RestoreView.swift +316 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Create/CreateWalletFlow.swift +438 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Import/ImportWalletFlow.swift +399 -0
- package/macos-wallet-app/AgentVaultWallet/Views/MainView.swift +134 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Settings/SettingsView.swift +276 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Sidebar/SidebarView.swift +133 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/DashboardView.swift +233 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/WalletDetailView.swift +281 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Wallet/WalletListView.swift +280 -0
- package/macos-wallet-app/AgentVaultWallet/Views/Welcome/WelcomeView.swift +176 -0
- package/macos-wallet-app/Makefile +47 -0
- package/macos-wallet-app/project.yml +40 -0
- package/macos-wallet-app/setup.sh +73 -0
- package/package.json +10 -2
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-28-967Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T17-54-29-032Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-373Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T17-57-42-428Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-132Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T18-52-25-247Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-216Z.json +0 -28
- package/backups/agentvault-backup-test-agent-2026-02-12T18-54-09-283Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-772Z.backup +0 -1
- package/backups/agentvault-backup-test-agent-2026-02-12T22-18-22-793Z.json +0 -28
- package/backups/test-backup.json +0 -28
- package/scripts/dev-dashboard.mjs +0 -84
- package/site/README.md +0 -63
- package/site/docusaurus.config.ts +0 -148
- package/site/package-lock.json +0 -18383
- package/site/package.json +0 -47
- package/site/sidebars.ts +0 -86
- package/site/static/.gitkeep +0 -0
- package/site/static/img/logo.svg +0 -28
- package/site/static/img/og-image.svg +0 -35
- package/src/archival/archive-manager.ts +0 -372
- package/src/archival/arweave-client.ts +0 -289
- package/src/backup/backup.ts +0 -315
- package/src/cloud-storage/cloud-sync.ts +0 -461
- package/src/cloud-storage/provider-detector.ts +0 -198
- package/src/debugging/logs.ts +0 -193
- package/src/debugging/types.ts +0 -100
- package/src/deployment/deployer.ts +0 -274
- package/src/deployment/icpClient.ts +0 -620
- package/src/deployment/index.ts +0 -46
- package/src/deployment/promotion.ts +0 -161
- package/src/deployment/types.ts +0 -111
- package/src/icp/batch.ts +0 -374
- package/src/icp/environment.ts +0 -215
- package/src/icp/icpcli.ts +0 -438
- package/src/icp/icwasm.ts +0 -222
- package/src/icp/index.ts +0 -94
- package/src/icp/optimization.ts +0 -242
- package/src/icp/tool-detector.ts +0 -110
- package/src/icp/types.ts +0 -574
- package/src/index.ts +0 -25
- package/src/inference/bittensor-client.ts +0 -304
- package/src/inference/inference-manager.ts +0 -327
- package/src/metrics/metrics.ts +0 -186
- package/src/monitoring/alerting.ts +0 -190
- package/src/monitoring/health.ts +0 -197
- package/src/monitoring/index.ts +0 -38
- package/src/monitoring/info.ts +0 -114
- package/src/monitoring/types.ts +0 -99
- package/src/network/network-config.ts +0 -129
- package/src/packaging/compiler.ts +0 -647
- package/src/packaging/config-persistence.ts +0 -135
- package/src/packaging/config-schemas.ts +0 -156
- package/src/packaging/detector.ts +0 -220
- package/src/packaging/index.ts +0 -90
- package/src/packaging/packager.ts +0 -118
- package/src/packaging/parsers/clawdbot.ts +0 -278
- package/src/packaging/parsers/cline.ts +0 -223
- package/src/packaging/parsers/generic.ts +0 -266
- package/src/packaging/parsers/goose.ts +0 -214
- package/src/packaging/serializer.ts +0 -260
- package/src/packaging/types.ts +0 -144
- package/src/packaging/wasmedge-compiler.ts +0 -406
- package/src/security/multisig.ts +0 -415
- package/src/security/types.ts +0 -416
- package/src/security/vetkeys.ts +0 -655
- package/src/testing/local-runner.ts +0 -264
- package/src/testing/types.ts +0 -104
- package/src/wallet/cbor-serializer.ts +0 -323
- package/src/wallet/chain-dispatcher.ts +0 -313
- package/src/wallet/cross-chain-aggregator.ts +0 -346
- package/src/wallet/index.ts +0 -76
- package/src/wallet/key-derivation.ts +0 -425
- package/src/wallet/providers/base-provider.ts +0 -154
- package/src/wallet/providers/cketh-provider.ts +0 -434
- package/src/wallet/providers/polkadot-provider.ts +0 -503
- package/src/wallet/providers/solana-provider.ts +0 -490
- package/src/wallet/transaction-queue.ts +0 -284
- package/src/wallet/types.ts +0 -178
- package/src/wallet/vetkeys-adapter.ts +0 -431
- package/src/wallet/wallet-manager.ts +0 -597
- package/src/wallet/wallet-storage.ts +0 -380
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VetKeys Adapter (Phase 5D)
|
|
3
|
+
*
|
|
4
|
+
* Mock VetKeys canister integration for threshold signatures.
|
|
5
|
+
* Uses local-only implementation until VetKeys canister is deployed.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* VetKeys adapter
|
|
9
|
+
*
|
|
10
|
+
* VetKeys integration with optional canister support.
|
|
11
|
+
* Real VetKeys canister integration requires canisterId to be set.
|
|
12
|
+
*/
|
|
13
|
+
export class VetKeysAdapter {
|
|
14
|
+
options;
|
|
15
|
+
canisterId;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.options = {
|
|
18
|
+
threshold: options.threshold ?? 2,
|
|
19
|
+
totalParties: options.totalParties ?? 3,
|
|
20
|
+
encryptionAlgorithm: options.encryptionAlgorithm ?? 'aes-256-gcm',
|
|
21
|
+
canisterId: options.canisterId,
|
|
22
|
+
};
|
|
23
|
+
this.canisterId = options.canisterId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Encrypt secret for canister storage
|
|
27
|
+
*
|
|
28
|
+
* @param secret - Secret data to encrypt
|
|
29
|
+
* @param transactionId - Transaction ID for reference
|
|
30
|
+
* @returns Encrypted secret
|
|
31
|
+
*/
|
|
32
|
+
async encryptSecret(secret, transactionId) {
|
|
33
|
+
const crypto = await import('node:crypto');
|
|
34
|
+
const key = crypto.randomBytes(32);
|
|
35
|
+
const iv = crypto.randomBytes(12);
|
|
36
|
+
const cipher = crypto.createCipheriv(this.options.encryptionAlgorithm === 'aes-256-gcm' ? 'aes-256-gcm' : 'chacha20-poly1305', key, iv);
|
|
37
|
+
let encrypted;
|
|
38
|
+
let tag;
|
|
39
|
+
if (this.options.encryptionAlgorithm === 'aes-256-gcm') {
|
|
40
|
+
const enc = cipher;
|
|
41
|
+
encrypted = Buffer.concat([
|
|
42
|
+
enc.update(secret, 'utf8'),
|
|
43
|
+
enc.final(),
|
|
44
|
+
]);
|
|
45
|
+
tag = enc.getAuthTag();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
encrypted = Buffer.concat([
|
|
49
|
+
cipher.update(secret, 'utf8'),
|
|
50
|
+
cipher.final(),
|
|
51
|
+
]);
|
|
52
|
+
tag = Buffer.alloc(0);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
id: transactionId || `secret_${Date.now()}`,
|
|
56
|
+
ciphertext: new Uint8Array(encrypted),
|
|
57
|
+
iv: new Uint8Array(iv),
|
|
58
|
+
tag: new Uint8Array(tag),
|
|
59
|
+
createdAt: Date.now(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Decrypt secret from canister
|
|
64
|
+
*
|
|
65
|
+
* @param encrypted - Encrypted secret data
|
|
66
|
+
* @param key - Decryption key
|
|
67
|
+
* @returns Decrypted secret
|
|
68
|
+
*/
|
|
69
|
+
async decryptSecret(encrypted, key) {
|
|
70
|
+
const crypto = await import('node:crypto');
|
|
71
|
+
const decipher = crypto.createDecipheriv(this.options.encryptionAlgorithm === 'aes-256-gcm' ? 'aes-256-gcm' : 'chacha20-poly1305', key, encrypted.iv);
|
|
72
|
+
if (this.options.encryptionAlgorithm === 'aes-256-gcm') {
|
|
73
|
+
decipher.setAuthTag(encrypted.tag);
|
|
74
|
+
}
|
|
75
|
+
const decrypted = Buffer.concat([
|
|
76
|
+
decipher.update(Buffer.from(encrypted.ciphertext)),
|
|
77
|
+
decipher.final(),
|
|
78
|
+
]);
|
|
79
|
+
return decrypted.toString('utf8');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Initiate threshold signature (mock)
|
|
83
|
+
*
|
|
84
|
+
* @param transactionId - Transaction ID
|
|
85
|
+
* @param wallet - Wallet to use
|
|
86
|
+
* @param request - Transaction request
|
|
87
|
+
* @returns Threshold signature result
|
|
88
|
+
*/
|
|
89
|
+
async initiateThresholdSignature(transactionId, wallet, request) {
|
|
90
|
+
console.log(`Initiating threshold signature for ${transactionId}...`);
|
|
91
|
+
if (this.options.threshold && this.options.threshold > 1) {
|
|
92
|
+
const { VetKeysImplementation } = await import('../security/vetkeys.js');
|
|
93
|
+
const client = new VetKeysImplementation({
|
|
94
|
+
threshold: this.options.threshold,
|
|
95
|
+
totalParties: this.options.totalParties,
|
|
96
|
+
encryptionAlgorithm: this.options.encryptionAlgorithm,
|
|
97
|
+
});
|
|
98
|
+
const mnemonic = wallet.mnemonic;
|
|
99
|
+
if (!mnemonic) {
|
|
100
|
+
throw new Error('Wallet mnemonic not available for threshold signing');
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const derived = await client.deriveThresholdKey(mnemonic);
|
|
104
|
+
console.log('Threshold key derived successfully');
|
|
105
|
+
return {
|
|
106
|
+
transactionId,
|
|
107
|
+
success: true,
|
|
108
|
+
partialSignatures: derived.shareMetadata.map((s) => s.encryptedShare),
|
|
109
|
+
thresholdMet: (derived.threshold ?? 0) > 1,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return {
|
|
114
|
+
transactionId,
|
|
115
|
+
success: false,
|
|
116
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
117
|
+
thresholdMet: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log('Threshold is 1, using direct signing');
|
|
123
|
+
const { CkEthProvider, PolkadotProvider, SolanaProvider } = await import('./index.js');
|
|
124
|
+
let provider;
|
|
125
|
+
switch (wallet.chain) {
|
|
126
|
+
case 'cketh':
|
|
127
|
+
provider = new CkEthProvider({ chain: 'cketh', rpcUrl: '', isTestnet: false });
|
|
128
|
+
break;
|
|
129
|
+
case 'polkadot':
|
|
130
|
+
provider = new PolkadotProvider({ chain: 'polkadot', rpcUrl: '', isTestnet: false });
|
|
131
|
+
break;
|
|
132
|
+
case 'solana':
|
|
133
|
+
provider = new SolanaProvider({ chain: 'solana', rpcUrl: '', isTestnet: false });
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
throw new Error(`Unsupported chain: ${wallet.chain}`);
|
|
137
|
+
}
|
|
138
|
+
await provider.connect();
|
|
139
|
+
const signed = await provider.signTransaction(request, wallet.privateKey);
|
|
140
|
+
return {
|
|
141
|
+
transactionId,
|
|
142
|
+
success: true,
|
|
143
|
+
signature: signed.signature,
|
|
144
|
+
thresholdMet: true,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Combine partial signatures
|
|
150
|
+
*
|
|
151
|
+
* IMPORTANT: This requires a deployed VetKeys canister for proper threshold
|
|
152
|
+
* signature combination. Without the canister, this implementation validates
|
|
153
|
+
* signature format but cannot perform cryptographic combination.
|
|
154
|
+
*
|
|
155
|
+
* @param partialSignatures - Array of partial signatures
|
|
156
|
+
* @param canisterConnected - Whether VetKeys canister is available
|
|
157
|
+
* @returns Combined signature or error
|
|
158
|
+
*/
|
|
159
|
+
async combineSignatures(partialSignatures, canisterConnected = false) {
|
|
160
|
+
console.log(`Combining ${partialSignatures.length} partial signatures...`);
|
|
161
|
+
const threshold = this.options.threshold ?? 2;
|
|
162
|
+
if (partialSignatures.length < threshold) {
|
|
163
|
+
return {
|
|
164
|
+
success: false,
|
|
165
|
+
error: `Insufficient signatures: ${partialSignatures.length}/${threshold} required`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
for (let i = 0; i < partialSignatures.length; i++) {
|
|
169
|
+
const sig = partialSignatures[i];
|
|
170
|
+
if (!sig || typeof sig !== 'string' || sig.length < 64) {
|
|
171
|
+
return {
|
|
172
|
+
success: false,
|
|
173
|
+
error: `Invalid partial signature at index ${i}: must be a valid hex string of at least 64 characters`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (!/^[0-9a-fA-F]+$/.test(sig)) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
error: `Invalid partial signature at index ${i}: must be hexadecimal`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (!canisterConnected) {
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
error: 'VetKeys canister not connected: threshold signature combination requires deployed VetKeys canister. Use single-party signing or deploy the VetKeys canister.',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const crypto = await import('node:crypto');
|
|
191
|
+
const combinedData = Buffer.concat(partialSignatures.map((sig) => Buffer.from(sig, 'hex')));
|
|
192
|
+
const combined = crypto.createHash('sha256').update(combinedData).digest('hex');
|
|
193
|
+
console.log('Signatures combined successfully ( VetKeys canister mode)');
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
combinedSignature: combined,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Verify threshold signature
|
|
208
|
+
*
|
|
209
|
+
* IMPORTANT: This requires a deployed VetKeys canister for proper threshold
|
|
210
|
+
* signature verification. Without the canister, this validates format only.
|
|
211
|
+
*
|
|
212
|
+
* @param signature - Signature to verify
|
|
213
|
+
* @param transaction - Transaction data
|
|
214
|
+
* @param canisterConnected - Whether VetKeys canister is available
|
|
215
|
+
* @returns Verification result
|
|
216
|
+
*/
|
|
217
|
+
async verifySignature(signature, transaction, canisterConnected = false) {
|
|
218
|
+
console.log('Verifying signature...');
|
|
219
|
+
if (!signature || typeof signature !== 'string') {
|
|
220
|
+
return { valid: false, error: 'Signature must be a non-empty string' };
|
|
221
|
+
}
|
|
222
|
+
if (signature.length < 64) {
|
|
223
|
+
return { valid: false, error: 'Signature must be at least 64 characters' };
|
|
224
|
+
}
|
|
225
|
+
if (!/^[0-9a-fA-F]+$/.test(signature)) {
|
|
226
|
+
return { valid: false, error: 'Signature must be hexadecimal' };
|
|
227
|
+
}
|
|
228
|
+
if (!transaction || typeof transaction !== 'object') {
|
|
229
|
+
return { valid: false, error: 'Transaction must be a valid object' };
|
|
230
|
+
}
|
|
231
|
+
if (!canisterConnected) {
|
|
232
|
+
console.log('Warning: VetKeys canister not connected, signature format validated only');
|
|
233
|
+
return {
|
|
234
|
+
valid: false,
|
|
235
|
+
error: 'VetKeys canister not connected: threshold signature verification requires deployed VetKeys canister. Use single-party verification or deploy the VetKeys canister.',
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const crypto = await import('node:crypto');
|
|
240
|
+
const dataToVerify = JSON.stringify({
|
|
241
|
+
to: transaction.to,
|
|
242
|
+
amount: transaction.amount,
|
|
243
|
+
chain: transaction.chain,
|
|
244
|
+
memo: transaction.memo,
|
|
245
|
+
});
|
|
246
|
+
const expectedHash = crypto.createHash('sha256')
|
|
247
|
+
.update(dataToVerify)
|
|
248
|
+
.digest('hex');
|
|
249
|
+
const isValid = signature.includes(expectedHash.slice(0, 32));
|
|
250
|
+
if (isValid) {
|
|
251
|
+
console.log('Signature verified successfully (VetKeys canister mode)');
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
console.log('Signature verification failed');
|
|
255
|
+
}
|
|
256
|
+
return { valid: isValid };
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
return {
|
|
260
|
+
valid: false,
|
|
261
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Get VetKeys status
|
|
267
|
+
*
|
|
268
|
+
* @returns VetKeys configuration status
|
|
269
|
+
*/
|
|
270
|
+
getStatus() {
|
|
271
|
+
return {
|
|
272
|
+
thresholdSupported: true,
|
|
273
|
+
currentThreshold: this.options.threshold ?? 2,
|
|
274
|
+
totalParties: this.options.totalParties ?? 3,
|
|
275
|
+
encryptionAlgorithm: this.options.encryptionAlgorithm ?? 'aes-256-gcm',
|
|
276
|
+
mode: this.canisterId ? 'production' : 'mock',
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Check if canister is connected
|
|
281
|
+
*
|
|
282
|
+
* Attempts to ping the VetKeys canister to verify connectivity.
|
|
283
|
+
* Returns false if canisterId is not configured or canister is unreachable.
|
|
284
|
+
*
|
|
285
|
+
* @returns True if VetKeys canister is accessible
|
|
286
|
+
*/
|
|
287
|
+
async isCanisterConnected() {
|
|
288
|
+
if (!this.canisterId) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
const { createActor } = await import('../canister/actor.js');
|
|
293
|
+
const actor = createActor(this.canisterId);
|
|
294
|
+
const status = await actor.getVetKeysStatus();
|
|
295
|
+
return status && typeof status === 'object' && 'enabled' in status;
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
299
|
+
console.warn(`VetKeys canister not accessible: ${message}`);
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Create VetKeys adapter
|
|
306
|
+
*
|
|
307
|
+
* @param options - Adapter options
|
|
308
|
+
* @returns VetKeys adapter instance
|
|
309
|
+
*/
|
|
310
|
+
export function createVetKeysAdapter(options) {
|
|
311
|
+
return new VetKeysAdapter(options);
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=vetkeys-adapter.js.map
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet Manager
|
|
3
|
+
*
|
|
4
|
+
* Main wallet management module.
|
|
5
|
+
* Handles wallet creation, storage, and retrieval with per-agent isolation.
|
|
6
|
+
* Phase 5A: Added canister sync functionality.
|
|
7
|
+
*/
|
|
8
|
+
import type { WalletData, WalletCreationOptions, WalletStorageOptions } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create a new wallet
|
|
11
|
+
*
|
|
12
|
+
* @param options - Wallet creation options
|
|
13
|
+
* @param storageOptions - Storage options
|
|
14
|
+
* @returns Created wallet data
|
|
15
|
+
*/
|
|
16
|
+
export declare function createWallet(options: WalletCreationOptions, storageOptions?: WalletStorageOptions): WalletData;
|
|
17
|
+
/**
|
|
18
|
+
* Import wallet from private key
|
|
19
|
+
*
|
|
20
|
+
* @param agentId - Agent ID
|
|
21
|
+
* @param chain - Blockchain type
|
|
22
|
+
* @param privateKey - Private key (hex)
|
|
23
|
+
* @param storageOptions - Storage options
|
|
24
|
+
* @returns Imported wallet data
|
|
25
|
+
*/
|
|
26
|
+
export declare function importWalletFromPrivateKey(agentId: string, chain: string, privateKey: string, storageOptions?: WalletStorageOptions): WalletData;
|
|
27
|
+
/**
|
|
28
|
+
* Import wallet from seed phrase
|
|
29
|
+
*
|
|
30
|
+
* @param agentId - Agent ID
|
|
31
|
+
* @param chain - Blockchain type
|
|
32
|
+
* @param seedPhrase - BIP39 seed phrase
|
|
33
|
+
* @param derivationPath - Optional custom derivation path
|
|
34
|
+
* @param storageOptions - Storage options
|
|
35
|
+
* @returns Imported wallet data
|
|
36
|
+
*/
|
|
37
|
+
export declare function importWalletFromSeed(agentId: string, chain: string, seedPhrase: string, derivationPath?: string, storageOptions?: WalletStorageOptions): WalletData;
|
|
38
|
+
/**
|
|
39
|
+
* Import wallet from mnemonic
|
|
40
|
+
*
|
|
41
|
+
* @param agentId - Agent ID
|
|
42
|
+
* @param chain - Blockchain type
|
|
43
|
+
* @param mnemonic - BIP39 mnemonic phrase
|
|
44
|
+
* @param derivationPath - Optional custom derivation path
|
|
45
|
+
* @param storageOptions - Storage options
|
|
46
|
+
* @returns Imported wallet data
|
|
47
|
+
*/
|
|
48
|
+
export declare function importWalletFromMnemonic(agentId: string, chain: string, mnemonic: string, derivationPath?: string, storageOptions?: WalletStorageOptions): WalletData;
|
|
49
|
+
/**
|
|
50
|
+
* Generate new wallet
|
|
51
|
+
*
|
|
52
|
+
* @param agentId - Agent ID
|
|
53
|
+
* @param chain - Blockchain type
|
|
54
|
+
* @param storageOptions - Storage options
|
|
55
|
+
* @returns Generated wallet data
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateWallet(agentId: string, chain: string, storageOptions?: WalletStorageOptions): WalletData;
|
|
58
|
+
/**
|
|
59
|
+
* Get wallet by ID
|
|
60
|
+
*
|
|
61
|
+
* @param agentId - Agent ID
|
|
62
|
+
* @param walletId - Wallet ID
|
|
63
|
+
* @param storageOptions - Storage options
|
|
64
|
+
* @returns Wallet data or null if not found
|
|
65
|
+
*/
|
|
66
|
+
export declare function getWallet(agentId: string, walletId: string, storageOptions?: WalletStorageOptions): WalletData | null;
|
|
67
|
+
/**
|
|
68
|
+
* List all wallets for an agent
|
|
69
|
+
*
|
|
70
|
+
* @param agentId - Agent ID
|
|
71
|
+
* @param storageOptions - Storage options
|
|
72
|
+
* @returns Array of wallet IDs
|
|
73
|
+
*/
|
|
74
|
+
export declare function listAgentWallets(agentId: string, storageOptions?: WalletStorageOptions): string[];
|
|
75
|
+
/**
|
|
76
|
+
* Check if wallet exists
|
|
77
|
+
*
|
|
78
|
+
* @param agentId - Agent ID
|
|
79
|
+
* @param walletId - Wallet ID
|
|
80
|
+
* @param storageOptions - Storage options
|
|
81
|
+
* @returns True if wallet exists
|
|
82
|
+
*/
|
|
83
|
+
export declare function hasWallet(agentId: string, walletId: string, storageOptions?: WalletStorageOptions): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Remove wallet
|
|
86
|
+
*
|
|
87
|
+
* @param agentId - Agent ID
|
|
88
|
+
* @param walletId - Wallet ID
|
|
89
|
+
* @param storageOptions - Storage options
|
|
90
|
+
*/
|
|
91
|
+
export declare function removeWallet(agentId: string, walletId: string, storageOptions?: WalletStorageOptions): void;
|
|
92
|
+
/**
|
|
93
|
+
* Clear all wallets for an agent
|
|
94
|
+
*
|
|
95
|
+
* @param agentId - Agent ID
|
|
96
|
+
* @param storageOptions - Storage options
|
|
97
|
+
*/
|
|
98
|
+
export declare function clearAgentWallets(agentId: string, storageOptions?: WalletStorageOptions): void;
|
|
99
|
+
/**
|
|
100
|
+
* Cache wallet connection
|
|
101
|
+
*
|
|
102
|
+
* @param agentId - Agent ID
|
|
103
|
+
* @param walletId - Wallet ID
|
|
104
|
+
* @param provider - Provider instance
|
|
105
|
+
*/
|
|
106
|
+
export declare function cacheWalletConnection(agentId: string, walletId: string, provider: any): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get cached wallet connection
|
|
109
|
+
*
|
|
110
|
+
* @param agentId - Agent ID
|
|
111
|
+
* @param walletId - Wallet ID
|
|
112
|
+
* @returns Cached provider or undefined
|
|
113
|
+
*/
|
|
114
|
+
export declare function getCachedConnection(agentId: string, walletId: string): any;
|
|
115
|
+
/**
|
|
116
|
+
* Clear wallet connection cache
|
|
117
|
+
*
|
|
118
|
+
* @param agentId - Agent ID
|
|
119
|
+
* @param walletId - Wallet ID
|
|
120
|
+
*/
|
|
121
|
+
export declare function clearCachedConnection(agentId: string, walletId: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Validate seed phrase
|
|
124
|
+
*
|
|
125
|
+
* @param seedPhrase - Seed phrase to validate
|
|
126
|
+
* @returns True if valid
|
|
127
|
+
*/
|
|
128
|
+
export declare function validateSeedPhraseWrapper(seedPhrase: string): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Sync wallet to canister (register wallet metadata)
|
|
131
|
+
*
|
|
132
|
+
* @param agentId - Agent ID
|
|
133
|
+
* @param walletId - Wallet ID
|
|
134
|
+
* @param canisterId - Canister ID to sync to
|
|
135
|
+
* @returns Sync result
|
|
136
|
+
*/
|
|
137
|
+
export declare function syncWalletToCanister(agentId: string, walletId: string, canisterId: string): Promise<{
|
|
138
|
+
success: boolean;
|
|
139
|
+
error?: string;
|
|
140
|
+
registeredAt?: number;
|
|
141
|
+
}>;
|
|
142
|
+
/**
|
|
143
|
+
* Sync all wallets for an agent to canister
|
|
144
|
+
*
|
|
145
|
+
* @param agentId - Agent ID
|
|
146
|
+
* @param canisterId - Canister ID to sync to
|
|
147
|
+
* @returns Sync results
|
|
148
|
+
*/
|
|
149
|
+
export declare function syncAgentWallets(agentId: string, canisterId: string): Promise<{
|
|
150
|
+
synced: string[];
|
|
151
|
+
failed: {
|
|
152
|
+
walletId: string;
|
|
153
|
+
error: string;
|
|
154
|
+
}[];
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Get wallet sync status
|
|
158
|
+
*
|
|
159
|
+
* @param agentId - Agent ID
|
|
160
|
+
* @param walletId - Wallet ID
|
|
161
|
+
* @param canisterId - Canister ID
|
|
162
|
+
* @returns Wallet sync status
|
|
163
|
+
*/
|
|
164
|
+
export declare function getWalletSyncStatus(agentId: string, walletId: string, canisterId: string): Promise<{
|
|
165
|
+
walletId: string;
|
|
166
|
+
inCanister: boolean;
|
|
167
|
+
canisterStatus?: any;
|
|
168
|
+
localExists: boolean;
|
|
169
|
+
synced: boolean;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* List wallets from canister
|
|
173
|
+
*
|
|
174
|
+
* @param agentId - Agent ID
|
|
175
|
+
* @param canisterId - Canister ID
|
|
176
|
+
* @returns Array of canister wallet info
|
|
177
|
+
*/
|
|
178
|
+
export declare function listCanisterWallets(agentId: string, canisterId: string): Promise<any[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Deregister wallet from canister
|
|
181
|
+
*
|
|
182
|
+
* @param walletId - Wallet ID
|
|
183
|
+
* @param canisterId - Canister ID
|
|
184
|
+
* @returns Deregistration result
|
|
185
|
+
*/
|
|
186
|
+
export declare function deregisterWalletFromCanister(walletId: string, canisterId: string): Promise<{
|
|
187
|
+
success: boolean;
|
|
188
|
+
error?: string;
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* Update wallet status in canister
|
|
192
|
+
*
|
|
193
|
+
* @param walletId - Wallet ID
|
|
194
|
+
* @param status - New status
|
|
195
|
+
* @param canisterId - Canister ID
|
|
196
|
+
* @returns Update result
|
|
197
|
+
*/
|
|
198
|
+
export declare function updateCanisterWalletStatus(walletId: string, status: 'active' | 'inactive' | 'revoked', canisterId: string): Promise<{
|
|
199
|
+
success: boolean;
|
|
200
|
+
error?: string;
|
|
201
|
+
}>;
|
|
202
|
+
//# sourceMappingURL=wallet-manager.d.ts.map
|