@pnp/cli-microsoft365 5.0.0-beta.60ed6bc → 5.0.0-beta.6be8a88

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.
Files changed (123) hide show
  1. package/.devcontainer/devcontainer.json +9 -1
  2. package/.eslintrc.js +2 -0
  3. package/README.md +1 -1
  4. package/dist/Utils.js +7 -0
  5. package/dist/api.d.ts +11 -0
  6. package/dist/api.js +17 -0
  7. package/dist/appInsights.js +5 -2
  8. package/dist/cli/Cli.js +42 -7
  9. package/dist/m365/aad/commands/app/app-add.js +101 -12
  10. package/dist/m365/aad/commands/app/app-get.js +97 -0
  11. package/dist/m365/aad/commands/group/group-list.js +41 -0
  12. package/dist/m365/aad/commands/o365group/{GroupUser.js → GroupExtended.js} +1 -1
  13. package/dist/m365/aad/commands/o365group/o365group-add.js +56 -50
  14. package/dist/m365/aad/commands/o365group/o365group-user-set.js +3 -3
  15. package/dist/m365/aad/commands/oauth2grant/oauth2grant-list.js +4 -4
  16. package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +36 -12
  17. package/dist/m365/aad/commands/user/user-get.js +33 -6
  18. package/dist/m365/aad/commands/user/user-hibp.js +67 -0
  19. package/dist/m365/aad/commands/user/user-list.js +7 -4
  20. package/dist/m365/aad/commands/user/user-password-validate.js +42 -0
  21. package/dist/m365/aad/commands.js +4 -0
  22. package/dist/m365/app/commands/permission/permission-list.js +266 -0
  23. package/dist/m365/app/commands.js +7 -0
  24. package/dist/m365/base/AppCommand.js +76 -0
  25. package/dist/m365/{aad/commands/o365group/Group.js → base/M365RcJson.js} +1 -1
  26. package/dist/m365/cli/commands/cli-doctor.js +2 -0
  27. package/dist/m365/cli/commands/config/config-set.js +4 -1
  28. package/dist/m365/file/commands/file-list.js +181 -0
  29. package/dist/m365/file/commands.js +2 -1
  30. package/dist/m365/flow/commands/flow-get.js +2 -2
  31. package/dist/m365/pa/cds-project-mutator.js +1 -1
  32. package/dist/m365/pa/commands/app/app-list.js +28 -1
  33. package/dist/m365/planner/AppliedCategories.js +3 -0
  34. package/dist/m365/planner/commands/task/task-add.js +288 -0
  35. package/dist/m365/planner/commands/task/task-details-get.js +39 -0
  36. package/dist/m365/planner/commands/task/task-get.js +37 -0
  37. package/dist/m365/planner/commands/task/task-set.js +357 -0
  38. package/dist/m365/planner/commands.js +5 -1
  39. package/dist/m365/search/commands/externalconnection/externalconnection-add.js +99 -0
  40. package/dist/m365/search/commands.js +7 -0
  41. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006005_CFG_PS_metadata.js +63 -0
  42. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +60 -0
  43. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
  44. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.13.1.js +53 -0
  45. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0-beta.5.js +59 -0
  46. package/dist/m365/spfx/commands/project/project-upgrade.js +17 -13
  47. package/dist/m365/spfx/commands/spfx-doctor.js +176 -62
  48. package/dist/m365/spo/commands/contenttype/contenttype-list.js +52 -0
  49. package/dist/m365/spo/commands/group/group-user-add.js +64 -13
  50. package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
  51. package/dist/m365/spo/commands/list/list-get.js +6 -2
  52. package/dist/m365/spo/commands/page/Page.js +3 -1
  53. package/dist/m365/spo/commands/page/page-add.js +7 -10
  54. package/dist/m365/spo/commands/page/page-set.js +7 -10
  55. package/dist/m365/spo/commands/site/site-ensure.js +1 -1
  56. package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
  57. package/dist/m365/spo/commands/site/site-remove.js +98 -30
  58. package/dist/m365/spo/commands/web/web-installedlanguage-list.js +48 -0
  59. package/dist/m365/spo/commands.js +5 -1
  60. package/dist/m365/teams/commands/app/app-list.js +9 -6
  61. package/dist/m365/teams/commands/chat/chat-list.js +43 -0
  62. package/dist/m365/teams/commands/chat/chat-member-list.js +42 -0
  63. package/dist/m365/teams/commands/chat/chat-message-list.js +60 -0
  64. package/dist/m365/teams/commands/message/message-get.js +1 -1
  65. package/dist/m365/teams/commands/report/report-directroutingcalls.js +1 -1
  66. package/dist/m365/teams/commands/tab/tab-get.js +9 -6
  67. package/dist/m365/teams/commands.js +3 -0
  68. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
  69. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
  70. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
  71. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
  72. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
  73. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
  74. package/dist/m365/tenant/commands.js +6 -0
  75. package/dist/request.js +9 -4
  76. package/dist/settingsNames.js +6 -1
  77. package/docs/docs/cmd/_global.md +2 -2
  78. package/docs/docs/cmd/aad/app/app-add.md +11 -0
  79. package/docs/docs/cmd/aad/app/app-get.md +48 -0
  80. package/docs/docs/cmd/aad/group/group-list.md +21 -0
  81. package/docs/docs/cmd/aad/o365group/o365group-add.md +1 -0
  82. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-list.md +2 -2
  83. package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.md +9 -0
  84. package/docs/docs/cmd/aad/user/user-get.md +13 -4
  85. package/docs/docs/cmd/aad/user/user-hibp.md +46 -0
  86. package/docs/docs/cmd/aad/user/user-list.md +9 -0
  87. package/docs/docs/cmd/aad/user/user-password-validate.md +29 -0
  88. package/docs/docs/cmd/app/permission/permission-list.md +36 -0
  89. package/docs/docs/cmd/file/file-list.md +46 -0
  90. package/docs/docs/cmd/pa/app/app-list.md +17 -1
  91. package/docs/docs/cmd/planner/task/task-add.md +78 -0
  92. package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
  93. package/docs/docs/cmd/planner/task/task-get.md +24 -0
  94. package/docs/docs/cmd/planner/task/task-set.md +99 -0
  95. package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +43 -0
  96. package/docs/docs/cmd/spfx/project/project-externalize.md +1 -1
  97. package/docs/docs/cmd/spfx/project/project-rename.md +1 -1
  98. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  99. package/docs/docs/cmd/spfx/spfx-doctor.md +1 -1
  100. package/docs/docs/cmd/spo/contenttype/contenttype-list.md +33 -0
  101. package/docs/docs/cmd/spo/group/group-user-add.md +24 -6
  102. package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
  103. package/docs/docs/cmd/spo/list/list-get.md +9 -0
  104. package/docs/docs/cmd/spo/page/page-add.md +2 -2
  105. package/docs/docs/cmd/spo/page/page-set.md +3 -3
  106. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
  107. package/docs/docs/cmd/spo/site/site-remove.md +3 -1
  108. package/docs/docs/cmd/spo/web/web-installedlanguage-list.md +24 -0
  109. package/docs/docs/cmd/teams/channel/channel-get.md +1 -1
  110. package/docs/docs/cmd/teams/chat/chat-list.md +30 -0
  111. package/docs/docs/cmd/teams/chat/chat-member-list.md +24 -0
  112. package/docs/docs/cmd/teams/chat/chat-message-list.md +24 -0
  113. package/docs/docs/cmd/teams/message/message-get.md +0 -3
  114. package/docs/docs/cmd/teams/report/report-directroutingcalls.md +0 -3
  115. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
  116. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
  117. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
  118. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
  119. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
  120. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
  121. package/npm-shrinkwrap.json +1308 -1478
  122. package/package.json +36 -28
  123. package/dist/m365/base/AadCommand.js +0 -10
