@alchemy/cli 0.8.0 → 0.9.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.
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
+ import {
4
+ registerAuth,
5
+ selectAppAfterAuth
6
+ } from "./chunk-XCKUCXC6.js";
7
+ import "./chunk-RGVM5SNE.js";
8
+ import "./chunk-75ICFV5K.js";
9
+ import "./chunk-7ZSEELHZ.js";
10
+ import "./chunk-MV7O3XBG.js";
11
+ import "./chunk-GDLPBPG3.js";
12
+ import "./chunk-OVLQH6KL.js";
13
+ export {
14
+ registerAuth,
15
+ selectAppAfterAuth
16
+ };
@@ -11,8 +11,8 @@ import {
11
11
  prepareLogin,
12
12
  revokeToken,
13
13
  waitForCallback
14
- } from "./chunk-NGF46GZP.js";
15
- import "./chunk-46LMXT54.js";
14
+ } from "./chunk-RGVM5SNE.js";
15
+ import "./chunk-OVLQH6KL.js";
16
16
  export {
17
17
  AUTH_PORT,
18
18
  DEFAULT_EXPIRES_IN_SECONDS,
@@ -2,7 +2,7 @@
2
2
  if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  isJSONMode
5
- } from "./chunk-46LMXT54.js";
5
+ } from "./chunk-OVLQH6KL.js";
6
6
 
7
7
  // src/lib/interaction.ts
8
8
  import { stdin, stdout } from "process";
@@ -4,7 +4,7 @@ import {
4
4
  configDir,
5
5
  load,
6
6
  save
7
- } from "./chunk-ROBA7SR7.js";
7
+ } from "./chunk-GDLPBPG3.js";
8
8
  import {
9
9
  CLIError,
10
10
  ErrorCode,
@@ -30,7 +30,7 @@ import {
30
30
  parseBaseURLOverride,
31
31
  redactSensitiveText,
32
32
  verbose
33
- } from "./chunk-46LMXT54.js";
33
+ } from "./chunk-OVLQH6KL.js";
34
34
 
35
35
  // src/lib/resolve.ts
36
36
  import { readFileSync as readFileSync2 } from "fs";
@@ -1051,7 +1051,20 @@ var walletSessionEnvironmentSchema = z.object({
1051
1051
  clientInstanceId: z.string().uuid().optional(),
1052
1052
  clientInstanceName: z.string().min(1).max(64).optional()
1053
1053
  }).strict();
