@pnp/cli-microsoft365 10.4.0-beta.17b3a55 → 10.4.0-beta.47f1e4d

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/cli/cli.js CHANGED
@@ -159,9 +159,17 @@ async function execute(rawArgs) {
159
159
  shouldPrompt) {
160
160
  await cli.error('🌶️ Provide values for the following parameters:');
161
161
  for (const error of result.error.errors) {
162
- const optionInfo = cli.commandToExecute.options.find(o => o.name === error.path.join('.'));
162
+ const optionName = error.path.join('.');
163
+ const optionInfo = cli.commandToExecute.options.find(o => o.name === optionName);
163
164
  const answer = await cli.promptForValue(optionInfo);
164
- cli.optionsFromArgs.options[error.path.join('.')] = answer;
165
+ // coerce the answer to the correct type
166
+ try {
167
+ const parsed = getCommandOptionsFromArgs([`--${optionName}`, answer], cli.commandToExecute);
168
+ cli.optionsFromArgs.options[optionName] = parsed[optionName];
169
+ }
170
+ catch (e) {
171
+ return cli.closeWithError(e.message, cli.optionsFromArgs, true);
172
+ }
165
173
  }
166
174
  }
167
175
  else {
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import GraphCommand from '../../../base/GraphCommand.js';
5
+ import commands from '../../commands.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import request from '../../../../request.js';
8
+ import { cli } from '../../../../cli/cli.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ const options = globalOptionsZod
11
+ .extend({
12
+ userId: zod.alias('i', z.string().refine(id => validation.isValidGuid(id), id => ({
13
+ message: `'${id}' is not a valid GUID.`
14
+ })).optional()),
15
+ userName: zod.alias('n', z.string().refine(name => validation.isValidUserPrincipalName(name), name => ({
16
+ message: `'${name}' is not a valid UPN.`
17
+ })).optional()),
18
+ force: zod.alias('f', z.boolean().optional())
19
+ })
20
+ .strict();
21
+ class EntraUserSessionRevokeCommand extends GraphCommand {
22
+ get name() {
23
+ return commands.USER_SESSION_REVOKE;
24
+ }
25
+ get description() {
26
+ return 'Revokes all sign-in sessions for a given user';
27
+ }
28
+ get schema() {
29
+ return options;
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine(options => [options.userId, options.userName].filter(o => o !== undefined).length === 1, {
34
+ message: `Specify either 'userId' or 'userName'.`
35
+ });
36
+ }
37
+ async commandAction(logger, args) {
38
+ const revokeUserSessions = async () => {
39
+ try {
40
+ const userIdentifier = args.options.userId ?? args.options.userName;
41
+ if (this.verbose) {
42
+ await logger.logToStderr(`Invalidating all the refresh tokens for user ${userIdentifier}...`);
43
+ }
44
+ const requestOptions = {
45
+ url: `${this.resource}/v1.0/users('${formatting.encodeQueryParameter(userIdentifier)}')/revokeSignInSessions`,
46
+ headers: {
47
+ accept: 'application/json;odata.metadata=none'
48
+ },
49
+ responseType: 'json',
50
+ data: {}
51
+ };
52
+ await request.post(requestOptions);
53
+ }
54
+ catch (err) {
55
+ this.handleRejectedODataJsonPromise(err);
56
+ }
57
+ };
58
+ if (args.options.force) {
59
+ await revokeUserSessions();
60
+ }
61
+ else {
62
+ const result = await cli.promptForConfirmation({ message: `This will revoke all sessions for the user '${args.options.userId || args.options.userName}', requiring the user to re-sign in from all devices. Are you sure?` });
63
+ if (result) {
64
+ await revokeUserSessions();
65
+ }
66
+ }
67
+ }
68
+ }
69
+ export default new EntraUserSessionRevokeCommand();
70
+ //# sourceMappingURL=user-session-revoke.js.map
@@ -119,6 +119,7 @@ export default {
119
119
  USER_REGISTRATIONDETAILS_LIST: `${prefix} user registrationdetails list`,
120
120
  USER_REMOVE: `${prefix} user remove`,
121
121
  USER_RECYCLEBINITEM_RESTORE: `${prefix} user recyclebinitem restore`,
122
+ USER_SESSION_REVOKE: `${prefix} user session revoke`,
122
123
  USER_SET: `${prefix} user set`,
123
124
  USER_SIGNIN_LIST: `${prefix} user signin list`
124
125
  };
@@ -0,0 +1,65 @@
1
+ import Global from '/docs/cmd/_global.mdx';
2
+
3
+ # entra user session revoke
4
+
5
+ Revokes all sign-in sessions for a given user
6
+
7
+ ## Usage
8
+
9
+ ```sh
10
+ m365 entra user session revoke [options]
11
+ ```
12
+
13
+ ## Options
14
+ ```md definition-list
15
+ `-i, --userId [userId]`
16
+ : The id of the user. Specify either `userId` or `userName`, but not both.
17
+
18
+ `-n, --userName [userName]`
19
+ : The user principal name of the user. Specify either `userId` or `userName`, but not both.
20
+
21
+ `-f, --force`
22
+ : Don't prompt for confirmation.
23
+ ```
24
+
25
+ <Global />
26
+
27
+ ## Remarks
28
+
29
+ :::info
30
+
31
+ To use this command you must be either **User Administrator** or **Global Administrator**.
32
+
33
+ :::
34
+
35
+ :::note
36
+
37
+ There might be a small delay of a few minutes before tokens are revoked.
38
+
39
+ This API doesn't revoke sign-in sessions for external users, because external users sign in through their home tenant.
40
+
41
+ :::
42
+
43
+ ## Examples
44
+
45
+ Revoke sign-in sessions of a user specified by id
46
+
47
+ ```sh
48
+ m365 entra user session revoke --userId 4fb72b9b-d0b0-4a35-8bc1-83f9a6488c48
49
+ ```
50
+
51
+ Revoke sign-in sessions of a user specified by its UPN
52
+
53
+ ```sh
54
+ m365 entra user session revoke --userName john.doe@contoso.onmicrosoft.com
55
+ ```
56
+
57
+ Revoke sign-in sessions of a user specified by its UPN without prompting for confirmation
58
+
59
+ ```sh
60
+ m365 entra user session revoke --userName john.doe@contoso.onmicrosoft.com --force
61
+ ```
62
+
63
+ ## Response
64
+
65
+ The command won't return a response on success.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "10.4.0-beta.17b3a55",
3
+ "version": "10.4.0-beta.47f1e4d",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",