@@ -5,6 +5,7 @@ const path = require("path");
5
5
  const request_1 = require("../../../../request");
6
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
7
7
  const commands_1 = require("../../commands");
8
+ const Utils_1 = require("../../../../Utils");
8
9
  class AadO365GroupAddCommand extends GraphCommand_1.default {
9
10
  get name() {
10
11
  return commands_1.default.O365GROUP_ADD;
@@ -14,6 +15,8 @@ class AadO365GroupAddCommand extends GraphCommand_1.default {
14
15
  }
15
16
  commandAction(logger, args, cb) {
16
17
  let group;
18
+ let ownerIds = [];
19
+ let memberIds = [];
17
20
  if (this.verbose) {
18
21
  logger.logToStderr(`Creating Microsoft 365 Group...`);
19
22
  }
@@ -35,8 +38,16 @@ class AadO365GroupAddCommand extends GraphCommand_1.default {
35
38
  visibility: args.options.isPrivate === 'true' ? 'Private' : 'Public'
36
39
  }
37
40
  };
38
- request_1.default
39
- .post(requestOptions)
41
+ this
42
+ .getUserIds(logger, args.options.owners)
43
+ .then((ownerIdsRes) => {
44
+ ownerIds = ownerIdsRes;
45
+ return this.getUserIds(logger, args.options.members);
46
+ })
47
+ .then((memberIdsRes) => {
48
+ memberIds = memberIdsRes;
49
+ return request_1.default.post(requestOptions);
50
+ })
40
51
  .then((res) => {
41
52
  group = res;
42
53
  if (!args.options.logoPath) {
@@ -61,72 +72,32 @@ class AadO365GroupAddCommand extends GraphCommand_1.default {
61
72
  });
62
73
  })
63
74
  .then(() => {
64
- if (!args.options.owners) {
65
- if (this.debug) {
66
- logger.logToStderr('Owners not set. Skipping');
67
- }
68
- return Promise.resolve(undefined);
69
- }
70
- const owners = args.options.owners.split(',').map(o => o.trim());
71
- if (this.verbose) {
72
- logger.logToStderr('Retrieving user information to set group owners...');
73
- }
74
- const requestOptions = {
75
- url: `${this.resource}/v1.0/users?$filter=${owners.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
76
- headers: {
77
- 'content-type': 'application/json'
78
- },
79
- responseType: 'json'
80
- };
81
- return request_1.default.get(requestOptions);
82
- })
83
- .then((res) => {
84
- if (!res) {
85
- return Promise.resolve();
75
+ if (ownerIds.length === 0) {
76
+ return Promise.resolve([]);
86
77
  }
87
- return Promise.all(res.value.map(u => request_1.default.post({
78
+ return Promise.all(ownerIds.map(ownerId => request_1.default.post({
88
79
  url: `${this.resource}/v1.0/groups/${group.id}/owners/$ref`,
89
80
  headers: {
90
81
  'content-type': 'application/json'
91
82
  },
92
83
  responseType: 'json',
93
84
  data: {
94
- "@odata.id": `https://graph.microsoft.com/v1.0/users/${u.id}`
85
+ "@odata.id": `https://graph.microsoft.com/v1.0/users/${ownerId}`
95
86
  }
96
87
  })));
