@pnp/cli-microsoft365 7.5.0-beta.d4d820f → 7.6.0-beta.682272b

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 (178) hide show
  1. package/.devcontainer/Dockerfile +2 -2
  2. package/.eslintrc.cjs +6 -2
  3. package/.mocharc.json +3 -5
  4. package/Dockerfile +2 -5
  5. package/README.md +2 -2
  6. package/allCommands.json +1 -1
  7. package/allCommandsFull.json +1 -1
  8. package/dist/Auth.js +171 -69
  9. package/dist/AuthServer.js +3 -3
  10. package/dist/Command.js +8 -5
  11. package/dist/auth/FileTokenStorage.js +4 -1
  12. package/dist/m365/base/AppCommand.js +2 -2
  13. package/dist/m365/base/PowerAppsCommand.js +2 -2
  14. package/dist/m365/base/PowerAutomateCommand.js +2 -2
  15. package/dist/m365/base/PowerPlatformCommand.js +2 -2
  16. package/dist/m365/base/SpoCommand.js +3 -3
  17. package/dist/m365/base/{YammerCommand.js → VivaEngageCommand.js} +2 -2
  18. package/dist/m365/cli/commands/cli-consent.js +5 -3
  19. package/dist/m365/cli/commands/cli-doctor.js +5 -5
  20. package/dist/m365/commands/ConnectionDetails.js +2 -0
  21. package/dist/m365/commands/login.js +26 -48
  22. package/dist/m365/commands/logout.js +2 -2
  23. package/dist/m365/commands/request.js +2 -2
  24. package/dist/m365/commands/status.js +15 -23
  25. package/dist/m365/connection/commands/connection-list.js +47 -0
  26. package/dist/m365/connection/commands/connection-remove.js +67 -0
  27. package/dist/m365/connection/commands/connection-set.js +56 -0
  28. package/dist/m365/connection/commands/connection-use.js +51 -0
  29. package/dist/m365/connection/commands.js +8 -0
  30. package/dist/m365/entra/aadCommands.js +3 -0
  31. package/dist/m365/entra/commands/administrativeunit/administrativeunit-member-remove.js +153 -0
  32. package/dist/m365/entra/commands/app/app-add.js +2 -2
  33. package/dist/m365/entra/commands/app/app-get.js +1 -1
  34. package/dist/m365/entra/commands/app/app-list.js +1 -1
  35. package/dist/m365/entra/commands/app/app-permission-add.js +1 -1
  36. package/dist/m365/entra/commands/app/app-permission-list.js +182 -0
  37. package/dist/m365/entra/commands/app/app-remove.js +1 -1
  38. package/dist/m365/entra/commands/app/app-role-add.js +1 -1
  39. package/dist/m365/entra/commands/app/app-role-list.js +1 -1
  40. package/dist/m365/entra/commands/app/app-role-remove.js +1 -1
  41. package/dist/m365/entra/commands/app/app-set.js +1 -1
  42. package/dist/m365/entra/commands/{sp/sp-add.js → enterpriseapp/enterpriseapp-add.js} +18 -18
  43. package/dist/m365/entra/commands/{sp/sp-get.js → enterpriseapp/enterpriseapp-get.js} +19 -19
  44. package/dist/m365/entra/commands/{sp/sp-list.js → enterpriseapp/enterpriseapp-list.js} +13 -13
  45. package/dist/m365/entra/commands/group/group-add.js +224 -0
  46. package/dist/m365/entra/commands/group/group-user-add.js +145 -0
  47. package/dist/m365/entra/commands/m365group/m365group-report-activitygroupcounts.js +1 -1
  48. package/dist/m365/entra/commands/user/user-get.js +38 -38
  49. package/dist/m365/entra/commands/user/user-license-list.js +1 -1
  50. package/dist/m365/entra/commands/user/user-registrationdetails-list.js +224 -0
  51. package/dist/m365/entra/commands/user/user-set.js +2 -2
  52. package/dist/m365/entra/commands.js +17 -0
  53. package/dist/m365/external/commands/connection/connection-doctor.js +2 -1
  54. package/dist/m365/file/commands/convert/convert-pdf.js +1 -1
  55. package/dist/m365/file/commands/file-copy.js +151 -0
  56. package/dist/m365/file/commands.js +1 -0
  57. package/dist/m365/outlook/commands/mail/mail-send.js +1 -1
  58. package/dist/m365/outlook/commands/message/message-get.js +1 -1
  59. package/dist/m365/pa/commands/app/app-permission-ensure.js +1 -1
  60. package/dist/m365/pa/commands/app/app-permission-remove.js +1 -1
  61. package/dist/m365/planner/commands/roster/roster-plan-list.js +1 -1
  62. package/dist/m365/purview/commands/auditlog/auditlog-list.js +1 -1
  63. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-get.js +1 -1
  64. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-list.js +1 -1
  65. package/dist/m365/purview/commands/sensitivitylabel/sensitivitylabel-policysettings-list.js +1 -1
  66. package/dist/m365/spfx/commands/project/DeployWorkflow.js +4 -3
  67. package/dist/m365/spo/commands/spo-get.js +1 -1
  68. package/dist/m365/spo/commands/spo-search.js +52 -22
  69. package/dist/m365/spo/commands/spo-set.js +1 -1
  70. package/dist/m365/teams/commands/chat/chat-get.js +1 -1
  71. package/dist/m365/teams/commands/chat/chat-list.js +1 -1
  72. package/dist/m365/teams/commands/chat/chat-message-send.js +1 -1
  73. package/dist/m365/teams/commands/meeting/meeting-add.js +1 -1
  74. package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +1 -1
  75. package/dist/m365/teams/commands/meeting/meeting-get.js +1 -1
  76. package/dist/m365/teams/commands/meeting/meeting-list.js +2 -2
  77. package/dist/m365/teams/commands/meeting/meeting-transcript-list.js +1 -1
  78. package/dist/m365/tenant/commands/id/id-get.js +1 -1
  79. package/dist/m365/tenant/commands/info/info-get.js +1 -1
  80. package/dist/m365/util/commands/accesstoken/accesstoken-get.js +3 -3
  81. package/dist/m365/{yammer/commands/group/group-list.js → viva/commands/engage/engage-group-list.js} +19 -14
  82. package/dist/m365/{yammer/commands/group/group-user-add.js → viva/commands/engage/engage-group-user-add.js} +19 -14
  83. package/dist/m365/{yammer/commands/group/group-user-remove.js → viva/commands/engage/engage-group-user-remove.js} +19 -14
  84. package/dist/m365/{yammer/commands/message/message-add.js → viva/commands/engage/engage-message-add.js} +19 -14
  85. package/dist/m365/{yammer/commands/message/message-get.js → viva/commands/engage/engage-message-get.js} +17 -12
  86. package/dist/m365/{yammer/commands/message/message-like-set.js → viva/commands/engage/engage-message-like-set.js} +21 -16
  87. package/dist/m365/{yammer/commands/message/message-list.js → viva/commands/engage/engage-message-list.js} +21 -16
  88. package/dist/m365/{yammer/commands/message/message-remove.js → viva/commands/engage/engage-message-remove.js} +20 -15
  89. package/dist/m365/{yammer/commands/network/network-list.js → viva/commands/engage/engage-network-list.js} +16 -11
  90. package/dist/m365/viva/commands/engage/engage-report-activitycounts.js +23 -0
  91. package/dist/m365/viva/commands/engage/engage-report-activityusercounts.js +23 -0
  92. package/dist/m365/viva/commands/engage/engage-report-activityuserdetail.js +23 -0
  93. package/dist/m365/viva/commands/engage/engage-report-deviceusagedistributionusercounts.js +23 -0
  94. package/dist/m365/viva/commands/engage/engage-report-deviceusageusercounts.js +23 -0
  95. package/dist/m365/viva/commands/engage/engage-report-deviceusageuserdetail.js +23 -0
  96. package/dist/m365/viva/commands/engage/engage-report-groupsactivitycounts.js +23 -0
  97. package/dist/m365/viva/commands/engage/engage-report-groupsactivitydetail.js +23 -0
  98. package/dist/m365/viva/commands/engage/engage-report-groupsactivitygroupcounts.js +23 -0
  99. package/dist/m365/{yammer/commands/yammer-search.js → viva/commands/engage/engage-search.js} +23 -18
  100. package/dist/m365/{yammer/commands/user/user-get.js → viva/commands/engage/engage-user-get.js} +18 -13
  101. package/dist/m365/{yammer/commands/user/user-list.js → viva/commands/engage/engage-user-list.js} +18 -13
  102. package/dist/m365/{yammer/commands.js → viva/commands/engage/yammerCommands.js} +1 -1
  103. package/dist/m365/viva/commands.js +22 -1
  104. package/dist/request.js +1 -1
  105. package/dist/utils/entraUser.js +36 -0
  106. package/dist/utils/spo.js +36 -14
  107. package/dist/utils/urlUtil.js +31 -0
  108. package/dist/utils/validation.js +8 -0
  109. package/docs/docs/cmd/cli/cli-consent.mdx +9 -9
  110. package/docs/docs/cmd/connection/connection-list.mdx +100 -0
  111. package/docs/docs/cmd/connection/connection-remove.mdx +45 -0
  112. package/docs/docs/cmd/connection/connection-set.mdx +39 -0
  113. package/docs/docs/cmd/connection/connection-use.mdx +98 -0
  114. package/docs/docs/cmd/entra/administrativeunit/administrativeunit-member-add.mdx +5 -3
  115. package/docs/docs/cmd/entra/administrativeunit/administrativeunit-member-remove.mdx +107 -0
  116. package/docs/docs/cmd/entra/app/app-add.mdx +2 -1
  117. package/docs/docs/cmd/entra/app/app-get.mdx +1 -0
  118. package/docs/docs/cmd/entra/app/app-list.mdx +1 -0
  119. package/docs/docs/cmd/entra/app/app-permission-add.mdx +1 -0
  120. package/docs/docs/cmd/entra/app/app-permission-list.mdx +105 -0
  121. package/docs/docs/cmd/entra/app/app-remove.mdx +1 -0
  122. package/docs/docs/cmd/entra/app/app-role-add.mdx +1 -0
  123. package/docs/docs/cmd/entra/app/app-role-list.mdx +1 -0
  124. package/docs/docs/cmd/entra/app/app-role-remove.mdx +1 -0
  125. package/docs/docs/cmd/entra/app/app-set.mdx +1 -0
  126. package/docs/docs/cmd/entra/{sp/sp-add.mdx → enterpriseapp/enterpriseapp-add.mdx} +16 -15
  127. package/docs/docs/cmd/entra/{sp/sp-get.mdx → enterpriseapp/enterpriseapp-get.mdx} +15 -14
  128. package/docs/docs/cmd/entra/{sp/sp-list.mdx → enterpriseapp/enterpriseapp-list.mdx} +22 -21
  129. package/docs/docs/cmd/entra/group/group-add.mdx +231 -0
  130. package/docs/docs/cmd/entra/group/group-user-add.mdx +62 -0
  131. package/docs/docs/cmd/entra/m365group/m365group-report-activitygroupcounts.mdx +1 -1
  132. package/docs/docs/cmd/entra/oauth2grant/oauth2grant-add.mdx +3 -3
  133. package/docs/docs/cmd/entra/oauth2grant/oauth2grant-list.mdx +1 -1
  134. package/docs/docs/cmd/entra/user/user-registrationdetails-list.mdx +246 -0
  135. package/docs/docs/cmd/external/item/item-add.mdx +1 -1
  136. package/docs/docs/cmd/file/convert/convert-pdf.mdx +4 -0
  137. package/docs/docs/cmd/file/file-add.mdx +4 -0
  138. package/docs/docs/cmd/file/file-copy.mdx +68 -0
  139. package/docs/docs/cmd/file/file-list.mdx +100 -0
  140. package/docs/docs/cmd/login.mdx +15 -0
  141. package/docs/docs/cmd/setup.mdx +4 -0
  142. package/docs/docs/cmd/spo/list/list-webhook-set.mdx +1 -1
  143. package/docs/docs/cmd/spo/spo-search.mdx +6 -2
  144. package/docs/docs/cmd/spo/theme/theme-set.mdx +14 -2
  145. package/docs/docs/cmd/{yammer/group/group-list.mdx → viva/engage/engage-group-list.mdx} +13 -13
  146. package/docs/docs/cmd/{yammer/group/group-user-add.mdx → viva/engage/engage-group-user-add.mdx} +7 -7
  147. package/docs/docs/cmd/{yammer/group/group-user-remove.mdx → viva/engage/engage-group-user-remove.mdx} +10 -10
  148. package/docs/docs/cmd/{yammer/message/message-add.mdx → viva/engage/engage-message-add.mdx} +12 -13
  149. package/docs/docs/cmd/{yammer/message/message-get.mdx → viva/engage/engage-message-get.mdx} +10 -10
  150. package/docs/docs/cmd/{yammer/message/message-like-set.mdx → viva/engage/engage-message-like-set.mdx} +10 -10
  151. package/docs/docs/cmd/{yammer/message/message-list.mdx → viva/engage/engage-message-list.mdx} +21 -21
  152. package/docs/docs/cmd/{yammer/message/message-remove.mdx → viva/engage/engage-message-remove.mdx} +10 -10
  153. package/docs/docs/cmd/{yammer/network/network-list.mdx → viva/engage/engage-network-list.mdx} +6 -6
  154. package/docs/docs/cmd/{yammer/report/report-activitycounts.mdx → viva/engage/engage-report-activitycounts.mdx} +9 -9
  155. package/docs/docs/cmd/{yammer/report/report-activityusercounts.mdx → viva/engage/engage-report-activityusercounts.mdx} +9 -9
  156. package/docs/docs/cmd/{yammer/report/report-activityuserdetail.mdx → viva/engage/engage-report-activityuserdetail.mdx} +11 -12
  157. package/docs/docs/cmd/{yammer/report/report-deviceusagedistributionusercounts.mdx → viva/engage/engage-report-deviceusagedistributionusercounts.mdx} +5 -5
  158. package/docs/docs/cmd/{yammer/report/report-deviceusageusercounts.mdx → viva/engage/engage-report-deviceusageusercounts.mdx} +5 -5
  159. package/docs/docs/cmd/{yammer/report/report-deviceusageuserdetail.mdx → viva/engage/engage-report-deviceusageuserdetail.mdx} +11 -11
  160. package/docs/docs/cmd/{yammer/report/report-groupsactivitycounts.mdx → viva/engage/engage-report-groupsactivitycounts.mdx} +9 -9
  161. package/docs/docs/cmd/{yammer/report/report-groupsactivitydetail.mdx → viva/engage/engage-report-groupsactivitydetail.mdx} +11 -11
  162. package/docs/docs/cmd/{yammer/report/report-groupsactivitygroupcounts.mdx → viva/engage/engage-report-groupsactivitygroupcounts.mdx} +5 -5
  163. package/docs/docs/cmd/{yammer/yammer-search.mdx → viva/engage/engage-search.mdx} +10 -10
  164. package/docs/docs/cmd/{yammer/user/user-get.mdx → viva/engage/engage-user-get.mdx} +8 -8
  165. package/docs/docs/cmd/{yammer/user/user-list.mdx → viva/engage/engage-user-list.mdx} +11 -11
  166. package/npm-shrinkwrap.json +230 -168
  167. package/package.json +20 -19
  168. package/dist/m365/base/AzmgmtCommand.js +0 -18
  169. package/dist/m365/base/AzmgmtItemsListCommand.js +0 -41
  170. package/dist/m365/yammer/commands/report/report-activitycounts.js +0 -15
  171. package/dist/m365/yammer/commands/report/report-activityusercounts.js +0 -15
  172. package/dist/m365/yammer/commands/report/report-activityuserdetail.js +0 -15
  173. package/dist/m365/yammer/commands/report/report-deviceusagedistributionusercounts.js +0 -15
  174. package/dist/m365/yammer/commands/report/report-deviceusageusercounts.js +0 -15
  175. package/dist/m365/yammer/commands/report/report-deviceusageuserdetail.js +0 -15
  176. package/dist/m365/yammer/commands/report/report-groupsactivitycounts.js +0 -15
  177. package/dist/m365/yammer/commands/report/report-groupsactivitydetail.js +0 -15
  178. package/dist/m365/yammer/commands/report/report-groupsactivitygroupcounts.js +0 -15