1054
+ var chainWalletSessionSchema = z.object({
1055
+ sessionId: z.string().uuid(),
1056
+ status: z.enum(["pending", "approved", "revoked", "expired"]),
1057
+ expiresAt: z.string().datetime(),
1058
+ chainType: z.enum(["evm", "solana"]),
1059
+ walletId: z.string().min(1).optional(),
1060
+ walletAddress: z.string().min(1).optional(),
1061
+ providerKeyQuorumId: z.string().min(1).optional(),
1062
+ providerSignerId: z.string().min(1).optional(),
1063
+ capabilities: walletSessionCapabilitiesSchema.optional()
1064
+ }).strict();
1054
1065
  var walletSessionSchema = z.object({
1066
+ version: z.number().int().positive().optional(),
1067
+ connectionRequestId: z.string().min(1).optional(),
1055
1068
  sessionId: z.string().uuid(),
1056
1069
  status: z.enum(["pending", "approved", "revoked", "expired"]),
1057
1070
  createdAt: z.string().datetime(),
@@ -1070,7 +1083,11 @@ var walletSessionSchema = z.object({
1070
1083
  chainType: z.string().min(1).optional(),
1071
1084
  backendBaseUrl: z.string().min(1).optional(),
1072
1085
  environment: walletSessionEnvironmentSchema.optional(),
1073
- capabilities: walletSessionCapabilitiesSchema.optional()
1086
+ capabilities: walletSessionCapabilitiesSchema.optional(),
1087
+ sessionsByChain: z.object({
1088
+ evm: chainWalletSessionSchema.optional(),
1089
+ solana: chainWalletSessionSchema.optional()
1090
+ }).strict().optional()
1074
1091
  }).strict();
1075
1092
  function sessionPath() {
1076
1093
  return join(configDir(), SESSION_FILE);
@@ -1078,7 +1095,59 @@ function sessionPath() {
1078
1095
  function parseStoredSession(value) {
1079
1096
  const parsed = walletSessionSchema.safeParse(value);
1080
1097
  if (!parsed.success) return null;
1081
- return parsed.data;
1098
+ return withLegacyChainSessions(parsed.data);
1099
+ }
1100
+ function withLegacyChainSessions(session) {
1101
+ if (session.sessionsByChain) {
1102
+ return withCompatibilityAliases(session);
1103
+ }
1104
+ const chainType = session.chainType === "solana" ? "solana" : "evm";
1105
+ const walletId = chainType === "solana" ? session.solanaWalletId ?? session.walletId : session.evmWalletId ?? session.walletId;
1106
+ const walletAddress = chainType === "solana" ? session.solanaAddress : session.evmAddress;
1107
+ return withCompatibilityAliases({
1108
+ ...session,
1109
+ version: session.version ?? 1,
1110
+ sessionsByChain: {
1111
+ [chainType]: {
1112
+ sessionId: session.sessionId,
1113
+ status: session.status,
1114
+ expiresAt: session.expiresAt,
1115
+ chainType,
1116
+ ...walletId ? { walletId } : {},
1117
+ ...walletAddress ? { walletAddress } : {},
1118
+ ...session.privyKeyQuorumId ? { providerKeyQuorumId: session.privyKeyQuorumId } : {},
1119
+ ...session.privySignerId ? { providerSignerId: session.privySignerId } : {},
1120
+ ...session.capabilities ? { capabilities: session.capabilities } : {}
1121
+ }
1122
+ }
1123
+ });
1124
+ }
1125
+ function withCompatibilityAliases(session) {
1126
+ const evm = session.sessionsByChain?.evm;
1127
+ const solana = session.sessionsByChain?.solana;
1128
+ const preferred = evm ?? solana;
1129
+ if (!preferred) {
1130
+ return session;
1131
+ }
1132
+ return {
1133
+ ...session,
1134
+ sessionId: preferred.sessionId,
1135
+ status: preferred.status,
1136
+ expiresAt: preferred.expiresAt,
1137
+ walletId: evm?.walletId ?? solana?.walletId ?? session.walletId,
1138
+ evmWalletId: evm?.walletId ?? session.evmWalletId,
1139
+ evmAddress: evm?.walletAddress ?? session.evmAddress,
1140
+ solanaWalletId: solana?.walletId ?? session.solanaWalletId,
1141
+ solanaAddress: solana?.walletAddress ?? session.solanaAddress,
1142
+ privyKeyQuorumId: evm?.providerKeyQuorumId ?? solana?.providerKeyQuorumId ?? session.privyKeyQuorumId,
1143
+ privySignerId: evm?.providerSignerId ?? solana?.providerSignerId ?? session.privySignerId,
1144
+ chainType: evm && solana ? "both" : preferred.chainType,
1145
+ capabilities: {
1146
+ ...evm?.capabilities ?? {},
1147
+ ...solana?.capabilities ?? {},
1148
+ ...session.capabilities ?? {}
1149
+ }
1150
+ };
1082
1151
  }
1083
1152
  function loadStoredSessionFromPath(path) {
1084
1153
  if (!existsSync(path)) return null;
@@ -1092,13 +1161,23 @@ function isExpired(session) {
1092
1161
  const expiresAt = new Date(session.expiresAt);
1093
1162
  return !Number.isNaN(expiresAt.getTime()) && expiresAt <= /* @__PURE__ */ new Date();
1094
1163
  }
1164
+ function isSessionLoadable(session) {
1165
+ if (session.sessionsByChain) {
1166
+ return Object.values(session.sessionsByChain).some((chainSession) => {
1167
+ return Boolean(
1168
+ chainSession && chainSession.status !== "revoked" && !isExpired(chainSession)
1169
+ );
1170
+ });
1171
+ }
1172
+ if (session.status === "revoked") return false;
1173
+ return !isExpired(session);
1174
+ }
1095
1175
  function createFileWalletSessionStore(path = sessionPath()) {
1096
1176
  return {
1097
1177
  load() {
1098
1178
  const session = loadStoredSessionFromPath(path);
1099
1179
  if (!session) return null;
1100
- if (session.status === "revoked") return null;
1101
- if (isExpired(session)) return null;
1180
+ if (!isSessionLoadable(session)) return null;
1102
1181
  return session;
1103
1182
  },
1104
1183
  loadRaw() {
@@ -1142,6 +1221,7 @@ function createPendingSession() {
1142
1221
  const now = /* @__PURE__ */ new Date();
1143
1222
  const expiresAt = new Date(now.getTime() + SESSION_TTL_DAYS * 24 * 60 * 60 * 1e3);
1144
1223
  const session = {
1224
+ version: 2,
1145
1225
  sessionId: randomUUID(),
1146
1226
  status: "pending",
1147
1227
  createdAt: now.toISOString(),
@@ -1164,12 +1244,12 @@ function loadStoredSession() {
1164
1244
  return store.load();
1165
1245
  }
1166
1246
  function saveSession(session) {
1167
- getWalletSessionStore().save(session);
1247
+ getWalletSessionStore().save(withCompatibilityAliases(session));
1168
1248
  }
1169
1249
  function updateSession(updates) {
1170
1250
  const session = loadSession();
1171
1251
  if (!session) return null;
1172
- const updated = { ...session, ...updates };
1252
+ const updated = withCompatibilityAliases({ ...session, ...updates });
1173
1253
  saveSession(updated);
1174
1254
  return updated;
1175
1255
  }
@@ -1177,11 +1257,54 @@ function clearSession() {
1177
1257
  return getWalletSessionStore().clear();
1178
1258
  }
1179
1259
  function isSessionValid(session) {
1260
+ if (session.sessionsByChain) {
1261
+ return Object.values(session.sessionsByChain).some((chainSession) => {
1262
+ return Boolean(chainSession && isChainSessionValid(chainSession));
1263
+ });
1264
+ }
1180
1265
  if (session.status !== "approved") return false;
1181
1266
  const expiresAt = new Date(session.expiresAt);
1182
1267
  if (Number.isNaN(expiresAt.getTime())) return false;
1183
1268
  return expiresAt > /* @__PURE__ */ new Date();
1184
1269
  }
1270
+ function isChainSessionValid(session) {
1271
+ if (session.status !== "approved") return false;
1272
+ const expiresAt = new Date(session.expiresAt);
1273
+ if (Number.isNaN(expiresAt.getTime())) return false;
1274
+ return expiresAt > /* @__PURE__ */ new Date();
1275
+ }
1276
+ function getWalletSessionByChain(session, chainType) {
1277
+ const chainSession = session.sessionsByChain?.[chainType];
1278
+ if (!chainSession) {
1279
+ if (!isSessionValid(session)) return null;
1280
+ const legacyChainType = session.chainType === "solana" ? "solana" : "evm";
1281
+ if (chainType !== legacyChainType) return null;
1282
+ if (legacyChainType === "evm" && session.evmAddress) return session;
1283
+ if (legacyChainType === "solana" && session.solanaAddress) return session;
1284
+ return null;
1285
+ }
1286
+ if (!isChainSessionValid(chainSession)) {
1287
+ return null;
1288
+ }
1289
+ return withCompatibilityAliases({
1290
+ ...session,
1291
+ sessionId: chainSession.sessionId,
1292
+ status: chainSession.status,
1293
+ expiresAt: chainSession.expiresAt,
1294
+ walletId: chainSession.walletId,
1295
+ evmWalletId: chainType === "evm" ? chainSession.walletId : session.evmWalletId,
1296
+ evmAddress: chainType === "evm" ? chainSession.walletAddress : session.evmAddress,
1297
+ solanaWalletId: chainType === "solana" ? chainSession.walletId : session.solanaWalletId,
1298
+ solanaAddress: chainType === "solana" ? chainSession.walletAddress : session.solanaAddress,
1299
+ privyKeyQuorumId: chainSession.providerKeyQuorumId,
1300
+ privySignerId: chainSession.providerSignerId,
1301
+ chainType,
1302
+ capabilities: chainSession.capabilities ?? session.capabilities,
1303
+ sessionsByChain: {
1304
+ [chainType]: chainSession
1305
+ }
1306
+ });
1307
+ }
1185
1308
 
1186
1309
  // src/lib/resolve.ts
1187
1310
  function getCommandOptions(program) {
@@ -1427,6 +1550,7 @@ export {
1427
1550
  updateSession,
1428
1551
  clearSession,
1429
1552
  isSessionValid,
1553
+ getWalletSessionByChain,
1430
1554
  resolveAPIKey,
1431
1555
  resolveAccessKey,
1432
1556
  resolveNetwork,
@@ -3,7 +3,7 @@ if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  gasManagerClientFromFlags,
5
5
  toAdminNetworkId
6
- } from "./chunk-JWLZAO7S.js";
6
+ } from "./chunk-7ZSEELHZ.js";
7
7
  import {
8
8
  dim,
9
9
  green,
@@ -11,16 +11,16 @@ import {
11
11
  promptConfirm,
12
12
  promptText,
13
13
  withSpinner
14
- } from "./chunk-DGZYRBXR.js";
14
+ } from "./chunk-MV7O3XBG.js";
15
15
  import {
16
16
  load,
17
17
  save
18
- } from "./chunk-ROBA7SR7.js";
18
+ } from "./chunk-GDLPBPG3.js";
19
19
  import {
20
20
  errAppRequired,
21
21
  errInvalidArgs,
22
22
  errLoginRequired
23
- } from "./chunk-46LMXT54.js";
23
+ } from "./chunk-OVLQH6KL.js";
24
24
 
25
25
  // src/lib/policy-prompt.ts
26
26
  var CREATE_NEW_SENTINEL = "__create_new__";
@@ -2,7 +2,7 @@
2
2
  if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  isRevealMode
5
- } from "./chunk-46LMXT54.js";
5
+ } from "./chunk-OVLQH6KL.js";
6
6
 
7
7
  // src/lib/secrets.ts
8
8
  function maskSecret(value) {
@@ -5,7 +5,7 @@ import {
5
5
  isJSONMode,
6
6
  quiet,
7
7
  rgb
8
- } from "./chunk-46LMXT54.js";
8
+ } from "./chunk-OVLQH6KL.js";
9
9
 
10
10
  // src/lib/terminal-ui.ts
11
11
  import * as readline from "readline";
@@ -2,11 +2,11 @@
2
2
  if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  isInteractiveAllowed
5
- } from "./chunk-L7VFXQSF.js";
5
+ } from "./chunk-75ICFV5K.js";
6
6
  import {
7
7
  resolveAuthToken,
8
8
  resolveWalletSession
9
- } from "./chunk-JWLZAO7S.js";
9
+ } from "./chunk-7ZSEELHZ.js";
10
10
 
11
11
  // src/lib/onboarding.ts
12
12
  var SETUP_CAPABILITY_ORDER = [
@@ -74,14 +74,14 @@ function getSetupCapabilities(cfg) {
74
74
  missing: hasLocalWallet || hasSessionWallet ? [] : ["wallet signer"],
75
75
  nextCommands: hasLocalWallet || hasSessionWallet ? [] : [
76
76
  "alchemy wallet connect",
77
- "alchemy wallet connect --mode local --chain evm"
77
+ "alchemy wallet connect --mode local"
78
78
  ]
79
79
  }),
80
80
  x402: capabilityStatus({
81
81
  complete: x402Ready,
82
82
  satisfiedBy: x402Ready ? "x402_wallet" : null,
83
83
  missing: x402Ready ? [] : ["x402 enabled with wallet key file"],
84
- nextCommands: x402Ready ? [] : ["alchemy wallet connect --mode local --chain evm && alchemy config set x402 true"]
84
+ nextCommands: x402Ready ? [] : ["alchemy wallet connect --mode local && alchemy config set x402 true"]
85
85
  })
86
86
  };
87
87
  }
@@ -115,7 +115,7 @@ function getSetupStatus(cfg) {
115
115
  "alchemy auth",
116
116
  "alchemy config set app",
117
117
  "alchemy config set access-key <key> && alchemy config set app <app-id>",
118
- "alchemy wallet connect --mode local --chain evm && alchemy config set x402 true"
118
+ "alchemy wallet connect --mode local && alchemy config set x402 true"
119
119
  ],
120
120
  capabilities
121
121
  };