97
88
  })
98
89
  .then(() => {
99
- if (!args.options.members) {
100
- if (this.debug) {
101
- logger.logToStderr('Members not set. Skipping');
102
- }
103
- return Promise.resolve(undefined);
104
- }
105
- const members = args.options.members.split(',').map(o => o.trim());
106
- if (this.verbose) {
107
- logger.logToStderr('Retrieving user information to set group members...');
108
- }
109
- const requestOptions = {
110
- url: `${this.resource}/v1.0/users?$filter=${members.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
111
- headers: {
112
- 'content-type': 'application/json'
113
- },
114
- responseType: 'json'
115
- };
116
- return request_1.default.get(requestOptions);
117
- })
118
- .then((res) => {
119
- if (!res) {
120
- return Promise.resolve();
90
+ if (memberIds.length === 0) {
91
+ return Promise.resolve([]);
121
92
  }
122
- return Promise.all(res.value.map(u => request_1.default.post({
93
+ return Promise.all(memberIds.map(memberId => request_1.default.post({
123
94
  url: `${this.resource}/v1.0/groups/${group.id}/members/$ref`,
124
95
  headers: {
125
96
  'content-type': 'application/json'
126
97
  },
127
98
  responseType: 'json',
128
99
  data: {
129
- "@odata.id": `https://graph.microsoft.com/v1.0/users/${u.id}`
100
+ "@odata.id": `https://graph.microsoft.com/v1.0/users/${memberId}`
130
101
  }
131
102
  })));
