@pnp/cli-microsoft365 9.0.0-beta.f2c5f82 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +11 -12
  4. package/dist/Command.js +1 -3
  5. package/dist/cli/cli.js +57 -8
  6. package/dist/config.js +60 -5
  7. package/dist/m365/app/commands/permission/permission-add.js +9 -9
  8. package/dist/m365/base/SpoCommand.js +1 -1
  9. package/dist/m365/cli/commands/cli-consent.js +9 -5
  10. package/dist/m365/cli/commands/cli-doctor.js +2 -2
  11. package/dist/m365/cli/commands/cli-reconsent.js +2 -3
  12. package/dist/m365/cli/commands/config/config-set.js +12 -3
  13. package/dist/m365/commands/login.js +38 -14
  14. package/dist/m365/commands/setup.js +256 -33
  15. package/dist/m365/commands/status.js +2 -2
  16. package/dist/m365/connection/commands/connection-list.js +4 -4
  17. package/dist/m365/entra/commands/app/app-add.js +52 -288
  18. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +13 -13
  19. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +18 -18
  20. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +1 -1
  21. package/dist/m365/entra/commands/group/group-user-list.js +4 -4
  22. package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +4 -4
  23. package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +3 -3
  24. package/dist/m365/entra/commands/m365group/m365group-user-list.js +9 -6
  25. package/dist/m365/onenote/commands/notebook/notebook-add.js +132 -0
  26. package/dist/m365/onenote/commands.js +1 -0
  27. package/dist/m365/outlook/commands/message/message-get.js +11 -11
  28. package/dist/m365/spfx/commands/project/DeployWorkflow.js +1 -1
  29. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +10 -1
  30. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +1 -0
  31. package/dist/m365/spo/commands/file/file-copy.js +34 -55
  32. package/dist/m365/spo/commands/folder/folder-set.js +4 -0
  33. package/dist/m365/spo/commands/list/list-list.js +4 -1
  34. package/dist/m365/spo/commands/site/site-appcatalog-remove.js +24 -48
  35. package/dist/m365/spo/commands/site/site-get.js +12 -16
  36. package/dist/m365/spo/commands/site/site-remove.js +7 -1
  37. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +22 -2
  38. package/dist/m365/spo/commands.js +1 -0
  39. package/dist/m365/viva/commands/engage/engage-group-list.js +5 -0
  40. package/dist/m365/viva/commands/engage/engage-group-user-add.js +5 -0
  41. package/dist/m365/viva/commands/engage/engage-group-user-remove.js +5 -0
  42. package/dist/m365/viva/commands/engage/engage-message-add.js +5 -0
  43. package/dist/m365/viva/commands/engage/engage-message-get.js +5 -0
  44. package/dist/m365/viva/commands/engage/engage-message-like-set.js +5 -0
  45. package/dist/m365/viva/commands/engage/engage-message-list.js +5 -0
  46. package/dist/m365/viva/commands/engage/engage-message-remove.js +5 -0
  47. package/dist/m365/viva/commands/engage/engage-network-list.js +5 -0
  48. package/dist/m365/viva/commands/engage/engage-report-activitycounts.js +8 -0
  49. package/dist/m365/viva/commands/engage/engage-report-activityusercounts.js +8 -0
  50. package/dist/m365/viva/commands/engage/engage-report-activityuserdetail.js +8 -0
  51. package/dist/m365/viva/commands/engage/engage-report-deviceusagedistributionusercounts.js +8 -0
  52. package/dist/m365/viva/commands/engage/engage-report-deviceusageusercounts.js +8 -0
  53. package/dist/m365/viva/commands/engage/engage-report-deviceusageuserdetail.js +8 -0
  54. package/dist/m365/viva/commands/engage/engage-report-groupsactivitycounts.js +8 -0
  55. package/dist/m365/viva/commands/engage/engage-report-groupsactivitydetail.js +8 -0
  56. package/dist/m365/viva/commands/engage/engage-report-groupsactivitygroupcounts.js +8 -0
  57. package/dist/m365/viva/commands/engage/engage-search.js +5 -0
  58. package/dist/m365/viva/commands/engage/engage-user-get.js +5 -0
  59. package/dist/m365/viva/commands/engage/engage-user-list.js +5 -0
  60. package/dist/m365/viva/commands/engage/yammerCommands.js +25 -0
  61. package/dist/settingsNames.js +7 -1
  62. package/dist/utils/entraApp.js +283 -0
  63. package/dist/utils/spo.js +0 -74
  64. package/docs/docs/_clisettings.mdx +6 -0
  65. package/docs/docs/cmd/app/permission/permission-add.mdx +5 -5
  66. package/docs/docs/cmd/cli/cli-consent.mdx +1 -1
  67. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +12 -12
  68. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +14 -14
  69. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +5 -5
  70. package/docs/docs/cmd/entra/group/group-user-list.mdx +7 -7
  71. package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +5 -5
  72. package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +3 -3
  73. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +1 -1
  74. package/docs/docs/cmd/onenote/notebook/notebook-add.mdx +169 -0
  75. package/docs/docs/cmd/outlook/message/message-get.mdx +5 -5
  76. package/docs/docs/cmd/setup.mdx +16 -3
  77. package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +12 -11
  78. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +5 -6
  79. package/docs/docs/cmd/spo/file/file-copy.mdx +12 -119
  80. package/docs/docs/cmd/spo/folder/folder-set.mdx +6 -0
  81. package/docs/docs/cmd/spo/list/list-list.mdx +7 -5
  82. package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +2 -11
  83. package/docs/docs/cmd/spo/site/site-remove.mdx +3 -0
  84. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +49 -2
  85. package/package.json +2 -2
