epistery 1.0.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/Architecture.md +84 -0
- package/CLI.md +291 -0
- package/LICENSE +21 -0
- package/MONGODB_GOTCHA.md +69 -0
- package/README.md +50 -0
- package/SESSION.md +98 -0
- package/cli/epistery.mjs +576 -0
- package/client/client.js +18 -0
- package/client/ethers.js +24441 -0
- package/client/ethers.min.js +1 -0
- package/client/export.js +67 -0
- package/client/status.html +707 -0
- package/client/wallet.js +213 -0
- package/client/witness.js +663 -0
- package/contracts/agent.sol +108 -0
- package/default.ini +14 -0
- package/docs/EpisteryModuleConfig.md +317 -0
- package/docs/blog-unified-config.md +125 -0
- package/hardhat.config.js +33 -0
- package/index.mjs +385 -0
- package/package.json +46 -0
- package/scripts/deploy-agent.js +33 -0
- package/scripts/verify-agent.js +39 -0
- package/src/epistery.ts +275 -0
- package/src/utils/Aqua.ts +194 -0
- package/src/utils/CliWallet.ts +334 -0
- package/src/utils/Config.ts +196 -0
- package/src/utils/Utils.ts +571 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/types.ts +114 -0
- package/test/README.md +50 -0
- package/test/index.html +13 -0
- package/test/package.json +15 -0
- package/test/server.mjs +87 -0
- package/tsconfig.json +26 -0
package/client/export.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Export - Wallet export utilities for Epistery
|
|
3
|
+
*
|
|
4
|
+
* Allows users with browser-based wallets to export their private keys
|
|
5
|
+
* for import into Web3 wallets like MetaMask
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export default class Export {
|
|
9
|
+
static getWalletExportData(witness) {
|
|
10
|
+
if (!witness || !witness.wallet) {
|
|
11
|
+
return {
|
|
12
|
+
canExport: false,
|
|
13
|
+
message: 'No wallet found to export.'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const wallet = witness.wallet;
|
|
18
|
+
|
|
19
|
+
// Only allow export for browser wallets (source === 'local')
|
|
20
|
+
// Web3 wallets (MetaMask) should not export their keys
|
|
21
|
+
if (wallet.source !== 'local') {
|
|
22
|
+
return {
|
|
23
|
+
canExport: false,
|
|
24
|
+
source: wallet.source,
|
|
25
|
+
message: 'This wallet is managed by a browser extension and cannot be exported from here.'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
canExport: true,
|
|
31
|
+
source: wallet.source,
|
|
32
|
+
address: wallet.address,
|
|
33
|
+
privateKey: wallet.privateKey,
|
|
34
|
+
mnemonic: wallet.mnemonic,
|
|
35
|
+
publicKey: wallet.publicKey
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static downloadAsJSON(data, filename = 'epistery-wallet-export.json') {
|
|
40
|
+
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
|
|
41
|
+
const url = URL.createObjectURL(blob);
|
|
42
|
+
const a = document.createElement('a');
|
|
43
|
+
a.href = url;
|
|
44
|
+
a.download = filename;
|
|
45
|
+
document.body.appendChild(a);
|
|
46
|
+
a.click();
|
|
47
|
+
document.body.removeChild(a);
|
|
48
|
+
URL.revokeObjectURL(url);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static copyToClipboard(text) {
|
|
52
|
+
return navigator.clipboard.writeText(text);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static formatForMetaMask(exportData) {
|
|
56
|
+
if (!exportData.canExport) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
instructions: 'Import this private key into MetaMask or another Web3 wallet',
|
|
62
|
+
privateKey: exportData.privateKey,
|
|
63
|
+
address: exportData.address,
|
|
64
|
+
warning: 'Keep this private key secure. Anyone with access to it can control your wallet.'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|