132
103
  })
@@ -135,6 +106,41 @@ class AadO365GroupAddCommand extends GraphCommand_1.default {
135
106
  cb();
136
107
  }, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
137
108
  }
109
+ getUserIds(logger, users) {
110
+ if (!users) {
111
+ if (this.debug) {
112
+ logger.logToStderr('No users to validate, skipping.');
113
+ }
114
+ return Promise.resolve([]);
115
+ }
116
+ if (this.verbose) {
117
+ logger.logToStderr('Retrieving user information.');
118
+ }
119
+ const userArr = users.split(',').map(o => o.trim());
120
+ let promises = [];
121
+ let userIds = [];
122
+ promises = userArr.map(user => {
123
+ const requestOptions = {
124
+ url: `${this.resource}/v1.0/users?$filter=userPrincipalName eq '${Utils_1.default.encodeQueryParameter(user)}'&$select=id,userPrincipalName`,
125
+ headers: {
126
+ 'content-type': 'application/json'
127
+ },
128
+ responseType: 'json'
129
+ };
130
+ return request_1.default.get(requestOptions);
131
+ });
132
+ return Promise.all(promises).then((usersRes) => {
133
+ let userUpns = [];
134
+ userUpns = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.userPrincipalName; });
135
+ userIds = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.id; });
136
+ // Find the members where no graph response was found
137
+ const invalidUsers = userArr.filter(user => !userUpns.some((upn) => (upn === null || upn === void 0 ? void 0 : upn.toLowerCase()) === user.toLowerCase()));
138
+ if (invalidUsers && invalidUsers.length > 0) {
139
+ return Promise.reject(`Cannot proceed with group creation. The following users provided are invalid : ${invalidUsers.join(',')}`);
140
+ }
141
+ return Promise.resolve(userIds);
142
+ });
143
+ }
138
144
  setGroupLogo(requestOptions, retryLeft, resolve, reject, logger) {
139
145
  request_1.default
140
146
  .put(requestOptions)
@@ -37,14 +37,14 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
37
37
  logger.logToStderr(this.items);
38
38
  logger.logToStderr('');
39
39
  }
