@pnp/cli-microsoft365 10.0.0-beta.48e9f7d → 10.0.0-beta.58f28f9
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +17 -16
- package/dist/AuthServer.js +7 -7
- package/dist/Command.js +4 -1
- package/dist/api.js +1 -1
- package/dist/cli/cli.js +14 -0
- package/dist/config.js +61 -5
- package/dist/m365/base/PowerAutomateCommand.js +1 -1
- package/dist/m365/base/SpoCommand.js +1 -1
- package/dist/m365/cli/commands/cli-consent.js +2 -2
- package/dist/m365/cli/commands/cli-doctor.js +4 -4
- package/dist/m365/cli/commands/config/config-set.js +12 -4
- package/dist/m365/cli/commands.js +1 -2
- package/dist/m365/commands/login.js +28 -9
- package/dist/m365/commands/setup.js +256 -33
- package/dist/m365/commands/setupPresets.js +2 -4
- package/dist/m365/connection/commands/connection-list.js +4 -4
- package/dist/m365/entra/commands/app/app-add.js +52 -288
- package/dist/m365/entra/commands/m365group/m365group-set.js +24 -16
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +5 -12
- package/dist/m365/entra/commands/oauth2grant/oauth2grant-list.js +3 -12
- package/dist/m365/external/commands/item/item-add.js +2 -5
- package/dist/m365/file/commands/file-move.js +135 -0
- package/dist/m365/file/commands.js +2 -1
- package/dist/m365/flow/commands/environment/environment-get.js +1 -1
- package/dist/m365/flow/commands/environment/environment-list.js +2 -2
- package/dist/m365/flow/commands/flow-disable.js +1 -1
- package/dist/m365/flow/commands/flow-enable.js +1 -1
- package/dist/m365/flow/commands/flow-export.js +17 -16
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/flow/commands/flow-list.js +1 -1
- package/dist/m365/flow/commands/flow-remove.js +1 -1
- package/dist/m365/flow/commands/owner/owner-ensure.js +1 -1
- package/dist/m365/flow/commands/owner/owner-list.js +1 -1
- package/dist/m365/flow/commands/owner/owner-remove.js +1 -1
- package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-list.js +47 -0
- package/dist/m365/flow/commands/recyclebinitem/recyclebinitem-restore.js +48 -0
- package/dist/m365/flow/commands/run/run-cancel.js +1 -1
- package/dist/m365/flow/commands/run/run-get.js +1 -1
- package/dist/m365/flow/commands/run/run-list.js +1 -1
- package/dist/m365/flow/commands/run/run-resubmit.js +2 -2
- package/dist/m365/flow/commands.js +2 -0
- package/dist/m365/pa/commands/app/app-list.js +1 -6
- package/dist/m365/pa/commands/connector/connector-list.js +1 -6
- package/dist/m365/pa/commands/environment/environment-list.js +1 -1
- package/dist/m365/pp/commands/environment/environment-list.js +1 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.20.0-rc.1.js +25 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.20.0-rc.1.js +57 -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/app/app-instance-list.js +3 -18
- package/dist/m365/spo/commands/app/app-list.js +1 -8
- package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +8 -8
- package/dist/m365/spo/commands/contenttype/contenttype-field-set.js +2 -2
- package/dist/m365/spo/commands/feature/feature-list.js +1 -8
- package/dist/m365/spo/commands/file/file-copy.js +5 -1
- package/dist/m365/spo/commands/file/file-move.js +55 -33
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +17 -54
- package/dist/m365/spo/commands/file/file-roleassignment-remove.js +13 -40
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +5 -13
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +5 -13
- package/dist/m365/spo/commands/folder/folder-sharinglink-add.js +143 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-clear.js +111 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-remove.js +95 -0
- package/dist/m365/spo/commands/list/list-get.js +17 -4
- package/dist/m365/spo/commands/list/list-webhook-list.js +1 -6
- package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +1 -8
- package/dist/m365/spo/commands/page/page-list.js +1 -1
- package/dist/m365/spo/commands/page/page-section-add.js +185 -34
- package/dist/m365/spo/commands/page/page-template-list.js +1 -3
- package/dist/m365/spo/commands/site/SiteAdmin.js +2 -0
- package/dist/m365/spo/commands/site/site-admin-add.js +252 -0
- package/dist/m365/spo/commands/site/site-admin-list.js +10 -36
- package/dist/m365/spo/commands/site/site-admin-remove.js +194 -0
- package/dist/m365/spo/commands/sitescript/sitescript-get.js +3 -2
- package/dist/m365/spo/commands/sitescript/sitescript-list.js +1 -3
- package/dist/m365/spo/commands/{site/site-rename.js → tenant/tenant-site-rename.js} +29 -32
- package/dist/m365/spo/commands/theme/theme-list.js +1 -1
- package/dist/m365/spo/commands/user/user-get.js +67 -9
- package/dist/m365/spo/commands/web/web-clientsidewebpart-list.js +1 -6
- package/dist/m365/spo/commands.js +6 -1
- package/dist/m365/spp/commands/contentcenter/contentcenter-list.js +56 -0
- package/dist/m365/spp/commands.js +5 -0
- package/dist/m365/teams/MeetingTranscript.js +2 -0
- package/dist/m365/teams/commands/meeting/meeting-transcript-get.js +152 -0
- package/dist/m365/teams/commands/tab/tab-list.js +5 -3
- package/dist/m365/teams/commands.js +1 -0
- package/dist/m365/viva/commands/engage/Community.js +2 -0
- package/dist/m365/viva/commands/engage/engage-community-list.js +28 -0
- package/dist/m365/viva/commands.js +1 -0
- package/dist/request.js +46 -61
- package/dist/settingsNames.js +6 -1
- package/dist/utils/driveUtil.js +51 -0
- package/dist/utils/entraApp.js +283 -0
- package/dist/utils/spo.js +76 -8
- package/dist/utils/timersUtil.js +12 -0
- package/dist/utils/zod.js +1 -1
- package/docs/docs/_clisettings.mdx +6 -1
- package/docs/docs/cmd/cli/cli-doctor.mdx +24 -23
- package/docs/docs/cmd/entra/m365group/m365group-report-activitystorage.mdx +2 -2
- package/docs/docs/cmd/entra/m365group/m365group-set.mdx +9 -6
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +0 -3
- package/docs/docs/cmd/external/item/item-add.mdx +3 -3
- package/docs/docs/cmd/file/file-move.mdx +79 -0
- package/docs/docs/cmd/flow/recyclebinitem/recyclebinitem-list.mdx +132 -0
- package/docs/docs/cmd/flow/recyclebinitem/recyclebinitem-restore.mdx +55 -0
- package/docs/docs/cmd/setup.mdx +17 -6
- package/docs/docs/cmd/spo/cdn/cdn-get.mdx +1 -1
- package/docs/docs/cmd/spo/cdn/cdn-origin-add.mdx +1 -1
- package/docs/docs/cmd/spo/cdn/cdn-origin-list.mdx +1 -1
- package/docs/docs/cmd/spo/cdn/cdn-origin-remove.mdx +1 -1
- package/docs/docs/cmd/spo/cdn/cdn-policy-list.mdx +1 -1
- package/docs/docs/cmd/spo/cdn/cdn-policy-set.mdx +1 -1
- package/docs/docs/cmd/spo/contenttype/contenttype-field-remove.mdx +7 -7
- package/docs/docs/cmd/spo/contenttype/contenttype-field-set.mdx +2 -2
- package/docs/docs/cmd/spo/externaluser/externaluser-list.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-move.mdx +116 -9
- package/docs/docs/cmd/spo/folder/folder-sharinglink-add.mdx +125 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-clear.mdx +50 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-remove.mdx +50 -0
- package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-get.mdx +1 -1
- package/docs/docs/cmd/spo/hidedefaultthemes/hidedefaultthemes-set.mdx +1 -1
- package/docs/docs/cmd/spo/homesite/homesite-remove.mdx +1 -1
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-get.mdx +1 -1
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-remove.mdx +1 -1
- package/docs/docs/cmd/spo/knowledgehub/knowledgehub-set.mdx +1 -1
- package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-add.mdx +1 -1
- package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-list.mdx +1 -1
- package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-remove.mdx +1 -1
- package/docs/docs/cmd/spo/orgnewssite/orgnewssite-list.mdx +1 -1
- package/docs/docs/cmd/spo/orgnewssite/orgnewssite-remove.mdx +1 -1
- package/docs/docs/cmd/spo/orgnewssite/orgnewssite-set.mdx +1 -1
- package/docs/docs/cmd/spo/page/page-section-add.mdx +57 -2
- package/docs/docs/cmd/spo/site/site-admin-add.mdx +67 -0
- package/docs/docs/cmd/spo/site/site-admin-list.mdx +64 -12
- package/docs/docs/cmd/spo/site/site-admin-remove.mdx +67 -0
- package/docs/docs/cmd/spo/site/site-appcatalog-add.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-commsite-enable.mdx +1 -1
- package/docs/docs/cmd/spo/site/site-list.mdx +6 -4
- package/docs/docs/cmd/spo/site/site-set.mdx +1 -1
- package/docs/docs/cmd/spo/sitescript/sitescript-get.mdx +14 -1
- package/docs/docs/cmd/spo/storageentity/storageentity-remove.mdx +1 -1
- package/docs/docs/cmd/spo/storageentity/storageentity-set.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-appcatalog-add.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-appcatalogurl-get.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-list.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-remove.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-settings-list.mdx +1 -1
- package/docs/docs/cmd/spo/{site/site-rename.mdx → tenant/tenant-site-rename.mdx} +7 -7
- package/docs/docs/cmd/spo/theme/theme-apply.mdx +1 -1
- package/docs/docs/cmd/spo/theme/theme-get.mdx +1 -1
- package/docs/docs/cmd/spo/theme/theme-list.mdx +1 -1
- package/docs/docs/cmd/spo/theme/theme-remove.mdx +1 -1
- package/docs/docs/cmd/spo/theme/theme-set.mdx +1 -1
- package/docs/docs/cmd/spo/user/user-get.mdx +35 -9
- package/docs/docs/cmd/spp/contentcenter/contentcenter-list.mdx +287 -0
- package/docs/docs/cmd/teams/meeting/meeting-transcript-get.mdx +132 -0
- package/docs/docs/cmd/teams/tab/tab-list.mdx +1 -2
- package/docs/docs/cmd/viva/engage/engage-community-list.mdx +81 -0
- package/npm-shrinkwrap.json +203 -375
- package/package.json +16 -17
- package/dist/m365/cli/commands/cli-reconsent.js +0 -30
- package/docs/docs/cmd/cli/cli-reconsent.mdx +0 -62
|
@@ -9,10 +9,10 @@ import { v4 } from 'uuid';
|
|
|
9
9
|
import auth from '../../../../Auth.js';
|
|
10
10
|
import request from '../../../../request.js';
|
|
11
11
|
import { accessToken } from '../../../../utils/accessToken.js';
|
|
12
|
-
import {
|
|
12
|
+
import { entraApp } from '../../../../utils/entraApp.js';
|
|
13
13
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
14
|
-
import commands from '../../commands.js';
|
|
15
14
|
import aadCommands from '../../aadCommands.js';
|
|
15
|
+
import commands from '../../commands.js';
|
|
16
16
|
class EntraAppAddCommand extends GraphCommand {
|
|
17
17
|
get name() {
|
|
18
18
|
return commands.APP_ADD;
|
|
@@ -27,7 +27,6 @@ class EntraAppAddCommand extends GraphCommand {
|
|
|
27
27
|
super();
|
|
28
28
|
_EntraAppAddCommand_instances.add(this);
|
|
29
29
|
this.appName = '';
|
|
30
|
-
this.appPermissions = [];
|
|
31
30
|
__classPrivateFieldGet(this, _EntraAppAddCommand_instances, "m", _EntraAppAddCommand_initTelemetry).call(this);
|
|
32
31
|
__classPrivateFieldGet(this, _EntraAppAddCommand_instances, "m", _EntraAppAddCommand_initOptions).call(this);
|
|
33
32
|
__classPrivateFieldGet(this, _EntraAppAddCommand_instances, "m", _EntraAppAddCommand_initValidators).call(this);
|
|
@@ -35,16 +34,38 @@ class EntraAppAddCommand extends GraphCommand {
|
|
|
35
34
|
}
|
|
36
35
|
async commandAction(logger, args) {
|
|
37
36
|
await this.showDeprecationWarning(logger, aadCommands.APP_ADD, commands.APP_ADD);
|
|
37
|
+
if (!args.options.name && this.manifest) {
|
|
38
|
+
args.options.name = this.manifest.name;
|
|
39
|
+
}
|
|
40
|
+
this.appName = args.options.name;
|
|
38
41
|
try {
|
|
39
|
-
const apis = await
|
|
40
|
-
|
|
42
|
+
const apis = await entraApp.resolveApis({
|
|
43
|
+
options: args.options,
|
|
44
|
+
manifest: this.manifest,
|
|
45
|
+
logger,
|
|
46
|
+
verbose: this.verbose,
|
|
47
|
+
debug: this.debug
|
|
48
|
+
});
|
|
49
|
+
let appInfo = await entraApp.createAppRegistration({
|
|
50
|
+
options: args.options,
|
|
51
|
+
apis,
|
|
52
|
+
logger,
|
|
53
|
+
verbose: this.verbose,
|
|
54
|
+
debug: this.debug
|
|
55
|
+
});
|
|
41
56
|
// based on the assumption that we're adding Microsoft Entra app to the current
|
|
42
57
|
// directory. If we in the future extend the command with allowing
|
|
43
58
|
// users to create Microsoft Entra app in a different directory, we'll need to
|
|
44
59
|
// adjust this
|
|
45
60
|
appInfo.tenantId = accessToken.getTenantIdFromAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
|
|
46
61
|
appInfo = await this.updateAppFromManifest(args, appInfo);
|
|
47
|
-
appInfo = await
|
|
62
|
+
appInfo = await entraApp.grantAdminConsent({
|
|
63
|
+
appInfo,
|
|
64
|
+
appPermissions: entraApp.appPermissions,
|
|
65
|
+
adminConsent: args.options.grantAdminConsent,
|
|
66
|
+
logger,
|
|
67
|
+
debug: this.debug
|
|
68
|
+
});
|
|
48
69
|
appInfo = await this.configureUri(args, appInfo, logger);
|
|
49
70
|
appInfo = await this.configureSecret(args, appInfo, logger);
|
|
50
71
|
const _appInfo = await this.saveAppInfo(args, appInfo, logger);
|
|
@@ -62,128 +83,45 @@ class EntraAppAddCommand extends GraphCommand {
|
|
|
62
83
|
this.handleRejectedODataJsonPromise(err);
|
|
63
84
|
}
|
|
64
85
|
}
|
|
65
|
-
async
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
signInAudience: args.options.multitenant ? 'AzureADMultipleOrgs' : 'AzureADMyOrg'
|
|
69
|
-
};
|
|
70
|
-
if (!applicationInfo.displayName && this.manifest) {
|
|
71
|
-
applicationInfo.displayName = this.manifest.name;
|
|
72
|
-
}
|
|
73
|
-
this.appName = applicationInfo.displayName;
|
|
74
|
-
if (apis.length > 0) {
|
|
75
|
-
applicationInfo.requiredResourceAccess = apis;
|
|
76
|
-
}
|
|
77
|
-
if (args.options.redirectUris) {
|
|
78
|
-
applicationInfo[args.options.platform] = {
|
|
79
|
-
redirectUris: args.options.redirectUris.split(',').map(u => u.trim())
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (args.options.implicitFlow) {
|
|
83
|
-
if (!applicationInfo.web) {
|
|
84
|
-
applicationInfo.web = {};
|
|
85
|
-
}
|
|
86
|
-
applicationInfo.web.implicitGrantSettings = {
|
|
87
|
-
enableAccessTokenIssuance: true,
|
|
88
|
-
enableIdTokenIssuance: true
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
if (args.options.certificateFile || args.options.certificateBase64Encoded) {
|
|
92
|
-
const certificateBase64Encoded = await this.getCertificateBase64Encoded(args, logger);
|
|
93
|
-
const newKeyCredential = {
|
|
94
|
-
type: "AsymmetricX509Cert",
|
|
95
|
-
usage: "Verify",
|
|
96
|
-
displayName: args.options.certificateDisplayName,
|
|
97
|
-
key: certificateBase64Encoded
|
|
98
|
-
};
|
|
99
|
-
applicationInfo.keyCredentials = [newKeyCredential];
|
|
100
|
-
}
|
|
101
|
-
if (args.options.allowPublicClientFlows) {
|
|
102
|
-
applicationInfo.isFallbackPublicClient = true;
|
|
86
|
+
async configureSecret(args, appInfo, logger) {
|
|
87
|
+
if (!args.options.withSecret || (appInfo.secrets && appInfo.secrets.length > 0)) {
|
|
88
|
+
return appInfo;
|
|
103
89
|
}
|
|
104
90
|
if (this.verbose) {
|
|
105
|
-
await logger.logToStderr(`
|
|
106
|
-
}
|
|
107
|
-
const createApplicationRequestOptions = {
|
|
108
|
-
url: `${this.resource}/v1.0/myorganization/applications`,
|
|
109
|
-
headers: {
|
|
110
|
-
accept: 'application/json;odata.metadata=none'
|
|
111
|
-
},
|
|
112
|
-
responseType: 'json',
|
|
113
|
-
data: applicationInfo
|
|
114
|
-
};
|
|
115
|
-
return request.post(createApplicationRequestOptions);
|
|
116
|
-
}
|
|
117
|
-
async grantAdminConsent(appInfo, adminConsent, logger) {
|
|
118
|
-
if (!adminConsent || this.appPermissions.length === 0) {
|
|
119
|
-
return appInfo;
|
|
91
|
+
await logger.logToStderr(`Configure Microsoft Entra app secret...`);
|
|
120
92
|
}
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
|
|
93
|
+
const secret = await this.createSecret({ appObjectId: appInfo.id });
|
|
94
|
+
if (!appInfo.secrets) {
|
|
95
|
+
appInfo.secrets = [];
|
|
124
96
|
}
|
|
125
|
-
|
|
126
|
-
this.appPermissions.forEach(async (permission) => {
|
|
127
|
-
if (permission.scope.length > 0) {
|
|
128
|
-
tasks.push(this.grantOAuth2Permission(sp.id, permission.resourceId, permission.scope.join(' ')));
|
|
129
|
-
if (this.debug) {
|
|
130
|
-
await logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with delegated permissions: ${permission.scope.join(',')}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
permission.resourceAccess.filter(access => access.type === "Role").forEach(async (access) => {
|
|
134
|
-
tasks.push(this.addRoleToServicePrincipal(sp.id, permission.resourceId, access.id));
|
|
135
|
-
if (this.debug) {
|
|
136
|
-
await logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with application permission: ${access.id}`);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
await Promise.all(tasks);
|
|
97
|
+
appInfo.secrets.push(secret);
|
|
141
98
|
return appInfo;
|
|
142
99
|
}
|
|
143
|
-
async
|
|
100
|
+
async createSecret({ appObjectId, displayName = undefined, expirationDate = undefined }) {
|
|
101
|
+
let secretExpirationDate = expirationDate;
|
|
102
|
+
if (!secretExpirationDate) {
|
|
103
|
+
secretExpirationDate = new Date();
|
|
104
|
+
secretExpirationDate.setFullYear(secretExpirationDate.getFullYear() + 1);
|
|
105
|
+
}
|
|
106
|
+
const secretName = displayName ?? 'Default';
|
|
144
107
|
const requestOptions = {
|
|
145
|
-
url: `${this.resource}/v1.0/myorganization/
|
|
146
|
-
headers: {
|
|
147
|
-
'Content-Type': 'application/json'
|
|
148
|
-
},
|
|
149
|
-
responseType: 'json',
|
|
150
|
-
data: {
|
|
151
|
-
appRoleId: appRoleId,
|
|
152
|
-
principalId: objectId,
|
|
153
|
-
resourceId: resourceId
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
return request.post(requestOptions);
|
|
157
|
-
}
|
|
158
|
-
async grantOAuth2Permission(appId, resourceId, scopeName) {
|
|
159
|
-
const grantAdminConsentApplicationRequestOptions = {
|
|
160
|
-
url: `${this.resource}/v1.0/myorganization/oauth2PermissionGrants`,
|
|
108
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appObjectId}/addPassword`,
|
|
161
109
|
headers: {
|
|
162
|
-
|
|
110
|
+
'content-type': 'application/json'
|
|
163
111
|
},
|
|
164
112
|
responseType: 'json',
|
|
165
113
|
data: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
scope: scopeName
|
|
114
|
+
passwordCredential: {
|
|
115
|
+
displayName: secretName,
|
|
116
|
+
endDateTime: secretExpirationDate.toISOString()
|
|
117
|
+
}
|
|
171
118
|
}
|
|
172
119
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
url: `${this.resource}/v1.0/myorganization/servicePrincipals`,
|
|
178
|
-
headers: {
|
|
179
|
-
'content-type': 'application/json'
|
|
180
|
-
},
|
|
181
|
-
data: {
|
|
182
|
-
appId: appId
|
|
183
|
-
},
|
|
184
|
-
responseType: 'json'
|
|
120
|
+
const response = await request.post(requestOptions);
|
|
121
|
+
return {
|
|
122
|
+
displayName: secretName,
|
|
123
|
+
value: response.secretText
|
|
185
124
|
};
|
|
186
|
-
return request.post(requestOptions);
|
|
187
125
|
}
|
|
188
126
|
async updateAppFromManifest(args, appInfo) {
|
|
189
127
|
if (!args.options.manifest) {
|
|
@@ -423,180 +361,6 @@ class EntraAppAddCommand extends GraphCommand {
|
|
|
423
361
|
await request.patch(requestOptions);
|
|
424
362
|
return appInfo;
|
|
425
363
|
}
|
|
426
|
-
async resolveApis(args, logger) {
|
|
427
|
-
if (!args.options.apisDelegated && !args.options.apisApplication
|
|
428
|
-
&& (typeof this.manifest?.requiredResourceAccess === 'undefined' || this.manifest.requiredResourceAccess.length === 0)) {
|
|
429
|
-
return [];
|
|
430
|
-
}
|
|
431
|
-
if (this.verbose) {
|
|
432
|
-
await logger.logToStderr('Resolving requested APIs...');
|
|
433
|
-
}
|
|
434
|
-
const servicePrincipals = await odata.getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
|
|
435
|
-
let resolvedApis = [];
|
|
436
|
-
try {
|
|
437
|
-
if (args.options.apisDelegated || args.options.apisApplication) {
|
|
438
|
-
resolvedApis = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisDelegated, 'Scope', logger);
|
|
439
|
-
if (this.verbose) {
|
|
440
|
-
await logger.logToStderr(`Resolved delegated permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
|
|
441
|
-
}
|
|
442
|
-
const resolvedApplicationApis = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisApplication, 'Role', logger);
|
|
443
|
-
if (this.verbose) {
|
|
444
|
-
await logger.logToStderr(`Resolved application permissions: ${JSON.stringify(resolvedApplicationApis, null, 2)}`);
|
|
445
|
-
}
|
|
446
|
-
// merge resolved application APIs onto resolved delegated APIs
|
|
447
|
-
resolvedApplicationApis.forEach(resolvedRequiredResource => {
|
|
448
|
-
const requiredResource = resolvedApis.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
|
|
449
|
-
if (requiredResource) {
|
|
450
|
-
requiredResource.resourceAccess.push(...resolvedRequiredResource.resourceAccess);
|
|
451
|
-
}
|
|
452
|
-
else {
|
|
453
|
-
resolvedApis.push(resolvedRequiredResource);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
const manifestApis = this.manifest.requiredResourceAccess;
|
|
459
|
-
manifestApis.forEach(manifestApi => {
|
|
460
|
-
resolvedApis.push(manifestApi);
|
|
461
|
-
const app = servicePrincipals.find(servicePrincipals => servicePrincipals.appId === manifestApi.resourceAppId);
|
|
462
|
-
if (app) {
|
|
463
|
-
manifestApi.resourceAccess.forEach((res => {
|
|
464
|
-
const resourceAccessPermission = {
|
|
465
|
-
id: res.id,
|
|
466
|
-
type: res.type
|
|
467
|
-
};
|
|
468
|
-
const oAuthValue = app.oauth2PermissionScopes.find(scp => scp.id === res.id)?.value;
|
|
469
|
-
this.updateAppPermissions(app.id, resourceAccessPermission, oAuthValue);
|
|
470
|
-
}));
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
if (this.verbose) {
|
|
475
|
-
await logger.logToStderr(`Merged delegated and application permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
|
|
476
|
-
await logger.logToStderr(`App role assignments: ${JSON.stringify(this.appPermissions.flatMap(permission => permission.resourceAccess.filter(access => access.type === "Role")), null, 2)}`);
|
|
477
|
-
await logger.logToStderr(`OAuth2 permissions: ${JSON.stringify(this.appPermissions.flatMap(permission => permission.scope), null, 2)}`);
|
|
478
|
-
}
|
|
479
|
-
return resolvedApis;
|
|
480
|
-
}
|
|
481
|
-
catch (e) {
|
|
482
|
-
throw e;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
async getRequiredResourceAccessForApis(servicePrincipals, apis, scopeType, logger) {
|
|
486
|
-
if (!apis) {
|
|
487
|
-
return [];
|
|
488
|
-
}
|
|
489
|
-
const resolvedApis = [];
|
|
490
|
-
const requestedApis = apis.split(',').map(a => a.trim());
|
|
491
|
-
for (const api of requestedApis) {
|
|
492
|
-
const pos = api.lastIndexOf('/');
|
|
493
|
-
const permissionName = api.substr(pos + 1);
|
|
494
|
-
const servicePrincipalName = api.substr(0, pos);
|
|
495
|
-
if (this.debug) {
|
|
496
|
-
await logger.logToStderr(`Resolving ${api}...`);
|
|
497
|
-
await logger.logToStderr(`Permission name: ${permissionName}`);
|
|
498
|
-
await logger.logToStderr(`Service principal name: ${servicePrincipalName}`);
|
|
499
|
-
}
|
|
500
|
-
const servicePrincipal = servicePrincipals.find(sp => (sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1 ||
|
|
501
|
-
sp.servicePrincipalNames.indexOf(`${servicePrincipalName}/`) > -1));
|
|
502
|
-
if (!servicePrincipal) {
|
|
503
|
-
throw `Service principal ${servicePrincipalName} not found`;
|
|
504
|
-
}
|
|
505
|
-
const scopesOfType = scopeType === 'Scope' ? servicePrincipal.oauth2PermissionScopes : servicePrincipal.appRoles;
|
|
506
|
-
const permission = scopesOfType.find(scope => scope.value === permissionName);
|
|
507
|
-
if (!permission) {
|
|
508
|
-
throw `Permission ${permissionName} for service principal ${servicePrincipalName} not found`;
|
|
509
|
-
}
|
|
510
|
-
let resolvedApi = resolvedApis.find(a => a.resourceAppId === servicePrincipal.appId);
|
|
511
|
-
if (!resolvedApi) {
|
|
512
|
-
resolvedApi = {
|
|
513
|
-
resourceAppId: servicePrincipal.appId,
|
|
514
|
-
resourceAccess: []
|
|
515
|
-
};
|
|
516
|
-
resolvedApis.push(resolvedApi);
|
|
517
|
-
}
|
|
518
|
-
const resourceAccessPermission = {
|
|
519
|
-
id: permission.id,
|
|
520
|
-
type: scopeType
|
|
521
|
-
};
|
|
522
|
-
resolvedApi.resourceAccess.push(resourceAccessPermission);
|
|
523
|
-
this.updateAppPermissions(servicePrincipal.id, resourceAccessPermission, permission.value);
|
|
524
|
-
}
|
|
525
|
-
return resolvedApis;
|
|
526
|
-
}
|
|
527
|
-
updateAppPermissions(spId, resourceAccessPermission, oAuth2PermissionValue) {
|
|
528
|
-
// During API resolution, we store globally both app role assignments and oauth2permissions
|
|
529
|
-
// So that we'll be able to parse them during the admin consent process
|
|
530
|
-
let existingPermission = this.appPermissions.find(oauth => oauth.resourceId === spId);
|
|
531
|
-
if (!existingPermission) {
|
|
532
|
-
existingPermission = {
|
|
533
|
-
resourceId: spId,
|
|
534
|
-
resourceAccess: [],
|
|
535
|
-
scope: []
|
|
536
|
-
};
|
|
537
|
-
this.appPermissions.push(existingPermission);
|
|
538
|
-
}
|
|
539
|
-
if (resourceAccessPermission.type === 'Scope' && oAuth2PermissionValue && !existingPermission.scope.find(scp => scp === oAuth2PermissionValue)) {
|
|
540
|
-
existingPermission.scope.push(oAuth2PermissionValue);
|
|
541
|
-
}
|
|
542
|
-
if (!existingPermission.resourceAccess.find(res => res.id === resourceAccessPermission.id)) {
|
|
543
|
-
existingPermission.resourceAccess.push(resourceAccessPermission);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
async configureSecret(args, appInfo, logger) {
|
|
547
|
-
if (!args.options.withSecret || (appInfo.secrets && appInfo.secrets.length > 0)) {
|
|
548
|
-
return appInfo;
|
|
549
|
-
}
|
|
550
|
-
if (this.verbose) {
|
|
551
|
-
await logger.logToStderr(`Configure Microsoft Entra app secret...`);
|
|
552
|
-
}
|
|
553
|
-
const secret = await this.createSecret({ appObjectId: appInfo.id });
|
|
554
|
-
if (!appInfo.secrets) {
|
|
555
|
-
appInfo.secrets = [];
|
|
556
|
-
}
|
|
557
|
-
appInfo.secrets.push(secret);
|
|
558
|
-
return appInfo;
|
|
559
|
-
}
|
|
560
|
-
async createSecret({ appObjectId, displayName = undefined, expirationDate = undefined }) {
|
|
561
|
-
let secretExpirationDate = expirationDate;
|
|
562
|
-
if (!secretExpirationDate) {
|
|
563
|
-
secretExpirationDate = new Date();
|
|
564
|
-
secretExpirationDate.setFullYear(secretExpirationDate.getFullYear() + 1);
|
|
565
|
-
}
|
|
566
|
-
const secretName = displayName ?? 'Default';
|
|
567
|
-
const requestOptions = {
|
|
568
|
-
url: `${this.resource}/v1.0/myorganization/applications/${appObjectId}/addPassword`,
|
|
569
|
-
headers: {
|
|
570
|
-
'content-type': 'application/json'
|
|
571
|
-
},
|
|
572
|
-
responseType: 'json',
|
|
573
|
-
data: {
|
|
574
|
-
passwordCredential: {
|
|
575
|
-
displayName: secretName,
|
|
576
|
-
endDateTime: secretExpirationDate.toISOString()
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
const response = await request.post(requestOptions);
|
|
581
|
-
return {
|
|
582
|
-
displayName: secretName,
|
|
583
|
-
value: response.secretText
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
async getCertificateBase64Encoded(args, logger) {
|
|
587
|
-
if (args.options.certificateBase64Encoded) {
|
|
588
|
-
return args.options.certificateBase64Encoded;
|
|
589
|
-
}
|
|
590
|
-
if (this.debug) {
|
|
591
|
-
await logger.logToStderr(`Reading existing ${args.options.certificateFile}...`);
|
|
592
|
-
}
|
|
593
|
-
try {
|
|
594
|
-
return fs.readFileSync(args.options.certificateFile, { encoding: 'base64' });
|
|
595
|
-
}
|
|
596
|
-
catch (e) {
|
|
597
|
-
throw new Error(`Error reading certificate file: ${e}. Please add the certificate using base64 option '--certificateBase64Encoded'.`);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
364
|
async saveAppInfo(args, appInfo, logger) {
|
|
601
365
|
if (!args.options.save) {
|
|
602
366
|
return appInfo;
|
|
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _EntraM365GroupSetCommand_instances, _EntraM365GroupSetCommand_initTelemetry, _EntraM365GroupSetCommand_initOptions, _EntraM365GroupSetCommand_initTypes, _EntraM365GroupSetCommand_initValidators;
|
|
6
|
+
var _EntraM365GroupSetCommand_instances, _EntraM365GroupSetCommand_initTelemetry, _EntraM365GroupSetCommand_initOptions, _EntraM365GroupSetCommand_initOptionSets, _EntraM365GroupSetCommand_initTypes, _EntraM365GroupSetCommand_initValidators;
|
|
7
7
|
import { setTimeout } from 'timers/promises';
|
|
8
8
|
import fs from 'fs';
|
|
9
9
|
import path from 'path';
|
|
@@ -31,8 +31,9 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
31
31
|
this.pollingInterval = 500;
|
|
32
32
|
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initTelemetry).call(this);
|
|
33
33
|
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initOptions).call(this);
|
|
34
|
-
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initTypes).call(this);
|
|
35
34
|
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initValidators).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initOptionSets).call(this);
|
|
36
|
+
__classPrivateFieldGet(this, _EntraM365GroupSetCommand_instances, "m", _EntraM365GroupSetCommand_initTypes).call(this);
|
|
36
37
|
}
|
|
37
38
|
async commandAction(logger, args) {
|
|
38
39
|
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_SET, commands.M365GROUP_SET);
|
|
@@ -40,23 +41,24 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
40
41
|
if ((args.options.allowExternalSenders !== undefined || args.options.autoSubscribeNewMembers !== undefined) && accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken)) {
|
|
41
42
|
throw `Option 'allowExternalSenders' and 'autoSubscribeNewMembers' can only be used when using delegated permissions.`;
|
|
42
43
|
}
|
|
43
|
-
const
|
|
44
|
+
const groupId = args.options.id || await entraGroup.getGroupIdByDisplayName(args.options.displayName);
|
|
45
|
+
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
44
46
|
if (!isUnifiedGroup) {
|
|
45
|
-
throw Error(`Specified group with id '${
|
|
47
|
+
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
46
48
|
}
|
|
47
49
|
if (this.verbose) {
|
|
48
|
-
await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id}...`);
|
|
50
|
+
await logger.logToStderr(`Updating Microsoft 365 Group ${args.options.id || args.options.displayName}...`);
|
|
49
51
|
}
|
|
50
|
-
if (args.options.
|
|
52
|
+
if (args.options.newDisplayName || args.options.description !== undefined || args.options.isPrivate !== undefined) {
|
|
51
53
|
const update = {
|
|
52
|
-
displayName: args.options.
|
|
54
|
+
displayName: args.options.newDisplayName,
|
|
53
55
|
description: args.options.description !== '' ? args.options.description : null
|
|
54
56
|
};
|
|
55
57
|
if (args.options.isPrivate !== undefined) {
|
|
56
58
|
update.visibility = args.options.isPrivate ? 'Private' : 'Public';
|
|
57
59
|
}
|
|
58
60
|
const requestOptions = {
|
|
59
|
-
url: `${this.resource}/v1.0/groups/${
|
|
61
|
+
url: `${this.resource}/v1.0/groups/${groupId}`,
|
|
60
62
|
headers: {
|
|
61
63
|
'accept': 'application/json;odata.metadata=none'
|
|
62
64
|
},
|
|
@@ -74,7 +76,7 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
74
76
|
hideFromOutlookClients: args.options.hideFromOutlookClients
|
|
75
77
|
};
|
|
76
78
|
const requestOptions = {
|
|
77
|
-
url: `${this.resource}/v1.0/groups/${
|
|
79
|
+
url: `${this.resource}/v1.0/groups/${groupId}`,
|
|
78
80
|
headers: {
|
|
79
81
|
accept: 'application/json;odata.metadata=none'
|
|
80
82
|
},
|
|
@@ -89,7 +91,7 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
89
91
|
await logger.logToStderr(`Setting group logo ${fullPath}...`);
|
|
90
92
|
}
|
|
91
93
|
const requestOptions = {
|
|
92
|
-
url: `${this.resource}/v1.0/groups/${
|
|
94
|
+
url: `${this.resource}/v1.0/groups/${groupId}/photo/$value`,
|
|
93
95
|
headers: {
|
|
94
96
|
'content-type': this.getImageContentType(fullPath)
|
|
95
97
|
},
|
|
@@ -114,7 +116,7 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
114
116
|
};
|
|
115
117
|
const res = await request.get(requestOptions);
|
|
116
118
|
await Promise.all(res.value.map(u => request.post({
|
|
117
|
-
url: `${this.resource}/v1.0/groups/${
|
|
119
|
+
url: `${this.resource}/v1.0/groups/${groupId}/owners/$ref`,
|
|
118
120
|
headers: {
|
|
119
121
|
'content-type': 'application/json'
|
|
120
122
|
},
|
|
@@ -141,7 +143,7 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
141
143
|
};
|
|
142
144
|
const res = await request.get(requestOptions);
|
|
143
145
|
await Promise.all(res.value.map(u => request.post({
|
|
144
|
-
url: `${this.resource}/v1.0/groups/${
|
|
146
|
+
url: `${this.resource}/v1.0/groups/${groupId}/members/$ref`,
|
|
145
147
|
headers: {
|
|
146
148
|
'content-type': 'application/json'
|
|
147
149
|
},
|
|
@@ -188,7 +190,9 @@ class EntraM365GroupSetCommand extends GraphCommand {
|
|
|
188
190
|
_EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_initTelemetry = function _EntraM365GroupSetCommand_initTelemetry() {
|
|
189
191
|
this.telemetry.push((args) => {
|
|
190
192
|
Object.assign(this.telemetryProperties, {
|
|
193
|
+
id: typeof args.options.id !== 'undefined',
|
|
191
194
|
displayName: typeof args.options.displayName !== 'undefined',
|
|
195
|
+
newDisplayName: typeof args.options.newDisplayName !== 'undefined',
|
|
192
196
|
description: typeof args.options.description !== 'undefined',
|
|
193
197
|
owners: typeof args.options.owners !== 'undefined',
|
|
194
198
|
members: typeof args.options.members !== 'undefined',
|
|
@@ -202,9 +206,11 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
202
206
|
});
|
|
203
207
|
}, _EntraM365GroupSetCommand_initOptions = function _EntraM365GroupSetCommand_initOptions() {
|
|
204
208
|
this.options.unshift({
|
|
205
|
-
option: '-i, --id
|
|
209
|
+
option: '-i, --id [id]'
|
|
206
210
|
}, {
|
|
207
211
|
option: '-n, --displayName [displayName]'
|
|
212
|
+
}, {
|
|
213
|
+
option: '--newDisplayName [newDisplayName]'
|
|
208
214
|
}, {
|
|
209
215
|
option: '-d, --description [description]'
|
|
210
216
|
}, {
|
|
@@ -229,12 +235,14 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
229
235
|
option: '--hideFromOutlookClients [hideFromOutlookClients]',
|
|
230
236
|
autocomplete: ['true', 'false']
|
|
231
237
|
});
|
|
238
|
+
}, _EntraM365GroupSetCommand_initOptionSets = function _EntraM365GroupSetCommand_initOptionSets() {
|
|
239
|
+
this.optionSets.push({ options: ['id', 'displayName'] });
|
|
232
240
|
}, _EntraM365GroupSetCommand_initTypes = function _EntraM365GroupSetCommand_initTypes() {
|
|
233
241
|
this.types.boolean.push('isPrivate', 'allowEternalSenders', 'autoSubscribeNewMembers', 'hideFromAddressLists', 'hideFromOutlookClients');
|
|
234
|
-
this.types.string.push('id', 'displayName', 'description', 'owners', 'members', 'logoPath');
|
|
242
|
+
this.types.string.push('id', 'displayName', 'newDisplayName', 'description', 'owners', 'members', 'logoPath');
|
|
235
243
|
}, _EntraM365GroupSetCommand_initValidators = function _EntraM365GroupSetCommand_initValidators() {
|
|
236
244
|
this.validators.push(async (args) => {
|
|
237
|
-
if (!args.options.
|
|
245
|
+
if (!args.options.newDisplayName &&
|
|
238
246
|
args.options.description === undefined &&
|
|
239
247
|
!args.options.members &&
|
|
240
248
|
!args.options.owners &&
|
|
@@ -246,7 +254,7 @@ _EntraM365GroupSetCommand_instances = new WeakSet(), _EntraM365GroupSetCommand_i
|
|
|
246
254
|
args.options.hideFromOutlookClients === undefined) {
|
|
247
255
|
return 'Specify at least one option to update.';
|
|
248
256
|
}
|
|
249
|
-
if (!validation.isValidGuid(args.options.id)) {
|
|
257
|
+
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
250
258
|
return `${args.options.id} is not a valid GUID`;
|
|
251
259
|
}
|
|
252
260
|
if (args.options.owners) {
|
|
@@ -35,19 +35,15 @@ class EntraM365GroupUserAddCommand extends GraphCommand {
|
|
|
35
35
|
}
|
|
36
36
|
async commandAction(logger, args) {
|
|
37
37
|
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_ADD, commands.M365GROUP_USER_ADD);
|
|
38
|
-
if (args.options.userName) {
|
|
39
|
-
await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
|
|
40
|
-
}
|
|
41
38
|
try {
|
|
42
|
-
const userNames = args.options.userNames || args.options.userName;
|
|
43
39
|
const providedGroupId = await this.getGroupId(logger, args);
|
|
44
40
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(providedGroupId);
|
|
45
41
|
if (!isUnifiedGroup) {
|
|
46
42
|
throw Error(`Specified group with id '${providedGroupId}' is not a Microsoft 365 group.`);
|
|
47
43
|
}
|
|
48
|
-
const userIds = await this.getUserIds(logger, args.options.ids, userNames);
|
|
44
|
+
const userIds = await this.getUserIds(logger, args.options.ids, args.options.userNames);
|
|
49
45
|
if (this.verbose) {
|
|
50
|
-
await logger.logToStderr(`Adding user(s) ${args.options.ids || userNames} to group ${args.options.groupId || args.options.groupName || args.options.teamId || args.options.teamName}...`);
|
|
46
|
+
await logger.logToStderr(`Adding user(s) ${args.options.ids || args.options.userNames} to group ${args.options.groupId || args.options.groupName || args.options.teamId || args.options.teamName}...`);
|
|
51
47
|
}
|
|
52
48
|
await this.addUsers(providedGroupId, userIds, args.options.role);
|
|
53
49
|
}
|
|
@@ -122,14 +118,11 @@ _EntraM365GroupUserAddCommand_instances = new WeakSet(), _EntraM365GroupUserAddC
|
|
|
122
118
|
teamName: typeof args.options.teamName !== 'undefined',
|
|
123
119
|
groupName: typeof args.options.groupName !== 'undefined',
|
|
124
120
|
ids: typeof args.options.ids !== 'undefined',
|
|
125
|
-
userNames: typeof args.options.userNames !== 'undefined'
|
|
126
|
-
userName: typeof args.options.userName !== 'undefined'
|
|
121
|
+
userNames: typeof args.options.userNames !== 'undefined'
|
|
127
122
|
});
|
|
128
123
|
});
|
|
129
124
|
}, _EntraM365GroupUserAddCommand_initOptions = function _EntraM365GroupUserAddCommand_initOptions() {
|
|
130
125
|
this.options.unshift({
|
|
131
|
-
option: '-n, --userName [userName]'
|
|
132
|
-
}, {
|
|
133
126
|
option: '--ids [ids]'
|
|
134
127
|
}, {
|
|
135
128
|
option: '--userNames [userNames]'
|
|
@@ -172,9 +165,9 @@ _EntraM365GroupUserAddCommand_instances = new WeakSet(), _EntraM365GroupUserAddC
|
|
|
172
165
|
});
|
|
173
166
|
}, _EntraM365GroupUserAddCommand_initOptionSets = function _EntraM365GroupUserAddCommand_initOptionSets() {
|
|
174
167
|
this.optionSets.push({ options: ['groupId', 'groupName', 'teamId', 'teamName'] });
|
|
175
|
-
this.optionSets.push({ options: ['
|
|
168
|
+
this.optionSets.push({ options: ['ids', 'userNames'] });
|
|
176
169
|
}, _EntraM365GroupUserAddCommand_initTypes = function _EntraM365GroupUserAddCommand_initTypes() {
|
|
177
|
-
this.types.string.push('
|
|
170
|
+
this.types.string.push('ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
|
|
178
171
|
};
|
|
179
172
|
export default new EntraM365GroupUserAddCommand();
|
|
180
173
|
//# sourceMappingURL=m365group-user-add.js.map
|
|
@@ -4,8 +4,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _EntraOAuth2GrantListCommand_instances, _EntraOAuth2GrantListCommand_initOptions, _EntraOAuth2GrantListCommand_initValidators;
|
|
7
|
-
import request from '../../../../request.js';
|
|
8
7
|
import { formatting } from '../../../../utils/formatting.js';
|
|
8
|
+
import { odata } from '../../../../utils/odata.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import aadCommands from '../../aadCommands.js';
|
|
@@ -35,17 +35,8 @@ class EntraOAuth2GrantListCommand extends GraphCommand {
|
|
|
35
35
|
await logger.logToStderr(`Retrieving list of OAuth grants for the service principal...`);
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
headers: {
|
|
41
|
-
accept: 'application/json;odata.metadata=none'
|
|
42
|
-
},
|
|
43
|
-
responseType: 'json'
|
|
44
|
-
};
|
|
45
|
-
const res = await request.get(requestOptions);
|
|
46
|
-
if (res.value && res.value.length > 0) {
|
|
47
|
-
await logger.log(res.value);
|
|
48
|
-
}
|
|
38
|
+
const res = await odata.getAllItems(`${this.resource}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${formatting.encodeQueryParameter(args.options.spObjectId)}'`);
|
|
39
|
+
await logger.log(res);
|
|
49
40
|
}
|
|
50
41
|
catch (err) {
|
|
51
42
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -45,8 +45,7 @@ class ExternalItemAddCommand extends GraphCommand {
|
|
|
45
45
|
properties: {}
|
|
46
46
|
};
|
|
47
47
|
// we need to rewrite the @odata properties to the correct format
|
|
48
|
-
//
|
|
49
|
-
// we also need to extract multiple values for collections into arrays
|
|
48
|
+
// to extract multiple values for collections into arrays
|
|
50
49
|
this.rewriteCollectionProperties(args.options);
|
|
51
50
|
this.addUnknownOptionsToPayload(requestBody.properties, args.options);
|
|
52
51
|
const requestOptions = {
|
|
@@ -81,11 +80,9 @@ class ExternalItemAddCommand extends GraphCommand {
|
|
|
81
80
|
}
|
|
82
81
|
rewriteCollectionProperties(options) {
|
|
83
82
|
Object.getOwnPropertyNames(options).forEach(name => {
|
|
84
|
-
if (!name.
|
|
83
|
+
if (!name.includes('@odata')) {
|
|
85
84
|
return;
|
|
86
85
|
}
|
|
87
|
-
options[`${name}.type`] = options[name].type;
|
|
88
|
-
delete options[name];
|
|
89
86
|
// convert the value of a collection to an array
|
|
90
87
|
const nameWithoutOData = name.substring(0, name.indexOf('@odata'));
|
|
91
88
|
if (options[nameWithoutOData]) {
|