@@ -455,8 +455,8 @@ function errAppRequired() {
455
455
  function errWalletKeyRequired() {
456
456
  return new CLIError(
457
457
  ErrorCode.AUTH_REQUIRED,
458
- "Wallet key required for x402. Set ALCHEMY_WALLET_KEY, run 'alchemy wallet connect --mode local --chain evm', or use --wallet-key-file.",
459
- "alchemy wallet connect --mode local --chain evm"
458
+ "Wallet key required for x402. Set ALCHEMY_WALLET_KEY, run 'alchemy wallet connect --mode local', or use --wallet-key-file.",
459
+ "alchemy wallet connect --mode local"
460
460
  );
461
461
  }
462
462
  function errSessionExpired() {
@@ -476,8 +476,8 @@ function errNoActiveSession() {
476
476
  function errSolanaWalletKeyRequired() {
477
477
  return new CLIError(
478
478
  ErrorCode.AUTH_REQUIRED,
479
- "Solana wallet key required. Set ALCHEMY_SOLANA_WALLET_KEY, run 'alchemy wallet connect --mode local --chain solana', or use --solana-wallet-key-file.",
480
- "alchemy wallet connect --mode local --chain solana"
479
+ "Solana wallet key required. Set ALCHEMY_SOLANA_WALLET_KEY, run 'alchemy wallet connect --mode local', or use --solana-wallet-key-file.",
480
+ "alchemy wallet connect --mode local"
481
481
  );
482
482
  }
483
483
  function errSolanaTransactionFailed(details) {
@@ -2,7 +2,7 @@
2
2
  if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  getBaseDomain
5
- } from "./chunk-46LMXT54.js";
5
+ } from "./chunk-OVLQH6KL.js";
6
6
 
7
7
  // src/lib/auth.ts
8
8
  import { createHash, randomBytes } from "crypto";
@@ -2,10 +2,10 @@
2
2
  if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
3
  import {
4
4
  configPath
5
- } from "./chunk-ROBA7SR7.js";
5
+ } from "./chunk-GDLPBPG3.js";
6
6
  import {
7
7
  esc
8
- } from "./chunk-46LMXT54.js";
8
+ } from "./chunk-OVLQH6KL.js";
9
9
 