40
- if (this.items.filter(i => i.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase()).length <= 0) {
40
+ if (this.items.filter(i => args.options.userName.toUpperCase() === i.userPrincipalName.toUpperCase()).length <= 0) {
41
41
  const userNotInGroup = (typeof args.options.groupId !== 'undefined') ?
42
42
  'The specified user does not belong to the given Microsoft 365 Group. Please use the \'o365group user add\' command to add new users.' :
43
43
  'The specified user does not belong to the given Microsoft Teams team. Please use the \'graph teams user add\' command to add new users.';
44
44
  throw new Error(userNotInGroup);
45
45
  }
46
46
  if (args.options.role === "Owner") {
47
- const foundMember = this.items.find(e => e.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase() && e.userType === 'Member');
47
+ const foundMember = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Member');
48
48
  if (foundMember !== undefined) {
49
49
  const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/$ref`;
50
50
  const requestOptions = {
@@ -65,7 +65,7 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
65
65
  }
66
66
  }
67
67
  else {
68
- const foundOwner = this.items.find(e => e.userPrincipalName.toLocaleLowerCase() === args.options.userName.toLocaleLowerCase() && e.userType === 'Owner');
68
+ const foundOwner = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Owner');
69
69
  if (foundOwner !== undefined) {
70
70
  const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/${foundOwner.id}/$ref`;
71
71
  const requestOptions = {
@@ -19,7 +19,7 @@ class AadOAuth2GrantListCommand extends GraphCommand_1.default {
19
19
  logger.logToStderr(`Retrieving list of OAuth grants for the service principal...`);
20
20
  }
21
21
  const requestOptions = {
22
- url: `${this.resource}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${encodeURIComponent(args.options.clientId)}'`,
22
+ url: `${this.resource}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${encodeURIComponent(args.options.spObjectId)}'`,
23
23
  headers: {
24
24
  accept: 'application/json;odata.metadata=none'
25
25
  },
@@ -37,15 +37,15 @@ class AadOAuth2GrantListCommand extends GraphCommand_1.default {
37
37
  options() {
38
38
  const options = [
39
39
  {
40
- option: '-i, --clientId <clientId>'
40
+ option: '-i, --spObjectId <spObjectId>'
41
41
  }
42
42
  ];
43
43
  const parentOptions = super.options();
44
44
  return options.concat(parentOptions);
45
45
  }
46
46
  validate(args) {
47
- if (!Utils_1.default.isValidGuid(args.options.clientId)) {
48
- return `${args.options.clientId} is not a valid GUID`;
47
+ if (!Utils_1.default.isValidGuid(args.options.spObjectId)) {
48
+ return `${args.options.spObjectId} is not a valid GUID`;
49
49
  }
50
50
  return true;
51
51
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
3
4
  const request_1 = require("../../../../request");
4
5
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
6
  const commands_1 = require("../../commands");
@@ -11,24 +12,47 @@ class AadOAuth2GrantRemoveCommand extends GraphCommand_1.default {
11
12
  return 'Remove specified service principal OAuth2 permissions';
12
13
  }
13
14
  commandAction(logger, args, cb) {
14
- if (this.verbose) {
15
- logger.logToStderr(`Removing OAuth2 permissions...`);
16
- }
17
- const requestOptions = {
18
- url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
19
- headers: {
20
- 'accept': 'application/json;odata.metadata=none'
21
- },
22
- responseType: 'json'
15
+ const removeOauth2Grant = () => {
16
+ if (this.verbose) {
17
+ logger.logToStderr(`Removing OAuth2 permissions...`);
18
+ }
19
+ const requestOptions = {
20
+ url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
21
+ headers: {
22
+ 'accept': 'application/json;odata.metadata=none'
23
+ },
24
+ responseType: 'json'
25
+ };
26
+ request_1.default
27
+ .delete(requestOptions)
28
+ .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
23
29
  };
24
- request_1.default
25
- .delete(requestOptions)
26
- .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
30
+ if (args.options.confirm) {
31
+ removeOauth2Grant();
32
+ }
33
+ else {
34
+ cli_1.Cli.prompt({
35
+ type: 'confirm',
36
+ name: 'continue',
37
+ default: false,
38
+ message: `Are you sure you want to remove the OAuth2 permissions for ${args.options.grantId}?`
39
+ }, (result) => {
40
+ if (!result.continue) {
41
+ cb();
42
+ }
43
+ else {
44
+ removeOauth2Grant();
45
+ }
46
+ });
47
+ }
27
48
  }
28
49
  options() {
29
50
  const options = [
30
51
  {
31
52
  option: '-i, --grantId <grantId>'
53
+ },
54
+ {
55
+ option: '--confirm'
32
56
  }
33
57
  ];
34
58
  const parentOptions = super.options();
@@ -20,10 +20,20 @@ class AadUserGetCommand extends GraphCommand_1.default {
20
20
  }
21
21
  commandAction(logger, args, cb) {
22
22
  const properties = args.options.properties ?
23
- `?$select=${args.options.properties.split(',').map(p => encodeURIComponent(p.trim())).join(',')}` :
23
+ `&$select=${args.options.properties.split(',').map(p => encodeURIComponent(p.trim())).join(',')}` :
24
24
  '';
25
+ let requestUrl = `${this.resource}/v1.0/users`;
26
+ if (args.options.id) {
27
+ requestUrl += `?$filter=id eq '${encodeURIComponent(args.options.id)}'${properties}`;
28
+ }
29
+ else if (args.options.userName) {
30
+ requestUrl += `?$filter=userPrincipalName eq '${encodeURIComponent(args.options.userName)}'${properties}`;
31
+ }
32
+ else if (args.options.email) {
33
+ requestUrl += `?$filter=mail eq '${encodeURIComponent(args.options.email)}'${properties}`;
34
+ }
25
35
  const requestOptions = {
26
- url: `${this.resource}/v1.0/users/${encodeURIComponent(args.options.id ? args.options.id : args.options.userName)}${properties}`,
36
+ url: requestUrl,
27
37
  headers: {
28
38
  accept: 'application/json;odata.metadata=none'
29
39
  },
@@ -31,6 +41,18 @@ class AadUserGetCommand extends GraphCommand_1.default {
31
41
  };
32
42
  request_1.default
33
43
  .get(requestOptions)
44
+ .then((res) => {
45
+ if (res.value.length === 1) {
46
+ return Promise.resolve(res.value[0]);
47
+ }
48
+ const identifier = args.options.id ? `id ${args.options.id}`
49
+ : args.options.userName ? `user name ${args.options.userName}`
50
+ : `email ${args.options.email}`;
51
+ if (res.value.length === 0) {
52
+ return Promise.reject(`The specified user with ${identifier} does not exist`);
53
+ }
54
+ return Promise.reject(`Multiple users with ${identifier} found. Please disambiguate (user names): ${res.value.map(a => a.userPrincipalName).join(', ')} or (ids): ${res.value.map(a => a.id).join(', ')}`);
55
+ })
34
56
  .then((res) => {
35
57
  logger.log(res);
36
58
  cb();
@@ -44,6 +66,9 @@ class AadUserGetCommand extends GraphCommand_1.default {
44
66
  {
45
67
  option: '-n, --userName [userName]'
46
68
  },
69
+ {
70
+ option: '--email [email]'
71
+ },
47
72
  {
48
73
  option: '-p, --properties [properties]'
49
74
  }
@@ -52,11 +77,13 @@ class AadUserGetCommand extends GraphCommand_1.default {
52
77
  return options.concat(parentOptions);
53
78
  }
54
79
  validate(args) {
55
- if (!args.options.id && !args.options.userName) {
56
- return 'Specify either id or userName';
80
+ if (!args.options.id && !args.options.userName && !args.options.email) {
81
+ return 'Specify id, userName or email, one is required';
57
82
  }
58
- if (args.options.id && args.options.userName) {
59
- return 'Specify either id or userName but not both';
83
+ if ((args.options.id && args.options.email) ||
84
+ (args.options.id && args.options.userName) ||
85
+ (args.options.userName && args.options.email)) {
86
+ return 'Use either id, userName or email, but not all';
60
87
  }
61
88
  if (args.options.id &&
62
89
  !Utils_1.default.isValidGuid(args.options.id)) {
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const Utils_1 = require("../../../../Utils");
5
+ const AnonymousCommand_1 = require("../../../base/AnonymousCommand");
6
+ const commands_1 = require("../../commands");
7
+ class AadUserHibpCommand extends AnonymousCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.USER_HIBP;
10
+ }
11
+ get description() {
12
+ return 'Allows you to retrieve all accounts that have been pwned with the specified username';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.domain = args.options.domain;
17
+ return telemetryProps;
18
+ }
19
+ commandAction(logger, args, cb) {
20
+ const requestOptions = {
21
+ url: `https://haveibeenpwned.com/api/v3/breachedaccount/${encodeURIComponent(args.options.userName)}${(args.options.domain ? `?domain=${encodeURIComponent(args.options.domain)}` : '')}`,
22
+ headers: {
23
+ 'accept': 'application/json',
24
+ 'hibp-api-key': args.options.apiKey,
25
+ 'x-anonymous': true
26
+ },
27
+ responseType: 'json'
28
+ };
29
+ request_1.default
30
+ .get(requestOptions)
31
+ .then((res) => {
32
+ logger.log(res);
33
+ cb();
34
+ })
35
+ .catch((err) => {
36
+ if ((err && err.response !== undefined && err.response.status === 404) && (this.debug || this.verbose)) {
37
+ logger.log('No pwnage found');
38
+ cb();
39
+ return;
40
+ }
41
+ return this.handleRejectedODataJsonPromise(err, logger, cb);
42
+ });
43
+ }
44
+ options() {
45
+ const options = [
46
+ {
47
+ option: '-n, --userName <userName>'
48
+ },
49
+ {
50
+ option: '--apiKey, <apiKey>'
51
+ },
52
+ {
53
+ option: '--domain, [domain]'
54
+ }
55
+ ];
56
+ const parentOptions = super.options();
57
+ return options.concat(parentOptions);
58
+ }
59
+ validate(args) {
60
+ if (!Utils_1.default.isValidUserPrincipalName(args.options.userName)) {
61
+ return 'Specify valid userName';
62
+ }
63
+ return true;
64
+ }
65
+ }
66
+ module.exports = new AadUserHibpCommand();
67
+ //# sourceMappingURL=user-hibp.js.map
@@ -15,6 +15,7 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
15
15
  getTelemetryProperties(args) {
16
16
  const telemetryProps = super.getTelemetryProperties(args);
17
17
  telemetryProps.properties = args.options.properties;
18
+ telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
18
19
  return telemetryProps;
19
20
  }
20
21
  commandAction(logger, args, cb) {
@@ -22,7 +23,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
22
23
  args.options.properties.split(',').map(p => p.trim()) :
23
24
  ['userPrincipalName', 'displayName'];
24
25
  const filter = this.getFilter(args.options);
25
- const url = `${this.resource}/v1.0/users?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
26
+ const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.user' : 'users';
27
+ const url = `${this.resource}/v1.0/${endpoint}?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
26
28
  this
27
29
  .getAllItems(url, logger, true)
28
30
  .then(() => {
@@ -35,6 +37,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
35
37
  const excludeOptions = [
36
38
  'properties',
37
39
  'p',
40
+ 'deleted',
41
+ 'd',
38
42
  'debug',
39
43
  'verbose',
40
44
  'output',
@@ -55,9 +59,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
55
59
  }
56
60
  options() {
57
61
  const options = [
58
- {
59
- option: '-p, --properties [properties]'
60
- }
62
+ { option: '-p, --properties [properties]' },
63
+ { option: '-d, --deleted' }
61
64
  ];
62
65
  const parentOptions = super.options();
63
66
  return options.concat(parentOptions);
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const GraphCommand_1 = require("../../../base/GraphCommand");
5
+ const commands_1 = require("../../commands");
6
+ class AadUserPasswordValidateCommand extends GraphCommand_1.default {
7
+ get name() {
8
+ return commands_1.default.USER_PASSWORD_VALIDATE;
9
+ }
10
+ get description() {
11
+ return "Check a user's password against the organization's password validation policy";
12
+ }
13
+ commandAction(logger, args, cb) {
14
+ const requestOptions = {
15
+ url: `${this.resource}/beta/users/validatePassword`,
16
+ headers: {
17
+ accept: 'application/json;odata.metadata=none'
18
+ },
19
+ data: {
20
+ password: args.options.password
21
+ },
22
+ responseType: 'json'
23
+ };
24
+ request_1.default
25
+ .post(requestOptions)
26
+ .then((res) => {
27
+ logger.log(res);
28
+ cb();
29
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
30
+ }
31
+ options() {
32
+ const options = [
33
+ {
34
+ option: '-p, --password <password>'
35
+ }
36
+ ];
37
+ const parentOptions = super.options();
38
+ return options.concat(parentOptions);
39
+ }
40
+ }
41
+ module.exports = new AadUserPasswordValidateCommand();
42
+ //# sourceMappingURL=user-password-validate.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'aad';
4
4
  exports.default = {
5
5
  APP_ADD: `${prefix} app add`,
6
+ APP_GET: `${prefix} app get`,
6
7
  APP_SET: `${prefix} app set`,
7
8
  APP_ROLE_ADD: `${prefix} app role add`,
8
9
  APP_ROLE_LIST: `${prefix} app role list`,
@@ -10,6 +11,7 @@ exports.default = {
10
11
  APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
11
12
  APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
12
13
  APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
14
+ GROUP_LIST: `${prefix} group list`,
13
15
  GROUPSETTING_ADD: `${prefix} groupsetting add`,
14
16
  GROUPSETTING_GET: `${prefix} groupsetting get`,
15
17
  GROUPSETTING_LIST: `${prefix} groupsetting list`,
@@ -49,7 +51,9 @@ exports.default = {
49
51
  SP_ADD: `${prefix} sp add`,
50
52
  SP_GET: `${prefix} sp get`,
51
53
  USER_GET: `${prefix} user get`,
54
+ USER_HIBP: `${prefix} user hibp`,
52
55
  USER_LIST: `${prefix} user list`,
56
+ USER_PASSWORD_VALIDATE: `${prefix} user password validate`,
53
57
  USER_SET: `${prefix} user set`
54
58
  };
55
59
  //# sourceMappingURL=commands.js.map