@@ -8,6 +8,7 @@ import request from '../../../../request.js';
8
8
  import { formatting } from '../../../../utils/formatting.js';
9
9
  import VivaEngageCommand from '../../../base/VivaEngageCommand.js';
10
10
  import commands from '../../commands.js';
11
+ import yammerCommands from './yammerCommands.js';
11
12
  class VivaEngageUserGetCommand extends VivaEngageCommand {
12
13
  get name() {
13
14
  return commands.ENGAGE_USER_GET;
@@ -15,6 +16,9 @@ class VivaEngageUserGetCommand extends VivaEngageCommand {
15
16
  get description() {
16
17
  return 'Retrieves the current user or searches for a user by ID or e-mail';
17
18
  }
19
+ alias() {
20
+ return [yammerCommands.USER_GET];
21
+ }
18
22
  defaultProperties() {
19
23
  return ['id', 'full_name', 'email', 'job_title', 'state', 'url'];
20
24
  }
@@ -26,6 +30,7 @@ class VivaEngageUserGetCommand extends VivaEngageCommand {
26
30
  __classPrivateFieldGet(this, _VivaEngageUserGetCommand_instances, "m", _VivaEngageUserGetCommand_initValidators).call(this);
27
31
  }
28
32
  async commandAction(logger, args) {
33
+ await this.showDeprecationWarning(logger, this.alias()[0], this.name);
29
34
  let endPoint = `${this.resource}/v1/users/current.json`;
30
35
  if (args.options.id) {
31
36
  endPoint = `${this.resource}/v1/users/${args.options.id}.json`;
@@ -7,6 +7,7 @@ var _VivaEngageUserListCommand_instances, _VivaEngageUserListCommand_initTelemet
7
7
  import request from '../../../../request.js';
8
8
  import VivaEngageCommand from '../../../base/VivaEngageCommand.js';
9
9
  import commands from '../../commands.js';
10
+ import yammerCommands from './yammerCommands.js';
10
11
  class VivaEngageUserListCommand extends VivaEngageCommand {
11
12
  get name() {
12
13
  return commands.ENGAGE_USER_LIST;
@@ -14,6 +15,9 @@ class VivaEngageUserListCommand extends VivaEngageCommand {
14
15
  get description() {
15
16
  return 'Returns users from the current network';
16
17
  }
18
+ alias() {
19
+ return [yammerCommands.USER_LIST];
20
+ }
17
21
  defaultProperties() {
18
22
  return ['id', 'full_name', 'email'];
19
23
  }
@@ -88,6 +92,7 @@ class VivaEngageUserListCommand extends VivaEngageCommand {
88
92
  });
89
93
  }
90
94
  async commandAction(logger, args) {
95
+ await this.showDeprecationWarning(logger, this.alias()[0], this.name);
91
96
  this.items = []; // this will reset the items array in interactive mode
92
97
  try {
93
98
  await this.getAllItems(logger, args, 1);
@@ -0,0 +1,25 @@
1
+ const prefix = 'yammer';
2
+ export default {
3
+ GROUP_LIST: `${prefix} group list`,
4
+ GROUP_USER_ADD: `${prefix} group user add`,
5
+ GROUP_USER_REMOVE: `${prefix} group user remove`,
6
+ MESSAGE_ADD: `${prefix} message add`,
7
+ MESSAGE_GET: `${prefix} message get`,
8
+ MESSAGE_LIKE_SET: `${prefix} message like set`,
9
+ MESSAGE_LIST: `${prefix} message list`,
10
+ MESSAGE_REMOVE: `${prefix} message remove`,
11
+ NETWORK_LIST: `${prefix} network list`,
12
+ REPORT_ACTIVITYCOUNTS: `${prefix} report activitycounts`,
13
+ REPORT_ACTIVITYUSERCOUNTS: `${prefix} report activityusercounts`,
14
+ REPORT_ACTIVITYUSERDETAIL: `${prefix} report activityuserdetail`,
15
+ REPORT_DEVICEUSAGEDISTRIBUTIONUSERCOUNTS: `${prefix} report deviceusagedistributionusercounts`,
16
+ REPORT_DEVICEUSAGEUSERCOUNTS: `${prefix} report deviceusageusercounts`,
17
+ REPORT_DEVICEUSAGEUSERDETAIL: `${prefix} report deviceusageuserdetail`,
18
+ REPORT_GROUPSACTIVITYCOUNTS: `${prefix} report groupsactivitycounts`,
19
+ REPORT_GROUPSACTIVITYDETAIL: `${prefix} report groupsactivitydetail`,
20
+ REPORT_GROUPSACTIVITYGROUPCOUNTS: `${prefix} report groupsactivitygroupcounts`,
21
+ SEARCH: `${prefix} search`,
22
+ USER_GET: `${prefix} user get`,
23
+ USER_LIST: `${prefix} user list`
24
+ };
25
+ //# sourceMappingURL=yammerCommands.js.map
@@ -1,6 +1,11 @@
1
1
  const settingsNames = {
2
2
  authType: 'authType',
3
3
  autoOpenLinksInBrowser: 'autoOpenLinksInBrowser',
4
+ clientId: 'clientId',
5
+ clientSecret: 'clientSecret',
6
+ clientCertificateFile: 'clientCertificateFile',
7
+ clientCertificateBase64Encoded: 'clientCertificateBase64Encoded',
8
+ clientCertificatePassword: 'clientCertificatePassword',
4
9
  copyDeviceCodeToClipboard: 'copyDeviceCodeToClipboard',
5
10
  csvEscape: 'csvEscape',
6
11
  csvHeader: 'csvHeader',
@@ -16,7 +21,8 @@ const settingsNames = {
16
21
  prompt: 'prompt',
17
22
  promptListPageSize: 'promptListPageSize',
18
23
  showHelpOnFailure: 'showHelpOnFailure',
19
- showSpinner: 'showSpinner'
24
+ showSpinner: 'showSpinner',
25
+ tenantId: 'tenantId'
20
26
  };
21
27
  export { settingsNames };
22
28
  //# sourceMappingURL=settingsNames.js.map
@@ -0,0 +1,283 @@
1
+ import fs from 'fs';
2
+ import request from '../request.js';
3
+ import { odata } from './odata.js';
4
+ async function getCertificateBase64Encoded({ options, logger, debug }) {
5
+ if (options.certificateBase64Encoded) {
6
+ return options.certificateBase64Encoded;
7
+ }
8
+ if (debug) {
9
+ await logger.logToStderr(`Reading existing ${options.certificateFile}...`);
10
+ }
11
+ try {
12
+ return fs.readFileSync(options.certificateFile, { encoding: 'base64' });
13
+ }
14
+ catch (e) {
15
+ throw new Error(`Error reading certificate file: ${e}. Please add the certificate using base64 option '--certificateBase64Encoded'.`);
16
+ }
17
+ }
18
+ async function createServicePrincipal(appId) {
19
+ const requestOptions = {
20
+ url: `https://graph.microsoft.com/v1.0/myorganization/servicePrincipals`,
21
+ headers: {
22
+ 'content-type': 'application/json'
23
+ },
24
+ data: {
25
+ appId: appId
26
+ },
27
+ responseType: 'json'
28
+ };
29
+ return request.post(requestOptions);
30
+ }
31
+ async function grantOAuth2Permission({ appId, resourceId, scopeName }) {
32
+ const grantAdminConsentApplicationRequestOptions = {
33
+ url: `https://graph.microsoft.com/v1.0/myorganization/oauth2PermissionGrants`,
34
+ headers: {
35
+ accept: 'application/json;odata.metadata=none'
36
+ },
37
+ responseType: 'json',
38
+ data: {
39
+ clientId: appId,
40
+ consentType: "AllPrincipals",
41
+ principalId: null,
42
+ resourceId: resourceId,
43
+ scope: scopeName
44
+ }
45
+ };
46
+ return request.post(grantAdminConsentApplicationRequestOptions);
47
+ }
48
+ async function addRoleToServicePrincipal({ objectId, resourceId, appRoleId }) {
49
+ const requestOptions = {
50
+ url: `https://graph.microsoft.com/v1.0/myorganization/servicePrincipals/${objectId}/appRoleAssignments`,
51
+ headers: {
52
+ 'Content-Type': 'application/json'
53
+ },
54
+ responseType: 'json',
55
+ data: {
56
+ appRoleId: appRoleId,
57
+ principalId: objectId,
58
+ resourceId: resourceId
59
+ }
60
+ };
61
+ return request.post(requestOptions);
62
+ }
63
+ async function getRequiredResourceAccessForApis({ servicePrincipals, apis, scopeType, logger, debug }) {
64
+ if (!apis) {
65
+ return [];
66
+ }
67
+ const resolvedApis = [];
68
+ const requestedApis = apis.split(',').map(a => a.trim());
69
+ for (const api of requestedApis) {
70
+ const pos = api.lastIndexOf('/');
71
+ const permissionName = api.substring(pos + 1);
72
+ const servicePrincipalName = api.substring(0, pos);
73
+ if (debug) {
74
+ await logger.logToStderr(`Resolving ${api}...`);
75
+ await logger.logToStderr(`Permission name: ${permissionName}`);
76
+ await logger.logToStderr(`Service principal name: ${servicePrincipalName}`);
77
+ }
78
+ const servicePrincipal = servicePrincipals.find(sp => (sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1 ||
79
+ sp.servicePrincipalNames.indexOf(`${servicePrincipalName}/`) > -1));
80
+ if (!servicePrincipal) {
81
+ throw `Service principal ${servicePrincipalName} not found`;
82
+ }
83
+ const scopesOfType = scopeType === 'Scope' ? servicePrincipal.oauth2PermissionScopes : servicePrincipal.appRoles;
84
+ const permission = scopesOfType.find(scope => scope.value === permissionName);
85
+ if (!permission) {
86
+ throw `Permission ${permissionName} for service principal ${servicePrincipalName} not found`;
87
+ }
88
+ let resolvedApi = resolvedApis.find(a => a.resourceAppId === servicePrincipal.appId);
89
+ if (!resolvedApi) {
90
+ resolvedApi = {
91
+ resourceAppId: servicePrincipal.appId,
92
+ resourceAccess: []
93
+ };
94
+ resolvedApis.push(resolvedApi);
95
+ }
96
+ const resourceAccessPermission = {
97
+ id: permission.id,
98
+ type: scopeType
99
+ };
100
+ resolvedApi.resourceAccess.push(resourceAccessPermission);
101
+ updateAppPermissions({
102
+ spId: servicePrincipal.id,
103
+ resourceAccessPermission,
104
+ oAuth2PermissionValue: permission.value
105
+ });
106
+ }
107
+ return resolvedApis;
108
+ }
109
+ function updateAppPermissions({ spId, resourceAccessPermission, oAuth2PermissionValue }) {
110
+ // During API resolution, we store globally both app role assignments and oauth2permissions
111
+ // So that we'll be able to parse them during the admin consent process
112
+ let existingPermission = entraApp.appPermissions.find(oauth => oauth.resourceId === spId);
113
+ if (!existingPermission) {
114
+ existingPermission = {
115
+ resourceId: spId,
116
+ resourceAccess: [],
117
+ scope: []
118
+ };
119
+ entraApp.appPermissions.push(existingPermission);
120
+ }
121
+ if (resourceAccessPermission.type === 'Scope' && oAuth2PermissionValue && !existingPermission.scope.find(scp => scp === oAuth2PermissionValue)) {
122
+ existingPermission.scope.push(oAuth2PermissionValue);
123
+ }
124
+ if (!existingPermission.resourceAccess.find(res => res.id === resourceAccessPermission.id)) {
125
+ existingPermission.resourceAccess.push(resourceAccessPermission);
126
+ }
127
+ }
128
+ export const entraApp = {
129
+ appPermissions: [],
130
+ createAppRegistration: async ({ options, apis, logger, verbose, debug }) => {
131
+ const applicationInfo = {
132
+ displayName: options.name,
133
+ signInAudience: options.multitenant ? 'AzureADMultipleOrgs' : 'AzureADMyOrg'
134
+ };
135
+ if (apis.length > 0) {
136
+ applicationInfo.requiredResourceAccess = apis;
137
+ }
138
+ if (options.redirectUris) {
139
+ applicationInfo[options.platform] = {
140
+ redirectUris: options.redirectUris.split(',').map(u => u.trim())
141
+ };
142
+ }
143
+ if (options.implicitFlow) {
144
+ if (!applicationInfo.web) {
145
+ applicationInfo.web = {};
146
+ }
147
+ applicationInfo.web.implicitGrantSettings = {
148
+ enableAccessTokenIssuance: true,
149
+ enableIdTokenIssuance: true
150
+ };
151
+ }
152
+ if (options.certificateFile || options.certificateBase64Encoded) {
153
+ const certificateBase64Encoded = await getCertificateBase64Encoded({ options, logger, debug });
154
+ const newKeyCredential = {
155
+ type: 'AsymmetricX509Cert',
156
+ usage: 'Verify',
157
+ displayName: options.certificateDisplayName,
158
+ key: certificateBase64Encoded
159
+ };
160
+ applicationInfo.keyCredentials = [newKeyCredential];
161
+ }
162
+ if (options.allowPublicClientFlows) {
163
+ applicationInfo.isFallbackPublicClient = true;
164
+ }
165
+ if (verbose) {
166
+ await logger.logToStderr(`Creating Microsoft Entra app registration...`);
167
+ }
168
+ const createApplicationRequestOptions = {
169
+ url: `https://graph.microsoft.com/v1.0/myorganization/applications`,
170
+ headers: {
171
+ accept: 'application/json;odata.metadata=none'
172
+ },
173
+ responseType: 'json',
174
+ data: applicationInfo
175
+ };
176
+ return request.post(createApplicationRequestOptions);
177
+ },
178
+ grantAdminConsent: async ({ appInfo, appPermissions, adminConsent, logger, debug }) => {
179
+ if (!adminConsent || appPermissions.length === 0) {
180
+ return appInfo;
181
+ }
182
+ const sp = await createServicePrincipal(appInfo.appId);
183
+ if (debug) {
184
+ await logger.logToStderr("Service principal created, returned object id: " + sp.id);
185
+ }
186
+ const tasks = [];
187
+ appPermissions.forEach(async (permission) => {
188
+ if (permission.scope.length > 0) {
189
+ tasks.push(grantOAuth2Permission({
190
+ appId: sp.id,
191
+ resourceId: permission.resourceId,
192
+ scopeName: permission.scope.join(' ')
193
+ }));
194
+ if (debug) {
195
+ await logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with delegated permissions: ${permission.scope.join(',')}`);
196
+ }
197
+ }
198
+ permission.resourceAccess.filter(access => access.type === "Role").forEach(async (access) => {
199
+ tasks.push(addRoleToServicePrincipal({
200
+ objectId: sp.id,
201
+ resourceId: permission.resourceId,
202
+ appRoleId: access.id
203
+ }));
204
+ if (debug) {
205
+ await logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with application permission: ${access.id}`);
206
+ }
207
+ });
208
+ });
209
+ await Promise.all(tasks);
210
+ return appInfo;
211
+ },
212
+ resolveApis: async ({ options, manifest, logger, verbose, debug }) => {
213
+ if (!options.apisDelegated && !options.apisApplication
214
+ && (typeof manifest?.requiredResourceAccess === 'undefined' || manifest.requiredResourceAccess.length === 0)) {
215
+ return [];
216
+ }
217
+ if (verbose) {
218
+ await logger.logToStderr('Resolving requested APIs...');
219
+ }
220
+ const servicePrincipals = await odata.getAllItems(`https://graph.microsoft.com/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
221
+ let resolvedApis = [];
222
+ if (options.apisDelegated || options.apisApplication) {
223
+ resolvedApis = await getRequiredResourceAccessForApis({
224
+ servicePrincipals,
225
+ apis: options.apisDelegated,
226
+ scopeType: 'Scope',
227
+ logger,
228
+ debug
229
+ });
230
+ if (verbose) {
231
+ await logger.logToStderr(`Resolved delegated permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
232
+ }
233
+ const resolvedApplicationApis = await getRequiredResourceAccessForApis({
234
+ servicePrincipals,
235
+ apis: options.apisApplication,
236
+ scopeType: 'Role',
237
+ logger,
238
+ debug
239
+ });
240
+ if (verbose) {
241
+ await logger.logToStderr(`Resolved application permissions: ${JSON.stringify(resolvedApplicationApis, null, 2)}`);
242
+ }
243
+ // merge resolved application APIs onto resolved delegated APIs
244
+ resolvedApplicationApis.forEach(resolvedRequiredResource => {
245
+ const requiredResource = resolvedApis.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
246
+ if (requiredResource) {
247
+ requiredResource.resourceAccess.push(...resolvedRequiredResource.resourceAccess);
248
+ }
249
+ else {
250
+ resolvedApis.push(resolvedRequiredResource);
251
+ }
252
+ });
253
+ }
254
+ else {
255
+ const manifestApis = manifest.requiredResourceAccess;
256
+ manifestApis.forEach(manifestApi => {
257
+ resolvedApis.push(manifestApi);
258
+ const app = servicePrincipals.find(servicePrincipals => servicePrincipals.appId === manifestApi.resourceAppId);
259
+ if (app) {
260
+ manifestApi.resourceAccess.forEach((res => {
261
+ const resourceAccessPermission = {
262
+ id: res.id,
263
+ type: res.type
264
+ };
265
+ const oAuthValue = app.oauth2PermissionScopes.find(scp => scp.id === res.id)?.value;
266
+ updateAppPermissions({
267
+ spId: app.id,
268
+ resourceAccessPermission,
269
+ oAuth2PermissionValue: oAuthValue
270
+ });
271
+ }));
272
+ }
273
+ });
274
+ }
275
+ if (verbose) {
276
+ await logger.logToStderr(`Merged delegated and application permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
277
+ await logger.logToStderr(`App role assignments: ${JSON.stringify(entraApp.appPermissions.flatMap(permission => permission.resourceAccess.filter(access => access.type === "Role")), null, 2)}`);
278
+ await logger.logToStderr(`OAuth2 permissions: ${JSON.stringify(entraApp.appPermissions.flatMap(permission => permission.scope), null, 2)}`);
279
+ }
280
+ return resolvedApis;
281
+ }
282
+ };
283
+ //# sourceMappingURL=entraApp.js.map
package/dist/utils/spo.js CHANGED
@@ -12,16 +12,6 @@ import { RoleType } from '../m365/spo/commands/roledefinition/RoleType.js';
12
12
  import { entraGroup } from './entraGroup.js';
13
13
  import { SharingCapabilities } from '../m365/spo/commands/site/SharingCapabilities.js';
14
14
  import { setTimeout } from 'timers/promises';
15
- export var CreateCopyJobsNameConflictBehavior;
16
- (function (CreateCopyJobsNameConflictBehavior) {
17
- CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Fail"] = 0] = "Fail";
18
- CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Replace"] = 1] = "Replace";
19
- CreateCopyJobsNameConflictBehavior[CreateCopyJobsNameConflictBehavior["Rename"] = 2] = "Rename";
20
- })(CreateCopyJobsNameConflictBehavior || (CreateCopyJobsNameConflictBehavior = {}));
21
- // Wrapping this into a settings object so we can alter the values in tests
22
- export const settings = {
23
- pollingInterval: 3000
24
- };
25
15
  export const spo = {
26
16
  async getRequestDigest(siteUrl) {
27
17
  const requestOptions = {
@@ -1526,70 +1516,6 @@ export const spo = {
1526
1516
  };
1527
1517
  const itemsResponse = await request.get(requestOptionsItems);
1528
1518
  return (itemsResponse);
1529
- },
1530
- /**
1531
- * Create a SharePoint copy job to copy a file/folder to another location.
1532
- * @param webUrl Absolute web URL where the source file/folder is located.
1533
- * @param sourceUrl Absolute URL of the source file/folder.
1534
- * @param destinationUrl Absolute URL of the destination folder.
1535
- * @param options Options for the copy job.
1536
- * @returns Copy job information. Use {@link spo.getCopyJobResult} to get the result of the copy job.
1537
- */
1538
- async createCopyJob(webUrl, sourceUrl, destinationUrl, options) {
1539
- const requestOptions = {
1540
- url: `${webUrl}/_api/Site/CreateCopyJobs`,
1541
- headers: {
1542
- accept: 'application/json;odata=nometadata'
1543
- },
1544
- responseType: 'json',
1545
- data: {
1546
- destinationUri: destinationUrl,
1547
- exportObjectUris: [sourceUrl],
1548
- options: {
1549
- NameConflictBehavior: options?.nameConflictBehavior ?? CreateCopyJobsNameConflictBehavior.Fail,
1550
- AllowSchemaMismatch: true,
1551
- BypassSharedLock: !!options?.bypassSharedLock,
1552
- IgnoreVersionHistory: !!options?.ignoreVersionHistory,
1553
- CustomizedItemName: options?.newName ? [options.newName] : undefined,
1554
- SameWebCopyMoveOptimization: true
1555
- }
1556
- }
1557
- };
1558
- const response = await request.post(requestOptions);
1559
- return response.value[0];
1560
- },
1561
- /**
1562
- * Poll until the copy job is finished and return the result.
1563
- * @param webUrl Absolute web URL where the copy job was created.
1564
- * @param copyJobInfo Information about the copy job.
1565
- * @throws Error if the copy job has failed.
1566
- * @returns Information about the destination object.
1567
- */
1568
- async getCopyJobResult(webUrl, copyJobInfo) {
1569
- const requestOptions = {
1570
- url: `${webUrl}/_api/Site/GetCopyJobProgress`,
1571
- headers: {
1572
- accept: 'application/json;odata=nometadata'
1573
- },
1574
- responseType: 'json',
1575
- data: {
1576
- copyJobInfo: copyJobInfo
1577
- }
1578
- };
1579
- let progress = await request.post(requestOptions);
1580
- while (progress.JobState !== 0) {
1581
- await setTimeout(settings.pollingInterval);
1582
- progress = await request.post(requestOptions);
1583
- }
1584
- const logs = progress.Logs.map(l => JSON.parse(l));
1585
- // Check if the job has failed
1586
- const errorLog = logs.find(l => l.Event === 'JobError');
1587
- if (errorLog) {
1588
- throw new Error(errorLog.Message);
1589
- }
1590
- // Get the destination object information
1591
- const objectInfo = logs.find(l => l.Event === 'JobFinishedObjectInfo');
1592
- return objectInfo;
1593
1519
  }
1594
1520
  };
1595
1521
  //# sourceMappingURL=spo.js.map
@@ -2,6 +2,11 @@ Setting name|Definition|Default value
2
2
  ------------|----------|-------------
3
3
  `authType`|Default login method to use when running `m365 login` without the `--authType` option.|`deviceCode`
4
4
  `autoOpenLinksInBrowser`|Automatically open the browser for all commands which return a url and expect the user to copy paste this to the browser. For example when logging in, using `m365 login` in device code mode.|`false`
5
+ `clientId`|ID of the default Entra ID app use by the CLI to authenticate|``
6
+ `clientSecret`|Secret of the default Entra ID app use by the CLI to authenticate|``
7
+ `clientCertificateFile`|Path to the file containing the client certificate to use for authentication|``
8
+ `clientCertificateBase64Encoded`|Base64-encoded client certificate contents|``
9
+ `clientCertificatePassword`|Password to the client certificate file|``
5
10
  `copyDeviceCodeToClipboard`|Automatically copy the device code to the clipboard when running `m365 login` command in device code mode|`false`
6
11
  `csvEscape`|Single character used for escaping; only apply to characters matching the quote and the escape options|`"`
7
12
  `csvHeader`|Display the column names on the first line|`true`
@@ -18,3 +23,4 @@ Setting name|Definition|Default value
18
23
  `promptListPageSize`|By default, lists of choices longer than 7 will be paginated. Use this option to control how many choices will appear on the screen at once.|7
19
24
  `showHelpOnFailure`|Automatically display help when executing a command failed|`true`
20
25
  `showSpinner`|Display spinner when executing commands|`true`
26
+ `tenantId`|ID of the default tenant to use when authenticating with|``
@@ -16,10 +16,10 @@ m365 app permission add [options]
16
16
  `--appId [appId]`
17
17
  : Client ID of the Microsoft Entra app registered in the .m365rc.json file to retrieve API permissions for.
18
18
 
19
- `--applicationPermissions [applicationPermissions]`
19
+ `--applicationPermission [applicationPermission]`
20
20
  : Space-separated list of application permissions to add.
21
21
 
22
- `--delegatedPermissions [delegatedPermissions]`
22
+ `--delegatedPermission [delegatedPermission]`
23
23
  : Space-separated list of delegated permissions to add.
24
24
 
25
25
  `--grantAdminConsent`
@@ -37,19 +37,19 @@ If you have multiple apps registered in your .m365rc.json file, you can specify
37
37
  Adds the specified application permissions to the default app registered in the _.m365rc.json_ file while granting admin consent.
38
38
 
39
39
  ```sh
40
- m365 app permission add --applicationPermissions 'https://graph.microsoft.com/User.ReadWrite.All https://graph.microsoft.com/User.Read.All' --grantAdminConsent
40
+ m365 app permission add --applicationPermission 'https://graph.microsoft.com/User.ReadWrite.All https://graph.microsoft.com/User.Read.All' --grantAdminConsent
41
41
  ```
42
42
 
43
43
  Adds the specified delegated permissions to the default app registered in the _.m365rc.json_ file without granting admin consent.
44
44
 
45
45
  ```sh
46
- m365 app permission add --delegatedPermissions 'https://graph.microsoft.com/offline_access'
46
+ m365 app permission add --delegatedPermission 'https://graph.microsoft.com/offline_access'
47
47
  ```
48
48
 
49
49
  Adds the specified application and delegated permissions to a specific app registered in the _.m365rc.json_ file while granting admin consent.
50
50
 
51
51
  ```sh
52
- m365 app permission add --appId '1663767b-4172-4519-bfd1-28e6ff19055b' --applicationPermissions 'https://graph.microsoft.com/User.ReadWrite.All https://graph.microsoft.com/User.Read.All' --delegatedPermissions 'https://graph.microsoft.com/offline_access' --grantAdminConsent
52
+ m365 app permission add --appId '1663767b-4172-4519-bfd1-28e6ff19055b' --applicationPermission 'https://graph.microsoft.com/User.ReadWrite.All https://graph.microsoft.com/User.Read.All' --delegatedPermission 'https://graph.microsoft.com/offline_access' --grantAdminConsent
53
53
  ```
54
54
 
55
55
  ## Response
@@ -16,7 +16,7 @@ m365 cli consent [options]
16
16
 
17
17
  ```md definition-list
18
18
  `-s, --service <service>`
19
- : Service for which to consent permissions. Allowed values: `VivaEngage`.
19
+ : Service for which to consent permissions. Allowed values: `VivaEngage`, (deprecated)`yammer`.
20
20
  ```
21
21
 
22
22
  <Global />
@@ -22,39 +22,39 @@ m365 entra sp add [options]
22
22
  ## Options
23
23
 
24
24
  ```md definition-list
25
- `-i, --id [id]`
26
- : ID of the app for which the enterprise application should be created.
25
+ `--appId [appId]`
26
+ : ID of the app for which the enterprise application should be created
27
27
 
28
- `-n, --displayName [displayName]`
29
- : Display name of the app for which the enterprise application should be created.
28
+ `--appName [appName]`
29
+ : Display name of the app for which the enterprise application should be created
30
30
 
31
31
  `--objectId [objectId]`
32
- : ObjectId of the app for which the enterprise application should be created.
32
+ : ObjectId of the app for which the enterprise application should be created
33
33
  ```
34
34
 
35
35
  <Global />
36
36
 
37
37
  ## Remarks
38
38
 
39
- Specify either the `id`, `displayName` or `objectId`. If you specify more than one option value, the command will fail with an error.
39
+ Specify either the `appId`, `appName` or `objectId`. If you specify more than one option value, the command will fail with an error.
40
40
 
41
41
  If you register an application in the portal, an application object as well as an enterprise application object are automatically created in your home tenant. If you register an application using CLI for Microsoft 365 or the Microsoft Graph, you'll need to create the enterprise application separately. To register/create an application using the CLI for Microsoft 365, use the [m365 entra app add](../app/app-add.mdx) command.
42
42
 
43
43
  ## Examples
44
44
 
45
- Creates an enterprise application for a registered Entra app with the specified id.
45
+ Creates an enterprise application for a registered Entra app with appId _b2307a39-e878-458b-bc90-03bc578531d6_.
46
46
 
47
47
  ```sh
48
- m365 entra enterpriseapp add --id b2307a39-e878-458b-bc90-03bc578531d6
48
+ m365 entra enterpriseapp add --appId b2307a39-e878-458b-bc90-03bc578531d6
49
49
  ```
50
50
 
51
- Creates an enterprise application for a registered Entra app with the specified displayName.
51
+ Creates an enterprise application for a registered Entra app with appName _Microsoft Graph_.
52
52
 
53
53
  ```sh
54
- m365 entra enterpriseapp add --displayName "Microsoft Graph"
54
+ m365 entra enterpriseapp add --appName "Microsoft Graph"
55
55
  ```
56
56
 
57
- Creates an enterprise application for a registered Entra app with the specified objectId.
57
+ Creates an enterprise application for a registered Entra app with objectId _b2307a39-e878-458b-bc90-03bc578531d6_.
58
58
 
59
59
  ```sh
60
60
  m365 entra enterpriseapp add --objectId b2307a39-e878-458b-bc90-03bc578531d6
@@ -172,7 +172,7 @@ m365 entra enterpriseapp add --objectId b2307a39-e878-458b-bc90-03bc578531d6
172
172
  <TabItem value="Markdown">
173
173
 
174
174
  ```md
175
- # entra enterpriseapp add --id "8da75b6a-4272-4b17-8ee1-20ba66e2b06f"
175
+ # entra enterpriseapp add --appId "8da75b6a-4272-4b17-8ee1-20ba66e2b06f"
176
176
 
177
177
  Date: 2023-06-02
178
178
 
@@ -22,40 +22,40 @@ m365 entra sp get [options]
22
22
  ## Options
23
23
 
24
24
  ```md definition-list
25
- `-i, --id [id]`
26
- : ID of the application for which the enterprise application should be retrieved.
25
+ `-i, --appId [appId]`
26
+ : ID of the application for which the enterprise application should be retrieved
27
27
 
28
- `-n, --displayName [displayName]`
29
- : Display name of the application for which the enterprise application should be retrieved.
28
+ `-n, --appDisplayName [appDisplayName]`
29
+ : Display name of the application for which the enterprise application should be retrieved
30
30
 
31
- `--objectId [objectId]`
32
- : ObjectId of the application for which the enterprise application should be retrieved.
31
+ `--appObjectId [appObjectId]`
32
+ : ObjectId of the application for which the enterprise application should be retrieved
33
33
  ```
34
34
 
35
35
  <Global />
36
36
 
37
37
  ## Remarks
38
38
 
39
- Specify either the `id`, `objectId` or `displayName`. If you specify more than one option value, the command will fail with an error.
39
+ Specify either the `appId`, `appObjectId` or `appDisplayName`. If you specify more than one option value, the command will fail with an error.
40
40
 
41
41
  ## Examples
42
42
 
43
- Return details about the enterprise application with the specified id.
43
+ Return details about the enterprise application with appId _b2307a39-e878-458b-bc90-03bc578531d6_.
44
44
 
45
45
  ```sh
46
- m365 entra enterpriseapp get --id b2307a39-e878-458b-bc90-03bc578531d6
46
+ m365 entra enterpriseapp get --appId b2307a39-e878-458b-bc90-03bc578531d6
47
47
  ```
48
48
 
49
- Return details about the enterprise application with the specified displayName.
49
+ Return details about the _Microsoft Graph_ enterprise application.
50
50
 
51
51
  ```sh
52
- m365 entra enterpriseapp get --displayName "Microsoft Graph"
52
+ m365 entra enterpriseapp get --appDisplayName "Microsoft Graph"
53
53
  ```
54
54
 
55
- Return details about the enterprise application with the specified ObjectId.
55
+ Return details about the enterprise application with ObjectId _b2307a39-e878-458b-bc90-03bc578531dd_.
56
56
 
57
57
  ```sh
58
- m365 entra enterpriseapp get --objectId b2307a39-e878-458b-bc90-03bc578531dd
58
+ m365 entra enterpriseapp get --appObjectId b2307a39-e878-458b-bc90-03bc578531dd
59
59
  ```
60
60
 
61
61
  ## Response
@@ -198,7 +198,7 @@ m365 entra enterpriseapp get --objectId b2307a39-e878-458b-bc90-03bc578531dd
198
198
  <TabItem value="Markdown">
199
199
 
200
200
  ```md
201
- # entra enterpriseapp get --id "ac7c9b4b-83b0-4a5e-ace2-a3530162c8f8"
201
+ # entra enterpriseapp get --appId "ac7c9b4b-83b0-4a5e-ace2-a3530162c8f8"
202
202
 
203
203
  Date: 2023-06-02
204
204