@pnp/cli-microsoft365 5.0.0-beta.117f66f → 5.0.0-beta.156f91b
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/devcontainer.json +9 -1
- package/.eslintrc.js +1 -0
- package/dist/Command.js +1 -1
- package/dist/Utils.js +7 -0
- package/dist/api.d.ts +11 -0
- package/dist/api.js +17 -0
- package/dist/cli/Cli.js +26 -13
- package/dist/m365/aad/commands/app/app-add.js +43 -7
- package/dist/m365/aad/commands/app/app-delete.js +126 -0
- package/dist/m365/aad/commands/group/group-list.js +49 -0
- package/dist/m365/aad/commands/o365group/{Group.js → GroupExtended.js} +1 -1
- package/dist/m365/aad/commands/o365group/o365group-user-set.js +3 -3
- package/dist/m365/aad/commands/user/user-get.js +33 -6
- package/dist/m365/aad/commands/user/user-hibp.js +67 -0
- package/dist/m365/aad/commands/user/user-list.js +7 -4
- package/dist/m365/aad/commands.js +3 -0
- package/dist/m365/cli/commands/config/config-set.js +4 -1
- package/dist/m365/flow/commands/flow-get.js +2 -2
- package/dist/m365/pa/cds-project-mutator.js +1 -1
- package/dist/m365/{aad/commands/o365group/GroupUser.js → planner/AppliedCategories.js} +1 -1
- package/dist/m365/planner/commands/task/task-add.js +288 -0
- package/dist/m365/planner/commands/task/task-details-get.js +39 -0
- package/dist/m365/planner/commands/task/task-get.js +50 -0
- package/dist/m365/planner/commands/task/task-list.js +37 -7
- package/dist/m365/planner/commands/task/task-set.js +357 -0
- package/dist/m365/planner/commands.js +5 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
- package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.14.0-beta.4.js → upgrade-1.14.0-rc.2.js} +27 -25
- package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
- package/dist/m365/spo/commands/group/group-user-add.js +64 -13
- package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
- package/dist/m365/spo/commands/site/site-ensure.js +1 -1
- package/dist/m365/spo/commands/site/site-recyclebinitem-list.js +76 -0
- package/dist/m365/spo/commands.js +2 -0
- package/dist/m365/teams/commands/app/app-list.js +9 -6
- package/dist/m365/teams/commands/chat/chat-list.js +43 -0
- package/dist/m365/teams/commands/chat/chat-member-list.js +42 -0
- package/dist/m365/teams/commands/chat/chat-message-list.js +60 -0
- package/dist/m365/teams/commands/message/message-get.js +1 -1
- package/dist/m365/teams/commands/tab/tab-get.js +9 -6
- package/dist/m365/teams/commands.js +3 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
- package/dist/m365/tenant/commands.js +6 -0
- package/dist/settingsNames.js +6 -1
- package/docs/docs/cmd/aad/app/app-delete.md +51 -0
- package/docs/docs/cmd/aad/group/group-list.md +30 -0
- package/docs/docs/cmd/aad/user/user-get.md +13 -4
- package/docs/docs/cmd/aad/user/user-hibp.md +46 -0
- package/docs/docs/cmd/aad/user/user-list.md +9 -0
- package/docs/docs/cmd/planner/task/task-add.md +78 -0
- package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
- package/docs/docs/cmd/planner/task/task-get.md +29 -0
- package/docs/docs/cmd/planner/task/task-list.md +5 -0
- package/docs/docs/cmd/planner/task/task-set.md +99 -0
- package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +3 -3
- package/docs/docs/cmd/spo/group/group-user-add.md +24 -6
- package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
- package/docs/docs/cmd/spo/site/site-recyclebinitem-list.md +40 -0
- package/docs/docs/cmd/teams/channel/channel-get.md +1 -1
- package/docs/docs/cmd/teams/chat/chat-list.md +30 -0
- package/docs/docs/cmd/teams/chat/chat-member-list.md +24 -0
- package/docs/docs/cmd/teams/chat/chat-message-list.md +24 -0
- package/docs/docs/cmd/teams/message/message-get.md +0 -3
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
- package/npm-shrinkwrap.json +938 -1001
- package/package.json +31 -27
- package/dist/m365/base/AadCommand.js +0 -10
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
"name": "CLI for Microsoft 365",
|
|
3
3
|
"dockerFile": "Dockerfile",
|
|
4
4
|
"settings": {
|
|
5
|
-
"terminal.integrated.
|
|
5
|
+
"terminal.integrated.profiles.linux": {
|
|
6
|
+
"zsh": {
|
|
7
|
+
"path": "/bin/zsh",
|
|
8
|
+
"args": [
|
|
9
|
+
"-l"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"terminal.integrated.defaultProfile.linux": "zsh"
|
|
6
14
|
},
|
|
7
15
|
"postCreateCommand": "npm i && npm run clean && npm run build && npm link",
|
|
8
16
|
"extensions": [
|
package/.eslintrc.js
CHANGED
package/dist/Command.js
CHANGED
package/dist/Utils.js
CHANGED
|
@@ -40,6 +40,9 @@ class Utils {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
static isValidGuidArray(guids) {
|
|
44
|
+
return guids.every(guid => this.isValidGuid(guid));
|
|
45
|
+
}
|
|
43
46
|
static isValidGuid(guid) {
|
|
44
47
|
const guidRegEx = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
45
48
|
return guidRegEx.test(guid);
|
|
@@ -48,6 +51,10 @@ class Utils {
|
|
|
48
51
|
const guidRegEx = new RegExp(/^19:[0-9a-zA-Z-_]+@thread\.(skype|tacv2)$/i);
|
|
49
52
|
return guidRegEx.test(guid);
|
|
50
53
|
}
|
|
54
|
+
static isValidTeamsChatId(guid) {
|
|
55
|
+
const guidRegEx = new RegExp(/^19:[0-9a-zA-Z-_]+(@thread\.v2|@unq\.gbl\.spaces)$/i);
|
|
56
|
+
return guidRegEx.test(guid);
|
|
57
|
+
}
|
|
51
58
|
static isValidUserPrincipalName(upn) {
|
|
52
59
|
const upnRegEx = new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/i);
|
|
53
60
|
return upnRegEx.test(upn);
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CommandOutput {
|
|
2
|
+
error?: {
|
|
3
|
+
message: string;
|
|
4
|
+
code?: number;
|
|
5
|
+
}
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare function executeCommand(commandName: string, options: any): Promise<CommandOutput>;
|
|
11
|
+
export declare function on(eventName: string, listener: (...args: any[]) => void): void;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCommand = void 0;
|
|
4
|
+
const cli_1 = require("./cli");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function executeCommand(commandName, options, listener) {
|
|
7
|
+
const cli = cli_1.Cli.getInstance();
|
|
8
|
+
cli.commandsFolder = path.join(__dirname, 'm365');
|
|
9
|
+
cli.commands = [];
|
|
10
|
+
cli.loadCommandFromArgs(commandName.split(' '));
|
|
11
|
+
if (cli.commands.length !== 1) {
|
|
12
|
+
return Promise.reject(`Command not found: ${commandName}`);
|
|
13
|
+
}
|
|
14
|
+
return cli_1.Cli.executeCommandWithOutput(cli.commands[0].command, { options: options !== null && options !== void 0 ? options : {} }, listener);
|
|
15
|
+
}
|
|
16
|
+
exports.executeCommand = executeCommand;
|
|
17
|
+
//# sourceMappingURL=api.js.map
|
package/dist/cli/Cli.js
CHANGED
|
@@ -189,23 +189,38 @@ class Cli {
|
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
static executeCommandWithOutput(command, args) {
|
|
192
|
+
static executeCommandWithOutput(command, args, listener) {
|
|
193
193
|
return new Promise((resolve, reject) => {
|
|
194
194
|
const log = [];
|
|
195
195
|
const logErr = [];
|
|
196
196
|
const logger = {
|
|
197
197
|
log: (message) => {
|
|
198
|
-
|
|
198
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
199
|
+
if (listener && listener.stdout) {
|
|
200
|
+
listener.stdout(formattedMessage);
|
|
201
|
+
}
|
|
202
|
+
log.push(formattedMessage);
|
|
199
203
|
},
|
|
200
204
|
logRaw: (message) => {
|
|
201
|
-
|
|
205
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
206
|
+
if (listener && listener.stdout) {
|
|
207
|
+
listener.stdout(formattedMessage);
|
|
208
|
+
}
|
|
209
|
+
log.push(formattedMessage);
|
|
202
210
|
},
|
|
203
211
|
logToStderr: (message) => {
|
|
212
|
+
if (listener && listener.stderr) {
|
|
213
|
+
listener.stderr(message);
|
|
214
|
+
}
|
|
204
215
|
logErr.push(message);
|
|
205
216
|
}
|
|
206
217
|
};
|
|
207
218
|
if (args.options.debug) {
|
|
208
|
-
|
|
219
|
+
const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
|
|
220
|
+
if (listener && listener.stderr) {
|
|
221
|
+
listener.stderr(message);
|
|
222
|
+
}
|
|
223
|
+
logErr.push(message);
|
|
209
224
|
}
|
|
210
225
|
// store the current command name, if any and set the name to the name of
|
|
211
226
|
// the command to execute
|
|
@@ -447,16 +462,14 @@ class Cli {
|
|
|
447
462
|
}
|
|
448
463
|
if (options.output === 'csv') {
|
|
449
464
|
const { stringify } = require('csv-stringify/sync');
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
header: Display the column names on the first line if the columns option is provided or discovered.
|
|
453
|
-
escape: Single character used for escaping; only apply to characters matching the quote and the escape options default to ".
|
|
454
|
-
quote: The quote characters surrounding a field, defaults to the " (double quotation marks), an empty quote value will preserve the original field, whether it contains quotation marks or not.
|
|
455
|
-
quoted: Boolean, default to false, quote all the non-empty fields even if not required.
|
|
456
|
-
quotedEmpty: Quote empty strings and overrides quoted_string on empty strings when defined; default is false.
|
|
457
|
-
*/
|
|
465
|
+
const cli = Cli.getInstance();
|
|
466
|
+
// https://csv.js.org/stringify/options/
|
|
458
467
|
return stringify(logStatement, {
|
|
459
|
-
header: true
|
|
468
|
+
header: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvHeader, true),
|
|
469
|
+
escape: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvEscape, '"'),
|
|
470
|
+
quote: cli.config.get(settingsNames_1.settingsNames.csvQuote),
|
|
471
|
+
quoted: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvQuoted, false),
|
|
472
|
+
quotedEmpty: cli.getSettingWithDefaultValue(settingsNames_1.settingsNames.csvQuotedEmpty, false)
|
|
460
473
|
});
|
|
461
474
|
}
|
|
462
475
|
// display object as a list of key-value pairs
|
|
@@ -105,21 +105,49 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
105
105
|
if (!args.options.manifest) {
|
|
106
106
|
return Promise.resolve(appInfo);
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const v2Manifest = JSON.parse(args.options.manifest);
|
|
109
109
|
// remove properties that might be coming from the original app that was
|
|
110
110
|
// used to create the manifest and which can't be updated
|
|
111
|
-
delete
|
|
112
|
-
delete
|
|
113
|
-
delete
|
|
111
|
+
delete v2Manifest.id;
|
|
112
|
+
delete v2Manifest.appId;
|
|
113
|
+
delete v2Manifest.publisherDomain;
|
|
114
114
|
// Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
|
|
115
|
-
const
|
|
115
|
+
const graphManifest = this.transformManifest(v2Manifest);
|
|
116
116
|
const updateAppRequestOptions = {
|
|
117
117
|
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
118
118
|
headers: {
|
|
119
119
|
'content-type': 'application/json'
|
|
120
120
|
},
|
|
121
121
|
responseType: 'json',
|
|
122
|
-
data:
|
|
122
|
+
data: graphManifest
|
|
123
|
+
};
|
|
124
|
+
return request_1.default
|
|
125
|
+
.patch(updateAppRequestOptions)
|
|
126
|
+
.then(_ => this.updatePreAuthorizedAppsFromManifest(v2Manifest, appInfo))
|
|
127
|
+
.then(_ => Promise.resolve(appInfo));
|
|
128
|
+
}
|
|
129
|
+
updatePreAuthorizedAppsFromManifest(manifest, appInfo) {
|
|
130
|
+
if (!manifest ||
|
|
131
|
+
!manifest.preAuthorizedApplications ||
|
|
132
|
+
manifest.preAuthorizedApplications.length === 0) {
|
|
133
|
+
return Promise.resolve(appInfo);
|
|
134
|
+
}
|
|
135
|
+
const graphManifest = {
|
|
136
|
+
api: {
|
|
137
|
+
preAuthorizedApplications: manifest.preAuthorizedApplications
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
graphManifest.api.preAuthorizedApplications.forEach((p) => {
|
|
141
|
+
p.delegatedPermissionIds = p.permissionIds;
|
|
142
|
+
delete p.permissionIds;
|
|
143
|
+
});
|
|
144
|
+
const updateAppRequestOptions = {
|
|
145
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
146
|
+
headers: {
|
|
147
|
+
'content-type': 'application/json'
|
|
148
|
+
},
|
|
149
|
+
responseType: 'json',
|
|
150
|
+
data: graphManifest
|
|
123
151
|
};
|
|
124
152
|
return request_1.default
|
|
125
153
|
.patch(updateAppRequestOptions)
|
|
@@ -180,8 +208,16 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
180
208
|
delete graphManifest.oauth2AllowIdTokenImplicitFlow;
|
|
181
209
|
graphManifest.api.oauth2PermissionScopes = v2Manifest.oauth2Permissions;
|
|
182
210
|
delete graphManifest.oauth2Permissions;
|
|
211
|
+
if (graphManifest.api.oauth2PermissionScopes) {
|
|
212
|
+
graphManifest.api.oauth2PermissionScopes.forEach((scope) => {
|
|
213
|
+
delete scope.lang;
|
|
214
|
+
delete scope.origin;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
183
217
|
delete graphManifest.oauth2RequiredPostResponse;
|
|
184
|
-
|
|
218
|
+
// MS Graph doesn't support creating OAuth2 permissions and pre-authorized
|
|
219
|
+
// apps in one request. This is why we need to remove it here and do it in
|
|
220
|
+
// the next request
|
|
185
221
|
delete graphManifest.preAuthorizedApplications;
|
|
186
222
|
if (v2Manifest.replyUrlsWithType) {
|
|
187
223
|
v2Manifest.replyUrlsWithType.forEach((urlWithType) => {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const Utils_1 = require("../../../../Utils");
|
|
6
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
7
|
+
const commands_1 = require("../../commands");
|
|
8
|
+
class AadAppDeleteCommand extends GraphCommand_1.default {
|
|
9
|
+
get name() {
|
|
10
|
+
return commands_1.default.APP_DELETE;
|
|
11
|
+
}
|
|
12
|
+
get description() {
|
|
13
|
+
return 'Removes an Azure AD app registration';
|
|
14
|
+
}
|
|
15
|
+
getTelemetryProperties(args) {
|
|
16
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
|
+
telemetryProps.appId = typeof args.options.appId !== 'undefined';
|
|
18
|
+
telemetryProps.objectId = typeof args.options.objectId !== 'undefined';
|
|
19
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
|
+
return telemetryProps;
|
|
21
|
+
}
|
|
22
|
+
commandAction(logger, args, cb) {
|
|
23
|
+
const deleteApp = () => {
|
|
24
|
+
this
|
|
25
|
+
.processAppDelete(logger, args)
|
|
26
|
+
.then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
27
|
+
};
|
|
28
|
+
if (args.options.confirm) {
|
|
29
|
+
deleteApp();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
cli_1.Cli.prompt({
|
|
33
|
+
type: 'confirm',
|
|
34
|
+
name: 'continue',
|
|
35
|
+
default: false,
|
|
36
|
+
message: `Are you sure you want to delete the App?`
|
|
37
|
+
}, (result) => {
|
|
38
|
+
if (!result.continue) {
|
|
39
|
+
cb();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
deleteApp();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
processAppDelete(logger, args) {
|
|
48
|
+
return this
|
|
49
|
+
.getAadApp(args, logger)
|
|
50
|
+
.then((aadAppId) => {
|
|
51
|
+
if (this.verbose) {
|
|
52
|
+
logger.logToStderr(`Deleting Azure AD app ${aadAppId}...`);
|
|
53
|
+
}
|
|
54
|
+
const requestOptions = {
|
|
55
|
+
url: `${this.resource}/v1.0/myorganization/applications/${aadAppId}`,
|
|
56
|
+
headers: {
|
|
57
|
+
accept: 'application/json;odata.metadata=none'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json'
|
|
60
|
+
};
|
|
61
|
+
return request_1.default.delete(requestOptions);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getAadApp(args, logger) {
|
|
65
|
+
if (args.options.objectId) {
|
|
66
|
+
return Promise.resolve(args.options.objectId);
|
|
67
|
+
}
|
|
68
|
+
const { appId, name } = args.options;
|
|
69
|
+
if (this.verbose) {
|
|
70
|
+
logger.logToStderr(`Retrieving information about Azure AD app ${appId ? appId : name}...`);
|
|
71
|
+
}
|
|
72
|
+
const filter = appId ?
|
|
73
|
+
`appId eq '${encodeURIComponent(appId)}'` :
|
|
74
|
+
`displayName eq '${encodeURIComponent(name)}'`;
|
|
75
|
+
const requestOptions = {
|
|
76
|
+
url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
|
|
77
|
+
headers: {
|
|
78
|
+
accept: 'application/json;odata.metadata=none'
|
|
79
|
+
},
|
|
80
|
+
responseType: 'json'
|
|
81
|
+
};
|
|
82
|
+
return request_1.default
|
|
83
|
+
.get(requestOptions)
|
|
84
|
+
.then((res) => {
|
|
85
|
+
if (res.value.length === 1) {
|
|
86
|
+
return Promise.resolve(res.value[0].id);
|
|
87
|
+
}
|
|
88
|
+
if (res.value.length === 0) {
|
|
89
|
+
const applicationIdentifier = appId ? `ID ${appId}` : `name ${name}`;
|
|
90
|
+
return Promise.reject(`No Azure AD application registration with ${applicationIdentifier} found`);
|
|
91
|
+
}
|
|
92
|
+
return Promise.reject(`Multiple Azure AD application registration with name ${name} found. Please choose from one of the app object IDs: ${res.value.map(a => a.id).join(', ')}`);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
options() {
|
|
96
|
+
const options = [
|
|
97
|
+
{ option: '--appId [appId]' },
|
|
98
|
+
{ option: '--objectId [objectId]' },
|
|
99
|
+
{ option: '--name [name]' },
|
|
100
|
+
{ option: '--confirm' }
|
|
101
|
+
];
|
|
102
|
+
const parentOptions = super.options();
|
|
103
|
+
return options.concat(parentOptions);
|
|
104
|
+
}
|
|
105
|
+
validate(args) {
|
|
106
|
+
if (!args.options.appId &&
|
|
107
|
+
!args.options.objectId &&
|
|
108
|
+
!args.options.name) {
|
|
109
|
+
return 'Specify either appId, objectId, or name';
|
|
110
|
+
}
|
|
111
|
+
if ((args.options.appId && args.options.objectId) ||
|
|
112
|
+
(args.options.appId && args.options.name) ||
|
|
113
|
+
(args.options.objectId && args.options.name)) {
|
|
114
|
+
return 'Specify either appId, objectId, or name';
|
|
115
|
+
}
|
|
116
|
+
if (args.options.appId && !Utils_1.default.isValidGuid(args.options.appId)) {
|
|
117
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
118
|
+
}
|
|
119
|
+
if (args.options.objectId && !Utils_1.default.isValidGuid(args.options.objectId)) {
|
|
120
|
+
return `${args.options.objectId} is not a valid GUID`;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
module.exports = new AadAppDeleteCommand();
|
|
126
|
+
//# sourceMappingURL=app-delete.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
4
|
+
const commands_1 = require("../../commands");
|
|
5
|
+
class AadGroupListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
6
|
+
get name() {
|
|
7
|
+
return commands_1.default.GROUP_LIST;
|
|
8
|
+
}
|
|
9
|
+
get description() {
|
|
10
|
+
return 'Lists all groups defined in Azure Active Directory.';
|
|
11
|
+
}
|
|
12
|
+
defaultProperties() {
|
|
13
|
+
return ['id', 'displayName', 'groupType'];
|
|
14
|
+
}
|
|
15
|
+
commandAction(logger, args, cb) {
|
|
16
|
+
const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.group' : 'groups';
|
|
17
|
+
this
|
|
18
|
+
.getAllItems(`${this.resource}/v1.0/${endpoint}`, logger, true)
|
|
19
|
+
.then(() => {
|
|
20
|
+
if (args.options.output === 'text') {
|
|
21
|
+
this.items.forEach((group) => {
|
|
22
|
+
if (group.groupTypes && group.groupTypes.length > 0 && group.groupTypes[0] === 'Unified') {
|
|
23
|
+
group.groupType = 'Microsoft 365';
|
|
24
|
+
}
|
|
25
|
+
else if (group.mailEnabled && group.securityEnabled) {
|
|
26
|
+
group.groupType = 'Mail enabled security';
|
|
27
|
+
}
|
|
28
|
+
else if (group.securityEnabled) {
|
|
29
|
+
group.groupType = 'Security';
|
|
30
|
+
}
|
|
31
|
+
else if (group.mailEnabled) {
|
|
32
|
+
group.groupType = 'Distribution';
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
logger.log(this.items);
|
|
37
|
+
cb();
|
|
38
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
39
|
+
}
|
|
40
|
+
options() {
|
|
41
|
+
const options = [
|
|
42
|
+
{ option: '-d, --deleted' }
|
|
43
|
+
];
|
|
44
|
+
const parentOptions = super.options();
|
|
45
|
+
return options.concat(parentOptions);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
module.exports = new AadGroupListCommand();
|
|
49
|
+
//# sourceMappingURL=group-list.js.map
|
|
@@ -37,14 +37,14 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
|
|
|
37
37
|
logger.logToStderr(this.items);
|
|
38
38
|
logger.logToStderr('');
|
|
39
39
|
}
|
|
40
|
-
if (this.items.filter(i =>
|
|
40
|
+
if (this.items.filter(i => args.options.userName.toUpperCase() === i.userPrincipalName.toUpperCase()).length <= 0) {
|
|
41
41
|
const userNotInGroup = (typeof args.options.groupId !== 'undefined') ?
|
|
42
42
|
'The specified user does not belong to the given Microsoft 365 Group. Please use the \'o365group user add\' command to add new users.' :
|
|
43
43
|
'The specified user does not belong to the given Microsoft Teams team. Please use the \'graph teams user add\' command to add new users.';
|
|
44
44
|
throw new Error(userNotInGroup);
|
|
45
45
|
}
|
|
46
46
|
if (args.options.role === "Owner") {
|
|
47
|
-
const foundMember = this.items.find(e =>
|
|
47
|
+
const foundMember = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Member');
|
|
48
48
|
if (foundMember !== undefined) {
|
|
49
49
|
const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/$ref`;
|
|
50
50
|
const requestOptions = {
|
|
@@ -65,7 +65,7 @@ class AadO365GroupUserSetCommand extends GraphItemsListCommand_1.GraphItemsListC
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
68
|
-
const foundOwner = this.items.find(e =>
|
|
68
|
+
const foundOwner = this.items.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Owner');
|
|
69
69
|
if (foundOwner !== undefined) {
|
|
70
70
|
const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/${foundOwner.id}/$ref`;
|
|
71
71
|
const requestOptions = {
|
|
@@ -20,10 +20,20 @@ class AadUserGetCommand extends GraphCommand_1.default {
|
|
|
20
20
|
}
|
|
21
21
|
commandAction(logger, args, cb) {
|
|
22
22
|
const properties = args.options.properties ?
|
|
23
|
-
|
|
23
|
+
`&$select=${args.options.properties.split(',').map(p => encodeURIComponent(p.trim())).join(',')}` :
|
|
24
24
|
'';
|
|
25
|
+
let requestUrl = `${this.resource}/v1.0/users`;
|
|
26
|
+
if (args.options.id) {
|
|
27
|
+
requestUrl += `?$filter=id eq '${encodeURIComponent(args.options.id)}'${properties}`;
|
|
28
|
+
}
|
|
29
|
+
else if (args.options.userName) {
|
|
30
|
+
requestUrl += `?$filter=userPrincipalName eq '${encodeURIComponent(args.options.userName)}'${properties}`;
|
|
31
|
+
}
|
|
32
|
+
else if (args.options.email) {
|
|
33
|
+
requestUrl += `?$filter=mail eq '${encodeURIComponent(args.options.email)}'${properties}`;
|
|
34
|
+
}
|
|
25
35
|
const requestOptions = {
|
|
26
|
-
url:
|
|
36
|
+
url: requestUrl,
|
|
27
37
|
headers: {
|
|
28
38
|
accept: 'application/json;odata.metadata=none'
|
|
29
39
|
},
|
|
@@ -31,6 +41,18 @@ class AadUserGetCommand extends GraphCommand_1.default {
|
|
|
31
41
|
};
|
|
32
42
|
request_1.default
|
|
33
43
|
.get(requestOptions)
|
|
44
|
+
.then((res) => {
|
|
45
|
+
if (res.value.length === 1) {
|
|
46
|
+
return Promise.resolve(res.value[0]);
|
|
47
|
+
}
|
|
48
|
+
const identifier = args.options.id ? `id ${args.options.id}`
|
|
49
|
+
: args.options.userName ? `user name ${args.options.userName}`
|
|
50
|
+
: `email ${args.options.email}`;
|
|
51
|
+
if (res.value.length === 0) {
|
|
52
|
+
return Promise.reject(`The specified user with ${identifier} does not exist`);
|
|
53
|
+
}
|
|
54
|
+
return Promise.reject(`Multiple users with ${identifier} found. Please disambiguate (user names): ${res.value.map(a => a.userPrincipalName).join(', ')} or (ids): ${res.value.map(a => a.id).join(', ')}`);
|
|
55
|
+
})
|
|
34
56
|
.then((res) => {
|
|
35
57
|
logger.log(res);
|
|
36
58
|
cb();
|
|
@@ -44,6 +66,9 @@ class AadUserGetCommand extends GraphCommand_1.default {
|
|
|
44
66
|
{
|
|
45
67
|
option: '-n, --userName [userName]'
|
|
46
68
|
},
|
|
69
|
+
{
|
|
70
|
+
option: '--email [email]'
|
|
71
|
+
},
|
|
47
72
|
{
|
|
48
73
|
option: '-p, --properties [properties]'
|
|
49
74
|
}
|
|
@@ -52,11 +77,13 @@ class AadUserGetCommand extends GraphCommand_1.default {
|
|
|
52
77
|
return options.concat(parentOptions);
|
|
53
78
|
}
|
|
54
79
|
validate(args) {
|
|
55
|
-
if (!args.options.id && !args.options.userName) {
|
|
56
|
-
return 'Specify
|
|
80
|
+
if (!args.options.id && !args.options.userName && !args.options.email) {
|
|
81
|
+
return 'Specify id, userName or email, one is required';
|
|
57
82
|
}
|
|
58
|
-
if (args.options.id && args.options.
|
|
59
|
-
|
|
83
|
+
if ((args.options.id && args.options.email) ||
|
|
84
|
+
(args.options.id && args.options.userName) ||
|
|
85
|
+
(args.options.userName && args.options.email)) {
|
|
86
|
+
return 'Use either id, userName or email, but not all';
|
|
60
87
|
}
|
|
61
88
|
if (args.options.id &&
|
|
62
89
|
!Utils_1.default.isValidGuid(args.options.id)) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const Utils_1 = require("../../../../Utils");
|
|
5
|
+
const AnonymousCommand_1 = require("../../../base/AnonymousCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class AadUserHibpCommand extends AnonymousCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.USER_HIBP;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Allows you to retrieve all accounts that have been pwned with the specified username';
|
|
13
|
+
}
|
|
14
|
+
getTelemetryProperties(args) {
|
|
15
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
|
+
telemetryProps.domain = args.options.domain;
|
|
17
|
+
return telemetryProps;
|
|
18
|
+
}
|
|
19
|
+
commandAction(logger, args, cb) {
|
|
20
|
+
const requestOptions = {
|
|
21
|
+
url: `https://haveibeenpwned.com/api/v3/breachedaccount/${encodeURIComponent(args.options.userName)}${(args.options.domain ? `?domain=${encodeURIComponent(args.options.domain)}` : '')}`,
|
|
22
|
+
headers: {
|
|
23
|
+
'accept': 'application/json',
|
|
24
|
+
'hibp-api-key': args.options.apiKey,
|
|
25
|
+
'x-anonymous': true
|
|
26
|
+
},
|
|
27
|
+
responseType: 'json'
|
|
28
|
+
};
|
|
29
|
+
request_1.default
|
|
30
|
+
.get(requestOptions)
|
|
31
|
+
.then((res) => {
|
|
32
|
+
logger.log(res);
|
|
33
|
+
cb();
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
if ((err && err.response !== undefined && err.response.status === 404) && (this.debug || this.verbose)) {
|
|
37
|
+
logger.log('No pwnage found');
|
|
38
|
+
cb();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
return this.handleRejectedODataJsonPromise(err, logger, cb);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
options() {
|
|
45
|
+
const options = [
|
|
46
|
+
{
|
|
47
|
+
option: '-n, --userName <userName>'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
option: '--apiKey, <apiKey>'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
option: '--domain, [domain]'
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const parentOptions = super.options();
|
|
57
|
+
return options.concat(parentOptions);
|
|
58
|
+
}
|
|
59
|
+
validate(args) {
|
|
60
|
+
if (!Utils_1.default.isValidUserPrincipalName(args.options.userName)) {
|
|
61
|
+
return 'Specify valid userName';
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
module.exports = new AadUserHibpCommand();
|
|
67
|
+
//# sourceMappingURL=user-hibp.js.map
|
|
@@ -15,6 +15,7 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
15
15
|
getTelemetryProperties(args) {
|
|
16
16
|
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
17
|
telemetryProps.properties = args.options.properties;
|
|
18
|
+
telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
|
|
18
19
|
return telemetryProps;
|
|
19
20
|
}
|
|
20
21
|
commandAction(logger, args, cb) {
|
|
@@ -22,7 +23,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
22
23
|
args.options.properties.split(',').map(p => p.trim()) :
|
|
23
24
|
['userPrincipalName', 'displayName'];
|
|
24
25
|
const filter = this.getFilter(args.options);
|
|
25
|
-
const
|
|
26
|
+
const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.user' : 'users';
|
|
27
|
+
const url = `${this.resource}/v1.0/${endpoint}?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
|
|
26
28
|
this
|
|
27
29
|
.getAllItems(url, logger, true)
|
|
28
30
|
.then(() => {
|
|
@@ -35,6 +37,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
35
37
|
const excludeOptions = [
|
|
36
38
|
'properties',
|
|
37
39
|
'p',
|
|
40
|
+
'deleted',
|
|
41
|
+
'd',
|
|
38
42
|
'debug',
|
|
39
43
|
'verbose',
|
|
40
44
|
'output',
|
|
@@ -55,9 +59,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
55
59
|
}
|
|
56
60
|
options() {
|
|
57
61
|
const options = [
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
}
|
|
62
|
+
{ option: '-p, --properties [properties]' },
|
|
63
|
+
{ option: '-d, --deleted' }
|
|
61
64
|
];
|
|
62
65
|
const parentOptions = super.options();
|
|
63
66
|
return options.concat(parentOptions);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const prefix = 'aad';
|
|
4
4
|
exports.default = {
|
|
5
5
|
APP_ADD: `${prefix} app add`,
|
|
6
|
+
APP_DELETE: `${prefix} app delete`,
|
|
6
7
|
APP_GET: `${prefix} app get`,
|
|
7
8
|
APP_SET: `${prefix} app set`,
|
|
8
9
|
APP_ROLE_ADD: `${prefix} app role add`,
|
|
@@ -11,6 +12,7 @@ exports.default = {
|
|
|
11
12
|
APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
|
|
12
13
|
APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
|
|
13
14
|
APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
|
|
15
|
+
GROUP_LIST: `${prefix} group list`,
|
|
14
16
|
GROUPSETTING_ADD: `${prefix} groupsetting add`,
|
|
15
17
|
GROUPSETTING_GET: `${prefix} groupsetting get`,
|
|
16
18
|
GROUPSETTING_LIST: `${prefix} groupsetting list`,
|
|
@@ -50,6 +52,7 @@ exports.default = {
|
|
|
50
52
|
SP_ADD: `${prefix} sp add`,
|
|
51
53
|
SP_GET: `${prefix} sp get`,
|
|
52
54
|
USER_GET: `${prefix} user get`,
|
|
55
|
+
USER_HIBP: `${prefix} user hibp`,
|
|
53
56
|
USER_LIST: `${prefix} user list`,
|
|
54
57
|
USER_PASSWORD_VALIDATE: `${prefix} user password validate`,
|
|
55
58
|
USER_SET: `${prefix} user set`
|
|
@@ -21,6 +21,9 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
|
|
|
21
21
|
switch (args.options.key) {
|
|
22
22
|
case settingsNames_1.settingsNames.showHelpOnFailure:
|
|
23
23
|
case settingsNames_1.settingsNames.printErrorsAsPlainText:
|
|
24
|
+
case settingsNames_1.settingsNames.csvHeader:
|
|
25
|
+
case settingsNames_1.settingsNames.csvQuoted:
|
|
26
|
+
case settingsNames_1.settingsNames.csvQuotedEmpty:
|
|
24
27
|
value = args.options.value === 'true';
|
|
25
28
|
break;
|
|
26
29
|
default:
|
|
@@ -47,7 +50,7 @@ class CliConfigSetCommand extends AnonymousCommand_1.default {
|
|
|
47
50
|
if (CliConfigSetCommand.optionNames.indexOf(args.options.key) < 0) {
|
|
48
51
|
return `${args.options.key} is not a valid setting. Allowed values: ${CliConfigSetCommand.optionNames.join(', ')}`;
|
|
49
52
|
}
|
|
50
|
-
const allowedOutputs = ['text', 'json'];
|
|
53
|
+
const allowedOutputs = ['text', 'json', 'csv'];
|
|
51
54
|
if (args.options.key === settingsNames_1.settingsNames.output &&
|
|
52
55
|
allowedOutputs.indexOf(args.options.value) === -1) {
|
|
53
56
|
return `${args.options.value} is not a valid value for the option ${args.options.key}. Allowed values: ${allowedOutputs.join(', ')}`;
|