@alchemy/cli 0.7.1 → 0.7.2-alpha.26

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,134 @@
1
+ #!/usr/bin/env node
2
+ if(process.argv.includes("--no-color"))process.env.NO_COLOR="1";
3
+ import {
4
+ isInteractiveAllowed
5
+ } from "./chunk-64A5W4M2.js";
6
+ import {
7
+ resolveAuthToken,
8
+ resolveWalletSession
9
+ } from "./chunk-K6V3R7SH.js";
10
+
11
+ // src/lib/onboarding.ts
12
+ var SETUP_CAPABILITY_ORDER = [
13
+ "rpc_data",
14
+ "admin_api",
15
+ "notify_webhooks",
16
+ "wallet_signing",
17
+ "x402"
18
+ ];
19
+ var SETUP_CAPABILITY_LABELS = {
20
+ rpc_data: "RPC/data",
21
+ admin_api: "Admin API",
22
+ notify_webhooks: "Notify/webhooks",
23
+ wallet_signing: "Wallet signing",
24
+ x402: "x402"
25
+ };
26
+ function hasAPIKey(cfg) {
27
+ return Boolean(cfg.api_key?.trim());
28
+ }
29
+ function hasAccessKeyAndApp(cfg) {
30
+ return Boolean(cfg.access_key?.trim() && cfg.app?.id && cfg.app.apiKey);
31
+ }
32
+ function hasX402Wallet(cfg) {
33
+ return cfg.x402 === true && Boolean(cfg.wallet_key_file?.trim());
34
+ }
35
+ function hasAuthToken(cfg) {
36
+ return resolveAuthToken(cfg) !== void 0;
37
+ }
38
+ function capabilityStatus(args) {
39
+ return args;
40
+ }
41
+ function getSetupCapabilities(cfg) {
42
+ const hasConfiguredAPIKey = hasAPIKey(cfg) || Boolean(cfg.app?.apiKey?.trim());
43
+ const hasAdminAuth = Boolean(cfg.access_key?.trim()) || hasAuthToken(cfg);
44
+ const hasNotifyAuth = Boolean(
45
+ cfg.webhook_api_key?.trim() || cfg.app?.webhookApiKey?.trim()
46
+ );
47
+ const hasLocalWallet = Boolean(
48
+ cfg.wallet_key_file?.trim() || cfg.solana_wallet_key_file?.trim()
49
+ );
50
+ const hasSessionWallet = resolveWalletSession() !== null && hasAuthToken(cfg);
51
+ const x402Ready = hasX402Wallet(cfg);
52
+ return {
53
+ rpc_data: capabilityStatus({
54
+ complete: hasConfiguredAPIKey || x402Ready,
55
+ satisfiedBy: hasConfiguredAPIKey ? "api_key" : x402Ready ? "x402_wallet" : null,
56
+ missing: hasConfiguredAPIKey || x402Ready ? [] : ["api-key or x402 wallet"],
57
+ nextCommands: hasConfiguredAPIKey || x402Ready ? [] : ["alchemy config set app", "alchemy config set api-key <key>"]
58
+ }),
59
+ admin_api: capabilityStatus({
60
+ complete: hasAdminAuth,
61
+ satisfiedBy: cfg.access_key?.trim() ? "access_key" : hasAuthToken(cfg) ? "auth_token" : null,
62
+ missing: hasAdminAuth ? [] : ["access-key or auth token"],
63
+ nextCommands: hasAdminAuth ? [] : ["alchemy auth", "alchemy config set access-key <key>"]
64
+ }),
65
+ notify_webhooks: capabilityStatus({
66
+ complete: hasNotifyAuth,
67
+ satisfiedBy: cfg.webhook_api_key?.trim() ? "webhook-api-key" : cfg.app?.webhookApiKey?.trim() ? "configured app webhook key" : null,
68
+ missing: hasNotifyAuth ? [] : ["webhook API key"],
69
+ nextCommands: hasNotifyAuth ? [] : ["alchemy config set webhook-api-key <key>", "alchemy config set app"]
70
+ }),
71
+ wallet_signing: capabilityStatus({
72
+ complete: hasLocalWallet || hasSessionWallet,
73
+ satisfiedBy: hasSessionWallet ? "wallet_session" : hasLocalWallet ? "local_wallet" : null,
74
+ missing: hasLocalWallet || hasSessionWallet ? [] : ["wallet signer"],
75
+ nextCommands: hasLocalWallet || hasSessionWallet ? [] : [
76
+ "alchemy wallet connect",
77
+ "alchemy wallet connect --mode local --chain evm"
78
+ ]
79
+ }),
80
+ x402: capabilityStatus({
81
+ complete: x402Ready,
82
+ satisfiedBy: x402Ready ? "x402_wallet" : null,
83
+ missing: x402Ready ? [] : ["x402 enabled with wallet key file"],
84
+ nextCommands: x402Ready ? [] : ["alchemy wallet connect --mode local --chain evm && alchemy config set x402 true"]
85
+ })
86
+ };
87
+ }
88
+ function getSetupMethod(cfg) {
89
+ if (hasAPIKey(cfg)) return "api_key";
90
+ if (hasAccessKeyAndApp(cfg)) return "access_key_app";
91
+ if (hasX402Wallet(cfg)) return "x402_wallet";
92
+ if (hasAuthToken(cfg)) return "auth_token";
93
+ return null;
94
+ }
95
+ function isSetupComplete(cfg) {
96
+ return getSetupMethod(cfg) !== null;
97
+ }
98
+ function getSetupStatus(cfg) {
99
+ const satisfiedBy = getSetupMethod(cfg);
100
+ const capabilities = getSetupCapabilities(cfg);
101
+ if (satisfiedBy) {
102
+ return {
103
+ complete: true,
104
+ satisfiedBy,
105
+ missing: [],
106
+ nextCommands: [],
107
+ capabilities
108
+ };
109
+ }
110
+ return {
111
+ complete: false,
112
+ satisfiedBy: null,
113
+ missing: ["Provide one auth path: alchemy auth OR api-key OR ALCHEMY_ACCESS_KEY+app OR SIWx wallet"],
114
+ nextCommands: [
115
+ "alchemy auth",
116
+ "alchemy config set app",
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"
119
+ ],
120
+ capabilities
121
+ };
122
+ }
123
+ function shouldRunOnboarding(program, cfg) {
124
+ return isInteractiveAllowed(program) && !isSetupComplete(cfg);
125
+ }
126
+
127
+ export {
128
+ SETUP_CAPABILITY_ORDER,
129
+ SETUP_CAPABILITY_LABELS,
130
+ getSetupMethod,
131
+ isSetupComplete,
132
+ getSetupStatus,
133
+ shouldRunOnboarding
134
+ };
@@ -4,14 +4,14 @@ import {
4
4
  completeLogin,
5
5
  prepareLogin,
6
6
  revokeToken
7
- } from "./chunk-HSKKIATB.js";
7
+ } from "./chunk-C5HNQOLB.js";
8
8
  import {
9
9
  isInteractiveAllowed
10
- } from "./chunk-HYCRHNPX.js";
10
+ } from "./chunk-64A5W4M2.js";
11
11
  import {
12
12
  AdminClient,
13
13
  resolveAuthToken
14
- } from "./chunk-TOEVZMIP.js";
14
+ } from "./chunk-K6V3R7SH.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-5IFXLC2S.js";
23
+ } from "./chunk-5IL2PMZ6.js";
24
24
  import {
25
25
  configPath,
26
26
  load,
27
27
  maskIf,
28
28
  save
29
- } from "./chunk-7WD3YLRK.js";
29
+ } from "./chunk-JUCUKTP3.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-QEDAULQ2.js";
37
+ } from "./chunk-2BALTY22.js";
38
38
 
39
39
  // src/commands/auth.ts
40
40
  function registerAuth(program) {
@@ -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-7WD3YLRK.js";
5
+ } from "./chunk-JUCUKTP3.js";
6
6
  import {
7
7
  esc
8
- } from "./chunk-QEDAULQ2.js";
8
+ } from "./chunk-2BALTY22.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.7.1" : "0.0.0";
56
+ return true ? "0.7.2-alpha.26" : "0.0.0";
57
57
  }
58
58
  function toUpdateStatus(latestVersion, checkedAt) {
59
59
  const current = currentVersion();
@@ -24,8 +24,9 @@ import {
24
24
  errSolanaWalletKeyRequired,
25
25
  errWalletKeyRequired,
26
26
  exitWithError,
27
+ isReplMode,
27
28
  setReplMode
28
- } from "./chunk-QEDAULQ2.js";
29
+ } from "./chunk-2BALTY22.js";
29
30
  export {
30
31
  CLIError,
31
32
  EXIT_CODES,
@@ -50,5 +51,6 @@ export {
50
51
  errSolanaWalletKeyRequired,
51
52
  errWalletKeyRequired,
52
53
  exitWithError,
54
+ isReplMode,
53
55
  setReplMode
54
56
  };