10
10
  // src/lib/update-check.ts
11
11
  import { execFileSync } from "child_process";
@@ -53,7 +53,7 @@ function semverLT(a, b) {
53
53
  return false;
54
54
  }
55
55
  function currentVersion() {
56
- return true ? "0.8.0" : "0.0.0";
56
+ return true ? "0.9.0" : "0.0.0";
57
57
  }
58
58
  function toUpdateStatus(latestVersion, checkedAt) {
59
59
  const current = currentVersion();
@@ -4,14 +4,14 @@ import {
4
4
  completeLogin,
5
5
  prepareLogin,
6
6
  revokeToken
7
- } from "./chunk-NGF46GZP.js";
7
+ } from "./chunk-RGVM5SNE.js";
8
8
  import {
9
9
  isInteractiveAllowed
10
- } from "./chunk-L7VFXQSF.js";
10
+ } from "./chunk-75ICFV5K.js";
11
11
  import {
12
12
  AdminClient,
13
13
  resolveAuthToken
14
- } from "./chunk-JWLZAO7S.js";
14
+ } from "./chunk-7ZSEELHZ.js";
15
15
  import {
16
16
  bold,
17
17
  brand,
@@ -20,13 +20,13 @@ import {
20
20
  promptAutocomplete,
21
21
  promptText,
22
22
  withSpinner
23
- } from "./chunk-DGZYRBXR.js";
23
+ } from "./chunk-MV7O3XBG.js";
24
24
  import {
25
25
  configPath,
26
26
  load,
27
27
  maskIf,
28
28
  save
29
- } from "./chunk-ROBA7SR7.js";
29
+ } from "./chunk-GDLPBPG3.js";
30
30
  import {
31
31
  CLIError,
32
32
  ErrorCode,
@@ -34,7 +34,7 @@ import {
34
34
  exitWithError,
35
35
  isJSONMode,
36
36
  printHuman
37
- } from "./chunk-46LMXT54.js";
37
+ } from "./chunk-OVLQH6KL.js";
38
38
 
39
39
  // src/commands/auth.ts
40
40
  function registerAuth(program) {
@@ -27,7 +27,7 @@ import {
27
27
  exitWithError,
28
28
  isReplMode,
29
29
  setReplMode
30
- } from "./chunk-46LMXT54.js";
30
+ } from "./chunk-OVLQH6KL.js";
31
31
  export {
32
32
  CLIError,
33
33
  EXIT_CODES,