@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,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI user custom claim value subcommands.
|
|
3
|
+
*
|
|
4
|
+
* Manages custom claim values for users within an organization.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* porta user claims list --org <org-id> <user-id>
|
|
8
|
+
* porta user claims set --org <org-id> <user-id> --claim <claim-id> --value <value>
|
|
9
|
+
* porta user claims remove --org <org-id> <user-id> --claim <claim-id>
|
|
10
|
+
*
|
|
11
|
+
* @module commands/user-claim
|
|
12
|
+
*/
|
|
13
|
+
import { createClient } from '../client-factory.js';
|
|
14
|
+
import { handleError } from '../error-handler.js';
|
|
15
|
+
import { printTable, printJson, success, warn, info, truncate } from '../output.js';
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Command definition
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/** User claims subcommand group — registered under `user` */
|
|
20
|
+
export const userClaimsCommand = {
|
|
21
|
+
command: 'claims',
|
|
22
|
+
describe: 'Manage user custom claim values',
|
|
23
|
+
builder: (yargs) => {
|
|
24
|
+
return yargs
|
|
25
|
+
// ── list ───────────────────────────────────────────────────────
|
|
26
|
+
.command('list <user-id>', 'List custom claim values for a user', (y) => y
|
|
27
|
+
.positional('user-id', {
|
|
28
|
+
type: 'string',
|
|
29
|
+
demandOption: true,
|
|
30
|
+
description: 'User UUID',
|
|
31
|
+
})
|
|
32
|
+
.option('org', {
|
|
33
|
+
type: 'string',
|
|
34
|
+
demandOption: true,
|
|
35
|
+
description: 'Organization UUID',
|
|
36
|
+
}), async (argv) => {
|
|
37
|
+
try {
|
|
38
|
+
const sdkClient = createClient(argv);
|
|
39
|
+
const claims = await sdkClient.userClaims.list(argv.org, argv['user-id']);
|
|
40
|
+
if (claims.length === 0) {
|
|
41
|
+
warn('No custom claims set');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (argv.json) {
|
|
45
|
+
printJson(claims);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
printTable(['Claim ID', 'Claim Name', 'Value'], claims.map((c) => [
|
|
49
|
+
truncate(c.claimDefinitionId, 8),
|
|
50
|
+
c.claimName ?? '—',
|
|
51
|
+
String(c.value),
|
|
52
|
+
]));
|
|
53
|
+
info(`Total: ${claims.length} claims`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
handleError(err, argv.verbose);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
// ── set ────────────────────────────────────────────────────────
|
|
61
|
+
.command('set <user-id>', 'Set a custom claim value for a user', (y) => y
|
|
62
|
+
.positional('user-id', {
|
|
63
|
+
type: 'string',
|
|
64
|
+
demandOption: true,
|
|
65
|
+
description: 'User UUID',
|
|
66
|
+
})
|
|
67
|
+
.option('org', {
|
|
68
|
+
type: 'string',
|
|
69
|
+
demandOption: true,
|
|
70
|
+
description: 'Organization UUID',
|
|
71
|
+
})
|
|
72
|
+
.option('claim', {
|
|
73
|
+
type: 'string',
|
|
74
|
+
demandOption: true,
|
|
75
|
+
description: 'Claim definition UUID',
|
|
76
|
+
})
|
|
77
|
+
.option('value', {
|
|
78
|
+
type: 'string',
|
|
79
|
+
demandOption: true,
|
|
80
|
+
description: 'Claim value',
|
|
81
|
+
}), async (argv) => {
|
|
82
|
+
try {
|
|
83
|
+
const sdkClient = createClient(argv);
|
|
84
|
+
await sdkClient.userClaims.set(argv.org, argv['user-id'], argv.claim, argv.value);
|
|
85
|
+
success(`Claim ${argv.claim} set for user ${argv['user-id']}`);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
handleError(err, argv.verbose);
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
// ── remove ─────────────────────────────────────────────────────
|
|
92
|
+
.command('remove <user-id>', 'Remove a custom claim value from a user', (y) => y
|
|
93
|
+
.positional('user-id', {
|
|
94
|
+
type: 'string',
|
|
95
|
+
demandOption: true,
|
|
96
|
+
description: 'User UUID',
|
|
97
|
+
})
|
|
98
|
+
.option('org', {
|
|
99
|
+
type: 'string',
|
|
100
|
+
demandOption: true,
|
|
101
|
+
description: 'Organization UUID',
|
|
102
|
+
})
|
|
103
|
+
.option('claim', {
|
|
104
|
+
type: 'string',
|
|
105
|
+
demandOption: true,
|
|
106
|
+
description: 'Claim definition UUID to remove',
|
|
107
|
+
}), async (argv) => {
|
|
108
|
+
try {
|
|
109
|
+
const sdkClient = createClient(argv);
|
|
110
|
+
await sdkClient.userClaims.remove(argv.org, argv['user-id'], argv.claim);
|
|
111
|
+
success(`Claim ${argv.claim} removed from user ${argv['user-id']}`);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
handleError(err, argv.verbose);
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
.demandCommand(1, 'Specify a claims subcommand: list, set, remove');
|
|
118
|
+
},
|
|
119
|
+
handler: () => {
|
|
120
|
+
// No-op — subcommands handle execution
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=user-claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-claim.js","sourceRoot":"","sources":["../../src/commands/user-claim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG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ACD,OAAO,EAAE,GAAG,EAAE;QACZ,uCAAuC;IACzC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI user role assignment subcommands.
|
|
3
|
+
*
|
|
4
|
+
* Manages role assignments for users within an organization.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* porta user roles list --org <org-id> <user-id>
|
|
8
|
+
* porta user roles assign --org <org-id> <user-id> --role <role-id>
|
|
9
|
+
* porta user roles remove --org <org-id> <user-id> --role <role-id>
|
|
10
|
+
*
|
|
11
|
+
* @module commands/user-role
|
|
12
|
+
*/
|
|
13
|
+
import type { CommandModule } from 'yargs';
|
|
14
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
15
|
+
/** User roles subcommand group — registered under `user` */
|
|
16
|
+
export declare const userRolesCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
17
|
+
//# sourceMappingURL=user-role.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-role.d.ts","sourceRoot":"","sources":["../../src/commands/user-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAuB1D,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAsHxE,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI user role assignment subcommands.
|
|
3
|
+
*
|
|
4
|
+
* Manages role assignments for users within an organization.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* porta user roles list --org <org-id> <user-id>
|
|
8
|
+
* porta user roles assign --org <org-id> <user-id> --role <role-id>
|
|
9
|
+
* porta user roles remove --org <org-id> <user-id> --role <role-id>
|
|
10
|
+
*
|
|
11
|
+
* @module commands/user-role
|
|
12
|
+
*/
|
|
13
|
+
import { createClient } from '../client-factory.js';
|
|
14
|
+
import { handleError } from '../error-handler.js';
|
|
15
|
+
import { printTable, printJson, success, warn, info, formatDate, truncate } from '../output.js';
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Command definition
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/** User roles subcommand group — registered under `user` */
|
|
20
|
+
export const userRolesCommand = {
|
|
21
|
+
command: 'roles',
|
|
22
|
+
describe: 'Manage user role assignments',
|
|
23
|
+
builder: (yargs) => {
|
|
24
|
+
return yargs
|
|
25
|
+
// ── list ───────────────────────────────────────────────────────
|
|
26
|
+
.command('list <user-id>', 'List roles assigned to a user', (y) => y
|
|
27
|
+
.positional('user-id', {
|
|
28
|
+
type: 'string',
|
|
29
|
+
demandOption: true,
|
|
30
|
+
description: 'User UUID',
|
|
31
|
+
})
|
|
32
|
+
.option('org', {
|
|
33
|
+
type: 'string',
|
|
34
|
+
demandOption: true,
|
|
35
|
+
description: 'Organization UUID',
|
|
36
|
+
}), async (argv) => {
|
|
37
|
+
try {
|
|
38
|
+
const sdkClient = createClient(argv);
|
|
39
|
+
const roles = await sdkClient.userRoles.list(argv.org, argv['user-id']);
|
|
40
|
+
if (roles.length === 0) {
|
|
41
|
+
warn('No roles assigned');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (argv.json) {
|
|
45
|
+
printJson(roles);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
printTable(['Role ID', 'Role Name', 'Assigned At'], roles.map((r) => [
|
|
49
|
+
truncate(r.roleId, 8),
|
|
50
|
+
r.roleName ?? '—',
|
|
51
|
+
r.assignedAt ? formatDate(r.assignedAt) : '—',
|
|
52
|
+
]));
|
|
53
|
+
info(`Total: ${roles.length} roles`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
handleError(err, argv.verbose);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
// ── assign ─────────────────────────────────────────────────────
|
|
61
|
+
.command('assign <user-id>', 'Assign a role to a user', (y) => y
|
|
62
|
+
.positional('user-id', {
|
|
63
|
+
type: 'string',
|
|
64
|
+
demandOption: true,
|
|
65
|
+
description: 'User UUID',
|
|
66
|
+
})
|
|
67
|
+
.option('org', {
|
|
68
|
+
type: 'string',
|
|
69
|
+
demandOption: true,
|
|
70
|
+
description: 'Organization UUID',
|
|
71
|
+
})
|
|
72
|
+
.option('role', {
|
|
73
|
+
type: 'string',
|
|
74
|
+
demandOption: true,
|
|
75
|
+
description: 'Role UUID to assign',
|
|
76
|
+
}), async (argv) => {
|
|
77
|
+
try {
|
|
78
|
+
const sdkClient = createClient(argv);
|
|
79
|
+
await sdkClient.userRoles.assign(argv.org, argv['user-id'], argv.role);
|
|
80
|
+
success(`Role ${argv.role} assigned to user ${argv['user-id']}`);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
handleError(err, argv.verbose);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
// ── remove ─────────────────────────────────────────────────────
|
|
87
|
+
.command('remove <user-id>', 'Remove a role from a user', (y) => y
|
|
88
|
+
.positional('user-id', {
|
|
89
|
+
type: 'string',
|
|
90
|
+
demandOption: true,
|
|
91
|
+
description: 'User UUID',
|
|
92
|
+
})
|
|
93
|
+
.option('org', {
|
|
94
|
+
type: 'string',
|
|
95
|
+
demandOption: true,
|
|
96
|
+
description: 'Organization UUID',
|
|
97
|
+
})
|
|
98
|
+
.option('role', {
|
|
99
|
+
type: 'string',
|
|
100
|
+
demandOption: true,
|
|
101
|
+
description: 'Role UUID to remove',
|
|
102
|
+
}), async (argv) => {
|
|
103
|
+
try {
|
|
104
|
+
const sdkClient = createClient(argv);
|
|
105
|
+
await sdkClient.userRoles.remove(argv.org, argv['user-id'], argv.role);
|
|
106
|
+
success(`Role ${argv.role} removed from user ${argv['user-id']}`);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
handleError(err, argv.verbose);
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.demandCommand(1, 'Specify a roles subcommand: list, assign, remove');
|
|
113
|
+
},
|
|
114
|
+
handler: () => {
|
|
115
|
+
// No-op — subcommands handle execution
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=user-role.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-role.js","sourceRoot":"","sources":["../../src/commands/user-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAehG,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAgD;IAC3E,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,8BAA8B;IACxC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACjB,OAAO,KAAK;YACV,kEAAkE;aACjE,OAAO,CACN,gBAAgB,EAChB,+BAA+B,EAC/B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;aACE,UAAU,CAAC,SAAS,EAAE;YACrB,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,WAAW;SACzB,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,mBAAmB;SACjC,CAAC,EACN,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,IAAI,CAAC;gBACH,MAAM,SAAS,GAAG,YAAY,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,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvE,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACpE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;QACH,CAAC,CACF;aACA,aAAa,CAAC,CAAC,EAAE,kDAAkD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,EAAE,GAAG,EAAE;QACZ,uCAAuC;IACzC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI user management commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD, status lifecycle, password management, and nested
|
|
5
|
+
* role/claim subcommands for users within an organization.
|
|
6
|
+
* All operations are org-scoped (require --org flag).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* porta user create --org <id> --email <email> [--name "..."] [--password "..."]
|
|
10
|
+
* porta user invite --org <id> --email <email> [--name "..."]
|
|
11
|
+
* porta user list --org <id> [--status active|invited|...] [--search "..."]
|
|
12
|
+
* porta user show --org <id> <user-id>
|
|
13
|
+
* porta user update --org <id> <user-id> [--name "..."] [--email "..."]
|
|
14
|
+
* porta user suspend/reactivate/lock/unlock/deactivate --org <id> <user-id>
|
|
15
|
+
* porta user set-password --org <id> <user-id> --password "..."
|
|
16
|
+
* porta user history --org <id> <user-id>
|
|
17
|
+
* porta user roles <subcommand> ...
|
|
18
|
+
* porta user claims <subcommand> ...
|
|
19
|
+
*
|
|
20
|
+
* @module commands/user
|
|
21
|
+
*/
|
|
22
|
+
import type { CommandModule } from 'yargs';
|
|
23
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
24
|
+
/** The user command module — registered at the top level of the CLI */
|
|
25
|
+
export declare const userCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
26
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/commands/user.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAwE1D,uEAAuE;AACvE,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAyanE,CAAC"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI user management commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD, status lifecycle, password management, and nested
|
|
5
|
+
* role/claim subcommands for users within an organization.
|
|
6
|
+
* All operations are org-scoped (require --org flag).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* porta user create --org <id> --email <email> [--name "..."] [--password "..."]
|
|
10
|
+
* porta user invite --org <id> --email <email> [--name "..."]
|
|
11
|
+
* porta user list --org <id> [--status active|invited|...] [--search "..."]
|
|
12
|
+
* porta user show --org <id> <user-id>
|
|
13
|
+
* porta user update --org <id> <user-id> [--name "..."] [--email "..."]
|
|
14
|
+
* porta user suspend/reactivate/lock/unlock/deactivate --org <id> <user-id>
|
|
15
|
+
* porta user set-password --org <id> <user-id> --password "..."
|
|
16
|
+
* porta user history --org <id> <user-id>
|
|
17
|
+
* porta user roles <subcommand> ...
|
|
18
|
+
* porta user claims <subcommand> ...
|
|
19
|
+
*
|
|
20
|
+
* @module commands/user
|
|
21
|
+
*/
|
|
22
|
+
import { createClient } from '../client-factory.js';
|
|
23
|
+
import { handleError } from '../error-handler.js';
|
|
24
|
+
import { printTable, printJson, success, warn, info, formatDate, truncate, } from '../output.js';
|
|
25
|
+
import { confirm } from '../prompt.js';
|
|
26
|
+
import { userRolesCommand } from './user-role.js';
|
|
27
|
+
import { userClaimsCommand } from './user-claim.js';
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Shared option builder for --org
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
function withOrgOption(y) {
|
|
32
|
+
return y.option('org', {
|
|
33
|
+
type: 'string',
|
|
34
|
+
demandOption: true,
|
|
35
|
+
description: 'Organization UUID',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Command definition
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
/** The user command module — registered at the top level of the CLI */
|
|
42
|
+
export const userCommand = {
|
|
43
|
+
command: 'user',
|
|
44
|
+
describe: 'Manage users within an organization',
|
|
45
|
+
builder: (yargs) => {
|
|
46
|
+
return yargs
|
|
47
|
+
// ── create ──────────────────────────────────────────────────────
|
|
48
|
+
.command('create', 'Create a new user', (y) => withOrgOption(y)
|
|
49
|
+
.option('email', {
|
|
50
|
+
type: 'string',
|
|
51
|
+
demandOption: true,
|
|
52
|
+
description: 'User email address',
|
|
53
|
+
})
|
|
54
|
+
.option('name', {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'User display name',
|
|
57
|
+
})
|
|
58
|
+
.option('password', {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Initial password (optional — passwordless if omitted)',
|
|
61
|
+
}), async (argv) => {
|
|
62
|
+
try {
|
|
63
|
+
const sdkClient = createClient(argv);
|
|
64
|
+
const user = await sdkClient.users.create({
|
|
65
|
+
organizationId: argv.org,
|
|
66
|
+
email: argv.email,
|
|
67
|
+
name: argv.name,
|
|
68
|
+
password: argv.password,
|
|
69
|
+
});
|
|
70
|
+
if (argv.json) {
|
|
71
|
+
printJson(user);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
success(`User created: ${user.email}`);
|
|
75
|
+
printTable(['Field', 'Value'], [
|
|
76
|
+
['ID', user.id],
|
|
77
|
+
['Email', user.email],
|
|
78
|
+
['Name', user.name ?? '—'],
|
|
79
|
+
['Status', user.status],
|
|
80
|
+
['Created', formatDate(user.createdAt)],
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
handleError(err, argv.verbose);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
// ── invite ──────────────────────────────────────────────────────
|
|
89
|
+
.command('invite', 'Invite a user via email', (y) => withOrgOption(y)
|
|
90
|
+
.option('email', {
|
|
91
|
+
type: 'string',
|
|
92
|
+
demandOption: true,
|
|
93
|
+
description: 'Email address to invite',
|
|
94
|
+
})
|
|
95
|
+
.option('name', {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Invitee display name',
|
|
98
|
+
}), async (argv) => {
|
|
99
|
+
try {
|
|
100
|
+
const sdkClient = createClient(argv);
|
|
101
|
+
const user = await sdkClient.users.invite({
|
|
102
|
+
organizationId: argv.org,
|
|
103
|
+
email: argv.email,
|
|
104
|
+
name: argv.name,
|
|
105
|
+
});
|
|
106
|
+
if (argv.json) {
|
|
107
|
+
printJson(user);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
success(`Invitation sent to ${user.email}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
handleError(err, argv.verbose);
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
// ── list ────────────────────────────────────────────────────────
|
|
118
|
+
.command('list', 'List users in an organization', (y) => withOrgOption(y)
|
|
119
|
+
.option('status', {
|
|
120
|
+
type: 'string',
|
|
121
|
+
choices: ['active', 'invited', 'suspended', 'locked', 'deactivated'],
|
|
122
|
+
description: 'Filter by status',
|
|
123
|
+
})
|
|
124
|
+
.option('search', {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'Search by email or name',
|
|
127
|
+
})
|
|
128
|
+
.option('page', {
|
|
129
|
+
type: 'number',
|
|
130
|
+
default: 1,
|
|
131
|
+
description: 'Page number',
|
|
132
|
+
})
|
|
133
|
+
.option('page-size', {
|
|
134
|
+
type: 'number',
|
|
135
|
+
default: 20,
|
|
136
|
+
description: 'Items per page',
|
|
137
|
+
}), async (argv) => {
|
|
138
|
+
try {
|
|
139
|
+
const sdkClient = createClient(argv);
|
|
140
|
+
const result = await sdkClient.users.list(argv.org, {
|
|
141
|
+
page: argv.page,
|
|
142
|
+
pageSize: argv['page-size'],
|
|
143
|
+
...(argv.status && {
|
|
144
|
+
status: argv.status,
|
|
145
|
+
}),
|
|
146
|
+
...(argv.search && { search: argv.search }),
|
|
147
|
+
});
|
|
148
|
+
if (result.data.length === 0) {
|
|
149
|
+
warn('No users found');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (argv.json) {
|
|
153
|
+
printJson(result);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
printTable(['ID', 'Email', 'Name', 'Status', 'Last Login', 'Created'], result.data.map((u) => [
|
|
157
|
+
truncate(u.id, 8),
|
|
158
|
+
u.email,
|
|
159
|
+
u.name ?? '—',
|
|
160
|
+
u.status,
|
|
161
|
+
u.lastLoginAt ? formatDate(u.lastLoginAt) : '—',
|
|
162
|
+
formatDate(u.createdAt),
|
|
163
|
+
]));
|
|
164
|
+
info(`Total: ${result.total} users`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
handleError(err, argv.verbose);
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
// ── show ────────────────────────────────────────────────────────
|
|
172
|
+
.command('show <user-id>', 'Show user details', (y) => withOrgOption(y.positional('user-id', {
|
|
173
|
+
type: 'string',
|
|
174
|
+
demandOption: true,
|
|
175
|
+
description: 'User UUID',
|
|
176
|
+
})), async (argv) => {
|
|
177
|
+
try {
|
|
178
|
+
const sdkClient = createClient(argv);
|
|
179
|
+
const { data: u } = await sdkClient.users.get(argv.org, argv['user-id']);
|
|
180
|
+
if (argv.json) {
|
|
181
|
+
printJson(u);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
printTable(['Field', 'Value'], [
|
|
185
|
+
['ID', u.id],
|
|
186
|
+
['Email', u.email],
|
|
187
|
+
['Name', u.name ?? '—'],
|
|
188
|
+
['Status', u.status],
|
|
189
|
+
['Email Verified', u.emailVerified ? 'Yes' : 'No'],
|
|
190
|
+
['Has Password', u.hasPassword ? 'Yes' : 'No'],
|
|
191
|
+
['Failed Logins', String(u.failedLoginCount)],
|
|
192
|
+
['Last Login', u.lastLoginAt ? formatDate(u.lastLoginAt) : '—'],
|
|
193
|
+
['Locked At', u.lockedAt ? formatDate(u.lockedAt) : '—'],
|
|
194
|
+
['Created', formatDate(u.createdAt)],
|
|
195
|
+
['Updated', formatDate(u.updatedAt)],
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
handleError(err, argv.verbose);
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
// ── update ──────────────────────────────────────────────────────
|
|
204
|
+
.command('update <user-id>', 'Update user fields', (y) => withOrgOption(y.positional('user-id', {
|
|
205
|
+
type: 'string',
|
|
206
|
+
demandOption: true,
|
|
207
|
+
description: 'User UUID',
|
|
208
|
+
}))
|
|
209
|
+
.option('name', {
|
|
210
|
+
type: 'string',
|
|
211
|
+
description: 'New display name',
|
|
212
|
+
})
|
|
213
|
+
.option('email', {
|
|
214
|
+
type: 'string',
|
|
215
|
+
description: 'New email address',
|
|
216
|
+
}), async (argv) => {
|
|
217
|
+
try {
|
|
218
|
+
const sdkClient = createClient(argv);
|
|
219
|
+
const { etag } = await sdkClient.users.get(argv.org, argv['user-id']);
|
|
220
|
+
const updated = await sdkClient.users.update(argv.org, argv['user-id'], {
|
|
221
|
+
name: argv.name,
|
|
222
|
+
email: argv.email,
|
|
223
|
+
}, etag ?? undefined);
|
|
224
|
+
if (argv.json) {
|
|
225
|
+
printJson(updated);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
success(`User updated: ${updated.email}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
handleError(err, argv.verbose);
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
// ── status lifecycle commands ───────────────────────────────────
|
|
236
|
+
.command('suspend <user-id>', 'Suspend a user', (y) => withOrgOption(y.positional('user-id', { type: 'string', demandOption: true, description: 'User UUID' })), async (argv) => {
|
|
237
|
+
try {
|
|
238
|
+
const sdkClient = createClient(argv);
|
|
239
|
+
await sdkClient.users.suspend(argv.org, argv['user-id']);
|
|
240
|
+
success(`User suspended: ${argv['user-id']}`);
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
handleError(err, argv.verbose);
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
.command('reactivate <user-id>', 'Reactivate a suspended user', (y) => withOrgOption(y.positional('user-id', { type: 'string', demandOption: true, description: 'User UUID' })), async (argv) => {
|
|
247
|
+
try {
|
|
248
|
+
const sdkClient = createClient(argv);
|
|
249
|
+
await sdkClient.users.reactivate(argv.org, argv['user-id']);
|
|
250
|
+
success(`User reactivated: ${argv['user-id']}`);
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
handleError(err, argv.verbose);
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
.command('lock <user-id>', 'Lock a user account', (y) => withOrgOption(y.positional('user-id', { type: 'string', demandOption: true, description: 'User UUID' })), async (argv) => {
|
|
257
|
+
try {
|
|
258
|
+
const sdkClient = createClient(argv);
|
|
259
|
+
await sdkClient.users.lock(argv.org, argv['user-id']);
|
|
260
|
+
success(`User locked: ${argv['user-id']}`);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
handleError(err, argv.verbose);
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
.command('unlock <user-id>', 'Unlock a locked user account', (y) => withOrgOption(y.positional('user-id', { type: 'string', demandOption: true, description: 'User UUID' })), async (argv) => {
|
|
267
|
+
try {
|
|
268
|
+
const sdkClient = createClient(argv);
|
|
269
|
+
await sdkClient.users.unlock(argv.org, argv['user-id']);
|
|
270
|
+
success(`User unlocked: ${argv['user-id']}`);
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
handleError(err, argv.verbose);
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
.command('deactivate <user-id>', 'Deactivate a user (permanent)', (y) => withOrgOption(y.positional('user-id', { type: 'string', demandOption: true, description: 'User UUID' })), async (argv) => {
|
|
277
|
+
try {
|
|
278
|
+
if (!argv.force) {
|
|
279
|
+
const confirmed = await confirm(`Deactivate user ${argv['user-id']}? This action is permanent.`);
|
|
280
|
+
if (!confirmed) {
|
|
281
|
+
warn('Operation cancelled');
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const sdkClient = createClient(argv);
|
|
286
|
+
await sdkClient.users.deactivate(argv.org, argv['user-id']);
|
|
287
|
+
success(`User deactivated: ${argv['user-id']}`);
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
handleError(err, argv.verbose);
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
// ── set-password ────────────────────────────────────────────────
|
|
294
|
+
.command('set-password <user-id>', 'Set or reset a user password', (y) => withOrgOption(y.positional('user-id', {
|
|
295
|
+
type: 'string',
|
|
296
|
+
demandOption: true,
|
|
297
|
+
description: 'User UUID',
|
|
298
|
+
})).option('password', {
|
|
299
|
+
type: 'string',
|
|
300
|
+
demandOption: true,
|
|
301
|
+
description: 'New password',
|
|
302
|
+
}), async (argv) => {
|
|
303
|
+
try {
|
|
304
|
+
const sdkClient = createClient(argv);
|
|
305
|
+
await sdkClient.users.setPassword(argv.org, argv['user-id'], {
|
|
306
|
+
password: argv.password,
|
|
307
|
+
});
|
|
308
|
+
success(`Password set for user: ${argv['user-id']}`);
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
handleError(err, argv.verbose);
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
// ── history ─────────────────────────────────────────────────────
|
|
315
|
+
.command('history <user-id>', 'Show user change history', (y) => withOrgOption(y.positional('user-id', {
|
|
316
|
+
type: 'string',
|
|
317
|
+
demandOption: true,
|
|
318
|
+
description: 'User UUID',
|
|
319
|
+
})), async (argv) => {
|
|
320
|
+
try {
|
|
321
|
+
const sdkClient = createClient(argv);
|
|
322
|
+
const history = await sdkClient.users.getHistory(argv.org, argv['user-id']);
|
|
323
|
+
if (history.length === 0) {
|
|
324
|
+
warn('No history entries found');
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (argv.json) {
|
|
328
|
+
printJson(history);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
printTable(['Date', 'Action', 'Actor', 'Changes'], history.map((h) => [
|
|
332
|
+
formatDate(h.createdAt),
|
|
333
|
+
h.action,
|
|
334
|
+
h.performedBy ?? '—',
|
|
335
|
+
h.changes ? JSON.stringify(h.changes).slice(0, 60) : '—',
|
|
336
|
+
]));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
handleError(err, argv.verbose);
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
// ── nested subcommand groups ────────────────────────────────────
|
|
344
|
+
.command(userRolesCommand)
|
|
345
|
+
.command(userClaimsCommand)
|
|
346
|
+
.demandCommand(1, 'Specify a user subcommand: create, invite, list, show, update, suspend, reactivate, lock, unlock, deactivate, set-password, history, roles, claims');
|
|
347
|
+
},
|
|
348
|
+
handler: () => {
|
|
349
|
+
// No-op — subcommands handle execution
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
//# sourceMappingURL=user.js.map
|