@pnp/cli-microsoft365 4.0.0-beta.f87506e → 4.1.0-beta.6c0929c

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 (74) hide show
  1. package/.devcontainer/Dockerfile +3 -3
  2. package/dist/Auth.js +25 -9
  3. package/dist/Utils.js +6 -0
  4. package/dist/cli/Cli.js +4 -4
  5. package/dist/m365/aad/commands/app/app-add.js +1 -1
  6. package/dist/m365/aad/commands/app/app-role-add.js +1 -1
  7. package/dist/m365/aad/commands/o365group/o365group-get.js +0 -4
  8. package/dist/m365/aad/commands/o365group/o365group-teamify.js +14 -4
  9. package/dist/m365/aad/commands/o365group/o365group-user-list.js +5 -24
  10. package/dist/m365/aad/commands/siteclassification/siteclassification-disable.js +2 -2
  11. package/dist/m365/aad/commands/user/user-set.js +90 -0
  12. package/dist/m365/aad/commands.js +2 -1
  13. package/dist/m365/base/SpoCommand.js +13 -0
  14. package/dist/m365/commands/login.js +12 -0
  15. package/dist/m365/file/commands/convert/convert-pdf.js +2 -2
  16. package/dist/m365/onedrive/commands/onedrive-list.js +41 -24
  17. package/dist/m365/pa/commands/pcf/pcf-init.js +1 -1
  18. package/dist/m365/pa/commands/solution/solution-init.js +1 -1
  19. package/dist/m365/planner/commands/plan/plan-get.js +116 -0
  20. package/dist/m365/planner/commands/task/task-list.js +157 -7
  21. package/dist/m365/planner/commands.js +1 -0
  22. package/dist/m365/spfx/commands/package/package-generate.js +1 -1
  23. package/dist/m365/spfx/commands/project/project-rename.js +1 -1
  24. package/dist/m365/spfx/commands/project/project-upgrade/rules/DependencyRule.js +3 -3
  25. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006004_CFG_PS_developer.js +7 -6
  26. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN023001_GITIGNORE_release.js +3 -9
  27. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.13.0-beta.15.js → upgrade-1.13.0-beta.20.js} +26 -28
  28. package/dist/m365/spfx/commands/project/project-upgrade.js +3 -3
  29. package/dist/m365/spfx/commands/spfx-doctor.js +1 -1
  30. package/dist/m365/spo/commands/app/app-instance-list.js +59 -0
  31. package/dist/m365/spo/commands/file/file-add.js +1 -1
  32. package/dist/m365/spo/commands/file/file-list.js +2 -1
  33. package/dist/m365/spo/commands/group/group-user-list.js +66 -0
  34. package/dist/m365/spo/commands/listitem/listitem-get.js +5 -5
  35. package/dist/m365/spo/commands/page/Page.js +1 -1
  36. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +3 -3
  37. package/dist/m365/spo/commands/page/page-control-get.js +9 -1
  38. package/dist/m365/spo/commands/page/page-control-list.js +10 -13
  39. package/dist/m365/spo/commands/page/page-section-add.js +1 -1
  40. package/dist/m365/spo/commands/page/page-text-add.js +2 -2
  41. package/dist/m365/spo/commands/site/site-apppermission-remove.js +162 -0
  42. package/dist/m365/spo/commands/site/site-classic-list.js +41 -24
  43. package/dist/m365/spo/commands/site/site-list.js +44 -28
  44. package/dist/m365/spo/commands/sitedesign/sitedesign-set.js +7 -0
  45. package/dist/m365/spo/commands/spo-search.js +3 -3
  46. package/dist/m365/spo/commands/term/term-add.js +1 -1
  47. package/dist/m365/spo/commands/term/term-group-add.js +1 -1
  48. package/dist/m365/spo/commands/term/term-set-add.js +1 -1
  49. package/dist/m365/spo/commands/theme/theme-list.js +1 -1
  50. package/dist/m365/spo/commands.js +3 -0
  51. package/dist/m365/teams/commands/channel/channel-list.js +5 -4
  52. package/dist/m365/teams/commands/conversationmember/conversationmember-add.js +9 -8
  53. package/dist/m365/teams/commands/conversationmember/conversationmember-list.js +20 -22
  54. package/dist/m365/teams/commands/team/team-get.js +91 -0
  55. package/dist/m365/teams/commands/team/team-list.js +6 -4
  56. package/dist/m365/teams/commands/user/user-list.js +5 -24
  57. package/dist/m365/viva/commands/connections/connections-app-create.js +1 -1
  58. package/docs/docs/cmd/aad/o365group/o365group-teamify.md +0 -5
  59. package/docs/docs/cmd/aad/o365group/o365group-user-list.md +2 -17
  60. package/docs/docs/cmd/aad/siteclassification/siteclassification-disable.md +0 -5
  61. package/docs/docs/cmd/aad/user/user-set.md +60 -0
  62. package/docs/docs/cmd/login.md +11 -2
  63. package/docs/docs/cmd/planner/plan/plan-get.md +45 -0
  64. package/docs/docs/cmd/planner/task/task-list.md +49 -1
  65. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  66. package/docs/docs/cmd/spo/app/app-instance-list.md +24 -0
  67. package/docs/docs/cmd/spo/group/group-user-list.md +36 -0
  68. package/docs/docs/cmd/spo/listitem/listitem-get.md +3 -3
  69. package/docs/docs/cmd/spo/site/site-apppermission-remove.md +48 -0
  70. package/docs/docs/cmd/spo/sitedesign/sitedesign-set.md +3 -0
  71. package/docs/docs/cmd/teams/team/team-get.md +33 -0
  72. package/docs/docs/cmd/teams/user/user-list.md +2 -23
  73. package/npm-shrinkwrap.json +432 -333
  74. package/package.json +22 -20
