neozip-cli 0.90.0 → 0.95.1
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/AGENTS.md +93 -0
- package/CHANGELOG.md +70 -1
- package/DOCUMENTATION.md +22 -30
- package/README.md +214 -48
- package/dist/src/account/account-state.js +95 -0
- package/dist/src/account/format-account-status.js +62 -0
- package/dist/src/account/identity-provision.js +79 -0
- package/dist/src/account/identity-wrap.js +106 -0
- package/dist/src/account/profile-crypto.js +85 -0
- package/dist/src/account/profile-store.js +129 -0
- package/dist/src/account/require-account.js +32 -0
- package/dist/src/account/token-service-funding.js +151 -0
- package/dist/src/account/token-service-identity.js +488 -0
- package/dist/src/account/types.js +3 -0
- package/dist/src/account/wallet-evm.js +46 -0
- package/dist/src/account/wallet-setup.js +33 -0
- package/dist/src/archive/crypto-self.js +117 -0
- package/dist/src/archive/identity-key.js +217 -0
- package/dist/src/archive/recipient-lookup.js +61 -0
- package/dist/src/cli/output.js +100 -0
- package/dist/src/cli/params.js +122 -0
- package/dist/src/cli/schema.js +186 -0
- package/dist/src/cli/validate.js +119 -0
- package/dist/src/commands/mintTimestampProof.js +26 -14
- package/dist/src/commands/verifyEmail.js +9 -9
- package/dist/src/config/ConfigSetup.js +82 -423
- package/dist/src/config/ConfigStore.js +0 -33
- package/dist/src/connect/command.js +364 -0
- package/dist/src/connection/bootstrap.js +50 -0
- package/dist/src/connection/cli-guidance.js +101 -0
- package/dist/src/connection/cli-prefs.js +180 -0
- package/dist/src/connection/cli-settings.js +140 -0
- package/dist/src/connection/cli-types.js +14 -0
- package/dist/src/connection/coordinator.js +83 -0
- package/dist/src/connection/credentials.js +33 -0
- package/dist/src/connection/crypto.js +96 -0
- package/dist/src/connection/dump.js +117 -0
- package/dist/src/connection/funding.js +187 -0
- package/dist/src/connection/incomplete-setup.js +89 -0
- package/dist/src/connection/interactive.js +871 -0
- package/dist/src/connection/legacy-profile-reader.js +87 -0
- package/dist/src/connection/magic-link.js +142 -0
- package/dist/src/connection/migrate.js +115 -0
- package/dist/src/connection/onboarding.js +616 -0
- package/dist/src/connection/origin.js +69 -0
- package/dist/src/connection/phase.js +101 -0
- package/dist/src/connection/phone.js +26 -0
- package/dist/src/connection/promote-active.js +56 -0
- package/dist/src/connection/reset.js +56 -0
- package/dist/src/connection/status-report.js +52 -0
- package/dist/src/connection/store.js +406 -0
- package/dist/src/connection/token-auth.js +44 -0
- package/dist/src/connection/types.js +3 -0
- package/dist/src/connection/wallet-json-migration.js +155 -0
- package/dist/src/connection/wallet-login.js +65 -0
- package/dist/src/connection/wallet-setup.js +83 -0
- package/dist/src/constants/wallet-identity.js +14 -0
- package/dist/src/exit-codes.js +54 -10
- package/dist/src/neolist.js +93 -9
- package/dist/src/neounzip.js +217 -59
- package/dist/src/neozip/blockchain.js +18 -18
- package/dist/src/neozip/createZip.js +114 -91
- package/dist/src/neozip/upgradeZip.js +14 -11
- package/dist/src/neozip.js +252 -75
- package/dist/src/skills/command.js +256 -0
- package/dist/src/skills/locate.js +99 -0
- package/dist/src/util/mask.js +34 -0
- package/dist/src/util/token-service-fetch.js +26 -0
- package/env.example +18 -85
- package/package.json +89 -82
- package/skills/neozip-connect/SKILL.md +95 -0
- package/skills/neozip-create/SKILL.md +57 -0
- package/skills/neozip-extract/SKILL.md +58 -0
- package/skills/neozip-legacy/SKILL.md +48 -0
- package/skills/neozip-list/SKILL.md +56 -0
- package/skills/neozip-shared/SKILL.md +60 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCliPreferences = getCliPreferences;
|
|
4
|
+
exports.resolveNetwork = resolveNetwork;
|
|
5
|
+
exports.resolveRpcUrl = resolveRpcUrl;
|
|
6
|
+
exports.resolveGas = resolveGas;
|
|
7
|
+
exports.resolveDebugPrefs = resolveDebugPrefs;
|
|
8
|
+
exports.validateNetworkName = validateNetworkName;
|
|
9
|
+
exports.setCliPreference = setCliPreference;
|
|
10
|
+
exports.formatCliPreferencesSummary = formatCliPreferencesSummary;
|
|
11
|
+
const neozip_blockchain_1 = require("neozip-blockchain");
|
|
12
|
+
const store_1 = require("./store");
|
|
13
|
+
const DEFAULT_NETWORK = 'base-sepolia';
|
|
14
|
+
const DEFAULTS = {
|
|
15
|
+
defaultNetwork: DEFAULT_NETWORK,
|
|
16
|
+
rpcOverrides: {},
|
|
17
|
+
gas: { multiplier: 1.0, maxPriceGwei: 100 },
|
|
18
|
+
debug: { verbose: false, enabled: false },
|
|
19
|
+
};
|
|
20
|
+
const ENV_RPC_BY_NETWORK = {
|
|
21
|
+
'base-sepolia': process.env.NEOZIP_BASE_SEPOLIA_RPC_URL,
|
|
22
|
+
'base-mainnet': process.env.NEOZIP_BASE_MAINNET_RPC_URL,
|
|
23
|
+
};
|
|
24
|
+
function getCliPreferences() {
|
|
25
|
+
const meta = (0, store_1.getActiveConnection)();
|
|
26
|
+
if (!meta) {
|
|
27
|
+
return {
|
|
28
|
+
defaultNetwork: process.env.NEOZIP_NETWORK?.trim() || DEFAULTS.defaultNetwork,
|
|
29
|
+
rpcOverrides: {},
|
|
30
|
+
gas: resolveGasFromEnv(),
|
|
31
|
+
debug: resolveDebugFromEnv(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
defaultNetwork: meta.defaultNetwork?.trim() ||
|
|
36
|
+
process.env.NEOZIP_NETWORK?.trim() ||
|
|
37
|
+
DEFAULTS.defaultNetwork,
|
|
38
|
+
rpcOverrides: { ...(meta.rpcOverrides ?? {}) },
|
|
39
|
+
gas: {
|
|
40
|
+
multiplier: meta.gas?.multiplier ??
|
|
41
|
+
(process.env.NEOZIP_GAS_MULTIPLIER
|
|
42
|
+
? parseFloat(process.env.NEOZIP_GAS_MULTIPLIER)
|
|
43
|
+
: DEFAULTS.gas.multiplier),
|
|
44
|
+
maxPriceGwei: meta.gas?.maxPriceGwei ??
|
|
45
|
+
(process.env.NEOZIP_MAX_GAS_PRICE
|
|
46
|
+
? parseInt(process.env.NEOZIP_MAX_GAS_PRICE, 10)
|
|
47
|
+
: DEFAULTS.gas.maxPriceGwei),
|
|
48
|
+
},
|
|
49
|
+
debug: {
|
|
50
|
+
verbose: meta.debug?.verbose ??
|
|
51
|
+
(process.env.NEOZIP_VERBOSE === 'true' || DEFAULTS.debug.verbose),
|
|
52
|
+
enabled: meta.debug?.enabled ??
|
|
53
|
+
(process.env.NEOZIP_DEBUG === 'true' || DEFAULTS.debug.enabled),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function resolveGasFromEnv() {
|
|
58
|
+
return {
|
|
59
|
+
multiplier: process.env.NEOZIP_GAS_MULTIPLIER
|
|
60
|
+
? parseFloat(process.env.NEOZIP_GAS_MULTIPLIER)
|
|
61
|
+
: DEFAULTS.gas.multiplier,
|
|
62
|
+
maxPriceGwei: process.env.NEOZIP_MAX_GAS_PRICE
|
|
63
|
+
? parseInt(process.env.NEOZIP_MAX_GAS_PRICE, 10)
|
|
64
|
+
: DEFAULTS.gas.maxPriceGwei,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function resolveDebugFromEnv() {
|
|
68
|
+
return {
|
|
69
|
+
verbose: process.env.NEOZIP_VERBOSE === 'true' || DEFAULTS.debug.verbose,
|
|
70
|
+
enabled: process.env.NEOZIP_DEBUG === 'true' || DEFAULTS.debug.enabled,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** CLI --network > connection defaultNetwork > NEOZIP_NETWORK > base-sepolia */
|
|
74
|
+
function resolveNetwork(cliNetwork) {
|
|
75
|
+
if (cliNetwork?.trim()) {
|
|
76
|
+
return cliNetwork.trim();
|
|
77
|
+
}
|
|
78
|
+
return getCliPreferences().defaultNetwork;
|
|
79
|
+
}
|
|
80
|
+
/** rpcOverrides[network] > env > neozip-blockchain contract default */
|
|
81
|
+
function resolveRpcUrl(network) {
|
|
82
|
+
const prefs = getCliPreferences();
|
|
83
|
+
const override = prefs.rpcOverrides[network];
|
|
84
|
+
if (override?.trim()) {
|
|
85
|
+
return override.trim();
|
|
86
|
+
}
|
|
87
|
+
const envRpc = ENV_RPC_BY_NETWORK[network];
|
|
88
|
+
if (envRpc?.trim()) {
|
|
89
|
+
return envRpc.trim();
|
|
90
|
+
}
|
|
91
|
+
const chainId = (0, neozip_blockchain_1.getChainIdByName)(network);
|
|
92
|
+
if (chainId == null) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const config = (0, neozip_blockchain_1.getContractConfig)(chainId);
|
|
96
|
+
return config?.rpcUrls?.[0];
|
|
97
|
+
}
|
|
98
|
+
function resolveGas() {
|
|
99
|
+
return getCliPreferences().gas;
|
|
100
|
+
}
|
|
101
|
+
function resolveDebugPrefs() {
|
|
102
|
+
return getCliPreferences().debug;
|
|
103
|
+
}
|
|
104
|
+
function validateNetworkName(network) {
|
|
105
|
+
return (0, neozip_blockchain_1.getChainIdByName)(network) !== null;
|
|
106
|
+
}
|
|
107
|
+
function setCliPreference(key, value) {
|
|
108
|
+
const connectionId = (0, store_1.getActiveConnectionId)();
|
|
109
|
+
if (!connectionId) {
|
|
110
|
+
return { success: false, message: 'No active connection. Run: neozip connect' };
|
|
111
|
+
}
|
|
112
|
+
const meta = (0, store_1.getActiveConnection)();
|
|
113
|
+
if (!meta) {
|
|
114
|
+
return { success: false, message: 'No active connection metadata found.' };
|
|
115
|
+
}
|
|
116
|
+
const parts = key.split('.');
|
|
117
|
+
const patch = {};
|
|
118
|
+
if (key === 'defaultNetwork') {
|
|
119
|
+
if (!validateNetworkName(value)) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
message: `Invalid network "${value}". Supported: ${(0, neozip_blockchain_1.getSupportedNetworkNames)().join(', ')}`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
patch.defaultNetwork = value;
|
|
126
|
+
}
|
|
127
|
+
else if (parts[0] === 'rpc' && parts[1]) {
|
|
128
|
+
const networkKey = parts.slice(1).join('.');
|
|
129
|
+
const rpcOverrides = { ...(meta.rpcOverrides ?? {}) };
|
|
130
|
+
if (value.trim()) {
|
|
131
|
+
rpcOverrides[networkKey] = value.trim();
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
delete rpcOverrides[networkKey];
|
|
135
|
+
}
|
|
136
|
+
patch.rpcOverrides = rpcOverrides;
|
|
137
|
+
}
|
|
138
|
+
else if (parts[0] === 'gas') {
|
|
139
|
+
const gas = { ...(meta.gas ?? {}) };
|
|
140
|
+
if (parts[1] === 'multiplier') {
|
|
141
|
+
gas.multiplier = parseFloat(value);
|
|
142
|
+
}
|
|
143
|
+
else if (parts[1] === 'maxPriceGwei') {
|
|
144
|
+
gas.maxPriceGwei = parseInt(value, 10);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return { success: false, message: 'Unknown gas key. Use gas.multiplier or gas.maxPriceGwei' };
|
|
148
|
+
}
|
|
149
|
+
patch.gas = gas;
|
|
150
|
+
}
|
|
151
|
+
else if (parts[0] === 'debug') {
|
|
152
|
+
const debug = { ...(meta.debug ?? {}) };
|
|
153
|
+
if (parts[1] === 'verbose' || parts[1] === 'enabled') {
|
|
154
|
+
debug[parts[1]] = value === 'true';
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return { success: false, message: 'Unknown debug key. Use debug.verbose or debug.enabled' };
|
|
158
|
+
}
|
|
159
|
+
patch.debug = debug;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return { success: false, message: `Unknown preference key: ${key}` };
|
|
163
|
+
}
|
|
164
|
+
(0, store_1.updateConnection)(connectionId, patch);
|
|
165
|
+
return { success: true };
|
|
166
|
+
}
|
|
167
|
+
function formatCliPreferencesSummary() {
|
|
168
|
+
const prefs = getCliPreferences();
|
|
169
|
+
const lines = [
|
|
170
|
+
`Default network: ${prefs.defaultNetwork}`,
|
|
171
|
+
`Gas: ${prefs.gas.multiplier}x, max ${prefs.gas.maxPriceGwei} gwei`,
|
|
172
|
+
`Debug: verbose=${prefs.debug.verbose}, enabled=${prefs.debug.enabled}`,
|
|
173
|
+
];
|
|
174
|
+
const rpcKeys = Object.keys(prefs.rpcOverrides);
|
|
175
|
+
if (rpcKeys.length > 0) {
|
|
176
|
+
lines.push(`RPC overrides: ${rpcKeys.join(', ')}`);
|
|
177
|
+
}
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=cli-prefs.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runConnectSettingsInteractive = runConnectSettingsInteractive;
|
|
37
|
+
exports.promptDefaultNetworkAfterReady = promptDefaultNetworkAfterReady;
|
|
38
|
+
const readline = __importStar(require("node:readline/promises"));
|
|
39
|
+
const node_process_1 = require("node:process");
|
|
40
|
+
const neozip_blockchain_1 = require("neozip-blockchain");
|
|
41
|
+
const phase_1 = require("./phase");
|
|
42
|
+
const cli_prefs_1 = require("./cli-prefs");
|
|
43
|
+
const store_1 = require("./store");
|
|
44
|
+
async function runConnectSettingsInteractive() {
|
|
45
|
+
if ((0, phase_1.computeConnectionPhase)() !== 'ready') {
|
|
46
|
+
console.error('Connection is not ready. Run: neozip connect');
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
const rl = readline.createInterface({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
50
|
+
try {
|
|
51
|
+
console.error('\nNeoZip Connect — on-chain preferences');
|
|
52
|
+
console.error((0, cli_prefs_1.formatCliPreferencesSummary)());
|
|
53
|
+
console.error('\n1) Default network');
|
|
54
|
+
console.error('2) Custom RPC URL');
|
|
55
|
+
console.error('3) Gas multiplier');
|
|
56
|
+
console.error('4) Max gas price (gwei)');
|
|
57
|
+
console.error('5) Exit');
|
|
58
|
+
const choice = (await rl.question('\nChoice [5]: ')).trim() || '5';
|
|
59
|
+
const prefs = (0, cli_prefs_1.getCliPreferences)();
|
|
60
|
+
switch (choice) {
|
|
61
|
+
case '1': {
|
|
62
|
+
const networks = (0, neozip_blockchain_1.getSupportedNetworkNames)();
|
|
63
|
+
console.error(`Networks: ${networks.join(', ')}`);
|
|
64
|
+
const network = (await rl.question(`Default network [${prefs.defaultNetwork}]: `)).trim() ||
|
|
65
|
+
prefs.defaultNetwork;
|
|
66
|
+
const result = (0, cli_prefs_1.setCliPreference)('defaultNetwork', network);
|
|
67
|
+
if (!result.success) {
|
|
68
|
+
console.error(result.message);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
console.error(`Saved default network: ${network}`);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
case '2': {
|
|
75
|
+
const network = (await rl.question('Network name: ')).trim();
|
|
76
|
+
const url = (await rl.question('RPC URL: ')).trim();
|
|
77
|
+
if (!network || !url) {
|
|
78
|
+
console.error('Network and URL are required.');
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
const result = (0, cli_prefs_1.setCliPreference)(`rpc.${network}`, url);
|
|
82
|
+
if (!result.success) {
|
|
83
|
+
console.error(result.message);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
console.error(`Saved RPC override for ${network}`);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
case '3': {
|
|
90
|
+
const value = (await rl.question(`Gas multiplier [${prefs.gas.multiplier}]: `)).trim() ||
|
|
91
|
+
String(prefs.gas.multiplier);
|
|
92
|
+
const connectionId = (0, store_1.getActiveConnectionId)();
|
|
93
|
+
if (!connectionId)
|
|
94
|
+
return 1;
|
|
95
|
+
(0, store_1.updateConnection)(connectionId, {
|
|
96
|
+
gas: { ...prefs.gas, multiplier: parseFloat(value) },
|
|
97
|
+
});
|
|
98
|
+
console.error(`Saved gas multiplier: ${value}`);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
case '4': {
|
|
102
|
+
const value = (await rl.question(`Max gas gwei [${prefs.gas.maxPriceGwei}]: `)).trim() ||
|
|
103
|
+
String(prefs.gas.maxPriceGwei);
|
|
104
|
+
const connectionId = (0, store_1.getActiveConnectionId)();
|
|
105
|
+
if (!connectionId)
|
|
106
|
+
return 1;
|
|
107
|
+
(0, store_1.updateConnection)(connectionId, {
|
|
108
|
+
gas: { ...prefs.gas, maxPriceGwei: parseInt(value, 10) },
|
|
109
|
+
});
|
|
110
|
+
console.error(`Saved max gas price: ${value} gwei`);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
rl.close();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Optional default-network prompt after connect finish. */
|
|
122
|
+
async function promptDefaultNetworkAfterReady(prompter) {
|
|
123
|
+
const prefs = (0, cli_prefs_1.getCliPreferences)();
|
|
124
|
+
if (prefs.defaultNetwork !== 'base-sepolia') {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const configure = await prompter.question('\nSet default blockchain network for -b? [y/N]: ');
|
|
128
|
+
if (configure.toLowerCase() !== 'y') {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const networks = (0, neozip_blockchain_1.getSupportedNetworkNames)();
|
|
132
|
+
console.error(`Networks: ${networks.join(', ')}`);
|
|
133
|
+
const network = (await prompter.question('Default network [base-sepolia]: ')).trim() ||
|
|
134
|
+
'base-sepolia';
|
|
135
|
+
const result = (0, cli_prefs_1.setCliPreference)('defaultNetwork', network);
|
|
136
|
+
if (result.success) {
|
|
137
|
+
console.error(`Default network set to ${network}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=cli-settings.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emptyCliConnectionConfig = emptyCliConnectionConfig;
|
|
4
|
+
function emptyCliConnectionConfig() {
|
|
5
|
+
return {
|
|
6
|
+
tokenServiceUrl: null,
|
|
7
|
+
recipientEmail: null,
|
|
8
|
+
tokenServiceAccessToken: null,
|
|
9
|
+
walletKey: null,
|
|
10
|
+
network: 'base-sepolia',
|
|
11
|
+
debug: false,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cli-types.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchCoordinatorConfigParsed = fetchCoordinatorConfigParsed;
|
|
4
|
+
exports.assertCoordinatorWrapSupported = assertCoordinatorWrapSupported;
|
|
5
|
+
exports.probeTokenServiceReachable = probeTokenServiceReachable;
|
|
6
|
+
exports.coordinatorBaseUrl = coordinatorBaseUrl;
|
|
7
|
+
const wallet_identity_1 = require("../constants/wallet-identity");
|
|
8
|
+
const origin_1 = require("./origin");
|
|
9
|
+
function normalizeUrl(baseUrl) {
|
|
10
|
+
return baseUrl.trim().replace(/\/+$/, "");
|
|
11
|
+
}
|
|
12
|
+
async function fetchCoordinatorConfigParsed(baseUrl) {
|
|
13
|
+
const url = normalizeUrl(baseUrl);
|
|
14
|
+
let res;
|
|
15
|
+
try {
|
|
16
|
+
res = await fetch(`${url}/crypto/coordinator-config`, { method: "GET" });
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
return null;
|
|
23
|
+
const ct = res.headers.get("content-type") || "";
|
|
24
|
+
if (!ct.includes("application/json"))
|
|
25
|
+
return null;
|
|
26
|
+
try {
|
|
27
|
+
const data = (await res.json());
|
|
28
|
+
const wrap = data.walletEncryptedIdentityKey;
|
|
29
|
+
return {
|
|
30
|
+
cryptoRequirePhoneVerified: Boolean(data.cryptoRequirePhoneVerified),
|
|
31
|
+
walletGatedIdentityKey: Boolean(data.walletGatedIdentityKey),
|
|
32
|
+
walletEncryptedIdentityKey: wrap
|
|
33
|
+
? {
|
|
34
|
+
wrapFormatVersion: Number(wrap.wrapFormatVersion),
|
|
35
|
+
wrapKdfInfo: String(wrap.wrapKdfInfo ?? ""),
|
|
36
|
+
wrapAead: String(wrap.wrapAead ?? ""),
|
|
37
|
+
wrapKdfSaltLen: Number(wrap.wrapKdfSaltLen),
|
|
38
|
+
wrapIvLen: Number(wrap.wrapIvLen),
|
|
39
|
+
}
|
|
40
|
+
: null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function assertCoordinatorWrapSupported(config) {
|
|
48
|
+
if (!config?.walletEncryptedIdentityKey) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const w = config.walletEncryptedIdentityKey;
|
|
52
|
+
if (w.wrapFormatVersion !== wallet_identity_1.WRAP_FORMAT_VERSION) {
|
|
53
|
+
throw new Error(`Unsupported wrapFormatVersion ${w.wrapFormatVersion} (client supports ${wallet_identity_1.WRAP_FORMAT_VERSION}).`);
|
|
54
|
+
}
|
|
55
|
+
if (w.wrapAead !== wallet_identity_1.WRAP_AEAD) {
|
|
56
|
+
throw new Error(`Unsupported wrapAead ${w.wrapAead} (client supports ${wallet_identity_1.WRAP_AEAD}).`);
|
|
57
|
+
}
|
|
58
|
+
if (w.wrapKdfInfo !== wallet_identity_1.WRAP_KDF_INFO) {
|
|
59
|
+
throw new Error(`Unsupported wrapKdfInfo (client expects ${wallet_identity_1.WRAP_KDF_INFO}).`);
|
|
60
|
+
}
|
|
61
|
+
if (w.wrapKdfSaltLen !== wallet_identity_1.WRAP_KDF_SALT_LEN) {
|
|
62
|
+
throw new Error(`Unsupported wrapKdfSaltLen (client expects ${wallet_identity_1.WRAP_KDF_SALT_LEN}).`);
|
|
63
|
+
}
|
|
64
|
+
if (w.wrapIvLen !== wallet_identity_1.WRAP_IV_LEN) {
|
|
65
|
+
throw new Error(`Unsupported wrapIvLen (client expects ${wallet_identity_1.WRAP_IV_LEN}).`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function probeTokenServiceReachable(baseUrl) {
|
|
69
|
+
try {
|
|
70
|
+
const parsed = await fetchCoordinatorConfigParsed(baseUrl);
|
|
71
|
+
return parsed !== null;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function coordinatorBaseUrl(serverUrl) {
|
|
78
|
+
if (!serverUrl?.trim()) {
|
|
79
|
+
throw new Error("Token Service URL is required");
|
|
80
|
+
}
|
|
81
|
+
return (0, origin_1.normalizeTokenServiceOrigin)(serverUrl);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readConnectionCredentials = readConnectionCredentials;
|
|
4
|
+
exports.getConnectionStorePath = getConnectionStorePath;
|
|
5
|
+
const store_1 = require("./store");
|
|
6
|
+
/** Token Service and wallet credentials from neozip connect only (not MCP env or wallet.json). */
|
|
7
|
+
function readConnectionCredentials() {
|
|
8
|
+
const connectionId = (0, store_1.getActiveConnectionId)();
|
|
9
|
+
const meta = (0, store_1.getActiveConnection)();
|
|
10
|
+
const secrets = (0, store_1.readActiveConnectionSecrets)();
|
|
11
|
+
if (!meta || !secrets) {
|
|
12
|
+
return {
|
|
13
|
+
connectionId: null,
|
|
14
|
+
label: null,
|
|
15
|
+
tokenServiceUrl: null,
|
|
16
|
+
recipientEmail: null,
|
|
17
|
+
tokenServiceAccessToken: null,
|
|
18
|
+
walletKey: null,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
connectionId,
|
|
23
|
+
label: meta.label,
|
|
24
|
+
tokenServiceUrl: meta.tokenServiceOrigin ?? null,
|
|
25
|
+
recipientEmail: meta.emailVerified && meta.email ? meta.email : null,
|
|
26
|
+
tokenServiceAccessToken: secrets.accessToken?.trim() || null,
|
|
27
|
+
walletKey: secrets.evmPrivateKeyHex?.trim() || null,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getConnectionStorePath() {
|
|
31
|
+
return (0, store_1.getConnectionDir)();
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.machineUnlockPassphrase = machineUnlockPassphrase;
|
|
37
|
+
exports.usesCustomUnlockPassphrase = usesCustomUnlockPassphrase;
|
|
38
|
+
exports.resolveUnlockPassphrase = resolveUnlockPassphrase;
|
|
39
|
+
exports.encryptSecrets = encryptSecrets;
|
|
40
|
+
exports.decryptSecrets = decryptSecrets;
|
|
41
|
+
const crypto = __importStar(require("node:crypto"));
|
|
42
|
+
const os = __importStar(require("node:os"));
|
|
43
|
+
const CONNECTION_KDF_INFO = "NeoZip/ConnectionSecrets/v1";
|
|
44
|
+
const CONNECTION_KDF_SALT = Buffer.from("NeoZipConnectionStoreSalt-v1", "utf8");
|
|
45
|
+
/** Machine-local default when NEOZIP_UNLOCK_PASSPHRASE is unset. */
|
|
46
|
+
function machineUnlockPassphrase() {
|
|
47
|
+
return `${os.hostname()}:${os.userInfo().username}:neozip-connection`;
|
|
48
|
+
}
|
|
49
|
+
function usesCustomUnlockPassphrase() {
|
|
50
|
+
return Boolean(process.env.NEOZIP_UNLOCK_PASSPHRASE?.trim());
|
|
51
|
+
}
|
|
52
|
+
/** Passphrase for encrypting connection secrets at rest. */
|
|
53
|
+
function resolveUnlockPassphrase() {
|
|
54
|
+
return process.env.NEOZIP_UNLOCK_PASSPHRASE?.trim() || machineUnlockPassphrase();
|
|
55
|
+
}
|
|
56
|
+
function deriveKey() {
|
|
57
|
+
const passphrase = resolveUnlockPassphrase();
|
|
58
|
+
return Buffer.from(crypto.hkdfSync("sha256", Buffer.from(passphrase, "utf8"), CONNECTION_KDF_SALT, CONNECTION_KDF_INFO, 32));
|
|
59
|
+
}
|
|
60
|
+
function encryptSecrets(payload) {
|
|
61
|
+
const key = deriveKey();
|
|
62
|
+
const iv = crypto.randomBytes(12);
|
|
63
|
+
const plaintext = Buffer.from(JSON.stringify(payload), "utf8");
|
|
64
|
+
try {
|
|
65
|
+
const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
|
|
66
|
+
const ct = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
67
|
+
const tag = cipher.getAuthTag();
|
|
68
|
+
return JSON.stringify({
|
|
69
|
+
v: 1,
|
|
70
|
+
iv: iv.toString("base64"),
|
|
71
|
+
tag: tag.toString("base64"),
|
|
72
|
+
data: ct.toString("base64"),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
key.fill(0);
|
|
77
|
+
plaintext.fill(0);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function decryptSecrets(encrypted) {
|
|
81
|
+
const key = deriveKey();
|
|
82
|
+
const parsed = JSON.parse(encrypted);
|
|
83
|
+
const iv = Buffer.from(parsed.iv, "base64");
|
|
84
|
+
const tag = Buffer.from(parsed.tag, "base64");
|
|
85
|
+
const ct = Buffer.from(parsed.data, "base64");
|
|
86
|
+
try {
|
|
87
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", key, iv);
|
|
88
|
+
decipher.setAuthTag(tag);
|
|
89
|
+
const pt = Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
90
|
+
return JSON.parse(pt.toString("utf8"));
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
key.fill(0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.buildConnectionDump = buildConnectionDump;
|
|
37
|
+
exports.formatConnectionDump = formatConnectionDump;
|
|
38
|
+
exports.formatConnectionsSummaryText = formatConnectionsSummaryText;
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const phase_1 = require("./phase");
|
|
41
|
+
const store_1 = require("./store");
|
|
42
|
+
function readManifestForDump() {
|
|
43
|
+
const manifestPath = `${(0, store_1.getConnectionDir)()}/manifest.json`;
|
|
44
|
+
if (!fs.existsSync(manifestPath)) {
|
|
45
|
+
return { version: 1, activeConnectionId: null, workspaces: {} };
|
|
46
|
+
}
|
|
47
|
+
return JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
48
|
+
}
|
|
49
|
+
/** Safe snapshot of manifest + public.json files (never includes secrets.enc). */
|
|
50
|
+
function buildConnectionDump(options) {
|
|
51
|
+
const manifest = readManifestForDump();
|
|
52
|
+
const activeId = (0, store_1.getActiveConnectionId)();
|
|
53
|
+
const requestedId = options?.connectionId?.trim();
|
|
54
|
+
let ids = (0, store_1.listConnectionIds)();
|
|
55
|
+
if (requestedId) {
|
|
56
|
+
if (!(0, store_1.readConnectionPublic)(requestedId)) {
|
|
57
|
+
throw new Error(`Connection not found: ${requestedId}`);
|
|
58
|
+
}
|
|
59
|
+
ids = [requestedId];
|
|
60
|
+
}
|
|
61
|
+
const connections = [];
|
|
62
|
+
for (const id of ids) {
|
|
63
|
+
const meta = (0, store_1.readConnectionPublic)(id);
|
|
64
|
+
if (!meta)
|
|
65
|
+
continue;
|
|
66
|
+
connections.push({
|
|
67
|
+
id,
|
|
68
|
+
path: (0, store_1.connectionPathFor)(id),
|
|
69
|
+
active: id === activeId,
|
|
70
|
+
hasSecretsEnc: fs.existsSync(`${(0, store_1.connectionPathFor)(id)}/secrets.enc`),
|
|
71
|
+
public: meta,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
connectionDir: (0, store_1.getConnectionDir)(),
|
|
76
|
+
phase: (0, phase_1.computeConnectionPhase)(),
|
|
77
|
+
manifest,
|
|
78
|
+
connections,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function formatConnectionDump(snapshot) {
|
|
82
|
+
return JSON.stringify(snapshot, null, 2);
|
|
83
|
+
}
|
|
84
|
+
function formatAccountLine(meta, activeId) {
|
|
85
|
+
const phase = (0, phase_1.computeConnectionPhaseForId)(meta.id);
|
|
86
|
+
const active = meta.id === activeId ? " [active]" : "";
|
|
87
|
+
const email = meta.email ?? "no email";
|
|
88
|
+
const wallet = meta.evmAddress ?? "no wallet";
|
|
89
|
+
const phone = meta.phoneVerifiedAt
|
|
90
|
+
? "phone verified"
|
|
91
|
+
: meta.phoneE164
|
|
92
|
+
? "phone pending"
|
|
93
|
+
: "no phone";
|
|
94
|
+
const ready = meta.onboardingCompleteAt ? "onboarding complete" : "onboarding incomplete";
|
|
95
|
+
return [
|
|
96
|
+
` • ${meta.label}${active}`,
|
|
97
|
+
` Email: ${email}`,
|
|
98
|
+
` Token Service: ${meta.tokenServiceOrigin}`,
|
|
99
|
+
` Phase: ${phase} · Wallet: ${wallet}`,
|
|
100
|
+
` ${phone} · ${ready}`,
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
/** Human-readable summary of all saved accounts (no secrets). */
|
|
104
|
+
function formatConnectionsSummaryText() {
|
|
105
|
+
const activeId = (0, store_1.getActiveConnectionId)();
|
|
106
|
+
const connections = (0, store_1.listConnections)();
|
|
107
|
+
if (connections.length === 0) {
|
|
108
|
+
return `Connection store: ${(0, store_1.getConnectionDir)()}\nNo saved accounts.`;
|
|
109
|
+
}
|
|
110
|
+
const lines = [
|
|
111
|
+
`Connection store: ${(0, store_1.getConnectionDir)()}`,
|
|
112
|
+
`Saved accounts (${connections.length}):`,
|
|
113
|
+
...connections.flatMap((conn) => formatAccountLine(conn, activeId)),
|
|
114
|
+
];
|
|
115
|
+
return lines.join("\n");
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=dump.js.map
|