@pnp/cli-microsoft365 10.10.0-beta.eb74779 → 10.11.0-beta.24af61c
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/.eslintrc.cjs +2 -0
- package/Dockerfile +2 -2
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/config.js +1 -0
- package/dist/m365/base/GraphApplicationCommand.js +17 -0
- package/dist/m365/base/{DelegatedGraphCommand.js → GraphDelegatedCommand.js} +4 -4
- package/dist/m365/base/PowerAppsCommand.js +1 -1
- package/dist/m365/base/PowerAutomateCommand.js +1 -1
- package/dist/m365/base/PowerBICommand.js +1 -1
- package/dist/m365/base/PowerPlatformCommand.js +1 -1
- package/dist/m365/base/VivaEngageCommand.js +1 -1
- package/dist/m365/cli/commands/app/app-add.js +95 -0
- package/dist/m365/cli/commands.js +1 -0
- package/dist/m365/entra/commands/app/app-get.js +11 -52
- package/dist/m365/entra/commands/app/app-permission-add.js +19 -30
- package/dist/m365/entra/commands/app/app-permission-list.js +2 -19
- package/dist/m365/entra/commands/app/app-permission-remove.js +22 -31
- package/dist/m365/entra/commands/app/app-remove.js +2 -18
- package/dist/m365/entra/commands/app/app-role-add.js +10 -43
- package/dist/m365/entra/commands/app/app-role-list.js +2 -20
- package/dist/m365/entra/commands/app/app-role-remove.js +9 -40
- package/dist/m365/entra/commands/app/app-set.js +2 -19
- package/dist/m365/entra/commands/group/group-member-add.js +55 -10
- package/dist/m365/entra/commands/group/group-member-set.js +18 -3
- package/dist/m365/entra/commands/organization/organization-set.js +104 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/outlook/commands/message/message-move.js +1 -1
- package/dist/m365/pp/commands/managementapp/managementapp-add.js +7 -21
- package/dist/m365/spe/commands/container/container-recyclebinitem-restore.js +96 -0
- package/dist/m365/spe/commands.js +1 -0
- package/dist/m365/spfx/commands/project/base-project-command.js +1 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.21.0.js +2 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.21.1.js +2 -0
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.22.0-beta.1.js +21 -0
- package/dist/m365/spfx/commands/project/project-doctor/rules/FN002022_DEVDEP_typescript.js +10 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-model/SassJson.js +2 -0
- package/dist/m365/spfx/commands/project/project-model/index.js +1 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002001_DEVDEP_microsoft_sp_build_web.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002004_DEVDEP_gulp.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002007_DEVDEP_ajv.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002029_DEVDEP_microsoft_rush_stack_compiler_5_3.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002030_DEVDEP_microsoft_spfx_web_build_rig.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002031_DEVDEP_rushstack_heft.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002032_DEVDEP_typescript_eslint_parser.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002033_DEVDEP_jest_junit.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010011_YORC_useGulp.js +40 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015010_FILE_gulpfile_js.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015011_FILE_tsconfig_json.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015012_FILE_config_heft_json.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015013_FILE_config_jest_config_json.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015014_FILE_config_rig_json.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015015_FILE_config_typescript_json.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021004_PKG_scripts_build.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021005_PKG_scripts_test.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021006_PKG_scripts_clean.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021007_PKG_scripts_deploy.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021008_PKG_scripts_start.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021009_PKG_scripts_build_watch.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021010_PKG_scripts_package_solution.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021011_PKG_scripts_deploy_azure_storage.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021012_PKG_scripts_eject_webpack.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN021013_PKG_overrides_rushstack_heft.js +45 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN023003_GITIGNORE_libdts.js +36 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN023004_GITIGNORE_libcommonjs.js +36 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN023005_GITIGNORE_libesm.js +36 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN023006_GITIGNORE_jestoutput.js +36 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN026001_CFG_SASS_schema.js +40 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN026002_CFG_SASS_extends.js +40 -0
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FileAddRemoveRule.js +7 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.22.0-beta.1.js +241 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +16 -13
- package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
- package/dist/m365/spo/commands/file/file-version-get.js +1 -0
- package/dist/m365/spo/commands/file/file-version-list.js +2 -2
- package/dist/m365/spo/commands/homesite/homesite-remove.js +57 -37
- package/dist/m365/spo/commands/list/list-view-add.js +140 -87
- package/dist/m365/spo/commands/page/Page.js +10 -3
- package/dist/m365/spo/commands/page/clientsidepages.js +4 -0
- package/dist/m365/spo/commands/page/page-section-add.js +73 -13
- package/dist/m365/spo/commands/page/page-section-list.js +5 -1
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-permissionrequest-list.js +13 -7
- package/dist/m365/spo/commands/site/site-appcatalog-list.js +38 -2
- package/dist/m365/spo/commands/tenant/tenant-site-unarchive.js +1 -1
- package/dist/m365/teams/commands/callrecord/callrecord-list.js +100 -0
- package/dist/m365/teams/commands/chat/chat-message-send.js +2 -2
- package/dist/m365/teams/commands/message/message-remove.js +2 -2
- package/dist/m365/teams/commands/message/message-restore.js +2 -2
- package/dist/m365/teams/commands.js +1 -0
- package/dist/m365/todo/commands/list/list-add.js +2 -2
- package/dist/m365/todo/commands/list/list-get.js +2 -2
- package/dist/m365/todo/commands/list/list-list.js +2 -2
- package/dist/m365/todo/commands/list/list-remove.js +2 -2
- package/dist/m365/todo/commands/list/list-set.js +2 -2
- package/dist/m365/todo/commands/task/task-add.js +2 -2
- package/dist/m365/todo/commands/task/task-get.js +2 -2
- package/dist/m365/todo/commands/task/task-list.js +2 -2
- package/dist/m365/todo/commands/task/task-remove.js +2 -2
- package/dist/m365/todo/commands/task/task-set.js +2 -2
- package/dist/m365/viva/commands/engage/EngageRole.js +2 -0
- package/dist/m365/viva/commands/engage/engage-role-list.js +28 -0
- package/dist/m365/viva/commands/engage/engage-role-member-list.js +57 -0
- package/dist/m365/viva/commands.js +2 -0
- package/dist/utils/accessToken.js +9 -5
- package/dist/utils/entraApp.js +15 -0
- package/dist/utils/entraGroup.js +43 -0
- package/dist/utils/vivaEngage.js +19 -0
- package/docs/docs/cmd/cli/app/app-add.mdx +50 -0
- package/docs/docs/cmd/entra/group/group-member-add.mdx +26 -5
- package/docs/docs/cmd/entra/group/group-member-set.mdx +7 -4
- package/docs/docs/cmd/entra/organization/organization-set.mdx +84 -0
- package/docs/docs/cmd/spe/container/container-recyclebinitem-restore.mdx +53 -0
- package/docs/docs/cmd/spo/file/file-version-get.mdx +5 -2
- package/docs/docs/cmd/spo/file/file-version-list.mdx +7 -5
- package/docs/docs/cmd/spo/homesite/homesite-remove.mdx +6 -3
- package/docs/docs/cmd/spo/list/list-view-add.mdx +53 -10
- package/docs/docs/cmd/spo/page/page-section-add.mdx +22 -2
- package/docs/docs/cmd/spo/site/site-appcatalog-list.mdx +11 -0
- package/docs/docs/cmd/spo/tenant/tenant-site-unarchive.mdx +1 -1
- package/docs/docs/cmd/teams/callrecord/callrecord-list.mdx +173 -0
- package/docs/docs/cmd/viva/engage/engage-role-list.mdx +102 -0
- package/docs/docs/cmd/viva/engage/engage-role-member-list.mdx +118 -0
- package/npm-shrinkwrap.json +293 -765
- package/package.json +18 -17
package/dist/config.js
CHANGED
|
@@ -16,6 +16,7 @@ export default {
|
|
|
16
16
|
'https://graph.microsoft.com/Community.ReadWrite.All',
|
|
17
17
|
'https://graph.microsoft.com/Directory.AccessAsUser.All',
|
|
18
18
|
'https://graph.microsoft.com/Directory.ReadWrite.All',
|
|
19
|
+
'https://graph.microsoft.com/EngagementRole.ReadWrite.All',
|
|
19
20
|
'https://graph.microsoft.com/ExternalConnection.ReadWrite.All',
|
|
20
21
|
'https://graph.microsoft.com/ExternalItem.ReadWrite.All',
|
|
21
22
|
'https://graph.microsoft.com/FileStorageContainer.Selected',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import auth from '../../Auth.js';
|
|
2
|
+
import { accessToken } from '../../utils/accessToken.js';
|
|
3
|
+
import GraphCommand from './GraphCommand.js';
|
|
4
|
+
/**
|
|
5
|
+
* This command class is for application-only Graph commands.
|
|
6
|
+
*/
|
|
7
|
+
export default class GraphApplicationCommand extends GraphCommand {
|
|
8
|
+
async initAction(args, logger) {
|
|
9
|
+
await super.initAction(args, logger);
|
|
10
|
+
if (!auth.connection.active) {
|
|
11
|
+
// we fail no login in the base command command class
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
accessToken.assertAccessTokenType('application');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=GraphApplicationCommand.js.map
|
|
@@ -2,16 +2,16 @@ import auth from '../../Auth.js';
|
|
|
2
2
|
import { accessToken } from '../../utils/accessToken.js';
|
|
3
3
|
import GraphCommand from './GraphCommand.js';
|
|
4
4
|
/**
|
|
5
|
-
* This command class is for delegated
|
|
5
|
+
* This command class is for delegated Graph commands.
|
|
6
6
|
*/
|
|
7
|
-
export default class
|
|
7
|
+
export default class GraphDelegatedCommand extends GraphCommand {
|
|
8
8
|
async initAction(args, logger) {
|
|
9
9
|
await super.initAction(args, logger);
|
|
10
10
|
if (!auth.connection.active) {
|
|
11
11
|
// we fail no login in the base command command class
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
accessToken.
|
|
14
|
+
accessToken.assertAccessTokenType('delegated');
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=GraphDelegatedCommand.js.map
|
|
@@ -14,7 +14,7 @@ export default class PowerAppsCommand extends Command {
|
|
|
14
14
|
if (auth.connection.cloudType !== CloudType.Public) {
|
|
15
15
|
throw new CommandError(`Power Apps commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
|
|
16
16
|
}
|
|
17
|
-
accessToken.
|
|
17
|
+
accessToken.assertAccessTokenType('delegated');
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=PowerAppsCommand.js.map
|
|
@@ -14,7 +14,7 @@ export default class PowerAutomateCommand extends Command {
|
|
|
14
14
|
if (auth.connection.cloudType !== CloudType.Public) {
|
|
15
15
|
throw new CommandError(`Power Automate commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
|
|
16
16
|
}
|
|
17
|
-
accessToken.
|
|
17
|
+
accessToken.assertAccessTokenType('delegated');
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=PowerAutomateCommand.js.map
|
|
@@ -11,7 +11,7 @@ export default class PowerBICommand extends Command {
|
|
|
11
11
|
// we fail no login in the base command command class
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
accessToken.
|
|
14
|
+
accessToken.assertAccessTokenType('delegated');
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=PowerBICommand.js.map
|
|
@@ -14,7 +14,7 @@ export default class PowerPlatformCommand extends Command {
|
|
|
14
14
|
if (auth.connection.cloudType !== CloudType.Public) {
|
|
15
15
|
throw new CommandError(`Power Platform commands only support the public cloud at the moment. We'll add support for other clouds in the future. Sorry for the inconvenience.`);
|
|
16
16
|
}
|
|
17
|
-
accessToken.
|
|
17
|
+
accessToken.assertAccessTokenType('delegated');
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=PowerPlatformCommand.js.map
|
|
@@ -11,7 +11,7 @@ export default class VivaEngageCommand extends Command {
|
|
|
11
11
|
// we fail no login in the base command command class
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
accessToken.
|
|
14
|
+
accessToken.assertAccessTokenType('delegated');
|
|
15
15
|
}
|
|
16
16
|
handleRejectedODataJsonPromise(response) {
|
|
17
17
|
if (response.statusCode === 404) {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
|
+
import { zod } from '../../../../utils/zod.js';
|
|
4
|
+
import config from '../../../../config.js';
|
|
5
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
6
|
+
import commands from '../../commands.js';
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import { entraApp } from '../../../../utils/entraApp.js';
|
|
9
|
+
import { accessToken } from '../../../../utils/accessToken.js';
|
|
10
|
+
import auth from '../../../../Auth.js';
|
|
11
|
+
const options = globalOptionsZod
|
|
12
|
+
.extend({
|
|
13
|
+
name: zod.alias('n', z.string().optional().default('CLI for M365')),
|
|
14
|
+
scopes: zod.alias('s', z.string().optional().default('minimal')),
|
|
15
|
+
saveToConfig: z.boolean().optional()
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
class CliAppAddCommand extends GraphCommand {
|
|
19
|
+
get name() {
|
|
20
|
+
return commands.APP_ADD;
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return 'Creates a Microsoft Entra application registration for CLI for Microsoft 365';
|
|
24
|
+
}
|
|
25
|
+
get schema() {
|
|
26
|
+
return options;
|
|
27
|
+
}
|
|
28
|
+
getRefinedSchema(schema) {
|
|
29
|
+
return schema
|
|
30
|
+
.refine(options => {
|
|
31
|
+
const scopes = options.scopes;
|
|
32
|
+
if (!scopes.includes(',')) {
|
|
33
|
+
return scopes === 'minimal' || scopes === 'all';
|
|
34
|
+
}
|
|
35
|
+
const scopeList = scopes.split(',').map(s => s.trim());
|
|
36
|
+
return scopeList.every(scope => scope.startsWith('https'));
|
|
37
|
+
}, {
|
|
38
|
+
message: "Scopes must be 'minimal', 'all', or comma-separated list of URLs starting with 'https'. 'minimal' and 'all' cannot be combined with other scopes.",
|
|
39
|
+
path: ['scopes']
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async commandAction(logger, args) {
|
|
43
|
+
try {
|
|
44
|
+
const options = {
|
|
45
|
+
allowPublicClientFlows: true,
|
|
46
|
+
apisDelegated: this.getScopes(args.options),
|
|
47
|
+
implicitFlow: false,
|
|
48
|
+
multitenant: false,
|
|
49
|
+
name: args.options.name,
|
|
50
|
+
platform: 'publicClient',
|
|
51
|
+
redirectUris: 'http://localhost,https://localhost,https://login.microsoftonline.com/common/oauth2/nativeclient'
|
|
52
|
+
};
|
|
53
|
+
const apis = await entraApp.resolveApis({
|
|
54
|
+
options,
|
|
55
|
+
logger,
|
|
56
|
+
verbose: this.verbose,
|
|
57
|
+
debug: this.debug
|
|
58
|
+
});
|
|
59
|
+
const appInfo = await entraApp.createAppRegistration({
|
|
60
|
+
options,
|
|
61
|
+
unknownOptions: {},
|
|
62
|
+
apis,
|
|
63
|
+
logger,
|
|
64
|
+
verbose: this.verbose,
|
|
65
|
+
debug: this.debug
|
|
66
|
+
});
|
|
67
|
+
appInfo.tenantId = accessToken.getTenantIdFromAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
|
|
68
|
+
await entraApp.grantAdminConsent({
|
|
69
|
+
appInfo,
|
|
70
|
+
appPermissions: entraApp.appPermissions,
|
|
71
|
+
adminConsent: true,
|
|
72
|
+
logger,
|
|
73
|
+
debug: this.debug
|
|
74
|
+
});
|
|
75
|
+
if (args.options.saveToConfig) {
|
|
76
|
+
cli.getConfig().set('clientId', appInfo.appId);
|
|
77
|
+
cli.getConfig().set('tenantId', appInfo.tenantId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
this.handleRejectedODataJsonPromise(err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
getScopes(options) {
|
|
85
|
+
if (options.scopes === 'all') {
|
|
86
|
+
return config.allScopes.join(',');
|
|
87
|
+
}
|
|
88
|
+
else if (options.scopes === 'minimal') {
|
|
89
|
+
return config.minimalScopes.join(',');
|
|
90
|
+
}
|
|
91
|
+
return options.scopes;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export default new CliAppAddCommand();
|
|
95
|
+
//# sourceMappingURL=app-add.js.map
|
|
@@ -5,12 +5,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraAppGetCommand_instances, _EntraAppGetCommand_initTelemetry, _EntraAppGetCommand_initOptions, _EntraAppGetCommand_initValidators, _EntraAppGetCommand_initOptionSets;
|
|
7
7
|
import fs from 'fs';
|
|
8
|
-
import request from '../../../../request.js';
|
|
9
|
-
import { formatting } from '../../../../utils/formatting.js';
|
|
10
8
|
import { validation } from '../../../../utils/validation.js';
|
|
11
9
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
10
|
import commands from '../../commands.js';
|
|
13
|
-
import { cli } from '../../../../cli/cli.js';
|
|
14
11
|
import { entraApp } from '../../../../utils/entraApp.js';
|
|
15
12
|
class EntraAppGetCommand extends GraphCommand {
|
|
16
13
|
get name() {
|
|
@@ -29,8 +26,7 @@ class EntraAppGetCommand extends GraphCommand {
|
|
|
29
26
|
}
|
|
30
27
|
async commandAction(logger, args) {
|
|
31
28
|
try {
|
|
32
|
-
const
|
|
33
|
-
const appInfo = await this.getAppInfo(appObjectId, args.options.properties);
|
|
29
|
+
const appInfo = await this.getAppInfo(args, logger);
|
|
34
30
|
const res = await this.saveAppInfo(args, appInfo, logger);
|
|
35
31
|
await logger.log(res);
|
|
36
32
|
}
|
|
@@ -38,58 +34,21 @@ class EntraAppGetCommand extends GraphCommand {
|
|
|
38
34
|
this.handleRejectedODataJsonPromise(err);
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
async
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const { appId, name } = args.options;
|
|
37
|
+
async getAppInfo(args, logger) {
|
|
38
|
+
const { objectId, appId, name } = args.options;
|
|
39
|
+
const properties = args.options.properties?.split(',');
|
|
46
40
|
if (this.verbose) {
|
|
47
|
-
await logger.logToStderr(`Retrieving information about Microsoft Entra app ${appId ? appId : name}...`);
|
|
41
|
+
await logger.logToStderr(`Retrieving information about Microsoft Entra app ${objectId ? objectId : (appId ? appId : name)}...`);
|
|
48
42
|
}
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
return app.id;
|
|
43
|
+
if (objectId) {
|
|
44
|
+
return await entraApp.getAppRegistrationByObjectId(objectId, properties);
|
|
52
45
|
}
|
|
53
|
-
else {
|
|
54
|
-
|
|
55
|
-
url: `${this.resource}/v1.0/myorganization/applications?$filter=displayName eq '${formatting.encodeQueryParameter(name)}'&$select=id`,
|
|
56
|
-
headers: {
|
|
57
|
-
accept: 'application/json;odata.metadata=none'
|
|
58
|
-
},
|
|
59
|
-
responseType: 'json'
|
|
60
|
-
};
|
|
61
|
-
const res = await request.get(requestOptions);
|
|
62
|
-
if (res.value.length === 1) {
|
|
63
|
-
return res.value[0].id;
|
|
64
|
-
}
|
|
65
|
-
if (res.value.length === 0) {
|
|
66
|
-
throw `No Microsoft Entra application registration with name ${name} found`;
|
|
67
|
-
}
|
|
68
|
-
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
|
|
69
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Microsoft Entra application registrations with name '${name}' found.`, resultAsKeyValuePair);
|
|
70
|
-
return result.id;
|
|
46
|
+
else if (appId) {
|
|
47
|
+
return await entraApp.getAppRegistrationByAppId(appId, properties);
|
|
71
48
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const queryParameters = [];
|
|
75
|
-
if (properties) {
|
|
76
|
-
const allProperties = properties.split(',');
|
|
77
|
-
const selectProperties = allProperties.filter(prop => !prop.includes('/'));
|
|
78
|
-
if (selectProperties.length > 0) {
|
|
79
|
-
queryParameters.push(`$select=${selectProperties}`);
|
|
80
|
-
}
|
|
49
|
+
else {
|
|
50
|
+
return await entraApp.getAppRegistrationByAppName(name, properties);
|
|
81
51
|
}
|
|
82
|
-
const queryString = queryParameters.length > 0
|
|
83
|
-
? `?${queryParameters.join('&')}`
|
|
84
|
-
: '';
|
|
85
|
-
const requestOptions = {
|
|
86
|
-
url: `${this.resource}/v1.0/myorganization/applications/${appObjectId}${queryString}`,
|
|
87
|
-
headers: {
|
|
88
|
-
accept: 'application/json;odata.metadata=none'
|
|
89
|
-
},
|
|
90
|
-
responseType: 'json'
|
|
91
|
-
};
|
|
92
|
-
return request.get(requestOptions);
|
|
93
52
|
}
|
|
94
53
|
async saveAppInfo(args, appInfo, logger) {
|
|
95
54
|
if (!args.options.save) {
|
|
@@ -9,8 +9,7 @@ import GraphCommand from "../../../base/GraphCommand.js";
|
|
|
9
9
|
import commands from "../../commands.js";
|
|
10
10
|
import request from "../../../../request.js";
|
|
11
11
|
import { validation } from "../../../../utils/validation.js";
|
|
12
|
-
import {
|
|
13
|
-
import { cli } from "../../../../cli/cli.js";
|
|
12
|
+
import { entraApp } from "../../../../utils/entraApp.js";
|
|
14
13
|
import { entraServicePrincipal } from "../../../../utils/entraServicePrincipal.js";
|
|
15
14
|
var ScopeType;
|
|
16
15
|
(function (ScopeType) {
|
|
@@ -34,35 +33,35 @@ class EntraAppPermissionAddCommand extends GraphCommand {
|
|
|
34
33
|
}
|
|
35
34
|
async commandAction(logger, args) {
|
|
36
35
|
try {
|
|
37
|
-
const
|
|
36
|
+
const entraApp = await this.getEntraApp(args.options, logger);
|
|
38
37
|
const servicePrincipals = await this.getServicePrincipals();
|
|
39
38
|
const appPermissions = [];
|
|
40
39
|
if (args.options.delegatedPermissions) {
|
|
41
40
|
const delegatedPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.delegatedPermissions, ScopeType.Scope, appPermissions, logger);
|
|
42
|
-
this.addPermissionsToResourceArray(delegatedPermissions,
|
|
41
|
+
this.addPermissionsToResourceArray(delegatedPermissions, entraApp.requiredResourceAccess);
|
|
43
42
|
}
|
|
44
43
|
if (args.options.applicationPermissions) {
|
|
45
44
|
const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermissions, ScopeType.Role, appPermissions, logger);
|
|
46
|
-
this.addPermissionsToResourceArray(applicationPermissions,
|
|
45
|
+
this.addPermissionsToResourceArray(applicationPermissions, entraApp.requiredResourceAccess);
|
|
47
46
|
}
|
|
48
47
|
const addPermissionsRequestOptions = {
|
|
49
|
-
url: `${this.resource}/v1.0/applications/${
|
|
48
|
+
url: `${this.resource}/v1.0/applications/${entraApp.id}`,
|
|
50
49
|
headers: {
|
|
51
50
|
accept: 'application/json;odata.metadata=none'
|
|
52
51
|
},
|
|
53
52
|
responseType: 'json',
|
|
54
53
|
data: {
|
|
55
|
-
requiredResourceAccess:
|
|
54
|
+
requiredResourceAccess: entraApp.requiredResourceAccess
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
57
|
await request.patch(addPermissionsRequestOptions);
|
|
59
58
|
if (args.options.grantAdminConsent) {
|
|
60
|
-
let appServicePrincipal = servicePrincipals.find(sp => sp.appId ===
|
|
59
|
+
let appServicePrincipal = servicePrincipals.find(sp => sp.appId === entraApp.appId);
|
|
61
60
|
if (!appServicePrincipal) {
|
|
62
61
|
if (this.verbose) {
|
|
63
|
-
await logger.logToStderr(`Creating service principal for app ${
|
|
62
|
+
await logger.logToStderr(`Creating service principal for app ${entraApp.appId}...`);
|
|
64
63
|
}
|
|
65
|
-
appServicePrincipal = await entraServicePrincipal.createServicePrincipal(
|
|
64
|
+
appServicePrincipal = await entraServicePrincipal.createServicePrincipal(entraApp.appId);
|
|
66
65
|
}
|
|
67
66
|
await this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
|
|
68
67
|
}
|
|
@@ -71,30 +70,20 @@ class EntraAppPermissionAddCommand extends GraphCommand {
|
|
|
71
70
|
this.handleRejectedODataJsonPromise(err);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
async
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
apps = await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=appId eq '${options.appId}'&$select=id,appId,requiredResourceAccess`);
|
|
79
|
-
appNotFoundMessage = `client id ${options.appId}`;
|
|
73
|
+
async getEntraApp(options, logger) {
|
|
74
|
+
const { appObjectId, appId, appName } = options;
|
|
75
|
+
if (this.verbose) {
|
|
76
|
+
await logger.logToStderr(`Retrieving information about Microsoft Entra app ${appObjectId ? appObjectId : (appId ? appId : appName)}...`);
|
|
80
77
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
appNotFoundMessage = `name ${options.appName}`;
|
|
84
|
-
if (apps.length > 1) {
|
|
85
|
-
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', apps);
|
|
86
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Entra application registrations with name '${options.appName}' found.`, resultAsKeyValuePair);
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
78
|
+
if (appObjectId) {
|
|
79
|
+
return await entraApp.getAppRegistrationByObjectId(appObjectId, ['id', 'appId', 'requiredResourceAccess']);
|
|
89
80
|
}
|
|
90
|
-
else if (
|
|
91
|
-
|
|
92
|
-
appNotFoundMessage = `object id ${options.appObjectId}`;
|
|
81
|
+
else if (appId) {
|
|
82
|
+
return await entraApp.getAppRegistrationByAppId(appId, ['id', 'appId', 'requiredResourceAccess']);
|
|
93
83
|
}
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
else {
|
|
85
|
+
return await entraApp.getAppRegistrationByAppName(appName, ['id', 'appId', 'requiredResourceAccess']);
|
|
96
86
|
}
|
|
97
|
-
return apps[0];
|
|
98
87
|
}
|
|
99
88
|
async getServicePrincipals() {
|
|
100
89
|
return await odata.getAllItems(`${this.resource}/v1.0/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
|
|
@@ -8,8 +8,6 @@ import GraphCommand from "../../../base/GraphCommand.js";
|
|
|
8
8
|
import commands from "../../commands.js";
|
|
9
9
|
import request from "../../../../request.js";
|
|
10
10
|
import { validation } from "../../../../utils/validation.js";
|
|
11
|
-
import { formatting } from "../../../../utils/formatting.js";
|
|
12
|
-
import { cli } from "../../../../cli/cli.js";
|
|
13
11
|
import { entraApp } from "../../../../utils/entraApp.js";
|
|
14
12
|
class EntraAppPermissionListCommand extends GraphCommand {
|
|
15
13
|
get name() {
|
|
@@ -51,23 +49,8 @@ class EntraAppPermissionListCommand extends GraphCommand {
|
|
|
51
49
|
return app.id;
|
|
52
50
|
}
|
|
53
51
|
else {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
headers: {
|
|
57
|
-
accept: 'application/json;odata.metadata=none'
|
|
58
|
-
},
|
|
59
|
-
responseType: 'json'
|
|
60
|
-
};
|
|
61
|
-
const res = await request.get(requestOptions);
|
|
62
|
-
if (res.value.length === 1) {
|
|
63
|
-
return res.value[0].id;
|
|
64
|
-
}
|
|
65
|
-
if (res.value.length === 0) {
|
|
66
|
-
throw `No Microsoft Entra application registration with name ${appName} found`;
|
|
67
|
-
}
|
|
68
|
-
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
|
|
69
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Entra application registrations with name '${appName}' found.`, resultAsKeyValuePair);
|
|
70
|
-
return result.id;
|
|
52
|
+
const app = await entraApp.getAppRegistrationByAppName(appName, ["id"]);
|
|
53
|
+
return app.id;
|
|
71
54
|
}
|
|
72
55
|
}
|
|
73
56
|
async getAppRegPermissions(appObjectId, permissionType, logger) {
|
|
@@ -10,7 +10,7 @@ import commands from "../../commands.js";
|
|
|
10
10
|
import request from "../../../../request.js";
|
|
11
11
|
import { validation } from "../../../../utils/validation.js";
|
|
12
12
|
import { cli } from "../../../../cli/cli.js";
|
|
13
|
-
import {
|
|
13
|
+
import { entraApp } from "../../../../utils/entraApp.js";
|
|
14
14
|
var ScopeType;
|
|
15
15
|
(function (ScopeType) {
|
|
16
16
|
ScopeType["Role"] = "Role";
|
|
@@ -38,41 +38,41 @@ class EntraAppPermissionRemoveCommand extends GraphCommand {
|
|
|
38
38
|
if (this.verbose) {
|
|
39
39
|
await logger.logToStderr(`Removing permissions from application ${args.options.appId || args.options.appObjectId || args.options.appName}...`);
|
|
40
40
|
}
|
|
41
|
-
const
|
|
41
|
+
const entraApp = await this.getEntraApp(args.options, logger);
|
|
42
42
|
const servicePrincipals = await odata.getAllItems(`${this.resource}/v1.0/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
|
|
43
43
|
const appPermissions = [];
|
|
44
44
|
if (args.options.delegatedPermissions) {
|
|
45
45
|
const delegatedPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.delegatedPermissions, ScopeType.Scope, appPermissions, logger);
|
|
46
|
-
this.removePermissionsFromResourceArray(delegatedPermissions,
|
|
46
|
+
this.removePermissionsFromResourceArray(delegatedPermissions, entraApp.requiredResourceAccess);
|
|
47
47
|
}
|
|
48
48
|
if (args.options.applicationPermissions) {
|
|
49
49
|
const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermissions, ScopeType.Role, appPermissions, logger);
|
|
50
|
-
this.removePermissionsFromResourceArray(applicationPermissions,
|
|
50
|
+
this.removePermissionsFromResourceArray(applicationPermissions, entraApp.requiredResourceAccess);
|
|
51
51
|
}
|
|
52
|
-
for (let i = 0; i <
|
|
53
|
-
if (
|
|
54
|
-
|
|
52
|
+
for (let i = 0; i < entraApp.requiredResourceAccess.length; i++) {
|
|
53
|
+
if (entraApp.requiredResourceAccess[i].resourceAccess?.length === 0) {
|
|
54
|
+
entraApp.requiredResourceAccess.splice(i, 1);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
const removePermissionRequestOptions = {
|
|
58
|
-
url: `${this.resource}/v1.0/applications/${
|
|
58
|
+
url: `${this.resource}/v1.0/applications/${entraApp.id}`,
|
|
59
59
|
headers: {
|
|
60
60
|
accept: 'application/json;odata.metadata=none'
|
|
61
61
|
},
|
|
62
62
|
responseType: 'json',
|
|
63
63
|
data: {
|
|
64
|
-
requiredResourceAccess:
|
|
64
|
+
requiredResourceAccess: entraApp.requiredResourceAccess
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
await request.patch(removePermissionRequestOptions);
|
|
68
68
|
if (args.options.revokeAdminConsent) {
|
|
69
|
-
const appServicePrincipal = servicePrincipals.find(sp => sp.appId ===
|
|
69
|
+
const appServicePrincipal = servicePrincipals.find(sp => sp.appId === entraApp.appId);
|
|
70
70
|
if (appServicePrincipal) {
|
|
71
71
|
await this.revokeAdminConsent(appServicePrincipal, appPermissions, logger);
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
74
|
if (this.debug) {
|
|
75
|
-
await logger.logToStderr(`No service principal found for the appId: ${
|
|
75
|
+
await logger.logToStderr(`No service principal found for the appId: ${entraApp.appId}. Skipping revoking admin consent.`);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -91,29 +91,20 @@ class EntraAppPermissionRemoveCommand extends GraphCommand {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
async
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
responseType: 'json'
|
|
103
|
-
};
|
|
104
|
-
return request.get(requestOptions);
|
|
94
|
+
async getEntraApp(options, logger) {
|
|
95
|
+
const { appObjectId, appId, appName } = options;
|
|
96
|
+
if (this.verbose) {
|
|
97
|
+
await logger.logToStderr(`Retrieving information about Microsoft Entra app ${appObjectId ? appObjectId : (appId ? appId : appName)}...`);
|
|
98
|
+
}
|
|
99
|
+
if (appObjectId) {
|
|
100
|
+
return await entraApp.getAppRegistrationByObjectId(appObjectId, ['id', 'appId', 'requiredResourceAccess']);
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
: await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=displayName eq '${options.appName}'&${selectProperties}`);
|
|
109
|
-
if (apps.length === 0) {
|
|
110
|
-
throw `App with ${options.appId ? 'id' : 'name'} ${options.appId || options.appName} not found in Microsoft Entra ID`;
|
|
102
|
+
else if (appId) {
|
|
103
|
+
return await entraApp.getAppRegistrationByAppId(appId, ['id', 'appId', 'requiredResourceAccess']);
|
|
111
104
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return cli.handleMultipleResultsFound(`Multiple apps with name '${options.appName}' found.`, resultAsKeyValuePair);
|
|
105
|
+
else {
|
|
106
|
+
return await entraApp.getAppRegistrationByAppName(appName, ['id', 'appId', 'requiredResourceAccess']);
|
|
115
107
|
}
|
|
116
|
-
return apps[0];
|
|
117
108
|
}
|
|
118
109
|
async revokeAdminConsent(servicePrincipal, appPermissions, logger) {
|
|
119
110
|
// Check if contains app permissions
|
|
@@ -7,7 +7,6 @@ var _EntraAppRemoveCommand_instances, _EntraAppRemoveCommand_initTelemetry, _Ent
|
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
9
|
import { entraApp } from '../../../../utils/entraApp.js';
|
|
10
|
-
import { formatting } from '../../../../utils/formatting.js';
|
|
11
10
|
import { validation } from '../../../../utils/validation.js';
|
|
12
11
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
12
|
import commands from '../../commands.js';
|
|
@@ -69,23 +68,8 @@ class EntraAppRemoveCommand extends GraphCommand {
|
|
|
69
68
|
return app.id;
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
headers: {
|
|
75
|
-
accept: 'application/json;odata.metadata=none'
|
|
76
|
-
},
|
|
77
|
-
responseType: 'json'
|
|
78
|
-
};
|
|
79
|
-
const res = await request.get(requestOptions);
|
|
80
|
-
if (res.value.length === 1) {
|
|
81
|
-
return res.value[0].id;
|
|
82
|
-
}
|
|
83
|
-
if (res.value.length === 0) {
|
|
84
|
-
throw `No Microsoft Entra application registration with name ${name} found`;
|
|
85
|
-
}
|
|
86
|
-
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
|
|
87
|
-
const result = await cli.handleMultipleResultsFound(`Multiple Microsoft Entra application registration with name '${name}' found.`, resultAsKeyValuePair);
|
|
88
|
-
return result.id;
|
|
71
|
+
const app = await entraApp.getAppRegistrationByAppName(name, ['id']);
|
|
72
|
+
return app.id;
|
|
89
73
|
}
|
|
90
74
|
}
|
|
91
75
|
}
|