@@ -8,8 +8,8 @@ LABEL name="CLI for Microsoft 365 Development" \
8
8
  Garry Trinder <garry.trinder@live.com>, \
9
9
  Albert-Jan Schot <appie@digiwijs.nl>, \
10
10
  Rabia Williams <rabiawilliams@gmail.com>, \
11
- Mark Powney <mpowney@icloud.com>, \
12
- Patrick Lamber <patrick@nubo.eu>"
11
+ Patrick Lamber <patrick@nubo.eu>, \
12
+ Arjun Menon <arjun.umenon@gmail.com>"
13
13
 
14
14
  ENV NPM_CONFIG_PREFIX=/home/cli-microsoft365-dev/.npm-global \
15
15
  PATH=$PATH:/home/cli-microsoft365-dev/.npm-global/bin
@@ -51,4 +51,4 @@ RUN zsh -c "$(curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/mast
51
51
  && sed -i "73s/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/" ~/.zshrc \
52
52
  && sed -i "50s/# COMPLETION_WAITING_DOTS/COMPLETION_WAITING_DOTS/" ~/.zshrc
53
53
 
54
- CMD [ "/bin/zsh", "-l" ]
54
+ CMD [ "/bin/zsh", "-l" ]
package/dist/Auth.js CHANGED
@@ -47,6 +47,7 @@ var AuthType;
47
47
  AuthType[AuthType["Certificate"] = 2] = "Certificate";
48
48
  AuthType[AuthType["Identity"] = 3] = "Identity";
49
49
  AuthType[AuthType["Browser"] = 4] = "Browser";
50
+ AuthType[AuthType["Secret"] = 5] = "Secret";
50
51
  })(AuthType = exports.AuthType || (exports.AuthType = {}));
51
52
  var CertificateType;
52
53
  (function (CertificateType) {
@@ -134,6 +135,9 @@ class Auth {
134
135
  case AuthType.Browser:
135
136
  getTokenPromise = this.ensureAccessTokenWithBrowser.bind(this);
136
137
  break;
138
+ case AuthType.Secret:
139
+ getTokenPromise = this.ensureAccessTokenWithSecret.bind(this);
140
+ break;
137
141
  }
138
142
  }
139
143
  const response = yield getTokenPromise(resource, logger, debug, fetchNew);
@@ -175,25 +179,29 @@ class Auth {
175
179
  case AuthType.Browser:
176
180
  return this.getPublicClient(logger, debug);
177
181
  case AuthType.Certificate:
178
- return this.getConfidentialClient(logger, debug, this.service.thumbprint, this.service.password);
182
+ return this.getConfidentialClient(logger, debug, this.service.thumbprint, this.service.password, undefined);
179
183
  case AuthType.Identity:
180
184
  // msal-node doesn't support managed identity so we need to do it manually
181
185
  return undefined;
186
+ case AuthType.Secret:
187
+ return this.getConfidentialClient(logger, debug, undefined, undefined, this.service.secret);
182
188
  }
183
189
  }
