@zeroxyz/cli 1.16.0 → 1.17.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.js +196 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78449,7 +78449,7 @@ init_esm_shims();
|
|
|
78449
78449
|
// ../sdk/dist/index.js
|
|
78450
78450
|
init_esm_shims();
|
|
78451
78451
|
|
|
78452
|
-
// ../sdk/dist/chunk-
|
|
78452
|
+
// ../sdk/dist/chunk-T77VVLOM.js
|
|
78453
78453
|
init_esm_shims();
|
|
78454
78454
|
|
|
78455
78455
|
// ../../node_modules/.pnpm/viem@2.52.2_bufferutil@4.1.0_typescript@5.9.3_utf-8-validate@6.0.6_zod@4.3.6/node_modules/viem/_esm/index.js
|
|
@@ -143831,7 +143831,7 @@ config(en_default2());
|
|
|
143831
143831
|
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
|
|
143832
143832
|
var zod_default = external_exports3;
|
|
143833
143833
|
|
|
143834
|
-
// ../sdk/dist/chunk-
|
|
143834
|
+
// ../sdk/dist/chunk-T77VVLOM.js
|
|
143835
143835
|
var createManagedAccount = (client, address2) => toAccount({
|
|
143836
143836
|
address: address2,
|
|
143837
143837
|
async signMessage({ message: message2 }) {
|
|
@@ -145757,7 +145757,7 @@ var clientFetch = async (client, url4, opts = {}) => {
|
|
|
145757
145757
|
return result;
|
|
145758
145758
|
};
|
|
145759
145759
|
var package_default = {
|
|
145760
|
-
version: "0.
|
|
145760
|
+
version: "0.11.0"
|
|
145761
145761
|
};
|
|
145762
145762
|
var SDK_VERSION2 = package_default.version;
|
|
145763
145763
|
var agentAuthMetadataSchema = external_exports3.object({
|
|
@@ -146243,6 +146243,7 @@ var userWalletDtoSchema = external_exports3.object({
|
|
|
146243
146243
|
source: external_exports3.enum(["self_custody", "privy_embedded"]),
|
|
146244
146244
|
isPrimary: external_exports3.boolean(),
|
|
146245
146245
|
linkedAt: external_exports3.union([external_exports3.string(), external_exports3.date()]).nullable().optional(),
|
|
146246
|
+
importedAt: external_exports3.union([external_exports3.string(), external_exports3.date()]).nullable().optional(),
|
|
146246
146247
|
delegationGranted: external_exports3.boolean(),
|
|
146247
146248
|
signerQuorumId: external_exports3.string().nullable(),
|
|
146248
146249
|
// Per-transaction USDC cap in base units (6 dp). null = unlimited, 0 = free-only.
|
|
@@ -147018,6 +147019,48 @@ var Wallet = class {
|
|
|
147018
147019
|
},
|
|
147019
147020
|
userWalletDtoSchema
|
|
147020
147021
|
);
|
|
147022
|
+
// Link an existing self-custody wallet to the session user by private key.
|
|
147023
|
+
// Session-only. 409s when the wallet is already linked (to this or another
|
|
147024
|
+
// profile — the error message says which).
|
|
147025
|
+
import = (opts) => request2(
|
|
147026
|
+
this.client,
|
|
147027
|
+
{
|
|
147028
|
+
method: "POST",
|
|
147029
|
+
path: "/v1/users/me/wallets/import",
|
|
147030
|
+
body: {
|
|
147031
|
+
privateKey: opts.privateKey,
|
|
147032
|
+
...opts.makePrimary !== void 0 ? { makePrimary: opts.makePrimary } : {}
|
|
147033
|
+
},
|
|
147034
|
+
signal: opts.signal
|
|
147035
|
+
},
|
|
147036
|
+
userWalletDtoSchema
|
|
147037
|
+
);
|
|
147038
|
+
// Make one of the session user's linked wallets the primary payer.
|
|
147039
|
+
// Session-only. 404s when the address isn't linked to the user.
|
|
147040
|
+
setPrimary = (opts) => request2(
|
|
147041
|
+
this.client,
|
|
147042
|
+
{
|
|
147043
|
+
method: "PATCH",
|
|
147044
|
+
path: "/v1/users/me/wallets/primary",
|
|
147045
|
+
body: { walletAddress: opts.walletAddress },
|
|
147046
|
+
signal: opts.signal
|
|
147047
|
+
},
|
|
147048
|
+
userWalletDtoSchema
|
|
147049
|
+
);
|
|
147050
|
+
// Unlink a wallet from the session user. Session-only. 409s on the primary
|
|
147051
|
+
// wallet or a non-zero balance (the error message says which); 404s when
|
|
147052
|
+
// the address isn't linked. Responds 204 — resolves to void.
|
|
147053
|
+
remove = async (opts) => {
|
|
147054
|
+
await request2(
|
|
147055
|
+
this.client,
|
|
147056
|
+
{
|
|
147057
|
+
method: "DELETE",
|
|
147058
|
+
path: `/v1/users/me/wallets/${opts.walletAddress}`,
|
|
147059
|
+
signal: opts.signal
|
|
147060
|
+
},
|
|
147061
|
+
external_exports3.undefined()
|
|
147062
|
+
);
|
|
147063
|
+
};
|
|
147021
147064
|
// Routes by identity: account mode signs EIP-191 against /v1/wallet/fund-url,
|
|
147022
147065
|
// session mode hits /v1/users/me/fund-url (Bearer-authed, wallet resolved
|
|
147023
147066
|
// server-side). Both honor `provider` (coinbase | stripe).
|
|
@@ -147742,7 +147785,7 @@ var placeholderFor = (fieldName, propSchema) => String(sampleValueFor(fieldName,
|
|
|
147742
147785
|
|
|
147743
147786
|
// package.json
|
|
147744
147787
|
var package_default2 = {
|
|
147745
|
-
version: "1.
|
|
147788
|
+
version: "1.17.0"};
|
|
147746
147789
|
|
|
147747
147790
|
// src/app.ts
|
|
147748
147791
|
init_esm_shims();
|
|
@@ -151795,17 +151838,20 @@ init_esm_shims();
|
|
|
151795
151838
|
|
|
151796
151839
|
// src/util/migrate-config.ts
|
|
151797
151840
|
init_esm_shims();
|
|
151798
|
-
var
|
|
151841
|
+
var backupAndStripConfigKeys = (zeroDir, keys) => {
|
|
151799
151842
|
const configPath = join$1(zeroDir, "config.json");
|
|
151800
151843
|
const backupPath = join$1(zeroDir, "config.backup.json");
|
|
151801
151844
|
const raw = readFileSync(configPath, "utf8");
|
|
151802
151845
|
ensureSecureDir(zeroDir);
|
|
151803
151846
|
writeSecureFile(backupPath, raw);
|
|
151804
151847
|
const parsed = JSON.parse(raw);
|
|
151805
|
-
|
|
151848
|
+
for (const key of keys) {
|
|
151849
|
+
delete parsed[key];
|
|
151850
|
+
}
|
|
151806
151851
|
writeSecureFile(configPath, JSON.stringify(parsed, null, 2));
|
|
151807
151852
|
return { backupPath, configPath };
|
|
151808
151853
|
};
|
|
151854
|
+
var backupAndStripPrivateKey = (zeroDir) => backupAndStripConfigKeys(zeroDir, ["privateKey"]);
|
|
151809
151855
|
|
|
151810
151856
|
// src/util/stdin.ts
|
|
151811
151857
|
init_esm_shims();
|
|
@@ -152034,6 +152080,148 @@ var walletSetCommand = (appContext) => new Command("set").description("Set walle
|
|
|
152034
152080
|
force: options.force ?? false
|
|
152035
152081
|
});
|
|
152036
152082
|
});
|
|
152083
|
+
var normalizeImportKey = (raw) => {
|
|
152084
|
+
const trimmed = raw.trim();
|
|
152085
|
+
const prefixed = trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
|
|
152086
|
+
return PRIVATE_KEY_PATTERN.test(prefixed) ? prefixed : null;
|
|
152087
|
+
};
|
|
152088
|
+
var SIGN_IN_FIRST_MESSAGE = "This command requires a signed-in session. Run `zero auth login` first.";
|
|
152089
|
+
var walletImportCommand = (appContext) => new Command("import").description(
|
|
152090
|
+
"Link an existing self-custody wallet to your Zero profile by private key"
|
|
152091
|
+
).argument("[privateKey]", "Hex-encoded private key (0x prefix optional)").option(
|
|
152092
|
+
"--key-stdin",
|
|
152093
|
+
"Read the private key from stdin instead of an argument"
|
|
152094
|
+
).option("--primary", "Make the imported wallet your primary payer wallet").action(
|
|
152095
|
+
async (privateKeyArg, options) => {
|
|
152096
|
+
const { analyticsService, client } = appContext.services;
|
|
152097
|
+
if (privateKeyArg && options.keyStdin) {
|
|
152098
|
+
console.error(
|
|
152099
|
+
"Pass the key as an argument OR via --key-stdin, not both."
|
|
152100
|
+
);
|
|
152101
|
+
process.exitCode = 1;
|
|
152102
|
+
return;
|
|
152103
|
+
}
|
|
152104
|
+
if (!privateKeyArg && !options.keyStdin) {
|
|
152105
|
+
console.error(
|
|
152106
|
+
"Missing private key. Pass it as an argument or pipe it with --key-stdin."
|
|
152107
|
+
);
|
|
152108
|
+
process.exitCode = 1;
|
|
152109
|
+
return;
|
|
152110
|
+
}
|
|
152111
|
+
let rawKey;
|
|
152112
|
+
if (options.keyStdin) {
|
|
152113
|
+
if (process.stdin.isTTY) {
|
|
152114
|
+
console.error(
|
|
152115
|
+
"Expected a private key on stdin. Example:\n zero wallet generate --json | jq -r .privateKey | zero wallet import --key-stdin"
|
|
152116
|
+
);
|
|
152117
|
+
process.exitCode = 1;
|
|
152118
|
+
return;
|
|
152119
|
+
}
|
|
152120
|
+
rawKey = await readStdin();
|
|
152121
|
+
} else {
|
|
152122
|
+
rawKey = privateKeyArg;
|
|
152123
|
+
}
|
|
152124
|
+
const privateKey = normalizeImportKey(rawKey);
|
|
152125
|
+
if (!privateKey) {
|
|
152126
|
+
console.error(
|
|
152127
|
+
"Invalid private key (expected 64 hex chars, 0x prefix optional)."
|
|
152128
|
+
);
|
|
152129
|
+
process.exitCode = 1;
|
|
152130
|
+
return;
|
|
152131
|
+
}
|
|
152132
|
+
if (client.getCredentials().kind !== "session") {
|
|
152133
|
+
console.error(SIGN_IN_FIRST_MESSAGE);
|
|
152134
|
+
process.exitCode = 1;
|
|
152135
|
+
return;
|
|
152136
|
+
}
|
|
152137
|
+
let wallet;
|
|
152138
|
+
try {
|
|
152139
|
+
wallet = await client.wallet.import({
|
|
152140
|
+
privateKey,
|
|
152141
|
+
...options.primary ? { makePrimary: true } : {}
|
|
152142
|
+
});
|
|
152143
|
+
} catch (err) {
|
|
152144
|
+
if (err instanceof ZeroApiError) {
|
|
152145
|
+
if (err.status === 401) {
|
|
152146
|
+
console.error(
|
|
152147
|
+
"Session expired. Run `zero auth login` and try again."
|
|
152148
|
+
);
|
|
152149
|
+
} else {
|
|
152150
|
+
console.error(`Could not import wallet: ${err.message}`);
|
|
152151
|
+
}
|
|
152152
|
+
} else {
|
|
152153
|
+
console.error("Could not import wallet: network error.");
|
|
152154
|
+
}
|
|
152155
|
+
process.exitCode = 1;
|
|
152156
|
+
return;
|
|
152157
|
+
}
|
|
152158
|
+
analyticsService.setWalletAddress(wallet.walletAddress);
|
|
152159
|
+
console.log(
|
|
152160
|
+
`Wallet imported: ${wallet.walletAddress}${wallet.isPrimary ? " (primary)" : ""}`
|
|
152161
|
+
);
|
|
152162
|
+
let localKeyStripped = false;
|
|
152163
|
+
const zeroDir = join$1(homedir(), ".zero");
|
|
152164
|
+
const configPath = join$1(zeroDir, "config.json");
|
|
152165
|
+
const config2 = existsSync(configPath) ? readConfig(configPath) : {};
|
|
152166
|
+
const localByoKey = config2.byoPrivateKey ? normalizeImportKey(config2.byoPrivateKey) : null;
|
|
152167
|
+
if (localByoKey && localByoKey.toLowerCase() === privateKey.toLowerCase()) {
|
|
152168
|
+
try {
|
|
152169
|
+
const { backupPath } = backupAndStripConfigKeys(zeroDir, [
|
|
152170
|
+
"byoPrivateKey"
|
|
152171
|
+
]);
|
|
152172
|
+
localKeyStripped = true;
|
|
152173
|
+
console.log(
|
|
152174
|
+
`Local key backed up to ${backupPath} and removed from config \u2014 managed signing now applies.`
|
|
152175
|
+
);
|
|
152176
|
+
} catch {
|
|
152177
|
+
console.error(
|
|
152178
|
+
"Could not back up the local key; it was left in place in ~/.zero/config.json."
|
|
152179
|
+
);
|
|
152180
|
+
}
|
|
152181
|
+
}
|
|
152182
|
+
analyticsService.capture("wallet_imported", {
|
|
152183
|
+
primary: wallet.isPrimary,
|
|
152184
|
+
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|
|
152185
|
+
key_source: options.keyStdin ? "stdin" : "arg",
|
|
152186
|
+
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|
|
152187
|
+
local_key_stripped: localKeyStripped
|
|
152188
|
+
});
|
|
152189
|
+
}
|
|
152190
|
+
);
|
|
152191
|
+
var walletListCommand = (appContext) => new Command("list").description("List the wallets linked to your Zero profile").action(async () => {
|
|
152192
|
+
const { analyticsService, client } = appContext.services;
|
|
152193
|
+
if (client.getCredentials().kind !== "session") {
|
|
152194
|
+
console.error(SIGN_IN_FIRST_MESSAGE);
|
|
152195
|
+
process.exitCode = 1;
|
|
152196
|
+
return;
|
|
152197
|
+
}
|
|
152198
|
+
let wallets;
|
|
152199
|
+
try {
|
|
152200
|
+
wallets = await client.wallet.list();
|
|
152201
|
+
} catch (err) {
|
|
152202
|
+
const message2 = err instanceof ZeroApiError && err.status === 401 ? "Session expired. Run `zero auth login` and try again." : "Failed to list wallets.";
|
|
152203
|
+
console.error(message2);
|
|
152204
|
+
process.exitCode = 1;
|
|
152205
|
+
return;
|
|
152206
|
+
}
|
|
152207
|
+
if (wallets.length === 0) {
|
|
152208
|
+
console.log(
|
|
152209
|
+
"No wallets linked. One is provisioned automatically on your first paid call, or run `zero wallet import <key>`."
|
|
152210
|
+
);
|
|
152211
|
+
} else {
|
|
152212
|
+
for (const wallet of wallets) {
|
|
152213
|
+
const source = wallet.importedAt ? "imported" : wallet.source === "privy_embedded" ? "managed" : "byo";
|
|
152214
|
+
const columns = [
|
|
152215
|
+
wallet.walletAddress,
|
|
152216
|
+
source.padEnd(8),
|
|
152217
|
+
(wallet.isPrimary ? "PRIMARY" : "").padEnd(7),
|
|
152218
|
+
wallet.delegationGranted ? "delegated" : "not delegated"
|
|
152219
|
+
];
|
|
152220
|
+
console.log(columns.join(" ").trimEnd());
|
|
152221
|
+
}
|
|
152222
|
+
}
|
|
152223
|
+
analyticsService.capture("wallet_listed", { count: wallets.length });
|
|
152224
|
+
});
|
|
152037
152225
|
var walletGenerateCommand = (appContext) => new Command("generate").description(
|
|
152038
152226
|
"Generate a fresh wallet (address + private key) without touching your configured wallet"
|
|
152039
152227
|
).option("--json", "Emit { address, privateKey } as JSON").option(
|
|
@@ -152121,6 +152309,8 @@ var walletCommand = (appContext) => {
|
|
|
152121
152309
|
cmd.addCommand(walletAddressCommand(appContext));
|
|
152122
152310
|
cmd.addCommand(walletSetCommand(appContext));
|
|
152123
152311
|
cmd.addCommand(walletGenerateCommand(appContext));
|
|
152312
|
+
cmd.addCommand(walletImportCommand(appContext));
|
|
152313
|
+
cmd.addCommand(walletListCommand(appContext));
|
|
152124
152314
|
return cmd;
|
|
152125
152315
|
};
|
|
152126
152316
|
|