@pnp/cli-microsoft365 6.7.0-beta.54db310 → 6.7.0-beta.872b0f5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/Dockerfile +1 -1
- package/README.md +1 -1
- package/dist/Auth.js +75 -4
- package/dist/AuthServer.js +2 -1
- package/dist/Command.js +56 -7
- package/dist/m365/aad/commands/user/user-set.js +145 -30
- package/dist/m365/base/AzmgmtCommand.js +11 -0
- package/dist/m365/base/PowerAppsCommand.js +11 -0
- package/dist/m365/base/PowerPlatformCommand.js +11 -0
- package/dist/m365/commands/login.js +17 -1
- package/dist/m365/commands/status.js +4 -2
- package/dist/m365/flow/commands/run/run-get.js +31 -1
- package/dist/m365/spo/commands/file/file-list.js +104 -31
- package/dist/m365/spo/commands/listitem/listitem-list.js +113 -55
- package/dist/m365/spo/commands/site/site-recyclebinitem-clear.js +115 -0
- package/dist/m365/spo/commands.js +1 -0
- package/dist/request.js +7 -0
- package/dist/utils/misc.js +11 -0
- package/docs/docs/cmd/aad/user/user-set.md +53 -8
- package/docs/docs/cmd/flow/run/run-get.md +110 -9
- package/docs/docs/cmd/login.md +5 -2
- package/docs/docs/cmd/planner/task/task-add.md +3 -1
- package/docs/docs/cmd/planner/task/task-set.md +6 -4
- package/docs/docs/cmd/spo/file/file-list.md +87 -2
- package/docs/docs/cmd/spo/listitem/listitem-list.md +22 -8
- package/docs/docs/cmd/spo/site/site-recyclebinitem-clear.md +45 -0
- package/docs/docs/cmd/tenant/id/id-get.md +6 -0
- package/docs/docs/cmd/tenant/report/report-activeusercounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-activeuserdetail.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationcounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationsusercounts.md +7 -0
- package/docs/docs/cmd/tenant/report/report-office365activationsuserdetail.md +7 -0
- package/docs/docs/cmd/tenant/report/report-servicesusercounts.md +7 -0
- package/docs/docs/cmd/tenant/security/security-alerts-list.md +23 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +32 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +32 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +26 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +26 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +22 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +22 -0
- package/package.json +2 -1
- package/dist/m365/spo/commands/file/FilePropertiesCollection.js +0 -3
- package/dist/m365/spo/commands/folder/FileFolderCollection.js +0 -3
package/.devcontainer/Dockerfile
CHANGED
|
@@ -26,7 +26,7 @@ RUN apt-get update && apt-get install -y \
|
|
|
26
26
|
vim \
|
|
27
27
|
python3.8 \
|
|
28
28
|
python3-pip \
|
|
29
|
-
&& curl -sL https://deb.nodesource.com/
|
|
29
|
+
&& curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - \
|
|
30
30
|
&& apt-get install nodejs -y \
|
|
31
31
|
&& rm -rf /var/lib/apt/lists/*
|
|
32
32
|
|
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ m365 spo site get --url https://contoso.sharepoint.com --output text
|
|
|
184
184
|
|
|
185
185
|
## Build
|
|
186
186
|
|
|
187
|
-
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>=
|
|
187
|
+
To build and run this CLI locally, you will need [`node`](https://nodejs.org) `>= 18.0.0` installed.
|
|
188
188
|
|
|
189
189
|
```sh
|
|
190
190
|
# Clone this repository
|
package/dist/Auth.js
CHANGED
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Auth = exports.CertificateType = exports.AuthType = exports.Service = void 0;
|
|
12
|
+
exports.Auth = exports.CertificateType = exports.AuthType = exports.Service = exports.CloudType = void 0;
|
|
13
|
+
const msal_common_1 = require("@azure/msal-common");
|
|
13
14
|
const FileTokenStorage_1 = require("./auth/FileTokenStorage");
|
|
14
15
|
const msalCachePlugin_1 = require("./auth/msalCachePlugin");
|
|
15
16
|
const Cli_1 = require("./cli/Cli");
|
|
@@ -17,14 +18,24 @@ const Command_1 = require("./Command");
|
|
|
17
18
|
const config_1 = require("./config");
|
|
18
19
|
const request_1 = require("./request");
|
|
19
20
|
const settingsNames_1 = require("./settingsNames");
|
|
21
|
+
var CloudType;
|
|
22
|
+
(function (CloudType) {
|
|
23
|
+
CloudType[CloudType["Public"] = 0] = "Public";
|
|
24
|
+
CloudType[CloudType["USGov"] = 1] = "USGov";
|
|
25
|
+
CloudType[CloudType["USGovHigh"] = 2] = "USGovHigh";
|
|
26
|
+
CloudType[CloudType["USGovDoD"] = 3] = "USGovDoD";
|
|
27
|
+
CloudType[CloudType["China"] = 4] = "China";
|
|
28
|
+
})(CloudType = exports.CloudType || (exports.CloudType = {}));
|
|
20
29
|
class Service {
|
|
21
30
|
constructor() {
|
|
22
31
|
this.connected = false;
|
|
23
32
|
this.authType = AuthType.DeviceCode;
|
|
24
33
|
this.certificateType = CertificateType.Unknown;
|
|
34
|
+
this.cloudType = CloudType.Public;
|
|
25
35
|
this.accessTokens = {};
|
|
26
36
|
this.appId = config_1.default.cliAadAppId;
|
|
27
37
|
this.tenant = config_1.default.tenant;
|
|
38
|
+
this.cloudType = CloudType.Public;
|
|
28
39
|
}
|
|
29
40
|
logout() {
|
|
30
41
|
this.connected = false;
|
|
@@ -62,11 +73,41 @@ class Auth {
|
|
|
62
73
|
return this._service;
|
|
63
74
|
}
|
|
64
75
|
get defaultResource() {
|
|
65
|
-
return 'https://graph.microsoft.com';
|
|
76
|
+
return Auth.getEndpointForResource('https://graph.microsoft.com', this._service.cloudType);
|
|
66
77
|
}
|
|
67
78
|
constructor() {
|
|
68
79
|
this._service = new Service();
|
|
69
80
|
}
|
|
81
|
+
// we need to init cloud endpoints here, because we're using CloudType enum
|
|
82
|
+
// as indexers, which we can't do in the static initializer
|
|
83
|
+
// it also needs to be a separate method that we call here, because in tests
|
|
84
|
+
// we're mocking auth and calling its constructor
|
|
85
|
+
static initialize() {
|
|
86
|
+
this.cloudEndpoints[CloudType.USGov] = {
|
|
87
|
+
'https://graph.microsoft.com': 'https://graph.microsoft.com',
|
|
88
|
+
'https://graph.windows.net': 'https://graph.windows.net',
|
|
89
|
+
'https://management.azure.com/': 'https://management.usgovcloudapi.net/',
|
|
90
|
+
'https://login.microsoftonline.com': 'https://login.microsoftonline.com'
|
|
91
|
+
};
|
|
92
|
+
this.cloudEndpoints[CloudType.USGovHigh] = {
|
|
93
|
+
'https://graph.microsoft.com': 'https://graph.microsoft.us',
|
|
94
|
+
'https://graph.windows.net': 'https://graph.windows.net',
|
|
95
|
+
'https://management.azure.com/': 'https://management.usgovcloudapi.net/',
|
|
96
|
+
'https://login.microsoftonline.com': 'https://login.microsoftonline.us'
|
|
97
|
+
};
|
|
98
|
+
this.cloudEndpoints[CloudType.USGovDoD] = {
|
|
99
|
+
'https://graph.microsoft.com': 'https://dod-graph.microsoft.us',
|
|
100
|
+
'https://graph.windows.net': 'https://graph.windows.net',
|
|
101
|
+
'https://management.azure.com/': 'https://management.usgovcloudapi.net/',
|
|
102
|
+
'https://login.microsoftonline.com': 'https://login.microsoftonline.us'
|
|
103
|
+
};
|
|
104
|
+
this.cloudEndpoints[CloudType.China] = {
|
|
105
|
+
'https://graph.microsoft.com': 'https://microsoftgraph.chinacloudapi.cn',
|
|
106
|
+
'https://graph.windows.net': 'https://graph.chinacloudapi.cn',
|
|
107
|
+
'https://management.azure.com/': 'https://management.chinacloudapi.cn',
|
|
108
|
+
'https://login.microsoftonline.com': 'https://login.chinacloudapi.cn'
|
|
109
|
+
};
|
|
110
|
+
}
|
|
70
111
|
restoreAuth() {
|
|
71
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
113
|
// check if auth has been restored previously
|
|
@@ -196,9 +237,27 @@ class Auth {
|
|
|
196
237
|
thumbprint: certificateThumbprint,
|
|
197
238
|
privateKey: certificatePrivateKey
|
|
198
239
|
};
|
|
240
|
+
let azureCloudInstance = 0;
|
|
241
|
+
switch (this.service.cloudType) {
|
|
242
|
+
case CloudType.Public:
|
|
243
|
+
azureCloudInstance = msal_common_1.AzureCloudInstance.AzurePublic;
|
|
244
|
+
break;
|
|
245
|
+
case CloudType.China:
|
|
246
|
+
azureCloudInstance = msal_common_1.AzureCloudInstance.AzureChina;
|
|
247
|
+
break;
|
|
248
|
+
case CloudType.USGov:
|
|
249
|
+
case CloudType.USGovHigh:
|
|
250
|
+
case CloudType.USGovDoD:
|
|
251
|
+
azureCloudInstance = msal_common_1.AzureCloudInstance.AzureUsGovernment;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
199
254
|
const config = {
|
|
200
255
|
clientId: this.service.appId,
|
|
201
|
-
authority:
|
|
256
|
+
authority: `${Auth.getEndpointForResource('https://login.microsoftonline.com', this.service.cloudType)}/${this.service.tenant}`,
|
|
257
|
+
azureCloudOptions: {
|
|
258
|
+
azureCloudInstance,
|
|
259
|
+
tenant: this.service.tenant
|
|
260
|
+
}
|
|
202
261
|
};
|
|
203
262
|
const authConfig = cert
|
|
204
263
|
? Object.assign(Object.assign({}, config), { clientCertificate: cert }) : Object.assign(Object.assign({}, config), { clientSecret });
|
|
@@ -534,7 +593,8 @@ class Auth {
|
|
|
534
593
|
if (pos > -1) {
|
|
535
594
|
resource = resource.substr(0, pos);
|
|
536
595
|
}
|
|
537
|
-
if (resource === 'https://api.bap.microsoft.com' ||
|
|
596
|
+
if (resource === 'https://api.bap.microsoft.com' ||
|
|
597
|
+
resource === 'https://api.powerapps.com') {
|
|
538
598
|
resource = 'https://service.powerapps.com/';
|
|
539
599
|
}
|
|
540
600
|
if (resource === 'https://api.powerbi.com') {
|
|
@@ -571,7 +631,18 @@ class Auth {
|
|
|
571
631
|
getMsalCacheStorage() {
|
|
572
632
|
return new FileTokenStorage_1.FileTokenStorage(FileTokenStorage_1.FileTokenStorage.msalCacheFilePath());
|
|
573
633
|
}
|
|
634
|
+
static getEndpointForResource(resource, cloudType) {
|
|
635
|
+
if (Auth.cloudEndpoints[cloudType] &&
|
|
636
|
+
Auth.cloudEndpoints[cloudType][resource]) {
|
|
637
|
+
return Auth.cloudEndpoints[cloudType][resource];
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
return resource;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
574
643
|
}
|
|
575
644
|
exports.Auth = Auth;
|
|
645
|
+
Auth.cloudEndpoints = [];
|
|
646
|
+
Auth.initialize();
|
|
576
647
|
exports.default = new Auth();
|
|
577
648
|
//# sourceMappingURL=Auth.js.map
|
package/dist/AuthServer.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.AuthServer = void 0;
|
|
|
4
4
|
const http = require("http");
|
|
5
5
|
const open = require("open");
|
|
6
6
|
const url = require("url");
|
|
7
|
+
const Auth_1 = require("./Auth");
|
|
7
8
|
class AuthServer {
|
|
8
9
|
constructor() {
|
|
9
10
|
this.open = open;
|
|
@@ -23,7 +24,7 @@ class AuthServer {
|
|
|
23
24
|
const requestState = Math.random().toString(16).substr(2, 20);
|
|
24
25
|
const address = this.httpServer.address();
|
|
25
26
|
this.generatedServerUrl = `http://localhost:${address.port}`;
|
|
26
|
-
const url =
|
|
27
|
+
const url = `${Auth_1.Auth.getEndpointForResource('https://login.microsoftonline.com', this.service.cloudType)}/${this.service.tenant}/oauth2/authorize?response_type=code&client_id=${this.service.appId}&redirect_uri=${this.generatedServerUrl}&state=${requestState}&resource=${this.resource}&prompt=select_account`;
|
|
27
28
|
if (this.debug) {
|
|
28
29
|
this.logger.logToStderr('Redirect URL:');
|
|
29
30
|
this.logger.logToStderr(url);
|
package/dist/Command.js
CHANGED
|
@@ -127,21 +127,70 @@ class Command {
|
|
|
127
127
|
if (!optionsSets || optionsSets.length === 0) {
|
|
128
128
|
return true;
|
|
129
129
|
}
|
|
130
|
+
let inquirer;
|
|
131
|
+
const shouldPrompt = Cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.prompt, false);
|
|
130
132
|
const argsOptions = Object.keys(args.options);
|
|
131
|
-
for (const optionSet of optionsSets) {
|
|
132
|
-
if (optionSet.runsWhen
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
for (const optionSet of optionsSets.sort(opt => opt.runsWhen ? 0 : 1)) {
|
|
134
|
+
if (optionSet.runsWhen && !optionSet.runsWhen(args)) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const commonOptions = argsOptions.filter(opt => optionSet.options.includes(opt));
|
|
138
|
+
if (commonOptions.length === 0) {
|
|
139
|
+
if (!shouldPrompt) {
|
|
140
|
+
return `Specify one of the following options: ${optionSet.options.join(', ')}.`;
|
|
136
141
|
}
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
yield this.promptForOptionSetNameAndValue(args, optionSet, inquirer);
|
|
143
|
+
}
|
|
144
|
+
if (commonOptions.length > 1) {
|
|
145
|
+
if (!shouldPrompt) {
|
|
146
|
+
return `Specify one of the following options: ${optionSet.options.join(', ')}, but not multiple.`;
|
|
139
147
|
}
|
|
148
|
+
yield this.promptForSpecificOption(args, commonOptions, inquirer);
|
|
140
149
|
}
|
|
141
150
|
}
|
|
142
151
|
return true;
|
|
143
152
|
});
|
|
144
153
|
}
|
|
154
|
+
promptForOptionSetNameAndValue(args, optionSet, inquirer) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
if (!inquirer) {
|
|
157
|
+
inquirer = require('inquirer');
|
|
158
|
+
}
|
|
159
|
+
Cli_1.Cli.log(`Please specify one of the following options:`);
|
|
160
|
+
const resultOptionName = yield inquirer
|
|
161
|
+
.prompt({
|
|
162
|
+
type: 'list',
|
|
163
|
+
name: 'missingRequiredOptionName',
|
|
164
|
+
message: `Option to use:`,
|
|
165
|
+
choices: optionSet.options
|
|
166
|
+
});
|
|
167
|
+
const missingRequiredOptionName = resultOptionName.missingRequiredOptionName;
|
|
168
|
+
const resultOptionValue = yield inquirer
|
|
169
|
+
.prompt({
|
|
170
|
+
name: 'missingRequiredOptionValue',
|
|
171
|
+
message: `Value for '${missingRequiredOptionName}':`
|
|
172
|
+
});
|
|
173
|
+
args.options[missingRequiredOptionName] = resultOptionValue.missingRequiredOptionValue;
|
|
174
|
+
Cli_1.Cli.log();
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
promptForSpecificOption(args, commonOptions, inquirer) {
|
|
178
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
+
if (!inquirer) {
|
|
180
|
+
inquirer = require('inquirer');
|
|
181
|
+
}
|
|
182
|
+
Cli_1.Cli.log(`Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
|
|
183
|
+
const requiredOptionNameResult = yield inquirer
|
|
184
|
+
.prompt({
|
|
185
|
+
type: 'list',
|
|
186
|
+
name: 'missingRequiredOptionName',
|
|
187
|
+
message: `Option to use:`,
|
|
188
|
+
choices: commonOptions
|
|
189
|
+
});
|
|
190
|
+
commonOptions.filter(y => y !== requiredOptionNameResult.missingRequiredOptionName).map(optionName => args.options[optionName] = undefined);
|
|
191
|
+
Cli_1.Cli.log();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
145
194
|
validateOutput(args) {
|
|
146
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
196
|
if (args.options.output &&
|
|
@@ -44,9 +44,6 @@ class AadUserSetCommand extends GraphCommand_1.default {
|
|
|
44
44
|
commandAction(logger, args) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
try {
|
|
47
|
-
if (this.verbose) {
|
|
48
|
-
logger.logToStderr(`Updating user ${args.options.userPrincipalName || args.options.objectId}`);
|
|
49
|
-
}
|
|
50
47
|
if (args.options.currentPassword) {
|
|
51
48
|
if (args.options.objectId && args.options.objectId !== accessToken_1.accessToken.getUserIdFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken)) {
|
|
52
49
|
throw `You can only change your own password. Please use --objectId @meId to reference to your own userId`;
|
|
@@ -55,11 +52,14 @@ class AadUserSetCommand extends GraphCommand_1.default {
|
|
|
55
52
|
throw 'You can only change your own password. Please use --userPrincipalName @meUserName to reference to your own user principal name';
|
|
56
53
|
}
|
|
57
54
|
}
|
|
55
|
+
if (this.verbose) {
|
|
56
|
+
logger.logToStderr(`Updating user ${args.options.userPrincipalName || args.options.objectId}`);
|
|
57
|
+
}
|
|
58
58
|
const requestUrl = `${this.resource}/v1.0/users/${formatting_1.formatting.encodeQueryParameter(args.options.objectId ? args.options.objectId : args.options.userPrincipalName)}`;
|
|
59
59
|
const manifest = this.mapRequestBody(args.options);
|
|
60
|
-
if (Object.keys(manifest).
|
|
60
|
+
if (Object.keys(manifest).some(k => manifest[k] !== undefined)) {
|
|
61
61
|
if (this.verbose) {
|
|
62
|
-
logger.logToStderr(`Setting the updated properties for
|
|
62
|
+
logger.logToStderr(`Setting the updated properties for user ${args.options.userPrincipalName || args.options.objectId}`);
|
|
63
63
|
}
|
|
64
64
|
const requestOptions = {
|
|
65
65
|
url: requestUrl,
|
|
@@ -74,6 +74,19 @@ class AadUserSetCommand extends GraphCommand_1.default {
|
|
|
74
74
|
if (args.options.currentPassword) {
|
|
75
75
|
yield this.changePassword(requestUrl, args.options, logger);
|
|
76
76
|
}
|
|
77
|
+
if (args.options.managerUserId || args.options.managerUserName) {
|
|
78
|
+
if (this.verbose) {
|
|
79
|
+
logger.logToStderr(`Updating the manager to ${args.options.managerUserId || args.options.managerUserName}`);
|
|
80
|
+
}
|
|
81
|
+
yield this.updateManager(args.options);
|
|
82
|
+
}
|
|
83
|
+
else if (args.options.removeManager) {
|
|
84
|
+
if (this.verbose) {
|
|
85
|
+
logger.logToStderr('Removing the manager');
|
|
86
|
+
}
|
|
87
|
+
const user = args.options.objectId || args.options.userPrincipalName;
|
|
88
|
+
yield this.removeManager(user);
|
|
89
|
+
}
|
|
77
90
|
}
|
|
78
91
|
catch (err) {
|
|
79
92
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -81,35 +94,32 @@ class AadUserSetCommand extends GraphCommand_1.default {
|
|
|
81
94
|
});
|
|
82
95
|
}
|
|
83
96
|
mapRequestBody(options) {
|
|
84
|
-
const requestBody = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
'forceChangePasswordNextSignIn'
|
|
98
|
-
];
|
|
99
|
-
if (options.accountEnabled !== undefined) {
|
|
100
|
-
requestBody['AccountEnabled'] = options.accountEnabled;
|
|
101
|
-
}
|
|
102
|
-
Object.keys(options).forEach(key => {
|
|
103
|
-
if (excludeOptions.indexOf(key) === -1) {
|
|
104
|
-
requestBody[key] = `${options[key]}`;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
97
|
+
const requestBody = {
|
|
98
|
+
displayName: options.displayName,
|
|
99
|
+
givenName: options.firstName,
|
|
100
|
+
surname: options.lastName,
|
|
101
|
+
usageLocation: options.usageLocation,
|
|
102
|
+
officeLocation: options.officeLocation,
|
|
103
|
+
jobTitle: options.jobTitle,
|
|
104
|
+
companyName: options.companyName,
|
|
105
|
+
department: options.department,
|
|
106
|
+
preferredLanguage: options.preferredLanguage,
|
|
107
|
+
accountEnabled: options.accountEnabled
|
|
108
|
+
};
|
|
109
|
+
this.addUnknownOptionsToPayload(requestBody, options);
|
|
107
110
|
if (options.resetPassword) {
|
|
108
111
|
requestBody.passwordProfile = {
|
|
109
112
|
forceChangePasswordNextSignIn: options.forceChangePasswordNextSignIn || false,
|
|
113
|
+
forceChangePasswordNextSignInWithMfa: options.forceChangePasswordNextSignInWithMfa || false,
|
|
110
114
|
password: options.newPassword
|
|
111
115
|
};
|
|
112
116
|
}
|
|
117
|
+
// Replace every empty string with null
|
|
118
|
+
for (const key in requestBody) {
|
|
119
|
+
if (typeof requestBody[key] === 'string' && requestBody[key].trim() === '') {
|
|
120
|
+
requestBody[key] = null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
113
123
|
return requestBody;
|
|
114
124
|
}
|
|
115
125
|
changePassword(requestUrl, options, logger) {
|
|
@@ -132,6 +142,31 @@ class AadUserSetCommand extends GraphCommand_1.default {
|
|
|
132
142
|
yield request_1.default.post(requestOptions);
|
|
133
143
|
});
|
|
134
144
|
}
|
|
145
|
+
updateManager(options) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const managerRequestOptions = {
|
|
148
|
+
url: `${this.resource}/v1.0/users/${options.objectId || options.userPrincipalName}/manager/$ref`,
|
|
149
|
+
headers: {
|
|
150
|
+
accept: 'application/json;odata.metadata=none'
|
|
151
|
+
},
|
|
152
|
+
data: {
|
|
153
|
+
'@odata.id': `${this.resource}/v1.0/users/${options.managerUserId || options.managerUserName}`
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
yield request_1.default.put(managerRequestOptions);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
removeManager(userId) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const managerRequestOptions = {
|
|
162
|
+
url: `${this.resource}/v1.0/users/${userId}/manager/$ref`,
|
|
163
|
+
headers: {
|
|
164
|
+
accept: 'application/json;odata.metadata=none'
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
yield request_1.default.delete(managerRequestOptions);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
135
170
|
}
|
|
136
171
|
_AadUserSetCommand_instances = new WeakSet(), _AadUserSetCommand_initTelemetry = function _AadUserSetCommand_initTelemetry() {
|
|
137
172
|
this.telemetry.push((args) => {
|
|
@@ -142,7 +177,20 @@ _AadUserSetCommand_instances = new WeakSet(), _AadUserSetCommand_initTelemetry =
|
|
|
142
177
|
resetPassword: !!args.options.resetPassword,
|
|
143
178
|
forceChangePasswordNextSignIn: !!args.options.forceChangePasswordNextSignIn,
|
|
144
179
|
currentPassword: typeof args.options.currentPassword !== 'undefined',
|
|
145
|
-
newPassword: typeof args.options.newPassword !== 'undefined'
|
|
180
|
+
newPassword: typeof args.options.newPassword !== 'undefined',
|
|
181
|
+
displayName: typeof args.options.displayName !== 'undefined',
|
|
182
|
+
firstName: typeof args.options.firstName !== 'undefined',
|
|
183
|
+
lastName: typeof args.options.lastName !== 'undefined',
|
|
184
|
+
forceChangePasswordNextSignInWithMfa: !!args.options.forceChangePasswordNextSignInWithMfa,
|
|
185
|
+
usageLocation: typeof args.options.usageLocation !== 'undefined',
|
|
186
|
+
officeLocation: typeof args.options.officeLocation !== 'undefined',
|
|
187
|
+
jobTitle: typeof args.options.jobTitle !== 'undefined',
|
|
188
|
+
companyName: typeof args.options.companyName !== 'undefined',
|
|
189
|
+
department: typeof args.options.department !== 'undefined',
|
|
190
|
+
preferredLanguage: typeof args.options.preferredLanguage !== 'undefined',
|
|
191
|
+
managerUserId: typeof args.options.managerUserId !== 'undefined',
|
|
192
|
+
managerUserName: typeof args.options.managerUserName !== 'undefined',
|
|
193
|
+
removeManager: typeof args.options.removeManager !== 'undefined'
|
|
146
194
|
});
|
|
147
195
|
});
|
|
148
196
|
}, _AadUserSetCommand_initOptions = function _AadUserSetCommand_initOptions() {
|
|
@@ -161,6 +209,32 @@ _AadUserSetCommand_instances = new WeakSet(), _AadUserSetCommand_initTelemetry =
|
|
|
161
209
|
option: '--currentPassword [currentPassword]'
|
|
162
210
|
}, {
|
|
163
211
|
option: '--newPassword [newPassword]'
|
|
212
|
+
}, {
|
|
213
|
+
option: '--displayName [displayName]'
|
|
214
|
+
}, {
|
|
215
|
+
option: '--firstName [firstName]'
|
|
216
|
+
}, {
|
|
217
|
+
option: '--lastName [lastName]'
|
|
218
|
+
}, {
|
|
219
|
+
option: '--forceChangePasswordNextSignInWithMfa'
|
|
220
|
+
}, {
|
|
221
|
+
option: '--usageLocation [usageLocation]'
|
|
222
|
+
}, {
|
|
223
|
+
option: '--officeLocation [officeLocation]'
|
|
224
|
+
}, {
|
|
225
|
+
option: '--jobTitle [jobTitle]'
|
|
226
|
+
}, {
|
|
227
|
+
option: '--companyName [companyName]'
|
|
228
|
+
}, {
|
|
229
|
+
option: '--department [department]'
|
|
230
|
+
}, {
|
|
231
|
+
option: '--preferredLanguage [preferredLanguage]'
|
|
232
|
+
}, {
|
|
233
|
+
option: '--managerUserId [managerUserId]'
|
|
234
|
+
}, {
|
|
235
|
+
option: '--managerUserName [managerUserName]'
|
|
236
|
+
}, {
|
|
237
|
+
option: '--removeManager'
|
|
164
238
|
});
|
|
165
239
|
}, _AadUserSetCommand_initTypes = function _AadUserSetCommand_initTypes() {
|
|
166
240
|
this.types.boolean.push('accountEnabled');
|
|
@@ -182,10 +256,51 @@ _AadUserSetCommand_instances = new WeakSet(), _AadUserSetCommand_initTelemetry =
|
|
|
182
256
|
if (args.options.resetPassword && !args.options.newPassword) {
|
|
183
257
|
return `When resetting a user's password, specify the new password to set for the user, using the newPassword option`;
|
|
184
258
|
}
|
|
259
|
+
if (args.options.firstName && args.options.firstName.length > 64) {
|
|
260
|
+
return `The max lenght for the firstName option is 64 characters`;
|
|
261
|
+
}
|
|
262
|
+
if (args.options.lastName && args.options.lastName.length > 64) {
|
|
263
|
+
return `The max lenght for the lastName option is 64 characters`;
|
|
264
|
+
}
|
|
265
|
+
if (args.options.forceChangePasswordNextSignIn && !args.options.resetPassword) {
|
|
266
|
+
return `The option forceChangePasswordNextSignIn can only be used in combination with the resetPassword option`;
|
|
267
|
+
}
|
|
268
|
+
if (args.options.forceChangePasswordNextSignInWithMfa && !args.options.resetPassword) {
|
|
269
|
+
return `The option forceChangePasswordNextSignInWithMfa can only be used in combination with the resetPassword option`;
|
|
270
|
+
}
|
|
271
|
+
if (args.options.usageLocation) {
|
|
272
|
+
const regex = new RegExp('^[a-zA-Z]{2}$');
|
|
273
|
+
if (!regex.test(args.options.usageLocation)) {
|
|
274
|
+
return `'${args.options.usageLocation}' is not a valid usageLocation.`;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (args.options.jobTitle && args.options.jobTitle.length > 128) {
|
|
278
|
+
return `The max lenght for the jobTitle option is 128 characters`;
|
|
279
|
+
}
|
|
280
|
+
if (args.options.companyName && args.options.companyName.length > 64) {
|
|
281
|
+
return `The max lenght for the companyName option is 64 characters`;
|
|
282
|
+
}
|
|
283
|
+
if (args.options.department && args.options.department.length > 64) {
|
|
284
|
+
return `The max lenght for the department option is 64 characters`;
|
|
285
|
+
}
|
|
286
|
+
if (args.options.preferredLanguage && args.options.preferredLanguage.length < 2) {
|
|
287
|
+
return `'${args.options.preferredLanguage}' is not a valid preferredLanguage`;
|
|
288
|
+
}
|
|
289
|
+
if (args.options.managerUserName && !validation_1.validation.isValidUserPrincipalName(args.options.managerUserName)) {
|
|
290
|
+
return `'${args.options.managerUserName}' is not a valid user principal name`;
|
|
291
|
+
}
|
|
292
|
+
if (args.options.managerUserId && !validation_1.validation.isValidGuid(args.options.managerUserId)) {
|
|
293
|
+
return `'${args.options.managerUserId}' is not a valid GUID`;
|
|
294
|
+
}
|
|
185
295
|
return true;
|
|
186
296
|
}));
|
|
187
297
|
}, _AadUserSetCommand_initOptionSets = function _AadUserSetCommand_initOptionSets() {
|
|
188
|
-
this.optionSets.push({
|
|
298
|
+
this.optionSets.push({
|
|
299
|
+
options: ['objectId', 'userPrincipalName']
|
|
300
|
+
}, {
|
|
301
|
+
options: ['managerUserId', 'managerUserName', 'removeManager'],
|
|
302
|
+
runsWhen: (args) => args.options.managerUserId || args.options.managerUserName || args.options.removeManager
|
|
303
|
+
});
|
|
189
304
|
};
|
|
190
305
|
module.exports = new AadUserSetCommand();
|
|
191
306
|
//# sourceMappingURL=user-set.js.map
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Auth_1 = require("../../Auth");
|
|
3
4
|
const Command_1 = require("../../Command");
|
|
4
5
|
class AzmgmtCommand extends Command_1.default {
|
|
5
6
|
get resource() {
|
|
6
7
|
return 'https://management.azure.com/';
|
|
7
8
|
}
|
|
9
|
+
initAction(args, logger) {
|
|
10
|
+
super.initAction(args, logger);
|
|
11
|
+
if (!Auth_1.default.service.connected) {
|
|
12
|
+
// we fail no login in the base command command class
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (Auth_1.default.service.cloudType !== Auth_1.CloudType.Public) {
|
|
16
|
+
throw new Command_1.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.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
}
|
|
9
20
|
exports.default = AzmgmtCommand;
|
|
10
21
|
//# sourceMappingURL=AzmgmtCommand.js.map
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Auth_1 = require("../../Auth");
|
|
3
4
|
const Command_1 = require("../../Command");
|
|
4
5
|
class PowerAppsCommand extends Command_1.default {
|
|
5
6
|
get resource() {
|
|
6
7
|
return 'https://api.powerapps.com';
|
|
7
8
|
}
|
|
9
|
+
initAction(args, logger) {
|
|
10
|
+
super.initAction(args, logger);
|
|
11
|
+
if (!Auth_1.default.service.connected) {
|
|
12
|
+
// we fail no login in the base command command class
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (Auth_1.default.service.cloudType !== Auth_1.CloudType.Public) {
|
|
16
|
+
throw new Command_1.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.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
}
|
|
9
20
|
exports.default = PowerAppsCommand;
|
|
10
21
|
//# sourceMappingURL=PowerAppsCommand.js.map
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Auth_1 = require("../../Auth");
|
|
3
4
|
const Command_1 = require("../../Command");
|
|
4
5
|
class PowerPlatformCommand extends Command_1.default {
|
|
5
6
|
get resource() {
|
|
6
7
|
return 'https://api.bap.microsoft.com';
|
|
7
8
|
}
|
|
9
|
+
initAction(args, logger) {
|
|
10
|
+
super.initAction(args, logger);
|
|
11
|
+
if (!Auth_1.default.service.connected) {
|
|
12
|
+
// we fail no login in the base command command class
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (Auth_1.default.service.cloudType !== Auth_1.CloudType.Public) {
|
|
16
|
+
throw new Command_1.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.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
}
|
|
9
20
|
exports.default = PowerPlatformCommand;
|
|
10
21
|
//# sourceMappingURL=PowerPlatformCommand.js.map
|
|
@@ -19,6 +19,7 @@ const fs = require("fs");
|
|
|
19
19
|
const Auth_1 = require("../../Auth");
|
|
20
20
|
const Command_1 = require("../../Command");
|
|
21
21
|
const config_1 = require("../../config");
|
|
22
|
+
const misc_1 = require("../../utils/misc");
|
|
22
23
|
const commands_1 = require("./commands");
|
|
23
24
|
class LoginCommand extends Command_1.default {
|
|
24
25
|
get name() {
|
|
@@ -71,6 +72,12 @@ class LoginCommand extends Command_1.default {
|
|
|
71
72
|
Auth_1.default.service.secret = args.options.secret;
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
75
|
+
if (args.options.cloud) {
|
|
76
|
+
Auth_1.default.service.cloudType = Auth_1.CloudType[args.options.cloud];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
Auth_1.default.service.cloudType = Auth_1.CloudType.Public;
|
|
80
|
+
}
|
|
74
81
|
try {
|
|
75
82
|
yield Auth_1.default.ensureAccessToken(Auth_1.default.defaultResource, logger, this.debug);
|
|
76
83
|
Auth_1.default.service.connected = true;
|
|
@@ -113,8 +120,10 @@ class LoginCommand extends Command_1.default {
|
|
|
113
120
|
}
|
|
114
121
|
_LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function _LoginCommand_initTelemetry() {
|
|
115
122
|
this.telemetry.push((args) => {
|
|
123
|
+
var _a;
|
|
116
124
|
Object.assign(this.telemetryProperties, {
|
|
117
|
-
authType: args.options.authType || 'deviceCode'
|
|
125
|
+
authType: args.options.authType || 'deviceCode',
|
|
126
|
+
cloud: (_a = args.options.cloud) !== null && _a !== void 0 ? _a : Auth_1.CloudType.Public
|
|
118
127
|
});
|
|
119
128
|
});
|
|
120
129
|
}, _LoginCommand_initOptions = function _LoginCommand_initOptions() {
|
|
@@ -137,6 +146,9 @@ _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function
|
|
|
137
146
|
option: '--tenant [tenant]'
|
|
138
147
|
}, {
|
|
139
148
|
option: '--secret [secret]'
|
|
149
|
+
}, {
|
|
150
|
+
option: '--cloud [cloud]',
|
|
151
|
+
autocomplete: misc_1.misc.getEnums(Auth_1.CloudType)
|
|
140
152
|
});
|
|
141
153
|
}, _LoginCommand_initValidators = function _LoginCommand_initValidators() {
|
|
142
154
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -170,6 +182,10 @@ _LoginCommand_instances = new WeakSet(), _LoginCommand_initTelemetry = function
|
|
|
170
182
|
return 'Required option secret missing';
|
|
171
183
|
}
|
|
172
184
|
}
|
|
185
|
+
if (args.options.cloud &&
|
|
186
|
+
typeof Auth_1.CloudType[args.options.cloud] === 'undefined') {
|
|
187
|
+
return `${args.options.cloud} is not a valid value for cloud. Valid options are ${misc_1.misc.getEnums(Auth_1.CloudType).join(', ')}`;
|
|
188
|
+
}
|
|
173
189
|
return true;
|
|
174
190
|
}));
|
|
175
191
|
};
|
|
@@ -39,7 +39,8 @@ class StatusCommand extends Command_1.default {
|
|
|
39
39
|
authType: Auth_1.AuthType[Auth_1.default.service.authType],
|
|
40
40
|
appId: Auth_1.default.service.appId,
|
|
41
41
|
appTenant: Auth_1.default.service.tenant,
|
|
42
|
-
accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2)
|
|
42
|
+
accessTokens: JSON.stringify(Auth_1.default.service.accessTokens, null, 2),
|
|
43
|
+
cloudType: Auth_1.CloudType[Auth_1.default.service.cloudType]
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
@@ -47,7 +48,8 @@ class StatusCommand extends Command_1.default {
|
|
|
47
48
|
connectedAs: accessToken_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken),
|
|
48
49
|
authType: Auth_1.AuthType[Auth_1.default.service.authType],
|
|
49
50
|
appId: Auth_1.default.service.appId,
|
|
50
|
-
appTenant: Auth_1.default.service.tenant
|
|
51
|
+
appTenant: Auth_1.default.service.tenant,
|
|
52
|
+
cloudType: Auth_1.CloudType[Auth_1.default.service.cloudType]
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
}
|