@@ -15,8 +15,8 @@ class CliDoctorCommand extends Command {
15
15
  async commandAction(logger) {
16
16
  const roles = [];
17
17
  const scopes = new Map();
18
- Object.keys(auth.service.accessTokens).forEach(resource => {
19
- const accessToken = auth.service.accessTokens[resource].accessToken;
18
+ Object.keys(auth.connection.accessTokens).forEach(resource => {
19
+ const accessToken = auth.connection.accessTokens[resource].accessToken;
20
20
  this.getRolesFromAccessToken(accessToken).forEach(role => roles.push(role));
21
21
  const [res, scp] = this.getScopesFromAccessToken(accessToken);
22
22
  if (res !== "") {
@@ -31,9 +31,9 @@ class CliDoctorCommand extends Command {
31
31
  },
32
32
  cliVersion: app.packageJson().version,
33
33
  nodeVersion: process.version,
34
- cliAadAppId: auth.service.appId,
35
- cliAadAppTenant: validation.isValidGuid(auth.service.tenant) ? 'single' : auth.service.tenant,
36
- authMode: AuthType[auth.service.authType],
34
+ cliAadAppId: auth.connection.appId,
35
+ cliAadAppTenant: validation.isValidGuid(auth.connection.tenant) ? 'single' : auth.connection.tenant,
36
+ authMode: AuthType[auth.connection.authType],
37
37
  cliEnvironment: process.env.CLIMICROSOFT365_ENV ? process.env.CLIMICROSOFT365_ENV : '',
38
38
  cliConfig: cli.getConfig().all,
39
39
  roles: roles,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ConnectionDetails.js.map
@@ -8,7 +8,6 @@ import fs from 'fs';
8
8
  import auth, { AuthType, CloudType } from '../../Auth.js';
9
9
  import Command, { CommandError } from '../../Command.js';
10
10
  import config from '../../config.js';
11
- import { accessToken } from '../../utils/accessToken.js';
12
11
  import { misc } from '../../utils/misc.js';
13
12
  import commands from './commands.js';
14
13
  import { settingsNames } from '../../settingsNames.js';
@@ -32,47 +31,48 @@ class LoginCommand extends Command {
32
31
  if (this.debug) {
33
32
  await logger.logToStderr(`Logging out from Microsoft 365...`);
34
33
  }
35
- const logout = () => auth.service.logout();
34
+ const deactivate = () => auth.connection.deactivate();
36
35
  const login = async () => {
37
36
  if (this.verbose) {
38
37
  await logger.logToStderr(`Signing in to Microsoft 365...`);
39
38
  }
40
39
  const authType = args.options.authType || cli.getSettingWithDefaultValue(settingsNames.authType, 'deviceCode');
41
- auth.service.appId = args.options.appId || config.cliAadAppId;
42
- auth.service.tenant = args.options.tenant || config.tenant;
40
+ auth.connection.appId = args.options.appId || config.cliAadAppId;
41
+ auth.connection.tenant = args.options.tenant || config.tenant;
42
+ auth.connection.name = args.options.connectionName;
43
43
  switch (authType) {
44
44
  case 'password':
45
- auth.service.authType = AuthType.Password;
46
- auth.service.userName = args.options.userName;
47
- auth.service.password = args.options.password;
45
+ auth.connection.authType = AuthType.Password;
46
+ auth.connection.userName = args.options.userName;
47
+ auth.connection.password = args.options.password;
48
48
  break;
49
49
  case 'certificate':
50
- auth.service.authType = AuthType.Certificate;
51
- auth.service.certificate = args.options.certificateBase64Encoded ? args.options.certificateBase64Encoded : fs.readFileSync(args.options.certificateFile, 'base64');
52
- auth.service.thumbprint = args.options.thumbprint;
53
- auth.service.password = args.options.password;
50
+ auth.connection.authType = AuthType.Certificate;
51
+ auth.connection.certificate = args.options.certificateBase64Encoded ? args.options.certificateBase64Encoded : fs.readFileSync(args.options.certificateFile, 'base64');
52
+ auth.connection.thumbprint = args.options.thumbprint;
53
+ auth.connection.password = args.options.password;
54
54
  break;
55
55
  case 'identity':
56
- auth.service.authType = AuthType.Identity;
57
- auth.service.userName = args.options.userName;
56
+ auth.connection.authType = AuthType.Identity;
57
+ auth.connection.userName = args.options.userName;
58
58
  break;
59
59
  case 'browser':
60
- auth.service.authType = AuthType.Browser;
60
+ auth.connection.authType = AuthType.Browser;
61
61
  break;
62
62
  case 'secret':
63
- auth.service.authType = AuthType.Secret;
64
- auth.service.secret = args.options.secret;
63
+ auth.connection.authType = AuthType.Secret;
64
+ auth.connection.secret = args.options.secret;
65
65
  break;
66
66
  }
67
67
  if (args.options.cloud) {
68
- auth.service.cloudType = CloudType[args.options.cloud];
68
+ auth.connection.cloudType = CloudType[args.options.cloud];
69
69
  }
70
70
  else {
71
- auth.service.cloudType = CloudType.Public;
71
+ auth.connection.cloudType = CloudType.Public;
72
72
  }
73
73
  try {
74
74
  await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
75
- auth.service.connected = true;
75
+ auth.connection.active = true;
76
76
  }
77
77
  catch (error) {
78
78
  if (this.debug) {
@@ -82,38 +82,14 @@ class LoginCommand extends Command {
82
82
  }
83
83
  throw new CommandError(error.message);
84
84
  }
85
+ const details = auth.getConnectionDetails(auth.connection);
85
86
  if (this.debug) {
86
- await logger.log({
87
- connectedAs: accessToken.getUserNameFromAccessToken(auth.service.accessTokens[auth.defaultResource].accessToken),
88
- authType: AuthType[auth.service.authType],
89
- appId: auth.service.appId,
90
- appTenant: auth.service.tenant,
91
- accessToken: JSON.stringify(auth.service.accessTokens, null, 2),
92
- cloudType: CloudType[auth.service.cloudType]
93
- });
94
- }
95
- else {
96
- await logger.log({
97
- connectedAs: accessToken.getUserNameFromAccessToken(auth.service.accessTokens[auth.defaultResource].accessToken),
98
- authType: AuthType[auth.service.authType],
99
- appId: auth.service.appId,
100
- appTenant: auth.service.tenant,
101
- cloudType: CloudType[auth.service.cloudType]
102
- });
87
+ details.accessToken = JSON.stringify(auth.connection.accessTokens, null, 2);
103
88
  }
89
+ await logger.log(details);
104
90
  };
105
- try {
106
- await auth.clearConnectionInfo();
107
- }
108
- catch (error) {
109
- if (this.debug) {
110
- await logger.logToStderr(new CommandError(error));
111
- }
112
- }
113
- finally {
114
- logout();
115
- await login();
116
- }
91
+ deactivate();
92
+ await login();
117
93
  }
118
94
  async action(logger, args) {
119
95
  try {
@@ -156,6 +132,8 @@ _a = LoginCommand, _LoginCommand_instances = new WeakSet(), _LoginCommand_initTe
156
132
  }, {
157
133
  option: '--cloud [cloud]',
158
134
  autocomplete: misc.getEnums(CloudType)
135
+ }, {
136
+ option: '--connectionName [connectionName]'
159
137
  });
160
138
  }, _LoginCommand_initValidators = function _LoginCommand_initValidators() {
161
139
  this.validators.push(async (args) => {
@@ -12,7 +12,7 @@ class LogoutCommand extends Command {
12
12
  if (this.verbose) {
13
13
  await logger.logToStderr('Logging out from Microsoft 365...');
14
14
  }
15
- const logout = () => auth.service.logout();
15
+ const deactivate = () => auth.connection.deactivate();
16
16
  try {
17
17
  await auth.clearConnectionInfo();
18
18
  }
@@ -22,7 +22,7 @@ class LogoutCommand extends Command {
22
22
  }
23
23
  }
24
24
  finally {
25
- logout();
25
+ deactivate();
26
26
  }
27
27
  }
28
28
  async action(logger, args) {
@@ -95,8 +95,8 @@ class RequestCommand extends Command {
95
95
  return url.replace('@graph', 'https://graph.microsoft.com/v1.0');
96
96
  }
97
97
  if (url.startsWith('@spo')) {
98
- if (auth.service.spoUrl) {
99
- return url.replace('@spo', auth.service.spoUrl);
98
+ if (auth.connection.spoUrl) {
99
+ return url.replace('@spo', auth.connection.spoUrl);
100
100
  }
101
101
  throw `SharePoint root site URL is unknown. Please set your SharePoint URL using command 'spo set'.`;
102
102
  }
@@ -1,6 +1,5 @@
1
- import auth, { AuthType, CloudType } from '../../Auth.js';
1
+ import auth from '../../Auth.js';
2
2
  import Command, { CommandError } from '../../Command.js';
3
- import { accessToken } from '../../utils/accessToken.js';
4
3
  import commands from './commands.js';
5
4
  class StatusCommand extends Command {
6
5
  get name() {
@@ -10,7 +9,7 @@ class StatusCommand extends Command {
10
9
  return 'Shows Microsoft 365 login status';
11
10
  }
12
11
  async commandAction(logger) {
13
- if (auth.service.connected) {
12
+ if (auth.connection.active) {
14
13
  try {
15
14
  await auth.ensureAccessToken(auth.defaultResource, logger, this.debug);
16
15
  }
@@ -18,35 +17,28 @@ class StatusCommand extends Command {
18
17
  if (this.debug) {
19
18
  await logger.logToStderr(err);
20
19
  }
21
- auth.service.logout();
20
+ auth.connection.deactivate();
22
21
  throw new CommandError(`Your login has expired. Sign in again to continue. ${err.message}`);
23
22
  }
23
+ const details = auth.getConnectionDetails(auth.connection);
24
24
  if (this.debug) {
25
- await logger.logToStderr({
26
- connectedAs: accessToken.getUserNameFromAccessToken(auth.service.accessTokens[auth.defaultResource].accessToken),
27
- authType: AuthType[auth.service.authType],
28
- appId: auth.service.appId,
29
- appTenant: auth.service.tenant,
30
- accessTokens: JSON.stringify(auth.service.accessTokens, null, 2),
31
- cloudType: CloudType[auth.service.cloudType]
32
- });
33
- }
34
- else {
35
- await logger.log({
36
- connectedAs: accessToken.getUserNameFromAccessToken(auth.service.accessTokens[auth.defaultResource].accessToken),
37
- authType: AuthType[auth.service.authType],
38
- appId: auth.service.appId,
39
- appTenant: auth.service.tenant,
40
- cloudType: CloudType[auth.service.cloudType]
41
- });
25
+ details.accessTokens = JSON.stringify(auth.connection.accessTokens, null, 2);
42
26
  }
27
+ await logger.log(details);
43
28
  }
44
29
  else {
30
+ const connections = await auth.getAllConnections();
45
31
  if (this.verbose) {
46
- await logger.logToStderr('Logged out from Microsoft 365');
32
+ const message = connections.length > 0
33
+ ? `Logged out from Microsoft 365, signed in connections available`
34
+ : 'Logged out from Microsoft 365';
35
+ await logger.logToStderr(message);
47
36
  }
48
37
  else {
49
- await logger.log('Logged out');
38
+ const message = connections.length > 0
39
+ ? `Logged out, signed in connections available`
40
+ : 'Logged out';
41
+ await logger.log(message);
50
42
  }
51
43
  }
52
44
  }
@@ -0,0 +1,47 @@
1
+ import auth, { AuthType } from '../../../Auth.js';
2
+ import commands from '../commands.js';
3
+ import Command, { CommandError } from '../../../Command.js';
4
+ import assert from 'assert';
5
+ class ConnectionListCommand extends Command {
6
+ get name() {
7
+ return commands.LIST;
8
+ }
9
+ get description() {
10
+ return 'Show the list of available connections';
11
+ }
12
+ defaultProperties() {
13
+ return ['name', 'connectedAs', 'authType', 'active'];
14
+ }
15
+ async commandAction(logger) {
16
+ const availableConnections = await auth.getAllConnections();
17
+ const output = availableConnections.map(connection => {
18
+ const isCurrentConnection = connection.name === auth.connection?.name;
19
+ return {
20
+ name: connection.name,
21
+ connectedAs: connection.identityName,
22
+ authType: AuthType[connection.authType],
23
+ active: isCurrentConnection
24
+ };
25
+ }).sort((a, b) => {
26
+ // Asserting name because it is optional, but required at this point.
27
+ assert(a.name !== undefined);
28
+ assert(b.name !== undefined);
29
+ const aName = a.name;
30
+ const bName = b.name;
31
+ return aName.localeCompare(bName);
32
+ });
33
+ await logger.log(output);
34
+ }
35
+ async action(logger, args) {
36
+ try {
37
+ await auth.restoreAuth();
38
+ }
39
+ catch (error) {
40
+ throw new CommandError(error);
41
+ }
42
+ this.initAction(args, logger);
43
+ await this.commandAction(logger);
44
+ }
45
+ }
46
+ export default new ConnectionListCommand();
47
+ //# sourceMappingURL=connection-list.js.map
@@ -0,0 +1,67 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _ConnectionRemoveCommand_instances, _ConnectionRemoveCommand_initTelemetry, _ConnectionRemoveCommand_initOptions;
7
+ import auth from '../../../Auth.js';
8
+ import commands from '../commands.js';
9
+ import Command, { CommandError } from '../../../Command.js';
10
+ import { cli } from '../../../cli/cli.js';
11
+ class ConnectionRemoveCommand extends Command {
12
+ get name() {
13
+ return commands.REMOVE;
14
+ }
15
+ get description() {
16
+ return 'Remove the specified connection';
17
+ }
18
+ constructor() {
19
+ super();
20
+ _ConnectionRemoveCommand_instances.add(this);
21
+ __classPrivateFieldGet(this, _ConnectionRemoveCommand_instances, "m", _ConnectionRemoveCommand_initTelemetry).call(this);
22
+ __classPrivateFieldGet(this, _ConnectionRemoveCommand_instances, "m", _ConnectionRemoveCommand_initOptions).call(this);
23
+ }
24
+ async commandAction(logger, args) {
25
+ const deleteConnection = async () => {
26
+ const connection = await auth.getConnection(args.options.name);
27
+ if (this.verbose) {
28
+ await logger.logToStderr(`Removing connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
29
+ }
30
+ await auth.removeConnectionInfo(connection, logger, this.debug);
31
+ };
32
+ if (args.options.force) {
33
+ await deleteConnection();
34
+ }
35
+ else {
36
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the connection?` });
37
+ if (result) {
38
+ await deleteConnection();
39
+ }
40
+ }
41
+ }
42
+ async action(logger, args) {
43
+ try {
44
+ await auth.restoreAuth();
45
+ }
46
+ catch (error) {
47
+ throw new CommandError(error);
48
+ }
49
+ this.initAction(args, logger);
50
+ await this.commandAction(logger, args);
51
+ }
52
+ }
53
+ _ConnectionRemoveCommand_instances = new WeakSet(), _ConnectionRemoveCommand_initTelemetry = function _ConnectionRemoveCommand_initTelemetry() {
54
+ this.telemetry.push((args) => {
55
+ Object.assign(this.telemetryProperties, {
56
+ force: (!(!args.options.force)).toString()
57
+ });
58
+ });
59
+ }, _ConnectionRemoveCommand_initOptions = function _ConnectionRemoveCommand_initOptions() {
60
+ this.options.unshift({
61
+ option: '-n, --name <name>'
62
+ }, {
63
+ option: '-f, --force'
64
+ });
65
+ };
66
+ export default new ConnectionRemoveCommand();
67
+ //# sourceMappingURL=connection-remove.js.map
@@ -0,0 +1,56 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _ConnectionSetCommand_instances, _ConnectionSetCommand_initOptions, _ConnectionSetCommand_initValidators;
7
+ import auth from '../../../Auth.js';
8
+ import commands from '../commands.js';
9
+ import Command, { CommandError } from '../../../Command.js';
10
+ class ConnectionSetCommand extends Command {
11
+ get name() {
12
+ return commands.SET;
13
+ }
14
+ get description() {
15
+ return 'Rename the specified connection';
16
+ }
17
+ constructor() {
18
+ super();
19
+ _ConnectionSetCommand_instances.add(this);
20
+ __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initOptions).call(this);
21
+ __classPrivateFieldGet(this, _ConnectionSetCommand_instances, "m", _ConnectionSetCommand_initValidators).call(this);
22
+ }
23
+ async commandAction(logger, args) {
24
+ const connection = await auth.getConnection(args.options.name);
25
+ if (this.verbose) {
26
+ await logger.logToStderr(`Updating connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
27
+ }
28
+ await auth.updateConnection(connection, args.options.newName);
29
+ }
30
+ async action(logger, args) {
31
+ try {
32
+ await auth.restoreAuth();
33
+ }
34
+ catch (error) {
35
+ throw new CommandError(error);
36
+ }
37
+ this.initAction(args, logger);
38
+ await this.commandAction(logger, args);
39
+ }
40
+ }
41
+ _ConnectionSetCommand_instances = new WeakSet(), _ConnectionSetCommand_initOptions = function _ConnectionSetCommand_initOptions() {
42
+ this.options.unshift({
43
+ option: '-n, --name <name>'
44
+ }, {
45
+ option: '--newName <newName>'
46
+ });
47
+ }, _ConnectionSetCommand_initValidators = function _ConnectionSetCommand_initValidators() {
48
+ this.validators.push(async (args) => {
49
+ if (args.options.name === args.options.newName) {
50
+ return `Choose a name different from the current one`;
51
+ }
52
+ return true;
53
+ });
54
+ };
55
+ export default new ConnectionSetCommand();
56
+ //# sourceMappingURL=connection-set.js.map
@@ -0,0 +1,51 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _ConnectionUseCommand_instances, _ConnectionUseCommand_initOptions;
7
+ import auth from '../../../Auth.js';
8
+ import commands from '../commands.js';
9
+ import Command, { CommandError } from '../../../Command.js';
10
+ class ConnectionUseCommand extends Command {
11
+ get name() {
12
+ return commands.USE;
13
+ }
14
+ get description() {
15
+ return 'Activate the specified Microsoft 365 tenant connection';
16
+ }
17
+ constructor() {
18
+ super();
19
+ _ConnectionUseCommand_instances.add(this);
20
+ __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initOptions).call(this);
21
+ }
22
+ async commandAction(logger, args) {
23
+ const connection = await auth.getConnection(args.options.name);
24
+ if (this.verbose) {
25
+ await logger.logToStderr(`Switching to connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
26
+ }
27
+ await auth.switchToConnection(connection);
28
+ const details = auth.getConnectionDetails(auth.connection);
29
+ if (this.debug) {
30
+ details.accessTokens = JSON.stringify(auth.connection.accessTokens, null, 2);
31
+ }
32
+ await logger.log(details);
33
+ }
34
+ async action(logger, args) {
35
+ try {
36
+ await auth.restoreAuth();
37
+ }
38
+ catch (error) {
39
+ throw new CommandError(error);
40
+ }
41
+ this.initAction(args, logger);
42
+ await this.commandAction(logger, args);
43
+ }
44
+ }
45
+ _ConnectionUseCommand_instances = new WeakSet(), _ConnectionUseCommand_initOptions = function _ConnectionUseCommand_initOptions() {
46
+ this.options.unshift({
47
+ option: '-n, --name <name>'
48
+ });
49
+ };
50
+ export default new ConnectionUseCommand();
51
+ //# sourceMappingURL=connection-use.js.map
@@ -0,0 +1,8 @@
1
+ const prefix = 'connection';
2
+ export default {
3
+ LIST: `${prefix} list`,
4
+ REMOVE: `${prefix} remove`,
5
+ SET: `${prefix} set`,
6
+ USE: `${prefix} use`
7
+ };
8
+ //# sourceMappingURL=commands.js.map
@@ -7,6 +7,7 @@ export default {
7
7
  ADMINISTRATIVEUNIT_MEMBER_ADD: `${prefix} administrativeunit member add`,
8
8
  ADMINISTRATIVEUNIT_MEMBER_GET: `${prefix} administrativeunit member get`,
9
9
  ADMINISTRATIVEUNIT_MEMBER_LIST: `${prefix} administrativeunit member list`,
10
+ ADMINISTRATIVEUNIT_MEMBER_REMOVE: `${prefix} administrativeunit member remove`,
10
11
  ADMINISTRATIVEUNIT_ROLEASSIGNMENT_ADD: `${prefix} administrativeunit roleassignment add`,
11
12
  APP_ADD: `${prefix} app add`,
12
13
  APP_GET: `${prefix} app get`,
@@ -20,6 +21,7 @@ export default {
20
21
  APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
21
22
  APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
22
23
  APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
24
+ GROUP_ADD: `${prefix} group add`,
23
25
  GROUP_GET: `${prefix} group get`,
24
26
  GROUP_LIST: `${prefix} group list`,
25
27
  GROUP_REMOVE: `${prefix} group remove`,
@@ -78,6 +80,7 @@ export default {
78
80
  USER_RECYCLEBINITEM_CLEAR: `${prefix} user recyclebinitem clear`,
79
81
  USER_RECYCLEBINITEM_LIST: `${prefix} user recyclebinitem list`,
80
82
  USER_RECYCLEBINITEM_REMOVE: `${prefix} user recyclebinitem remove`,
83
+ USER_REGISTRATIONDETAILS_LIST: `${prefix} user registrationdetails list`,
81
84
  USER_REMOVE: `${prefix} user remove`,
82
85
  USER_RECYCLEBINITEM_RESTORE: `${prefix} user recyclebinitem restore`,
83
86
  USER_SET: `${prefix} user set`,