184
- getAuthClientConfiguration(logger, debug, certificateThumbprint, certificatePrivateKey) {
190
+ getAuthClientConfiguration(logger, debug, certificateThumbprint, certificatePrivateKey, clientSecret) {
185
191
  const msal = require('@azure/msal-node');
186
192
  const { LogLevel } = msal;
187
193
  const cert = !certificateThumbprint ? undefined : {
188
194
  thumbprint: certificateThumbprint,
189
195
  privateKey: certificatePrivateKey
190
196
  };
197
+ const config = {
198
+ clientId: this.service.appId,
199
+ authority: `https://login.microsoftonline.com/${this.service.tenant}`
200
+ };
201
+ const authConfig = cert
202
+ ? Object.assign(Object.assign({}, config), { clientCertificate: cert }) : Object.assign(Object.assign({}, config), { clientSecret });
191
203
  return {
192
- auth: {
193
- clientId: this.service.appId,
194
- authority: `https://login.microsoftonline.com/${this.service.tenant}`,
195
- clientCertificate: cert
196
- },
204
+ auth: authConfig,
197
205
  cache: {
198
206
  cachePlugin: msalCachePlugin_1.msalCachePlugin
199
207
  },
@@ -223,10 +231,10 @@ class Auth {
223
231
  }
224
232
  return new PublicClientApplication(this.getAuthClientConfiguration(logger, debug));
225
233
  }
226
- getConfidentialClient(logger, debug, certificateThumbprint, certificatePrivateKey) {
234
+ getConfidentialClient(logger, debug, certificateThumbprint, certificatePrivateKey, clientSecret) {
227
235
  const msal = require('@azure/msal-node');
228
236
  const { ConfidentialClientApplication } = msal;
229
- return new ConfidentialClientApplication(this.getAuthClientConfiguration(logger, debug, certificateThumbprint, certificatePrivateKey));
237
+ return new ConfidentialClientApplication(this.getAuthClientConfiguration(logger, debug, certificateThumbprint, certificatePrivateKey, clientSecret));
230
238
  }
231
239
  retrieveAuthCodeWithBrowser(resource, logger, debug) {
232
240
  return new Promise((resolve, reject) => {
@@ -482,6 +490,14 @@ class Auth {
482
490
  }
483
491
  });
484
492
  }
493
+ ensureAccessTokenWithSecret(resource, logger, debug) {
494
+ return __awaiter(this, void 0, void 0, function* () {
495
+ this.clientApplication = this.getConfidentialClient(logger, debug, undefined, undefined, this.service.secret);
496
+ return this.clientApplication.acquireTokenByClientCredential({
497
+ scopes: [`${resource}/.default`]
498
+ });
499
+ });
500
+ }
485
501
  calculateThumbprint(certificate) {
486
502
  const nodeForge = require('node-forge');
487
503
  const { md, asn1, pki } = nodeForge;
package/dist/Utils.js CHANGED
@@ -557,6 +557,12 @@ class Utils {
557
557
  }
558
558
  return jsonObj;
559
559
  }
560
+ static encodeQueryParameter(value) {
561
+ if (!value) {
562
+ return value;
563
+ }
564
+ return encodeURIComponent(value).replace(/'/g, "''");
565
+ }
560
566
  }
561
567
  exports.default = Utils;
562
568
  //# sourceMappingURL=Utils.js.map
package/dist/cli/Cli.js CHANGED
@@ -385,7 +385,7 @@ class Cli {
385
385
  // #2095
386
386
  logStatementType = typeof logStatement;
387
387
  }
388
- if (options.output === 'json') {
388
+ if (!options.output || options.output === 'json') {
389
389
  return JSON.stringify(logStatement, null, 2);
390
390
  }
391
391
  if (logStatement instanceof Command_1.CommandError) {
@@ -413,11 +413,11 @@ class Cli {
413
413
  if (arrayType !== 'object') {
414
414
  return logStatement.join(os.EOL);
415
415
  }
416
- // if output type has not been set or set to 'text', process the retrieved
416
+ // if output type has been set to 'text', process the retrieved
417
417
  // data so that returned objects contain only default properties specified
418
418
  // on the current command. If there is no current command or the
419
419
  // command doesn't specify default properties, return original data
420
- if (!options.output || options.output === 'text') {
420
+ if (options.output === 'text') {
421
421
  const cli = Cli.getInstance();
422
422
  const currentCommand = cli.commandToExecute;
423
423
  if (arrayType === 'object' &&
@@ -632,7 +632,7 @@ class Cli {
632
632
  const chalk = require('chalk');
633
633
  let exitCode = 1;
634
634
  let errorMessage = error instanceof Command_1.CommandError ? error.message : error;
635
- if (args.options.output === 'json' &&
635
+ if ((!args.options.output || args.options.output === 'json') &&
636
636
  !this.getSettingWithDefaultValue(settingsNames_1.settingsNames.printErrorsAsPlainText, true)) {
637
637
  errorMessage = JSON.stringify({ error: errorMessage });
638
638
  }
@@ -206,7 +206,7 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
206
206
  oauth2PermissionScopes: [{
207
207
  adminConsentDescription: args.options.scopeAdminConsentDescription,
208
208
  adminConsentDisplayName: args.options.scopeAdminConsentDisplayName,
209
- id: uuid_1.v4(),
209
+ id: (0, uuid_1.v4)(),
210
210
  type: args.options.scopeConsentBy === 'adminsAndUsers' ? 'User' : 'Admin',
211
211
  value: args.options.scopeName
212
212
  }]
@@ -36,7 +36,7 @@ class AadAppRoleAddCommand extends GraphCommand_1.default {
36
36
  appRoles: appInfo.appRoles.concat({
37
37
  displayName: args.options.name,
38
38
  description: args.options.description,
39
- id: uuid_1.v4(),
39
+ id: (0, uuid_1.v4)(),
40
40
  value: args.options.claim,
41
41
  allowedMemberTypes: this.getAllowedMemberTypes(args)
42
42
  })
@@ -4,7 +4,6 @@ const request_1 = require("../../../../request");
4
4
  const Utils_1 = require("../../../../Utils");
5
5
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
6
  const commands_1 = require("../../commands");
7
- const commands_2 = require("../../../teams/commands");
8
7
  class AadO365GroupGetCommand extends GraphCommand_1.default {
9
8
  get name() {
10
9
  return commands_1.default.O365GROUP_GET;
@@ -12,9 +11,6 @@ class AadO365GroupGetCommand extends GraphCommand_1.default {
12
11
  get description() {
13
12
  return 'Gets information about the specified Microsoft 365 Group or Microsoft Teams team';
14
13
  }
15
- alias() {
16
- return [commands_2.default.TEAM_GET];
17
- }
18
14
  commandAction(logger, args, cb) {
19
15
  let group;
20
16
  const requestOptions = {
@@ -13,11 +13,21 @@ class AadO365GroupTeamifyCommand extends GraphCommand_1.default {
13
13
  }
14
14
  commandAction(logger, args, cb) {
15
15
  const data = {
16
- "template@odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('standard')",
17
- "group@odata.bind": `https://graph.microsoft.com/v1.0/groups('${encodeURIComponent(args.options.groupId)}')`
16
+ "memberSettings": {
17
+ "allowCreatePrivateChannels": true,
18
+ "allowCreateUpdateChannels": true
19
+ },
20
+ "messagingSettings": {
21
+ "allowUserEditMessages": true,
22
+ "allowUserDeleteMessages": true
23
+ },
24
+ "funSettings": {
25
+ "allowGiphy": true,
26
+ "giphyContentRating": "strict"
27
+ }
18
28
  };
19
29
  const requestOptions = {
20
- url: `${this.resource}/beta/teams`,
30
+ url: `${this.resource}/v1.0/groups/${encodeURIComponent(args.options.groupId)}/team`,
21
31
  headers: {
22
32
  accept: 'application/json;odata.metadata=none'
23
33
  },
@@ -25,7 +35,7 @@ class AadO365GroupTeamifyCommand extends GraphCommand_1.default {
25
35
  responseType: 'json'
26
36
  };
27
37
  request_1.default
28
- .post(requestOptions)
38
+ .put(requestOptions)
29
39
  .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
30
40
  }
31
41
  options() {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
3
  const Utils_1 = require("../../../../Utils");
5
4
  const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
6
5
  const commands_1 = require("../../commands");
@@ -9,33 +8,27 @@ class AadO365GroupUserListCommand extends GraphItemsListCommand_1.GraphItemsList
9
8
  return commands_1.default.O365GROUP_USER_LIST;
10
9
  }
11
10
  get description() {
12
- return "Lists users for the specified Microsoft 365 group or Microsoft Teams team";
11
+ return "Lists users for the specified Microsoft 365 group";
13
12
  }
14
13
  getTelemetryProperties(args) {
15
14
  const telemetryProps = super.getTelemetryProperties(args);
16
15
  telemetryProps.role = args.options.role;
17
- telemetryProps.teamId = typeof args.options.teamId !== 'undefined';
18
- telemetryProps.groupId = typeof args.options.groupId !== 'undefined';
19
16
  return telemetryProps;
20
17
  }
21
18
  commandAction(logger, args, cb) {
22
- const providedGroupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
23
19
  this
24
- .getOwners(logger, providedGroupId)
20
+ .getOwners(logger, args.options.groupId)
25
21
  .then(() => {
26
22
  if (args.options.role === "Owner") {
27
23
  return Promise.resolve();
28
24
  }
29
- return this.getMembersAndGuests(logger, providedGroupId);
25
+ return this.getMembersAndGuests(logger, args.options.groupId);
30
26
  })
31
27
  .then(() => {
32
28
  if (args.options.role) {
33
29
  this.items = this.items.filter(i => i.userType === args.options.role);
34
30
  }
35
31
  logger.log(this.items);
36
- if (this.verbose) {
37
- logger.logToStderr(chalk.green("DONE"));
38
- }
39
32
  cb();
40
33
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
41
34
  }
@@ -56,10 +49,7 @@ class AadO365GroupUserListCommand extends GraphItemsListCommand_1.GraphItemsList
56
49
  options() {
57
50
  const options = [
58
51
  {
59
- option: "-i, --groupId [groupId]"
60
- },
61
- {
62
- option: "--teamId [teamId]"
52
+ option: "-i, --groupId <groupId>"
63
53
  },
64
54
  {
65
55
  option: "-r, --role [type]",
@@ -70,16 +60,7 @@ class AadO365GroupUserListCommand extends GraphItemsListCommand_1.GraphItemsList
70
60
  return options.concat(parentOptions);
71
61
  }
72
62
  validate(args) {
73
- if (!args.options.groupId && !args.options.teamId) {
74
- return 'Please provide one of the following parameters: groupId or teamId';
75
- }
76
- if (args.options.groupId && args.options.teamId) {
77
- return 'You cannot provide both a groupId and teamId parameter, please provide only one';
78
- }
79
- if (args.options.teamId && !Utils_1.default.isValidGuid(args.options.teamId)) {
80
- return `${args.options.teamId} is not a valid GUID`;
81
- }
82
- if (args.options.groupId && !Utils_1.default.isValidGuid(args.options.groupId)) {
63
+ if (!Utils_1.default.isValidGuid(args.options.groupId)) {
83
64
  return `${args.options.groupId} is not a valid GUID`;
84
65
  }
85
66
  if (args.options.role) {
@@ -19,7 +19,7 @@ class AadSiteClassificationDisableCommand extends GraphCommand_1.default {
19
19
  commandAction(logger, args, cb) {
20
20
  const disableSiteClassification = () => {
21
21
  const requestOptions = {
22
- url: `${this.resource}/beta/settings`,
22
+ url: `${this.resource}/v1.0/groupSettings`,
23
23
  headers: {
24
24
  accept: 'application/json;odata.metadata=none'
25
25
  },
@@ -42,7 +42,7 @@ class AadSiteClassificationDisableCommand extends GraphCommand_1.default {
42
42
  return Promise.reject('Missing UnifiedGroupSettting id');
43
43
  }
44
44
  const requestOptions = {
45
- url: `${this.resource}/beta/settings/` + unifiedGroupSetting[0].id,
45
+ url: `${this.resource}/v1.0/groupSettings/` + unifiedGroupSetting[0].id,
46
46
  headers: {
47
47
  accept: 'application/json;odata.metadata=none',
48
48
  'content-type': 'application/json'
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const Utils_1 = require("../../../../Utils");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
+ const commands_1 = require("../../commands");
7
+ class AadUserSetCommand extends GraphCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.USER_SET;
10
+ }
11
+ get description() {
12
+ return 'Updates information about the specified user';
13
+ }
14
+ allowUnknownOptions() {
15
+ return true;
16
+ }
17
+ getTelemetryProperties(args) {
18
+ const telemetryProps = super.getTelemetryProperties(args);
19
+ telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
20
+ telemetryProps.userPrincipalName = typeof args.options.userPrincipalName !== 'undefined';
21
+ telemetryProps.accountEnabled = (!!args.options.accountEnabled).toString();
22
+ return telemetryProps;
23
+ }
24
+ commandAction(logger, args, cb) {
25
+ const manifest = this.mapRequestBody(args.options);
26
+ const requestOptions = {
27
+ url: `${this.resource}/v1.0/users/${encodeURIComponent(args.options.objectId ? args.options.objectId : args.options.userPrincipalName)}`,
28
+ headers: {
29
+ accept: 'application/json'
30
+ },
31
+ responseType: 'json',
32
+ data: manifest
33
+ };
34
+ request_1.default
35
+ .patch(requestOptions)
36
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
37
+ }
38
+ mapRequestBody(options) {
39
+ const requestBody = {};
40
+ const excludeOptions = [
41
+ 'debug',
42
+ 'verbose',
43
+ 'output',
44
+ 'objectId',
45
+ 'i',
46
+ 'userPrincipalName',
47
+ 'n',
48
+ 'accountEnabled'
49
+ ];
50
+ if (options.accountEnabled) {
51
+ requestBody['AccountEnabled'] = String(options.accountEnabled) === "true";
52
+ }
53
+ Object.keys(options).forEach(key => {
54
+ if (excludeOptions.indexOf(key) === -1) {
55
+ requestBody[key] = `${options[key]}`;
56
+ }
57
+ });
58
+ return requestBody;
59
+ }
60
+ options() {
61
+ const options = [
62
+ {
63
+ option: '-i, --objectId [objectId]'
64
+ },
65
+ {
66
+ option: '-n, --userPrincipalName [userPrincipalName]'
67
+ },
68
+ {
69
+ option: '--accountEnabled [accountEnabled]'
70
+ }
71
+ ];
72
+ const parentOptions = super.options();
73
+ return options.concat(parentOptions);
74
+ }
75
+ validate(args) {
76
+ if (!args.options.objectId && !args.options.userPrincipalName) {
77
+ return 'Specify either objectId or userPrincipalName';
78
+ }
79
+ if (args.options.objectId && args.options.userPrincipalName) {
80
+ return 'Specify either objectId or userPrincipalName but not both';
81
+ }
82
+ if (args.options.objectId &&
83
+ !Utils_1.default.isValidGuid(args.options.objectId)) {
84
+ return `${args.options.objectId} is not a valid GUID`;
85
+ }
86
+ return true;
87
+ }
88
+ }
89
+ module.exports = new AadUserSetCommand();
90
+ //# sourceMappingURL=user-set.js.map
@@ -47,6 +47,7 @@ exports.default = {
47
47
  SITECLASSIFICATION_SET: `${prefix} siteclassification set`,
48
48
  SP_GET: `${prefix} sp get`,
49
49
  USER_GET: `${prefix} user get`,
50
- USER_LIST: `${prefix} user list`
50
+ USER_LIST: `${prefix} user list`,
51
+ USER_SET: `${prefix} user set`
51
52
  };
52
53
  //# sourceMappingURL=commands.js.map
@@ -357,6 +357,19 @@ class SpoCommand extends Command_1.default {
357
357
  }
358
358
  return `${baseUrl}/${relativeUrl}`;
359
359
  }
360
+ action(logger, args, cb) {
361
+ Auth_1.default
362
+ .restoreAuth()
363
+ .then(() => {
364
+ if (Auth_1.default.service.connected && Auth_1.AuthType[Auth_1.default.service.authType] === Auth_1.AuthType[Auth_1.AuthType.Secret]) {
365
+ cb(new Command_1.CommandError(`SharePoint does not support authentication using client ID and secret. Please use a different login type to use SharePoint commands.`));
366
+ return;
367
+ }
368
+ super.action(logger, args, cb);
369
+ }, (error) => {
370
+ cb(new Command_1.CommandError(error));
371
+ });
372
+ }
360
373
  }
361
374
  exports.default = SpoCommand;
362
375
  //# sourceMappingURL=SpoCommand.js.map
@@ -48,6 +48,10 @@ class LoginCommand extends Command_1.default {
48
48
  case 'browser':
49
49
  Auth_1.default.service.authType = Auth_1.AuthType.Browser;
50
50
  break;
51
+ case 'secret':
52
+ Auth_1.default.service.authType = Auth_1.AuthType.Secret;
53
+ Auth_1.default.service.secret = args.options.secret;
54
+ break;
51
55
  }
52
56
  Auth_1.default
53
57
  .ensureAccessToken(Auth_1.default.defaultResource, logger, this.debug)
@@ -112,6 +116,9 @@ class LoginCommand extends Command_1.default {
112
116
  },
113
117
  {
114
118
  option: '--tenant [tenant]'
119
+ },
120
+ {
121
+ option: '--secret [secret]'
115
122
  }
116
123
  ];
117
124
  const parentOptions = super.options();
@@ -139,6 +146,11 @@ class LoginCommand extends Command_1.default {
139
146
  }
140
147
  }
141
148
  }
149
+ if (args.options.authType === 'secret') {
150
+ if (!args.options.secret) {
151
+ return 'Required option secret missing';
152
+ }
153
+ }
142
154
  return true;
143
155
  }
144
156
  }
@@ -32,7 +32,7 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
32
32
  sourceIsLocalFile = false;
33
33
  }
34
34
  if (args.options.targetFile.toLowerCase().startsWith('https://')) {
35
- localTargetFilePath = path.join(os.tmpdir(), uuid_1.v4());
35
+ localTargetFilePath = path.join(os.tmpdir(), (0, uuid_1.v4)());
36
36
  targetIsLocalFile = false;
37
37
  if (this.debug) {
38
38
  logger.logToStderr(`Target set to a URL. Will store the temporary converted file at ${localTargetFilePath}`);
@@ -101,7 +101,7 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
101
101
  const driveUrl = `${this.resource}/v1.0/${isAppOnlyAuth ? 'drive/root' : 'me/drive/root'}`;
102
102
  // we need the original file extension because otherwise Graph won't be able
103
103
  // to convert the file to PDF
104
- this.sourceFileGraphUrl = `${driveUrl}:/${uuid_1.v4()}${path.extname(args.options.sourceFile)}`;
104
+ this.sourceFileGraphUrl = `${driveUrl}:/${(0, uuid_1.v4)()}${path.extname(args.options.sourceFile)}`;
105
105
  if (this.debug) {
106
106
  logger.logToStderr(`Source is a local file. Uploading to ${this.sourceFileGraphUrl}...`);
107
107
  }
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Command_1 = require("../../../Command");
4
3
  const config_1 = require("../../../config");
5
4
  const request_1 = require("../../../request");
6
5
  const SpoCommand_1 = require("../../base/SpoCommand");
@@ -16,38 +15,56 @@ class OneDriveListCommand extends SpoCommand_1.default {
16
15
  return ['Title', 'Url'];
17
16
  }
18
17
  commandAction(logger, args, cb) {
19
- let spoAdminUrl = '';
20
18
  this
21
19
  .getSpoAdminUrl(logger, this.debug)
22
- .then((_spoAdminUrl) => {
23
- spoAdminUrl = _spoAdminUrl;
24
- return this.getRequestDigest(spoAdminUrl);
25
- })
26
- .then((res) => {
20
+ .then((spoAdminUrl) => {
27
21
  if (this.verbose) {
28
22
  logger.logToStderr(`Retrieving list of OneDrive sites...`);
29
23
  }
30
- const requestOptions = {
31
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
32
- headers: {
33
- 'X-RequestDigest': res.FormDigestValue
34
- },
35
- data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">1</Property><Property Name="StartIndex" Type="String">0</Property><Property Name="Template" Type="String">SPSPERS</Property></Parameter></Parameters></Method></ObjectPaths></Request>`
36
- };
37
- return request_1.default.post(requestOptions);
24
+ this.allSites = [];
25
+ return this.getAllSites(spoAdminUrl, '0', undefined, logger);
38
26
  })
39
- .then((res) => {
40
- const json = JSON.parse(res);
41
- const response = json[0];
42
- if (response.ErrorInfo) {
43
- cb(new Command_1.CommandError(response.ErrorInfo.ErrorMessage));
44
- return;
45
- }
46
- const oneDriveSites = json[json.length - 1];
47
- logger.log(oneDriveSites._Child_Items_);
27
+ .then(_ => {
28
+ logger.log(this.allSites);
48
29
  cb();
49
30
  }, (err) => this.handleRejectedPromise(err, logger, cb));
50
31
  }
32
+ getAllSites(spoAdminUrl, startIndex, formDigest, logger) {
33
+ return new Promise((resolve, reject) => {
34
+ this
35
+ .ensureFormDigest(spoAdminUrl, logger, formDigest, this.debug)
36
+ .then((res) => {
37
+ const requestOptions = {
38
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
39
+ headers: {
40
+ 'X-RequestDigest': res.FormDigestValue
41
+ },
42
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">1</Property><Property Name="StartIndex" Type="String">${startIndex}</Property><Property Name="Template" Type="String">SPSPERS</Property></Parameter></Parameters></Method></ObjectPaths></Request>`
43
+ };
44
+ return request_1.default.post(requestOptions);
45
+ })
46
+ .then((res) => {
47
+ const json = JSON.parse(res);
48
+ const response = json[0];
49
+ if (response.ErrorInfo) {
50
+ reject(response.ErrorInfo.ErrorMessage);
51
+ return;
52
+ }
53
+ else {
54
+ const sites = json[json.length - 1];
55
+ this.allSites.push(...sites._Child_Items_);
56
+ if (sites.NextStartIndexFromSharePoint) {
57
+ this
58
+ .getAllSites(spoAdminUrl, sites.NextStartIndexFromSharePoint, formDigest, logger)
59
+ .then(_ => resolve(), err => reject(err));
60
+ }
61
+ else {
62
+ resolve();
63
+ }
64
+ }
65
+ }, err => reject(err));
66
+ });
67
+ }
51
68
  }
52
69
  module.exports = new OneDriveListCommand();
53
70
  //# sourceMappingURL=onedrive-list.js.map
@@ -38,7 +38,7 @@ class PaPcfInitCommand extends AnonymousCommand_1.default {
38
38
  "$controlnameplaceholder$": args.options.name,
39
39
  "$pcfProjectName$": workingDirectoryName,
40
40
  "pcfprojecttype": workingDirectoryName,
41
- "$pcfProjectGuid$": uuid_1.v4()
41
+ "$pcfProjectGuid$": (0, uuid_1.v4)()
42
42
  };
43
43
  if (this.verbose) {
44
44
  logger.logToStderr(`name: ${args.options.name}`);
@@ -36,7 +36,7 @@ class PaSolutionInitCommand extends AnonymousCommand_1.default {
36
36
  "$publisherName$": publisherName,
37
37
  "$customizationPrefix$": publisherPrefix,
38
38
  "$customizationOptionValuePrefix$": customizationOptionValuePrefix,
39
- "$cdsProjectGuid$": uuid_1.v4(),
39
+ "$cdsProjectGuid$": (0, uuid_1.v4)(),
40
40
  "solutionprojecttype": workingDirectoryName,
41
41
  "$solutionName$": workingDirectoryName
42
42
  };