fastpass-cli 0.2.0 → 0.2.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/README.md CHANGED
@@ -60,12 +60,9 @@ Options:
60
60
 
61
61
  ## Credentials
62
62
 
63
- fastpass needs Cloudflare API access. It checks, in order:
63
+ fastpass needs a Cloudflare API token via the `CLOUDFLARE_API_TOKEN` environment variable.
64
64
 
65
- 1. `CLOUDFLARE_API_TOKEN` environment variable
66
- 2. Wrangler OAuth token from `~/.wrangler/config/default.toml` (from `npx wrangler login`)
67
-
68
- **Recommended:** Use an API token with:
65
+ Create an API token with:
69
66
 
70
67
  - **Access: Organizations, Identity Providers, and Groups** — Edit
71
68
  - **Access: Apps and Policies** — Edit
@@ -80,8 +77,6 @@ export CLOUDFLARE_API_TOKEN="your-token"
80
77
  export CLOUDFLARE_ACCOUNT_ID="your-account-id"
81
78
  ```
82
79
 
83
- **Note:** Wrangler’s OAuth token typically does not include Access scopes. If `wrangler login` works for Workers but fastpass fails with permission errors, use a dedicated API token with the permissions above.
84
-
85
80
  **Logs:** The `logs` and `status` commands fetch access events. If they fail, your token may need **Access: Audit Logs** — Read.
86
81
 
87
82
  ## Prerequisites
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastpass-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Cloudflare Access in 60 seconds.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/auth.js CHANGED
@@ -1,36 +1,21 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
4
1
  import pc from 'picocolors';
5
2
  import { spin } from './ui.js';
6
3
 
7
4
  /**
8
5
  * Resolve Cloudflare credentials.
9
6
  *
10
- * Priority:
11
- * 1. CLOUDFLARE_API_TOKEN env var
12
- * 2. Wrangler OAuth token from ~/.wrangler/config/default.toml
13
- *
14
- * Account ID:
15
- * 1. CLOUDFLARE_ACCOUNT_ID env var
16
- * 2. Fetched from /accounts API
7
+ * Token: CLOUDFLARE_API_TOKEN env var
8
+ * Account: CLOUDFLARE_ACCOUNT_ID env var, or fetched from /accounts API
17
9
  */
18
10
  export async function getCredentials() {
19
11
  const s = spin('Checking Cloudflare credentials');
20
12
 
21
- let token = process.env.CLOUDFLARE_API_TOKEN;
22
-
23
- if (!token) {
24
- s.text = 'Checking Cloudflare credentials (trying wrangler)';
25
- token = await tryWranglerToken();
26
- }
13
+ const token = process.env.CLOUDFLARE_API_TOKEN;
27
14
 
28
15
  if (!token) {
29
16
  s.fail('No Cloudflare credentials found');
30
17
  console.error('');
31
- console.error(` ${pc.bold('How to fix — pick one:')}`);
32
- console.error('');
33
- console.error(` ${pc.cyan('1.')} Set an API token (recommended):`);
18
+ console.error(` ${pc.bold('Set an API token:')}`);
34
19
  console.error('');
35
20
  console.error(` ${pc.bold('export CLOUDFLARE_API_TOKEN=<your-token>')}`);
36
21
  console.error('');
@@ -39,10 +24,6 @@ export async function getCredentials() {
39
24
  console.error(` ${pc.dim('•')} Access: Organizations, Identity Providers, and Groups — Edit`);
40
25
  console.error(` ${pc.dim('•')} Access: Apps and Policies — Edit`);
41
26
  console.error('');
42
- console.error(` ${pc.cyan('2.')} Log in with wrangler:`);
43
- console.error('');
44
- console.error(` ${pc.bold('npx wrangler login')}`);
45
- console.error('');
46
27
  process.exit(1);
47
28
  }
48
29
 
@@ -57,25 +38,6 @@ export async function getCredentials() {
57
38
  return { token, accountId };
58
39
  }
59
40
 
60
- async function tryWranglerToken() {
61
- try {
62
- const configPath = join(homedir(), '.wrangler', 'config', 'default.toml');
63
- const content = await readFile(configPath, 'utf-8');
64
- const match = content.match(/^oauth_token\s*=\s*"(.+)"/m);
65
- if (match?.[1]) {
66
- // Check if token is expired
67
- const expMatch = content.match(/^expiration_time\s*=\s*"(.+)"/m);
68
- if (expMatch?.[1] && new Date(expMatch[1]) < new Date()) {
69
- return null; // expired
70
- }
71
- return match[1];
72
- }
73
- } catch {
74
- // config file not found — wrangler not logged in
75
- }
76
- return null;
77
- }
78
-
79
41
  async function fetchAccountId(token) {
80
42
  const res = await fetch('https://api.cloudflare.com/client/v4/accounts?per_page=5', {
81
43
  headers: { Authorization: `Bearer ${token}` },
package/src/cli.js CHANGED
@@ -15,7 +15,7 @@ export function run() {
15
15
  program
16
16
  .name('fastpass-cli')
17
17
  .description('Cloudflare Access in 60 seconds.')
18
- .version('0.2.0');
18
+ .version('0.2.1');
19
19
 
20
20
  // Default action (no subcommand) — run the protect wizard
21
21
  program