@portaidentity/cli 0.1.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/auth/browser-flow.d.ts +42 -0
- package/dist/auth/browser-flow.d.ts.map +1 -0
- package/dist/auth/browser-flow.js +193 -0
- package/dist/auth/browser-flow.js.map +1 -0
- package/dist/auth/callback-server.d.ts +81 -0
- package/dist/auth/callback-server.d.ts.map +1 -0
- package/dist/auth/callback-server.js +193 -0
- package/dist/auth/callback-server.js.map +1 -0
- package/dist/auth/metadata.d.ts +43 -0
- package/dist/auth/metadata.d.ts.map +1 -0
- package/dist/auth/metadata.js +66 -0
- package/dist/auth/metadata.js.map +1 -0
- package/dist/auth/pkce.d.ts +42 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +52 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +11 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client-factory.d.ts +29 -0
- package/dist/client-factory.d.ts.map +1 -0
- package/dist/client-factory.js +43 -0
- package/dist/client-factory.js.map +1 -0
- package/dist/commands/app-claim.d.ts +9 -0
- package/dist/commands/app-claim.d.ts.map +1 -0
- package/dist/commands/app-claim.js +128 -0
- package/dist/commands/app-claim.js.map +1 -0
- package/dist/commands/app-module.d.ts +9 -0
- package/dist/commands/app-module.d.ts.map +1 -0
- package/dist/commands/app-module.js +104 -0
- package/dist/commands/app-module.js.map +1 -0
- package/dist/commands/app-permission.d.ts +9 -0
- package/dist/commands/app-permission.d.ts.map +1 -0
- package/dist/commands/app-permission.js +118 -0
- package/dist/commands/app-permission.js.map +1 -0
- package/dist/commands/app-role.d.ts +9 -0
- package/dist/commands/app-role.d.ts.map +1 -0
- package/dist/commands/app-role.js +166 -0
- package/dist/commands/app-role.js.map +1 -0
- package/dist/commands/app.d.ts +12 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +255 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/audit.d.ts +12 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +96 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/bulk.d.ts +12 -0
- package/dist/commands/bulk.d.ts.map +1 -0
- package/dist/commands/bulk.js +77 -0
- package/dist/commands/bulk.js.map +1 -0
- package/dist/commands/client-secret.d.ts +18 -0
- package/dist/commands/client-secret.d.ts.map +1 -0
- package/dist/commands/client-secret.js +126 -0
- package/dist/commands/client-secret.js.map +1 -0
- package/dist/commands/client.d.ts +27 -0
- package/dist/commands/client.d.ts.map +1 -0
- package/dist/commands/client.js +385 -0
- package/dist/commands/client.js.map +1 -0
- package/dist/commands/completion.d.ts +27 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +42 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +14 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +85 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +25 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +198 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/exports.d.ts +12 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +80 -0
- package/dist/commands/exports.js.map +1 -0
- package/dist/commands/health.d.ts +12 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +53 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/keys.d.ts +14 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +91 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/login.d.ts +36 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +78 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +25 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +43 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/org.d.ts +26 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +396 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/provision.d.ts +47 -0
- package/dist/commands/provision.d.ts.map +1 -0
- package/dist/commands/provision.js +400 -0
- package/dist/commands/provision.js.map +1 -0
- package/dist/commands/sessions.d.ts +14 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +122 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/stats.d.ts +12 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +46 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/user-claim.d.ts +17 -0
- package/dist/commands/user-claim.d.ts.map +1 -0
- package/dist/commands/user-claim.js +123 -0
- package/dist/commands/user-claim.js.map +1 -0
- package/dist/commands/user-role.d.ts +17 -0
- package/dist/commands/user-role.d.ts.map +1 -0
- package/dist/commands/user-role.js +118 -0
- package/dist/commands/user-role.js.map +1 -0
- package/dist/commands/user.d.ts +26 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +352 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/version.d.ts +25 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +83 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/commands/whoami.d.ts +26 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +66 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/credential-store.d.ts +101 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/credential-store.js +121 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/error-handler.d.ts +47 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +166 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/global-options.d.ts +50 -0
- package/dist/global-options.d.ts.map +1 -0
- package/dist/global-options.js +62 -0
- package/dist/global-options.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +75 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +100 -0
- package/dist/output.js.map +1 -0
- package/dist/parsers.d.ts +74 -0
- package/dist/parsers.d.ts.map +1 -0
- package/dist/parsers.js +125 -0
- package/dist/parsers.js.map +1 -0
- package/dist/prompt.d.ts +50 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +98 -0
- package/dist/prompt.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument parsers for complex flag values.
|
|
3
|
+
*
|
|
4
|
+
* Provides parsing functions for CLI flags that accept structured
|
|
5
|
+
* input, such as comma-separated lists. Used by command modules
|
|
6
|
+
* to validate and transform raw yargs argument strings.
|
|
7
|
+
*
|
|
8
|
+
* @module parsers
|
|
9
|
+
*/
|
|
10
|
+
/** Valid login method values */
|
|
11
|
+
declare const VALID_LOGIN_METHODS: readonly ["password", "magic_link"];
|
|
12
|
+
export type LoginMethod = (typeof VALID_LOGIN_METHODS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Parses a comma-separated list of login methods.
|
|
15
|
+
*
|
|
16
|
+
* Validates that each method is one of the allowed values.
|
|
17
|
+
* Used by `porta client login-methods set` and related commands.
|
|
18
|
+
*
|
|
19
|
+
* @param input - Comma-separated string (e.g., "password,magic_link")
|
|
20
|
+
* @returns Array of validated login methods
|
|
21
|
+
* @throws Error if any method is invalid
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* parseLoginMethods('password,magic_link');
|
|
26
|
+
* // Returns: ['password', 'magic_link']
|
|
27
|
+
*
|
|
28
|
+
* parseLoginMethods('password');
|
|
29
|
+
* // Returns: ['password']
|
|
30
|
+
*
|
|
31
|
+
* parseLoginMethods('invalid');
|
|
32
|
+
* // Throws: Error('Invalid login method: "invalid"...')
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseLoginMethods(input: string): LoginMethod[];
|
|
36
|
+
/**
|
|
37
|
+
* Parses the `--login-methods` flag with tri-state semantics.
|
|
38
|
+
*
|
|
39
|
+
* Three-state return semantics mirror the service-layer contract:
|
|
40
|
+
*
|
|
41
|
+
* | CLI input | Return value | Meaning |
|
|
42
|
+
* | ------------------------------------- | ----------------------------- | -------------------------------------------- |
|
|
43
|
+
* | flag omitted | `undefined` | Leave the field unchanged |
|
|
44
|
+
* | `--login-methods inherit` (client) | `null` | Reset client override → inherit org default |
|
|
45
|
+
* | `--login-methods password` | `['password']` | Explicit override |
|
|
46
|
+
* | `--login-methods password,magic_link` | `['password', 'magic_link']` | Explicit override (multiple) |
|
|
47
|
+
*
|
|
48
|
+
* The `inherit` sentinel is only accepted when `allowInherit` is `true`
|
|
49
|
+
* (i.e. on client commands). Organization commands pass `false` because
|
|
50
|
+
* `null` is not a valid value for `defaultLoginMethods` at the DB level.
|
|
51
|
+
*
|
|
52
|
+
* @param value - Raw CLI string; `undefined` if the flag was not provided
|
|
53
|
+
* @param allowInherit - Whether to accept the `inherit` sentinel → `null` mapping
|
|
54
|
+
* @returns `undefined` (omit), `null` (inherit), or a non-empty `LoginMethod[]`
|
|
55
|
+
* @throws Error when value is empty, contains unknown methods, or is `inherit` on an org command
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseLoginMethodsFlag(value: string | undefined, allowInherit: boolean): LoginMethod[] | null | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Parses a comma-separated string into an array of trimmed strings.
|
|
60
|
+
*
|
|
61
|
+
* @param input - Comma-separated string
|
|
62
|
+
* @returns Array of trimmed, non-empty strings
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseCommaSeparated(input: string): string[];
|
|
65
|
+
/**
|
|
66
|
+
* Parses a key=value string into a [key, value] tuple.
|
|
67
|
+
*
|
|
68
|
+
* @param input - String in "key=value" format
|
|
69
|
+
* @returns Tuple of [key, value]
|
|
70
|
+
* @throws Error if input doesn't contain '='
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseKeyValue(input: string): [string, string];
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,gCAAgC;AAChC,QAAA,MAAM,mBAAmB,qCAAsC,CAAC;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAY9D;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,GACpB,WAAW,EAAE,GAAG,IAAI,GAAG,SAAS,CAoClC;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAK3D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAM7D"}
|
package/dist/parsers.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument parsers for complex flag values.
|
|
3
|
+
*
|
|
4
|
+
* Provides parsing functions for CLI flags that accept structured
|
|
5
|
+
* input, such as comma-separated lists. Used by command modules
|
|
6
|
+
* to validate and transform raw yargs argument strings.
|
|
7
|
+
*
|
|
8
|
+
* @module parsers
|
|
9
|
+
*/
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Login Methods Parser
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/** Valid login method values */
|
|
14
|
+
const VALID_LOGIN_METHODS = ['password', 'magic_link'];
|
|
15
|
+
/**
|
|
16
|
+
* Parses a comma-separated list of login methods.
|
|
17
|
+
*
|
|
18
|
+
* Validates that each method is one of the allowed values.
|
|
19
|
+
* Used by `porta client login-methods set` and related commands.
|
|
20
|
+
*
|
|
21
|
+
* @param input - Comma-separated string (e.g., "password,magic_link")
|
|
22
|
+
* @returns Array of validated login methods
|
|
23
|
+
* @throws Error if any method is invalid
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* parseLoginMethods('password,magic_link');
|
|
28
|
+
* // Returns: ['password', 'magic_link']
|
|
29
|
+
*
|
|
30
|
+
* parseLoginMethods('password');
|
|
31
|
+
* // Returns: ['password']
|
|
32
|
+
*
|
|
33
|
+
* parseLoginMethods('invalid');
|
|
34
|
+
* // Throws: Error('Invalid login method: "invalid"...')
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function parseLoginMethods(input) {
|
|
38
|
+
const methods = input.split(',').map((m) => m.trim().toLowerCase());
|
|
39
|
+
for (const method of methods) {
|
|
40
|
+
if (!VALID_LOGIN_METHODS.includes(method)) {
|
|
41
|
+
throw new Error(`Invalid login method: "${method}". Valid values: ${VALID_LOGIN_METHODS.join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return methods;
|
|
45
|
+
}
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Login Methods Flag Parser (tri-state for client commands)
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
/**
|
|
50
|
+
* Parses the `--login-methods` flag with tri-state semantics.
|
|
51
|
+
*
|
|
52
|
+
* Three-state return semantics mirror the service-layer contract:
|
|
53
|
+
*
|
|
54
|
+
* | CLI input | Return value | Meaning |
|
|
55
|
+
* | ------------------------------------- | ----------------------------- | -------------------------------------------- |
|
|
56
|
+
* | flag omitted | `undefined` | Leave the field unchanged |
|
|
57
|
+
* | `--login-methods inherit` (client) | `null` | Reset client override → inherit org default |
|
|
58
|
+
* | `--login-methods password` | `['password']` | Explicit override |
|
|
59
|
+
* | `--login-methods password,magic_link` | `['password', 'magic_link']` | Explicit override (multiple) |
|
|
60
|
+
*
|
|
61
|
+
* The `inherit` sentinel is only accepted when `allowInherit` is `true`
|
|
62
|
+
* (i.e. on client commands). Organization commands pass `false` because
|
|
63
|
+
* `null` is not a valid value for `defaultLoginMethods` at the DB level.
|
|
64
|
+
*
|
|
65
|
+
* @param value - Raw CLI string; `undefined` if the flag was not provided
|
|
66
|
+
* @param allowInherit - Whether to accept the `inherit` sentinel → `null` mapping
|
|
67
|
+
* @returns `undefined` (omit), `null` (inherit), or a non-empty `LoginMethod[]`
|
|
68
|
+
* @throws Error when value is empty, contains unknown methods, or is `inherit` on an org command
|
|
69
|
+
*/
|
|
70
|
+
export function parseLoginMethodsFlag(value, allowInherit) {
|
|
71
|
+
if (value === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
const trimmed = value.trim();
|
|
74
|
+
if (trimmed.toLowerCase() === 'inherit') {
|
|
75
|
+
if (!allowInherit) {
|
|
76
|
+
throw new Error('--login-methods: "inherit" is only valid on client commands (orgs require explicit methods)');
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const parts = trimmed
|
|
81
|
+
.split(',')
|
|
82
|
+
.map((s) => s.trim())
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
if (parts.length === 0) {
|
|
85
|
+
throw new Error(allowInherit
|
|
86
|
+
? '--login-methods must not be empty (use "inherit" to reset to org default)'
|
|
87
|
+
: '--login-methods must not be empty');
|
|
88
|
+
}
|
|
89
|
+
for (const p of parts) {
|
|
90
|
+
if (!VALID_LOGIN_METHODS.includes(p)) {
|
|
91
|
+
throw new Error(`--login-methods: unknown method "${p}" (valid: ${VALID_LOGIN_METHODS.join(', ')})`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return parts;
|
|
95
|
+
}
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Generic Parsers
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
/**
|
|
100
|
+
* Parses a comma-separated string into an array of trimmed strings.
|
|
101
|
+
*
|
|
102
|
+
* @param input - Comma-separated string
|
|
103
|
+
* @returns Array of trimmed, non-empty strings
|
|
104
|
+
*/
|
|
105
|
+
export function parseCommaSeparated(input) {
|
|
106
|
+
return input
|
|
107
|
+
.split(',')
|
|
108
|
+
.map((s) => s.trim())
|
|
109
|
+
.filter((s) => s.length > 0);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Parses a key=value string into a [key, value] tuple.
|
|
113
|
+
*
|
|
114
|
+
* @param input - String in "key=value" format
|
|
115
|
+
* @returns Tuple of [key, value]
|
|
116
|
+
* @throws Error if input doesn't contain '='
|
|
117
|
+
*/
|
|
118
|
+
export function parseKeyValue(input) {
|
|
119
|
+
const idx = input.indexOf('=');
|
|
120
|
+
if (idx === -1) {
|
|
121
|
+
throw new Error(`Invalid key=value format: "${input}". Expected "key=value".`);
|
|
122
|
+
}
|
|
123
|
+
return [input.slice(0, idx).trim(), input.slice(idx + 1).trim()];
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=parsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E,gCAAgC;AAChC,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,YAAY,CAAU,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAAC,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C;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAgB,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CACb,oCAAoC,CAAC,aAAa,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACpF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,KAAsB,CAAC;AAChC,CAAC;AAED,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,0BAA0B,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive prompt helpers for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides confirmation, text input, and password prompts using
|
|
5
|
+
* Node.js readline. All prompts respect the `--force` flag —
|
|
6
|
+
* when set, confirmation prompts auto-approve and the command
|
|
7
|
+
* proceeds without user interaction.
|
|
8
|
+
*
|
|
9
|
+
* @module prompt
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Asks the user for yes/no confirmation.
|
|
13
|
+
*
|
|
14
|
+
* Displays the message and waits for 'y' or 'n' input.
|
|
15
|
+
* Returns true if the user confirms, false otherwise.
|
|
16
|
+
*
|
|
17
|
+
* @param message - The confirmation question
|
|
18
|
+
* @returns true if the user answers 'y' or 'yes'
|
|
19
|
+
*/
|
|
20
|
+
export declare function confirm(message: string): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Asks the user for type-to-confirm input.
|
|
23
|
+
*
|
|
24
|
+
* Used for destructive operations (e.g., `porta org destroy`).
|
|
25
|
+
* Requires the user to type the exact expected value to confirm.
|
|
26
|
+
*
|
|
27
|
+
* @param message - The prompt message
|
|
28
|
+
* @param expected - The value the user must type to confirm
|
|
29
|
+
* @returns true if the input matches the expected value
|
|
30
|
+
*/
|
|
31
|
+
export declare function confirmTyped(message: string, expected: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Prompts the user for text input.
|
|
34
|
+
*
|
|
35
|
+
* @param prompt - The prompt message to display
|
|
36
|
+
* @returns The user's input string
|
|
37
|
+
*/
|
|
38
|
+
export declare function question(prompt: string): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Prompts the user for password input (hidden).
|
|
41
|
+
*
|
|
42
|
+
* Masks input characters with asterisks. Uses the readline
|
|
43
|
+
* `_writeToOutput` override to suppress echo while still
|
|
44
|
+
* showing the prompt.
|
|
45
|
+
*
|
|
46
|
+
* @param prompt - The prompt message to display
|
|
47
|
+
* @returns The entered password string
|
|
48
|
+
*/
|
|
49
|
+
export declare function password(prompt: string): Promise<string>;
|
|
50
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG/D;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGtF;AAMD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9D;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyB9D"}
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive prompt helpers for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides confirmation, text input, and password prompts using
|
|
5
|
+
* Node.js readline. All prompts respect the `--force` flag —
|
|
6
|
+
* when set, confirmation prompts auto-approve and the command
|
|
7
|
+
* proceeds without user interaction.
|
|
8
|
+
*
|
|
9
|
+
* @module prompt
|
|
10
|
+
*/
|
|
11
|
+
import { createInterface } from 'node:readline';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Confirmation Prompt
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Asks the user for yes/no confirmation.
|
|
17
|
+
*
|
|
18
|
+
* Displays the message and waits for 'y' or 'n' input.
|
|
19
|
+
* Returns true if the user confirms, false otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @param message - The confirmation question
|
|
22
|
+
* @returns true if the user answers 'y' or 'yes'
|
|
23
|
+
*/
|
|
24
|
+
export async function confirm(message) {
|
|
25
|
+
const answer = await question(`${message} [y/N] `);
|
|
26
|
+
return answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Asks the user for type-to-confirm input.
|
|
30
|
+
*
|
|
31
|
+
* Used for destructive operations (e.g., `porta org destroy`).
|
|
32
|
+
* Requires the user to type the exact expected value to confirm.
|
|
33
|
+
*
|
|
34
|
+
* @param message - The prompt message
|
|
35
|
+
* @param expected - The value the user must type to confirm
|
|
36
|
+
* @returns true if the input matches the expected value
|
|
37
|
+
*/
|
|
38
|
+
export async function confirmTyped(message, expected) {
|
|
39
|
+
const answer = await question(`${message}: `);
|
|
40
|
+
return answer === expected;
|
|
41
|
+
}
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Input Prompts
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
/**
|
|
46
|
+
* Prompts the user for text input.
|
|
47
|
+
*
|
|
48
|
+
* @param prompt - The prompt message to display
|
|
49
|
+
* @returns The user's input string
|
|
50
|
+
*/
|
|
51
|
+
export async function question(prompt) {
|
|
52
|
+
const rl = createInterface({
|
|
53
|
+
input: process.stdin,
|
|
54
|
+
output: process.stderr, // Prompt on stderr so stdout stays clean for piping
|
|
55
|
+
});
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
rl.question(prompt, (answer) => {
|
|
58
|
+
rl.close();
|
|
59
|
+
resolve(answer.trim());
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Prompts the user for password input (hidden).
|
|
65
|
+
*
|
|
66
|
+
* Masks input characters with asterisks. Uses the readline
|
|
67
|
+
* `_writeToOutput` override to suppress echo while still
|
|
68
|
+
* showing the prompt.
|
|
69
|
+
*
|
|
70
|
+
* @param prompt - The prompt message to display
|
|
71
|
+
* @returns The entered password string
|
|
72
|
+
*/
|
|
73
|
+
export async function password(prompt) {
|
|
74
|
+
const rl = createInterface({
|
|
75
|
+
input: process.stdin,
|
|
76
|
+
output: process.stderr,
|
|
77
|
+
});
|
|
78
|
+
// Suppress echoing of password characters
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
rl._writeToOutput = function _writeToOutput(str) {
|
|
81
|
+
if (str.includes(prompt)) {
|
|
82
|
+
// Show the prompt itself
|
|
83
|
+
process.stderr.write(str);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Mask password characters with asterisks
|
|
87
|
+
process.stderr.write('*');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return new Promise((resolve) => {
|
|
91
|
+
rl.question(prompt, (answer) => {
|
|
92
|
+
process.stderr.write('\n'); // New line after hidden input
|
|
93
|
+
rl.close();
|
|
94
|
+
resolve(answer);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAe;IAC3C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;AACxE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,QAAgB;IAClE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IAC9C,OAAO,MAAM,KAAK,QAAQ,CAAC;AAC7B,CAAC;AAED,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;GAKG;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AAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@portaidentity/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standalone CLI for the Porta Identity Platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"porta": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts'",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"verify": "yarn lint && yarn typecheck && yarn test && yarn build",
|
|
19
|
+
"clean": "rm -rf dist"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@portaidentity/sdk": "0.1.0",
|
|
23
|
+
"chalk": "^5.0.0",
|
|
24
|
+
"cli-table3": "^0.6.0",
|
|
25
|
+
"jose": "^6.2.3",
|
|
26
|
+
"open": "^11.0.0",
|
|
27
|
+
"yaml": "^2.8.4",
|
|
28
|
+
"yargs": "^18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@eslint/js": "^10.0.0",
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"@types/yargs": "^17.0.0",
|
|
34
|
+
"eslint": "^10.3.0",
|
|
35
|
+
"eslint-config-prettier": "^10.0.0",
|
|
36
|
+
"typescript": "^6.0.0",
|
|
37
|
+
"typescript-eslint": "^8.59.2",
|
|
38
|
+
"vitest": "^4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|