@pnp/cli-microsoft365 4.2.0-beta.bf7382d → 4.3.0-beta.0aaa522
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/.devcontainer/Dockerfile +2 -2
- package/.eslintrc.js +1 -0
- package/README.md +1 -1
- package/dist/appInsights.js +5 -2
- package/dist/cli/Cli.js +26 -4
- package/dist/m365/aad/commands/app/app-add.js +58 -5
- package/dist/m365/aad/commands/app/app-get.js +97 -0
- package/dist/m365/aad/commands/o365group/o365group-add.js +56 -50
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-add.js +5 -8
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-remove.js +6 -3
- package/dist/m365/aad/commands/oauth2grant/oauth2grant-set.js +3 -3
- package/dist/m365/aad/commands/sp/sp-add.js +107 -0
- package/dist/m365/aad/commands/user/user-password-validate.js +42 -0
- package/dist/m365/aad/commands.js +3 -0
- package/dist/m365/app/commands/permission/permission-list.js +266 -0
- package/dist/m365/app/commands.js +7 -0
- package/dist/m365/base/AppCommand.js +76 -0
- package/dist/m365/base/M365RcJson.js +3 -0
- package/dist/m365/cli/commands/cli-doctor.js +2 -0
- package/dist/m365/file/commands/file-add.js +32 -13
- package/dist/m365/file/commands/file-list.js +181 -0
- package/dist/m365/file/commands.js +2 -1
- package/dist/m365/pa/commands/app/app-list.js +28 -1
- package/dist/m365/search/commands/externalconnection/externalconnection-add.js +99 -0
- package/dist/m365/search/commands.js +7 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006005_CFG_PS_metadata.js +63 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +60 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.13.1.js +53 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0-beta.4.js +57 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +17 -13
- package/dist/m365/spfx/commands/spfx-doctor.js +176 -62
- package/dist/m365/spo/commands/contenttype/contenttype-list.js +52 -0
- package/dist/m365/spo/commands/list/list-get.js +6 -2
- package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +90 -0
- package/dist/m365/spo/commands/page/Page.js +3 -1
- package/dist/m365/spo/commands/page/page-add.js +7 -10
- package/dist/m365/spo/commands/page/page-set.js +7 -10
- package/dist/m365/spo/commands/site/site-remove.js +98 -30
- package/dist/m365/spo/commands/web/web-installedlanguage-list.js +48 -0
- package/dist/m365/spo/commands.js +4 -1
- package/dist/m365/teams/commands/report/report-directroutingcalls.js +1 -1
- package/dist/m365/teams/commands/report/report-pstncalls.js +1 -1
- package/dist/request.js +9 -4
- package/docs/docs/cmd/_global.md +2 -2
- package/docs/docs/cmd/aad/app/app-add.md +11 -0
- package/docs/docs/cmd/aad/app/app-get.md +48 -0
- package/docs/docs/cmd/aad/o365group/o365group-add.md +1 -0
- package/docs/docs/cmd/aad/oauth2grant/oauth2grant-remove.md +2 -1
- package/docs/docs/cmd/aad/oauth2grant/oauth2grant-set.md +3 -2
- package/docs/docs/cmd/aad/sp/sp-add.md +53 -0
- package/docs/docs/cmd/aad/user/user-password-validate.md +29 -0
- package/docs/docs/cmd/app/permission/permission-list.md +36 -0
- package/docs/docs/cmd/file/file-add.md +11 -0
- package/docs/docs/cmd/file/file-list.md +46 -0
- package/docs/docs/cmd/pa/app/app-list.md +17 -1
- package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +43 -0
- package/docs/docs/cmd/spfx/project/project-externalize.md +1 -1
- package/docs/docs/cmd/spfx/project/project-rename.md +1 -1
- package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
- package/docs/docs/cmd/spfx/spfx-doctor.md +1 -1
- package/docs/docs/cmd/spo/contenttype/contenttype-list.md +33 -0
- package/docs/docs/cmd/spo/list/list-get.md +9 -0
- package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +39 -0
- package/docs/docs/cmd/spo/page/page-add.md +2 -2
- package/docs/docs/cmd/spo/page/page-set.md +3 -3
- package/docs/docs/cmd/spo/site/site-remove.md +3 -1
- package/docs/docs/cmd/spo/web/web-installedlanguage-list.md +24 -0
- package/docs/docs/cmd/teams/report/report-directroutingcalls.md +0 -3
- package/docs/docs/cmd/teams/report/report-pstncalls.md +4 -3
- package/npm-shrinkwrap.json +1050 -1568
- package/package.json +29 -24
package/.devcontainer/Dockerfile
CHANGED
|
@@ -23,11 +23,11 @@ RUN apt-get update && apt-get install -y \
|
|
|
23
23
|
vim \
|
|
24
24
|
python3.8 \
|
|
25
25
|
python3-pip \
|
|
26
|
-
&& curl -sL https://deb.nodesource.com/
|
|
26
|
+
&& curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - \
|
|
27
27
|
&& apt-get install nodejs -y \
|
|
28
28
|
&& rm -rf /var/lib/apt/lists/*
|
|
29
29
|
|
|
30
|
-
RUN pip3 install mkdocs-material==
|
|
30
|
+
RUN pip3 install mkdocs-material==7.1.7 pymdown-extensions==9.0
|
|
31
31
|
|
|
32
32
|
RUN useradd \
|
|
33
33
|
--user-group \
|
package/.eslintrc.js
CHANGED
package/README.md
CHANGED
|
@@ -179,7 +179,7 @@ m365 spo site get --url https://contoso.sharepoint.com --output text
|
|
|
179
179
|
|
|
180
180
|
## Build
|
|
181
181
|
|
|
182
|
-
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>=
|
|
182
|
+
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>= 16.0.0` installed.
|
|
183
183
|
|
|
184
184
|
```sh
|
|
185
185
|
# Clone this repository
|
package/dist/appInsights.js
CHANGED
|
@@ -4,6 +4,8 @@ const packageJSON = require('../package.json');
|
|
|
4
4
|
// disable automatic third-party instrumentation for Application Insights
|
|
5
5
|
// speeds up execution by preventing loading unnecessary dependencies
|
|
6
6
|
process.env.APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 'none';
|
|
7
|
+
// prevents tests from hanging
|
|
8
|
+
process.env.APPLICATION_INSIGHTS_NO_STATSBEAT = 'true';
|
|
7
9
|
const appInsights = require("applicationinsights");
|
|
8
10
|
const crypto = require("crypto");
|
|
9
11
|
const fs = require("fs");
|
|
@@ -18,10 +20,11 @@ const env = process.env.CLIMICROSOFT365_ENV !== undefined ? process.env.CLIMICRO
|
|
|
18
20
|
appInsights.defaultClient.commonProperties = {
|
|
19
21
|
version: version,
|
|
20
22
|
node: process.version,
|
|
21
|
-
env: env
|
|
23
|
+
env: env,
|
|
24
|
+
ci: Boolean(process.env.CI).toString()
|
|
22
25
|
};
|
|
23
26
|
appInsights.defaultClient.context.tags['ai.session.id'] = crypto.randomBytes(24).toString('base64');
|
|
24
|
-
|
|
27
|
+
appInsights.defaultClient.context.tags['ai.cloud.roleInstance'] = crypto.createHash('sha256').update(appInsights.defaultClient.context.tags['ai.cloud.roleInstance']).digest('hex');
|
|
25
28
|
delete appInsights.defaultClient.context.tags['ai.cloud.role'];
|
|
26
29
|
exports.default = appInsights.defaultClient;
|
|
27
30
|
//# sourceMappingURL=appInsights.js.map
|
package/dist/cli/Cli.js
CHANGED
|
@@ -17,6 +17,7 @@ const path = require("path");
|
|
|
17
17
|
const appInsights_1 = require("../appInsights");
|
|
18
18
|
const Command_1 = require("../Command");
|
|
19
19
|
const config_1 = require("../config");
|
|
20
|
+
const request_1 = require("../request");
|
|
20
21
|
const settingsNames_1 = require("../settingsNames");
|
|
21
22
|
const Utils_1 = require("../Utils");
|
|
22
23
|
const packageJSON = require('../../package.json');
|
|
@@ -204,16 +205,20 @@ class Cli {
|
|
|
204
205
|
}
|
|
205
206
|
};
|
|
206
207
|
if (args.options.debug) {
|
|
207
|
-
|
|
208
|
+
logErr.push(`Executing command ${command.name} with options ${JSON.stringify(args)}`);
|
|
208
209
|
}
|
|
209
210
|
// store the current command name, if any and set the name to the name of
|
|
210
211
|
// the command to execute
|
|
211
212
|
const cli = Cli.getInstance();
|
|
212
213
|
const parentCommandName = cli.currentCommandName;
|
|
213
214
|
cli.currentCommandName = command.getCommandName();
|
|
215
|
+
// store the current logger if any
|
|
216
|
+
const currentLogger = request_1.default.logger;
|
|
214
217
|
command.action(logger, args, (err) => {
|
|
215
218
|
// restore the original command name
|
|
216
219
|
cli.currentCommandName = parentCommandName;
|
|
220
|
+
// restore the original logger
|
|
221
|
+
request_1.default.logger = currentLogger;
|
|
217
222
|
if (err) {
|
|
218
223
|
return reject({
|
|
219
224
|
error: err,
|
|
@@ -386,7 +391,10 @@ class Cli {
|
|
|
386
391
|
logStatementType = typeof logStatement;
|
|
387
392
|
}
|
|
388
393
|
if (!options.output || options.output === 'json') {
|
|
389
|
-
return JSON
|
|
394
|
+
return JSON
|
|
395
|
+
.stringify(logStatement, null, 2)
|
|
396
|
+
// replace unescaped newlines with escaped newlines #2807
|
|
397
|
+
.replace(/([^\\])\\n/g, '$1\\\\\\n');
|
|
390
398
|
}
|
|
391
399
|
if (logStatement instanceof Command_1.CommandError) {
|
|
392
400
|
const chalk = require('chalk');
|
|
@@ -413,11 +421,11 @@ class Cli {
|
|
|
413
421
|
if (arrayType !== 'object') {
|
|
414
422
|
return logStatement.join(os.EOL);
|
|
415
423
|
}
|
|
416
|
-
// if output type has been set to 'text', process the retrieved
|
|
424
|
+
// if output type has been set to 'text' or 'csv', process the retrieved
|
|
417
425
|
// data so that returned objects contain only default properties specified
|
|
418
426
|
// on the current command. If there is no current command or the
|
|
419
427
|
// command doesn't specify default properties, return original data
|
|
420
|
-
if (options.output === 'text') {
|
|
428
|
+
if (options.output === 'text' || options.output === 'csv') {
|
|
421
429
|
const cli = Cli.getInstance();
|
|
422
430
|
const currentCommand = cli.commandToExecute;
|
|
423
431
|
if (arrayType === 'object' &&
|
|
@@ -437,6 +445,20 @@ class Cli {
|
|
|
437
445
|
}
|
|
438
446
|
}
|
|
439
447
|
}
|
|
448
|
+
if (options.output === 'csv') {
|
|
449
|
+
const { stringify } = require('csv-stringify/sync');
|
|
450
|
+
/*
|
|
451
|
+
https://csv.js.org/stringify/options/
|
|
452
|
+
header: Display the column names on the first line if the columns option is provided or discovered.
|
|
453
|
+
escape: Single character used for escaping; only apply to characters matching the quote and the escape options default to ".
|
|
454
|
+
quote: The quote characters surrounding a field, defaults to the " (double quotation marks), an empty quote value will preserve the original field, whether it contains quotation marks or not.
|
|
455
|
+
quoted: Boolean, default to false, quote all the non-empty fields even if not required.
|
|
456
|
+
quotedEmpty: Quote empty strings and overrides quoted_string on empty strings when defined; default is false.
|
|
457
|
+
*/
|
|
458
|
+
return stringify(logStatement, {
|
|
459
|
+
header: true
|
|
460
|
+
});
|
|
461
|
+
}
|
|
440
462
|
// display object as a list of key-value pairs
|
|
441
463
|
if (logStatement.length === 1) {
|
|
442
464
|
const obj = logStatement[0];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
3
4
|
const uuid_1 = require("uuid");
|
|
4
5
|
const Auth_1 = require("../../../../Auth");
|
|
5
6
|
const request_1 = require("../../../../request");
|
|
@@ -7,6 +8,10 @@ const Utils_1 = require("../../../../Utils");
|
|
|
7
8
|
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
8
9
|
const commands_1 = require("../../commands");
|
|
9
10
|
class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.appName = '';
|
|
14
|
+
}
|
|
10
15
|
get name() {
|
|
11
16
|
return commands_1.default.APP_ADD;
|
|
12
17
|
}
|
|
@@ -32,18 +37,23 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
32
37
|
this
|
|
33
38
|
.resolveApis(args, logger)
|
|
34
39
|
.then(apis => this.createAppRegistration(args, apis, logger))
|
|
40
|
+
.then(appInfo => {
|
|
41
|
+
// based on the assumption that we're adding AAD app to the current
|
|
42
|
+
// directory. If we in the future extend the command with allowing
|
|
43
|
+
// users to create AAD app in a different directory, we'll need to
|
|
44
|
+
// adjust this
|
|
45
|
+
appInfo.tenantId = Utils_1.default.getTenantIdFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
|
|
46
|
+
return Promise.resolve(appInfo);
|
|
47
|
+
})
|
|
35
48
|
.then(appInfo => this.updateAppFromManifest(args, appInfo))
|
|
36
49
|
.then(appInfo => this.configureUri(args, appInfo, logger))
|
|
37
50
|
.then(appInfo => this.configureSecret(args, appInfo, logger))
|
|
51
|
+
.then(appInfo => this.saveAppInfo(args, appInfo, logger))
|
|
38
52
|
.then((_appInfo) => {
|
|
39
53
|
const appInfo = {
|
|
40
54
|
appId: _appInfo.appId,
|
|
41
55
|
objectId: _appInfo.id,
|
|
42
|
-
|
|
43
|
-
// directory. If we in the future extend the command with allowing
|
|
44
|
-
// users to create AAD app in a different directory, we'll need to
|
|
45
|
-
// adjust this
|
|
46
|
-
tenantId: Utils_1.default.getTenantIdFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken)
|
|
56
|
+
tenantId: _appInfo.tenantId
|
|
47
57
|
};
|
|
48
58
|
if (_appInfo.secret) {
|
|
49
59
|
appInfo.secret = _appInfo.secret;
|
|
@@ -60,6 +70,7 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
60
70
|
if (!applicationInfo.displayName && this.manifest) {
|
|
61
71
|
applicationInfo.displayName = this.manifest.name;
|
|
62
72
|
}
|
|
73
|
+
this.appName = applicationInfo.displayName;
|
|
63
74
|
if (apis.length > 0) {
|
|
64
75
|
applicationInfo.requiredResourceAccess = apis;
|
|
65
76
|
}
|
|
@@ -332,6 +343,45 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
332
343
|
return Promise.resolve(appInfo);
|
|
333
344
|
});
|
|
334
345
|
}
|
|
346
|
+
saveAppInfo(args, appInfo, logger) {
|
|
347
|
+
if (!args.options.save) {
|
|
348
|
+
return Promise.resolve(appInfo);
|
|
349
|
+
}
|
|
350
|
+
const filePath = '.m365rc.json';
|
|
351
|
+
if (this.verbose) {
|
|
352
|
+
logger.logToStderr(`Saving Azure AD app registration information to the ${filePath} file...`);
|
|
353
|
+
}
|
|
354
|
+
let m365rc = {};
|
|
355
|
+
if (fs.existsSync(filePath)) {
|
|
356
|
+
if (this.debug) {
|
|
357
|
+
logger.logToStderr(`Reading existing ${filePath}...`);
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
361
|
+
if (fileContents) {
|
|
362
|
+
m365rc = JSON.parse(fileContents);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
catch (e) {
|
|
366
|
+
logger.logToStderr(`Error reading ${filePath}: ${e}. Please add app info to ${filePath} manually.`);
|
|
367
|
+
return Promise.resolve(appInfo);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!m365rc.apps) {
|
|
371
|
+
m365rc.apps = [];
|
|
372
|
+
}
|
|
373
|
+
m365rc.apps.push({
|
|
374
|
+
appId: appInfo.appId,
|
|
375
|
+
name: this.appName
|
|
376
|
+
});
|
|
377
|
+
try {
|
|
378
|
+
fs.writeFileSync(filePath, JSON.stringify(m365rc, null, 2));
|
|
379
|
+
}
|
|
380
|
+
catch (e) {
|
|
381
|
+
logger.logToStderr(`Error writing ${filePath}: ${e}. Please add app info to ${filePath} manually.`);
|
|
382
|
+
}
|
|
383
|
+
return Promise.resolve(appInfo);
|
|
384
|
+
}
|
|
335
385
|
options() {
|
|
336
386
|
const options = [
|
|
337
387
|
{
|
|
@@ -377,6 +427,9 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
377
427
|
},
|
|
378
428
|
{
|
|
379
429
|
option: '--manifest [manifest]'
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
option: '--save'
|
|
380
433
|
}
|
|
381
434
|
];
|
|
382
435
|
const parentOptions = super.options();
|
|
@@ -0,0 +1,97 @@
|
|
|
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 AadAppGetCommand extends GraphCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.APP_GET;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Gets an Azure AD app registration';
|
|
13
|
+
}
|
|
14
|
+
getTelemetryProperties(args) {
|
|
15
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
|
+
telemetryProps.appId = typeof args.options.appId !== 'undefined';
|
|
17
|
+
telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
|
|
18
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
19
|
+
return telemetryProps;
|
|
20
|
+
}
|
|
21
|
+
commandAction(logger, args, cb) {
|
|
22
|
+
this
|
|
23
|
+
.getAppObjectId(args)
|
|
24
|
+
.then((appObjectId) => {
|
|
25
|
+
const requestOptions = {
|
|
26
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appObjectId}`,
|
|
27
|
+
headers: {
|
|
28
|
+
accept: 'application/json;odata.metadata=none'
|
|
29
|
+
},
|
|
30
|
+
responseType: 'json'
|
|
31
|
+
};
|
|
32
|
+
return request_1.default.get(requestOptions);
|
|
33
|
+
})
|
|
34
|
+
.then((res) => {
|
|
35
|
+
logger.log(res);
|
|
36
|
+
cb();
|
|
37
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
38
|
+
}
|
|
39
|
+
getAppObjectId(args) {
|
|
40
|
+
if (args.options.objectId) {
|
|
41
|
+
return Promise.resolve(args.options.objectId);
|
|
42
|
+
}
|
|
43
|
+
const { appId, name } = args.options;
|
|
44
|
+
const filter = appId ?
|
|
45
|
+
`appId eq '${encodeURIComponent(appId)}'` :
|
|
46
|
+
`displayName eq '${encodeURIComponent(name)}'`;
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
|
|
49
|
+
headers: {
|
|
50
|
+
accept: 'application/json;odata.metadata=none'
|
|
51
|
+
},
|
|
52
|
+
responseType: 'json'
|
|
53
|
+
};
|
|
54
|
+
return request_1.default
|
|
55
|
+
.get(requestOptions)
|
|
56
|
+
.then((res) => {
|
|
57
|
+
if (res.value.length === 1) {
|
|
58
|
+
return Promise.resolve(res.value[0].id);
|
|
59
|
+
}
|
|
60
|
+
if (res.value.length === 0) {
|
|
61
|
+
const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
|
|
62
|
+
return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
|
|
63
|
+
}
|
|
64
|
+
return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please disambiguate (app object IDs): ${res.value.map(a => a.id).join(', ')}`);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
options() {
|
|
68
|
+
const options = [
|
|
69
|
+
{ option: '--appId [appId]' },
|
|
70
|
+
{ option: '--objectId [objectId]' },
|
|
71
|
+
{ option: '--name [name]' }
|
|
72
|
+
];
|
|
73
|
+
const parentOptions = super.options();
|
|
74
|
+
return options.concat(parentOptions);
|
|
75
|
+
}
|
|
76
|
+
validate(args) {
|
|
77
|
+
if (!args.options.appId &&
|
|
78
|
+
!args.options.objectId &&
|
|
79
|
+
!args.options.name) {
|
|
80
|
+
return 'Specify either appId, objectId, or name';
|
|
81
|
+
}
|
|
82
|
+
if ((args.options.appId && args.options.objectId) ||
|
|
83
|
+
(args.options.appId && args.options.name) ||
|
|
84
|
+
(args.options.objectId && args.options.name)) {
|
|
85
|
+
return 'Specify either appId, objectId, or name but not both';
|
|
86
|
+
}
|
|
87
|
+
if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
|
|
88
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
89
|
+
}
|
|
90
|
+
if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
|
|
91
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
module.exports = new AadAppGetCommand();
|
|
97
|
+
//# sourceMappingURL=app-get.js.map
|
|
@@ -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
|
-
|
|
39
|
-
.
|
|
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 (
|
|
65
|
-
|
|
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(
|
|
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/${
|
|
85
|
+
"@odata.id": `https://graph.microsoft.com/v1.0/users/${ownerId}`
|
|
95
86
|
}
|
|
96
87
|
})));
|
|
97
88
|
})
|
|
98
89
|
.then(() => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
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(
|
|
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/${
|
|
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)
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const request_1 = require("../../../../request");
|
|
4
4
|
const Utils_1 = require("../../../../Utils");
|
|
5
|
-
const
|
|
5
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
6
6
|
const commands_1 = require("../../commands");
|
|
7
|
-
class AadOAuth2GrantAddCommand extends
|
|
7
|
+
class AadOAuth2GrantAddCommand extends GraphCommand_1.default {
|
|
8
8
|
get name() {
|
|
9
9
|
return commands_1.default.OAUTH2GRANT_ADD;
|
|
10
10
|
}
|
|
@@ -16,20 +16,17 @@ class AadOAuth2GrantAddCommand extends AadCommand_1.default {
|
|
|
16
16
|
logger.logToStderr(`Granting the service principal specified permissions...`);
|
|
17
17
|
}
|
|
18
18
|
const requestOptions = {
|
|
19
|
-
url: `${this.resource}/
|
|
19
|
+
url: `${this.resource}/v1.0/oauth2PermissionGrants`,
|
|
20
20
|
headers: {
|
|
21
|
-
'content-type': 'application/json'
|
|
21
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
22
22
|
},
|
|
23
23
|
responseType: 'json',
|
|
24
24
|
data: {
|
|
25
|
-
"odata.type": "Microsoft.DirectoryServices.OAuth2PermissionGrant",
|
|
26
25
|
"clientId": args.options.clientId,
|
|
27
26
|
"consentType": "AllPrincipals",
|
|
28
27
|
"principalId": null,
|
|
29
28
|
"resourceId": args.options.resourceId,
|
|
30
|
-
"scope": args.options.scope
|
|
31
|
-
"startTime": "0001-01-01T00:00:00",
|
|
32
|
-
"expiryTime": "9000-01-01T00:00:00"
|
|
29
|
+
"scope": args.options.scope
|
|
33
30
|
}
|
|
34
31
|
};
|
|
35
32
|
request_1.default
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const request_1 = require("../../../../request");
|
|
4
|
-
const
|
|
4
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
5
5
|
const commands_1 = require("../../commands");
|
|
6
|
-
class AadOAuth2GrantRemoveCommand extends
|
|
6
|
+
class AadOAuth2GrantRemoveCommand extends GraphCommand_1.default {
|
|
7
7
|
get name() {
|
|
8
8
|
return commands_1.default.OAUTH2GRANT_REMOVE;
|
|
9
9
|
}
|
|
@@ -15,7 +15,10 @@ class AadOAuth2GrantRemoveCommand extends AadCommand_1.default {
|
|
|
15
15
|
logger.logToStderr(`Removing OAuth2 permissions...`);
|
|
16
16
|
}
|
|
17
17
|
const requestOptions = {
|
|
18
|
-
url: `${this.resource}/
|
|
18
|
+
url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
|
|
19
|
+
headers: {
|
|
20
|
+
'accept': 'application/json;odata.metadata=none'
|
|
21
|
+
},
|
|
19
22
|
responseType: 'json'
|
|
20
23
|
};
|
|
21
24
|
request_1.default
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const request_1 = require("../../../../request");
|
|
4
|
-
const
|
|
4
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
5
5
|
const commands_1 = require("../../commands");
|
|
6
|
-
class AadOAuth2GrantSetCommand extends
|
|
6
|
+
class AadOAuth2GrantSetCommand extends GraphCommand_1.default {
|
|
7
7
|
get name() {
|
|
8
8
|
return commands_1.default.OAUTH2GRANT_SET;
|
|
9
9
|
}
|
|
@@ -15,7 +15,7 @@ class AadOAuth2GrantSetCommand extends AadCommand_1.default {
|
|
|
15
15
|
logger.logToStderr(`Updating OAuth2 permissions...`);
|
|
16
16
|
}
|
|
17
17
|
const requestOptions = {
|
|
18
|
-
url: `${this.resource}/
|
|
18
|
+
url: `${this.resource}/v1.0/oauth2PermissionGrants/${encodeURIComponent(args.options.grantId)}`,
|
|
19
19
|
headers: {
|
|
20
20
|
'content-type': 'application/json'
|
|
21
21
|
},
|