fastpass-cli 0.2.2 → 0.2.4
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/package.json +2 -2
- package/src/cli.js +2 -1
- package/src/commands/list.js +1 -1
- package/src/commands/protect.js +14 -10
- /package/bin/{fastpass.js → fastpass-cli.js} +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastpass-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Cloudflare Access in 60 seconds.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"fastpass-cli": "./bin/fastpass.js"
|
|
7
|
+
"fastpass-cli": "./bin/fastpass-cli.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
package/src/cli.js
CHANGED
|
@@ -27,6 +27,7 @@ export function run() {
|
|
|
27
27
|
.description('Protect a domain with Cloudflare Access')
|
|
28
28
|
.option('--auth <method>', 'Auth method(s): email, github, google (comma-separated for multiple)')
|
|
29
29
|
.option('--allow <rule>', 'Who can access: email, *@domain.com, or "everyone"')
|
|
30
|
+
.option('--hidden', 'Hide email addresses from terminal output')
|
|
30
31
|
.action(async (domain, opts) => {
|
|
31
32
|
printBanner();
|
|
32
33
|
const creds = await getCredentials();
|
|
@@ -86,6 +87,6 @@ export function run() {
|
|
|
86
87
|
|
|
87
88
|
function printBanner() {
|
|
88
89
|
console.log('');
|
|
89
|
-
console.log(` ${pc.bold('fastpass')}: protect your app in 60 seconds`);
|
|
90
|
+
console.log(` ${pc.bold('fastpass-cli')}: protect your app in 60 seconds`);
|
|
90
91
|
console.log('');
|
|
91
92
|
}
|
package/src/commands/list.js
CHANGED
|
@@ -14,7 +14,7 @@ export async function list(api) {
|
|
|
14
14
|
|
|
15
15
|
if (!result?.length) {
|
|
16
16
|
console.log(pc.dim('\n No Access applications found.\n'));
|
|
17
|
-
console.log(` Run ${pc.cyan('fastpass protect <domain>')} to get started.\n`);
|
|
17
|
+
console.log(` Run ${pc.cyan('fastpass-cli protect <domain>')} to get started.\n`);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
|
package/src/commands/protect.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
|
-
import { input, select, confirm } from '@inquirer/prompts';
|
|
2
|
+
import { input, password, select, confirm } from '@inquirer/prompts';
|
|
3
3
|
import { getTeamName } from '../auth.js';
|
|
4
4
|
import { ensureEmailOtp } from '../idp/email-otp.js';
|
|
5
5
|
import { ensureGitHub } from '../idp/github.js';
|
|
@@ -39,8 +39,8 @@ export async function protect(api, opts = {}) {
|
|
|
39
39
|
const existing = await checkExistingApp(api, domain.trim());
|
|
40
40
|
if (existing) {
|
|
41
41
|
console.log(`\n ${pc.yellow('This domain is already protected by Access.')}\n`);
|
|
42
|
-
console.log(` Run ${pc.cyan(`fastpass inspect ${domain.trim()}`)} to view its configuration.`);
|
|
43
|
-
console.log(` Run ${pc.cyan(`fastpass remove ${domain.trim()}`)} to remove it first.\n`);
|
|
42
|
+
console.log(` Run ${pc.cyan(`fastpass-cli inspect ${domain.trim()}`)} to view its configuration.`);
|
|
43
|
+
console.log(` Run ${pc.cyan(`fastpass-cli remove ${domain.trim()}`)} to remove it first.\n`);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -61,7 +61,7 @@ export async function protect(api, opts = {}) {
|
|
|
61
61
|
console.log('');
|
|
62
62
|
|
|
63
63
|
// Resolve who gets access
|
|
64
|
-
const { include, includeType } = await resolveAccess(opts.allow);
|
|
64
|
+
const { include, includeType } = await resolveAccess(opts.allow, opts.hidden);
|
|
65
65
|
console.log('');
|
|
66
66
|
|
|
67
67
|
// Get team name for OAuth callback URLs
|
|
@@ -84,7 +84,9 @@ export async function protect(api, opts = {}) {
|
|
|
84
84
|
const policyInclude = buildIncludeRules(include, includeType);
|
|
85
85
|
|
|
86
86
|
// Describe access for the summary
|
|
87
|
-
const accessLabel =
|
|
87
|
+
const accessLabel = (opts.hidden && includeType === 'emails')
|
|
88
|
+
? pc.dim('(hidden)')
|
|
89
|
+
: describeAccess(include, includeType);
|
|
88
90
|
|
|
89
91
|
// Show confirmation summary (skip when all CLI flags provided)
|
|
90
92
|
const allFlagsProvided = opts.domain && opts.auth && opts.allow;
|
|
@@ -133,8 +135,8 @@ export async function protect(api, opts = {}) {
|
|
|
133
135
|
s.fail(`Failed to create Access application for ${pc.bold(domain.trim())}`);
|
|
134
136
|
if (err instanceof ApiError && err.message.includes('application_already_exists')) {
|
|
135
137
|
console.log(`\n ${pc.yellow('This domain is already protected by Access.')}\n`);
|
|
136
|
-
console.log(` Run ${pc.cyan(`fastpass inspect ${domain.trim()}`)} to view its configuration.`);
|
|
137
|
-
console.log(` Run ${pc.cyan(`fastpass remove ${domain.trim()}`)} to remove it first.\n`);
|
|
138
|
+
console.log(` Run ${pc.cyan(`fastpass-cli inspect ${domain.trim()}`)} to view its configuration.`);
|
|
139
|
+
console.log(` Run ${pc.cyan(`fastpass-cli remove ${domain.trim()}`)} to remove it first.\n`);
|
|
138
140
|
return;
|
|
139
141
|
}
|
|
140
142
|
throw err;
|
|
@@ -171,7 +173,7 @@ export async function validateDomain(api, domain) {
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
export async function resolveAccess(allowFlag) {
|
|
176
|
+
export async function resolveAccess(allowFlag, hidden) {
|
|
175
177
|
// If --allow flag was passed, parse it
|
|
176
178
|
if (allowFlag) {
|
|
177
179
|
if (allowFlag.startsWith('*@')) {
|
|
@@ -187,6 +189,8 @@ export async function resolveAccess(allowFlag) {
|
|
|
187
189
|
return { include: allowFlag.split(',').map((e) => e.trim()), includeType: 'emails' };
|
|
188
190
|
}
|
|
189
191
|
|
|
192
|
+
const emailPrompt = hidden ? password : input;
|
|
193
|
+
|
|
190
194
|
// Interactive
|
|
191
195
|
const accessType = await select({
|
|
192
196
|
message: 'Who should have access?',
|
|
@@ -195,7 +199,7 @@ export async function resolveAccess(allowFlag) {
|
|
|
195
199
|
|
|
196
200
|
switch (accessType) {
|
|
197
201
|
case 'me': {
|
|
198
|
-
const email = await
|
|
202
|
+
const email = await emailPrompt({
|
|
199
203
|
message: 'Your email address:',
|
|
200
204
|
validate: (v) => v.includes('@') || 'Enter a valid email',
|
|
201
205
|
});
|
|
@@ -216,7 +220,7 @@ export async function resolveAccess(allowFlag) {
|
|
|
216
220
|
return { include: [org.trim()], includeType: 'github_org' };
|
|
217
221
|
}
|
|
218
222
|
case 'emails': {
|
|
219
|
-
const emails = await
|
|
223
|
+
const emails = await emailPrompt({
|
|
220
224
|
message: 'Email addresses (comma-separated):',
|
|
221
225
|
validate: (v) => v.includes('@') || 'Enter at least one email',
|
|
222
226
|
});
|
|
File without changes
|