@pnp/cli-microsoft365 12.0.0-beta.0be7d8d → 12.0.0-beta.1752794
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/.devproxy/generate-openapi-spec.json +1 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +2 -6
- package/dist/auth/FileTokenStorage.js +0 -3
- package/dist/auth/msalCachePlugin.js +201 -12
- package/dist/googleAnalytics.js +96 -0
- package/dist/m365/commands/logout.js +2 -4
- package/dist/m365/entra/commands/m365group/m365group-remove.js +4 -3
- package/dist/m365/spe/commands/container/container-remove.js +6 -7
- package/dist/m365/spo/commands/app/app-add.js +35 -56
- package/dist/m365/spo/commands/app/app-deploy.js +41 -59
- package/dist/m365/spo/commands/app/app-get.js +40 -56
- package/dist/m365/spo/commands/app/app-install.js +20 -41
- package/dist/m365/spo/commands/app/app-instance-list.js +12 -24
- package/dist/m365/spo/commands/app/app-list.js +26 -44
- package/dist/m365/spo/commands/app/app-remove.js +32 -52
- package/dist/m365/spo/commands/app/app-retract.js +32 -51
- package/dist/m365/spo/commands/app/app-teamspackage-download.js +35 -54
- package/dist/m365/spo/commands/app/app-uninstall.js +21 -44
- package/dist/m365/spo/commands/app/app-upgrade.js +20 -41
- package/dist/m365/spo/commands/feature/feature-disable.js +20 -50
- package/dist/m365/spo/commands/feature/feature-enable.js +22 -50
- package/dist/m365/spo/commands/feature/feature-list.js +11 -36
- package/dist/m365/spo/commands/field/field-add.js +33 -62
- package/dist/m365/spo/commands/field/field-get.js +30 -57
- package/dist/m365/spo/commands/field/field-list.js +21 -46
- package/dist/m365/spo/commands/field/field-remove.js +32 -63
- package/dist/m365/spo/commands/field/field-set.js +34 -66
- package/dist/m365/spo/commands/file/file-archive.js +1 -1
- package/dist/m365/spo/commands/file/file-get.js +4 -3
- package/dist/m365/spo/commands/file/file-remove.js +5 -5
- package/dist/m365/spo/commands/file/file-unarchive.js +1 -1
- package/dist/m365/spo/commands/folder/folder-archive.js +1 -1
- package/dist/m365/spo/commands/folder/folder-remove.js +5 -5
- package/dist/m365/spo/commands/folder/folder-unarchive.js +90 -0
- package/dist/m365/spo/commands/hidedefaultthemes/hidedefaultthemes-get.js +5 -0
- package/dist/m365/spo/commands/hidedefaultthemes/hidedefaultthemes-set.js +8 -26
- package/dist/m365/spo/commands/homesite/homesite-list.js +5 -0
- package/dist/m365/spo/commands/hubsite/hubsite-connect.js +38 -63
- package/dist/m365/spo/commands/hubsite/hubsite-data-get.js +11 -27
- package/dist/m365/spo/commands/hubsite/hubsite-disconnect.js +25 -47
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +25 -37
- package/dist/m365/spo/commands/hubsite/hubsite-list.js +12 -24
- package/dist/m365/spo/commands/hubsite/hubsite-register.js +10 -18
- package/dist/m365/spo/commands/hubsite/hubsite-rights-grant.js +14 -32
- package/dist/m365/spo/commands/hubsite/hubsite-rights-revoke.js +12 -29
- package/dist/m365/spo/commands/hubsite/hubsite-set.js +19 -46
- package/dist/m365/spo/commands/hubsite/hubsite-unregister.js +11 -27
- package/dist/m365/spo/commands/list/list-remove.js +4 -4
- package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +5 -4
- package/dist/m365/spo/commands/listitem/listitem-get.js +1 -12
- package/dist/m365/spo/commands/listitem/listitem-remove.js +8 -5
- package/dist/m365/spo/commands/navigation/navigation-node-list.js +6 -4
- package/dist/m365/spo/commands/page/page-remove.js +7 -7
- package/dist/m365/spo/commands/site/site-list.js +60 -49
- package/dist/m365/spo/commands/site/site-remove.js +7 -7
- package/dist/m365/spo/commands/spo-get.js +5 -0
- package/dist/m365/spo/commands/spo-set.js +10 -21
- package/dist/m365/spo/commands/storageentity/storageentity-get.js +23 -17
- package/dist/m365/spo/commands/storageentity/storageentity-list.js +39 -36
- package/dist/m365/spo/commands/storageentity/storageentity-remove.js +26 -33
- package/dist/m365/spo/commands/storageentity/storageentity-set.js +26 -36
- package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +1 -1
- package/dist/m365/spo/commands/user/user-ensure.js +24 -60
- package/dist/m365/spo/commands/user/user-get.js +25 -65
- package/dist/m365/spo/commands/user/user-list.js +10 -18
- package/dist/m365/spo/commands/user/user-remove.js +26 -68
- package/dist/m365/spo/commands/userprofile/userprofile-get.js +10 -23
- package/dist/m365/spo/commands/userprofile/userprofile-set.js +10 -19
- package/dist/m365/spo/commands/web/web-add.js +20 -55
- package/dist/m365/spo/commands/web/web-clientsidewebpart-list.js +10 -18
- package/dist/m365/spo/commands/web/web-get.js +12 -30
- package/dist/m365/spo/commands/web/web-installedlanguage-list.js +10 -18
- package/dist/m365/spo/commands/web/web-list.js +10 -18
- package/dist/m365/spo/commands/web/web-reindex.js +10 -18
- package/dist/m365/spo/commands/web/web-remove.js +11 -27
- package/dist/m365/spo/commands/web/web-retentionlabel-list.js +10 -18
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +40 -64
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +31 -58
- package/dist/m365/spo/commands/web/web-roleinheritance-break.js +12 -36
- package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +11 -29
- package/dist/m365/spo/commands/web/web-rule-get.js +47 -0
- package/dist/m365/spo/commands/web/web-rule-list.js +6 -4
- package/dist/m365/spo/commands/web/web-rule-remove.js +0 -3
- package/dist/m365/spo/commands/web/web-set.js +26 -96
- package/dist/m365/spo/commands.js +3 -3
- package/dist/m365/teams/commands/channel/channel-add.js +46 -57
- package/dist/m365/teams/commands/channel/channel-get.js +41 -48
- package/dist/m365/teams/commands/channel/channel-list.js +30 -48
- package/dist/m365/teams/commands/channel/channel-member-add.js +55 -60
- package/dist/m365/teams/commands/channel/channel-member-list.js +49 -61
- package/dist/m365/teams/commands/channel/channel-member-remove.js +64 -68
- package/dist/m365/teams/commands/channel/channel-member-set.js +63 -71
- package/dist/m365/teams/commands/channel/channel-remove.js +49 -57
- package/dist/m365/teams/commands/channel/channel-set.js +49 -62
- package/dist/m365/teams/commands/chat/chat-get.js +30 -45
- package/dist/m365/teams/commands/chat/chat-list.js +22 -42
- package/dist/m365/teams/commands/chat/chat-member-add.js +43 -64
- package/dist/m365/teams/commands/chat/chat-member-list.js +10 -23
- package/dist/m365/teams/commands/chat/chat-member-remove.js +28 -50
- package/dist/m365/teams/commands/chat/chat-message-send.js +32 -55
- package/dist/m365/teams/commands/tab/tab-get.js +2 -6
- package/dist/m365/teams/commands/team/team-archive.js +2 -6
- package/dist/m365/teams/commands/team/team-remove.js +2 -6
- package/dist/m365/teams/commands/team/team-unarchive.js +2 -6
- package/dist/m365/util/commands/accesstoken/accesstoken-get.js +10 -28
- package/dist/telemetry.js +7 -11
- package/dist/utils/spo.js +1 -3
- package/dist/utils/urlUtil.js +2 -2
- package/docs/docs/cmd/entra/m365group/m365group-remove.mdx +4 -4
- package/docs/docs/cmd/spe/container/container-remove.mdx +5 -5
- package/docs/docs/cmd/spo/file/file-archive.mdx +9 -1
- package/docs/docs/cmd/spo/file/file-checkin.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-checkout-undo.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-checkout.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-copy.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-get.mdx +6 -6
- package/docs/docs/cmd/spo/file/file-remove.mdx +4 -4
- package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-retentionlabel-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +3 -3
- package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-sharinginfo-get.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-sharinglink-add.mdx +22 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-clear.mdx +24 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-get.mdx +22 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-list.mdx +22 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-remove.mdx +24 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-set.mdx +22 -1
- package/docs/docs/cmd/spo/file/file-unarchive.mdx +9 -1
- package/docs/docs/cmd/spo/file/file-version-clear.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-keep.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-list.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-restore.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-archive.mdx +7 -1
- package/docs/docs/cmd/spo/folder/folder-copy.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-get.mdx +2 -2
- package/docs/docs/cmd/spo/folder/folder-remove.mdx +4 -4
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-remove.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-sharinglink-add.mdx +22 -1
- package/docs/docs/cmd/spo/folder/folder-sharinglink-clear.mdx +23 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +22 -1
- package/docs/docs/cmd/spo/folder/folder-sharinglink-remove.mdx +24 -1
- package/docs/docs/cmd/spo/folder/folder-sharinglink-set.mdx +21 -0
- package/docs/docs/cmd/spo/folder/folder-unarchive.mdx +76 -0
- package/docs/docs/cmd/spo/list/list-remove.mdx +4 -4
- package/docs/docs/cmd/spo/listitem/listitem-batch-remove.mdx +8 -2
- package/docs/docs/cmd/spo/listitem/listitem-get.mdx +0 -6
- package/docs/docs/cmd/spo/listitem/listitem-remove.mdx +8 -2
- package/docs/docs/cmd/spo/navigation/navigation-node-list.mdx +37 -27
- package/docs/docs/cmd/spo/page/page-remove.mdx +4 -4
- package/docs/docs/cmd/spo/site/site-apppermission-add.mdx +52 -21
- package/docs/docs/cmd/spo/site/site-list.mdx +22 -1
- package/docs/docs/cmd/spo/site/site-remove.mdx +3 -3
- package/docs/docs/cmd/spo/storageentity/storageentity-get.mdx +11 -2
- package/docs/docs/cmd/spo/storageentity/storageentity-list.mdx +9 -3
- package/docs/docs/cmd/spo/storageentity/storageentity-remove.mdx +6 -6
- package/docs/docs/cmd/spo/storageentity/storageentity-set.mdx +10 -4
- package/docs/docs/cmd/spo/web/web-rule-get.mdx +108 -0
- package/docs/docs/cmd/spo/web/web-rule-list.mdx +8 -12
- package/docs/docs/cmd/spo/web/web-rule-remove.mdx +0 -6
- package/docs/docs/cmd/spp/model/model-get.mdx +1 -1
- package/docs/docs/cmd/spp/model/model-remove.mdx +1 -1
- package/docs/docs/cmd/teams/app/app-install.mdx +21 -0
- package/docs/docs/cmd/teams/app/app-list.mdx +19 -0
- package/docs/docs/cmd/teams/app/app-publish.mdx +17 -0
- package/docs/docs/cmd/teams/app/app-remove.mdx +19 -0
- package/docs/docs/cmd/teams/app/app-uninstall.mdx +21 -0
- package/docs/docs/cmd/teams/app/app-update.mdx +19 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-add.mdx +19 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-get.mdx +19 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-list.mdx +19 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-remove.mdx +19 -0
- package/docs/docs/cmd/tenant/people/people-profilecardproperty-set.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.mdx +19 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.mdx +19 -0
- package/npm-shrinkwrap.json +1120 -3216
- package/package.json +23 -33
- package/dist/appInsights.js +0 -43
package/dist/Auth.js
CHANGED
|
@@ -262,7 +262,7 @@ export class Auth {
|
|
|
262
262
|
return {
|
|
263
263
|
auth: authConfig,
|
|
264
264
|
cache: {
|
|
265
|
-
cachePlugin: msalCachePlugin
|
|
265
|
+
cachePlugin: await msalCachePlugin.getCachePlugin()
|
|
266
266
|
},
|
|
267
267
|
system: {
|
|
268
268
|
loggerOptions: {
|
|
@@ -735,8 +735,7 @@ export class Auth {
|
|
|
735
735
|
await allConnectionsStorage.remove();
|
|
736
736
|
// we need to manually clear MSAL cache, because MSAL doesn't have support
|
|
737
737
|
// for logging out when using cert-based auth
|
|
738
|
-
|
|
739
|
-
await msalCache.remove();
|
|
738
|
+
await msalCachePlugin.clearMsalCache();
|
|
740
739
|
}
|
|
741
740
|
async removeConnectionInfo(connection, logger, debug) {
|
|
742
741
|
const allConnections = await this.getAllConnections();
|
|
@@ -769,9 +768,6 @@ export class Auth {
|
|
|
769
768
|
getConnectionStorage() {
|
|
770
769
|
return new FileTokenStorage(FileTokenStorage.connectionInfoFilePath());
|
|
771
770
|
}
|
|
772
|
-
getMsalCacheStorage() {
|
|
773
|
-
return new FileTokenStorage(FileTokenStorage.msalCacheFilePath());
|
|
774
|
-
}
|
|
775
771
|
getAllConnectionsStorage() {
|
|
776
772
|
return new FileTokenStorage(FileTokenStorage.allConnectionsFilePath());
|
|
777
773
|
}
|
|
@@ -2,9 +2,6 @@ import fs from 'fs';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
export class FileTokenStorage {
|
|
5
|
-
static msalCacheFilePath() {
|
|
6
|
-
return path.join(os.homedir(), '.cli-m365-msal.json');
|
|
7
|
-
}
|
|
8
5
|
static connectionInfoFilePath() {
|
|
9
6
|
return path.join(os.homedir(), '.cli-m365-connection.json');
|
|
10
7
|
}
|
|
@@ -1,29 +1,218 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { lock } from 'proper-lockfile';
|
|
5
|
+
const legacyCachePath = path.join(os.homedir(), '.cli-m365-msal.json');
|
|
6
|
+
const fallbackCachePath = path.join(os.homedir(), '.cli-m365-msal-cache.json');
|
|
7
|
+
const lockRetryCount = 500;
|
|
8
|
+
const lockRetryDelay = 100;
|
|
9
|
+
const staleLockThreshold = 10000;
|
|
10
|
+
const persistenceConfiguration = {
|
|
11
|
+
cachePath: fallbackCachePath,
|
|
12
|
+
serviceName: 'cli-microsoft365',
|
|
13
|
+
accountName: 'msal-cache',
|
|
14
|
+
usePlaintextFileOnLinux: true
|
|
15
|
+
};
|
|
16
|
+
export const fileLock = { lock };
|
|
17
|
+
let _initPromise;
|
|
18
|
+
// Fallback ICachePlugin that stores tokens as plain JSON on disk.
|
|
19
|
+
// @azure/msal-node-extensions ships a usePlaintextFileOnLinux option
|
|
20
|
+
// for Linux systems without libsecret, but the package's barrel export
|
|
21
|
+
// eagerly loads LibSecretPersistence which does `import keytar` at the
|
|
22
|
+
// top level. When libsecret is missing, the entire dynamic import of
|
|
23
|
+
// the package fails before any fallback logic can run. This class
|
|
24
|
+
// provides equivalent file-based persistence without depending on the
|
|
25
|
+
// package at all.
|
|
26
|
+
// See: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/7170
|
|
27
|
+
class FileCachePlugin {
|
|
28
|
+
constructor(cachePath) {
|
|
29
|
+
this.cachePath = cachePath;
|
|
5
30
|
}
|
|
6
31
|
async beforeCacheAccess(tokenCacheContext) {
|
|
32
|
+
await this.acquireLock();
|
|
7
33
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
34
|
+
if (fs.existsSync(this.cachePath)) {
|
|
35
|
+
const data = fs.readFileSync(this.cachePath, 'utf8');
|
|
36
|
+
tokenCacheContext.tokenCache.deserialize(data);
|
|
37
|
+
}
|
|
10
38
|
}
|
|
11
39
|
catch {
|
|
12
40
|
// Do nothing
|
|
13
41
|
}
|
|
14
42
|
}
|
|
15
43
|
async afterCacheAccess(tokenCacheContext) {
|
|
16
|
-
if (!tokenCacheContext.cacheHasChanged) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
44
|
try {
|
|
20
|
-
|
|
45
|
+
if (tokenCacheContext.cacheHasChanged) {
|
|
46
|
+
if (fs.existsSync(this.cachePath)) {
|
|
47
|
+
fs.chmodSync(this.cachePath, 0o600);
|
|
48
|
+
}
|
|
49
|
+
fs.writeFileSync(this.cachePath, tokenCacheContext.tokenCache.serialize(), { encoding: 'utf8', mode: 0o600 });
|
|
50
|
+
}
|
|
21
51
|
}
|
|
22
52
|
catch {
|
|
23
53
|
// Do nothing
|
|
24
54
|
}
|
|
55
|
+
finally {
|
|
56
|
+
await this.releaseLock();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async clearCache() {
|
|
60
|
+
await this.acquireLock();
|
|
61
|
+
try {
|
|
62
|
+
removeFile(this.cachePath);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await this.releaseLock();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async acquireLock() {
|
|
69
|
+
this.releaseCacheLock = await msalCachePlugin.acquireFileLock(this.cachePath);
|
|
70
|
+
}
|
|
71
|
+
async releaseLock() {
|
|
72
|
+
if (this.releaseCacheLock === undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const releaseCacheLock = this.releaseCacheLock;
|
|
76
|
+
this.releaseCacheLock = undefined;
|
|
77
|
+
await releaseCacheLock();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class LockingCachePlugin {
|
|
81
|
+
constructor(plugin, lockPath) {
|
|
82
|
+
this.plugin = plugin;
|
|
83
|
+
this.lockPath = lockPath;
|
|
84
|
+
}
|
|
85
|
+
async beforeCacheAccess(tokenCacheContext) {
|
|
86
|
+
this.releaseCacheLock = await msalCachePlugin.acquireFileLock(this.lockPath);
|
|
87
|
+
try {
|
|
88
|
+
await this.plugin.beforeCacheAccess(tokenCacheContext);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
await this.releaseLock();
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async afterCacheAccess(tokenCacheContext) {
|
|
96
|
+
try {
|
|
97
|
+
await this.plugin.afterCacheAccess(tokenCacheContext);
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
await this.releaseLock();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async clearCache(clearCache) {
|
|
104
|
+
this.releaseCacheLock = await msalCachePlugin.acquireFileLock(this.lockPath);
|
|
105
|
+
try {
|
|
106
|
+
await clearCache();
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
await this.releaseLock();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async releaseLock() {
|
|
113
|
+
if (this.releaseCacheLock === undefined) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const releaseCacheLock = this.releaseCacheLock;
|
|
117
|
+
this.releaseCacheLock = undefined;
|
|
118
|
+
await releaseCacheLock();
|
|
25
119
|
}
|
|
26
120
|
}
|
|
27
|
-
|
|
28
|
-
|
|
121
|
+
function removeFile(filePath) {
|
|
122
|
+
try {
|
|
123
|
+
fs.unlinkSync(filePath);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (err.code !== 'ENOENT') {
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export const msalCachePlugin = {
|
|
132
|
+
async acquireFileLock(cachePath) {
|
|
133
|
+
return await fileLock.lock(cachePath, {
|
|
134
|
+
lockfilePath: `${cachePath}.lockfile`,
|
|
135
|
+
realpath: false,
|
|
136
|
+
stale: staleLockThreshold,
|
|
137
|
+
update: staleLockThreshold / 2,
|
|
138
|
+
retries: {
|
|
139
|
+
retries: lockRetryCount,
|
|
140
|
+
factor: 1,
|
|
141
|
+
minTimeout: lockRetryDelay,
|
|
142
|
+
maxTimeout: lockRetryDelay,
|
|
143
|
+
randomize: false
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
async importMsalExtensions() {
|
|
148
|
+
return await import('@azure/msal-node-extensions');
|
|
149
|
+
},
|
|
150
|
+
async createNativePersistence() {
|
|
151
|
+
const { DataProtectionScope, PersistenceCachePlugin, PersistenceCreator } = await msalCachePlugin.importMsalExtensions();
|
|
152
|
+
const persistence = await PersistenceCreator.createPersistence({
|
|
153
|
+
...persistenceConfiguration,
|
|
154
|
+
dataProtectionScope: DataProtectionScope.CurrentUser
|
|
155
|
+
});
|
|
156
|
+
const plugin = new LockingCachePlugin(new PersistenceCachePlugin(persistence), `${persistence.getFilePath()}.cli-m365`);
|
|
157
|
+
return {
|
|
158
|
+
plugin,
|
|
159
|
+
clearCache: async () => { await plugin.clearCache(async () => { await persistence.delete(); }); },
|
|
160
|
+
isFileFallback: false
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
createFileFallback() {
|
|
164
|
+
const plugin = new FileCachePlugin(persistenceConfiguration.cachePath);
|
|
165
|
+
return {
|
|
166
|
+
plugin,
|
|
167
|
+
clearCache: async () => { await plugin.clearCache(); },
|
|
168
|
+
isFileFallback: true
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
removeLegacyCache() {
|
|
172
|
+
removeFile(legacyCachePath);
|
|
173
|
+
},
|
|
174
|
+
async getCachePlugin() {
|
|
175
|
+
_initPromise ?? (_initPromise = (async () => {
|
|
176
|
+
msalCachePlugin.removeLegacyCache();
|
|
177
|
+
try {
|
|
178
|
+
return await msalCachePlugin.createNativePersistence();
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
// Fall back to file-based cache only on Linux where libsecret
|
|
182
|
+
// may not be installed. On Windows (DPAPI) and macOS (Keychain)
|
|
183
|
+
// native persistence should always work.
|
|
184
|
+
if (process.platform === 'linux') {
|
|
185
|
+
return msalCachePlugin.createFileFallback();
|
|
186
|
+
}
|
|
187
|
+
throw err;
|
|
188
|
+
}
|
|
189
|
+
})());
|
|
190
|
+
const { plugin } = await _initPromise;
|
|
191
|
+
return plugin;
|
|
192
|
+
},
|
|
193
|
+
async clearMsalCache() {
|
|
194
|
+
_initPromise ?? (_initPromise = (async () => {
|
|
195
|
+
msalCachePlugin.removeLegacyCache();
|
|
196
|
+
try {
|
|
197
|
+
return await msalCachePlugin.createNativePersistence();
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
if (process.platform === 'linux') {
|
|
201
|
+
return msalCachePlugin.createFileFallback();
|
|
202
|
+
}
|
|
203
|
+
throw err;
|
|
204
|
+
}
|
|
205
|
+
})());
|
|
206
|
+
const { clearCache, isFileFallback } = await _initPromise;
|
|
207
|
+
await clearCache();
|
|
208
|
+
// Also remove the file-based fallback cache to ensure no tokens
|
|
209
|
+
// remain if the machine previously used file-based persistence
|
|
210
|
+
if (!isFileFallback) {
|
|
211
|
+
await msalCachePlugin.createFileFallback().clearCache();
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
resetForTesting() {
|
|
215
|
+
_initPromise = undefined;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
29
218
|
//# sourceMappingURL=msalCachePlugin.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Axios from 'axios';
|
|
2
|
+
import Configstore from 'configstore';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import url from 'url';
|
|
8
|
+
import config from './config.js';
|
|
9
|
+
import { app } from './utils/app.js';
|
|
10
|
+
const measurementId = 'G-4BNT8MQCYT';
|
|
11
|
+
const apiSecret = 'mm_3WD_TRuO-9MKsuZnhDQ';
|
|
12
|
+
const endpoint = 'https://www.google-analytics.com/mp/collect';
|
|
13
|
+
const clientIdSetting = 'telemetryClientId';
|
|
14
|
+
const requestTimeout = 3000;
|
|
15
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
16
|
+
const commonProperties = {
|
|
17
|
+
version: `${app.packageJson().version}${fs.existsSync(path.join(__dirname, `..${path.sep}src`)) ? '-dev' : ''}`,
|
|
18
|
+
node: process.version,
|
|
19
|
+
os: os.platform(),
|
|
20
|
+
env: process.env.CLIMICROSOFT365_ENV ?? '',
|
|
21
|
+
ci: Boolean(process.env.CI).toString()
|
|
22
|
+
};
|
|
23
|
+
function getClientId() {
|
|
24
|
+
const store = new Configstore(config.configstoreName);
|
|
25
|
+
let clientId = store.get(clientIdSetting);
|
|
26
|
+
if (!clientId) {
|
|
27
|
+
clientId = crypto.randomUUID();
|
|
28
|
+
store.set(clientIdSetting, clientId);
|
|
29
|
+
}
|
|
30
|
+
return clientId;
|
|
31
|
+
}
|
|
32
|
+
function getSessionId(sessionId) {
|
|
33
|
+
return parseInt(crypto.createHash('sha256').update(sessionId).digest('hex').substring(0, 12), 16);
|
|
34
|
+
}
|
|
35
|
+
function toEventValue(value) {
|
|
36
|
+
if (typeof value === 'number') {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return String(value);
|
|
40
|
+
}
|
|
41
|
+
function getEvents(commandName, properties, context) {
|
|
42
|
+
const sessionId = getSessionId(context.sessionId);
|
|
43
|
+
const eventProperties = Object.entries(properties).reduce((result, [name, value]) => {
|
|
44
|
+
if (typeof value !== 'undefined') {
|
|
45
|
+
result[name] = toEventValue(value);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}, {});
|
|
49
|
+
return [{
|
|
50
|
+
name: 'command_used',
|
|
51
|
+
params: {
|
|
52
|
+
['command_name']: commandName,
|
|
53
|
+
...commonProperties,
|
|
54
|
+
shell: context.shell,
|
|
55
|
+
...eventProperties,
|
|
56
|
+
['session_id']: sessionId,
|
|
57
|
+
['engagement_time_msec']: 1
|
|
58
|
+
}
|
|
59
|
+
}];
|
|
60
|
+
}
|
|
61
|
+
async function sendEvents(events) {
|
|
62
|
+
const clientId = getClientId();
|
|
63
|
+
const response = await Axios.post(`${endpoint}?measurement_id=${measurementId}&api_secret=${apiSecret}`, {
|
|
64
|
+
['client_id']: clientId,
|
|
65
|
+
events
|
|
66
|
+
}, {
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json'
|
|
69
|
+
},
|
|
70
|
+
timeout: requestTimeout,
|
|
71
|
+
validateStatus: () => true
|
|
72
|
+
});
|
|
73
|
+
if (response.status < 200 || response.status >= 300) {
|
|
74
|
+
throw new Error(`Google Analytics returned ${response.status}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const googleAnalytics = {
|
|
78
|
+
commonProperties,
|
|
79
|
+
trackEvent: async (commandName, properties, context) => {
|
|
80
|
+
await sendEvents(getEvents(commandName, properties, context));
|
|
81
|
+
},
|
|
82
|
+
trackException: async (exception, context) => {
|
|
83
|
+
const description = exception instanceof Error ? exception.message : String(exception);
|
|
84
|
+
await sendEvents([{
|
|
85
|
+
name: 'exception',
|
|
86
|
+
params: {
|
|
87
|
+
description: description.substring(0, 100),
|
|
88
|
+
...commonProperties,
|
|
89
|
+
shell: context.shell,
|
|
90
|
+
['session_id']: getSessionId(context.sessionId),
|
|
91
|
+
['engagement_time_msec']: 1
|
|
92
|
+
}
|
|
93
|
+
}]);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=googleAnalytics.js.map
|
|
@@ -16,7 +16,6 @@ class LogoutCommand extends Command {
|
|
|
16
16
|
if (this.verbose) {
|
|
17
17
|
await logger.logToStderr('Logging out from Microsoft 365...');
|
|
18
18
|
}
|
|
19
|
-
const deactivate = () => auth.connection.deactivate();
|
|
20
19
|
try {
|
|
21
20
|
await auth.clearConnectionInfo();
|
|
22
21
|
}
|
|
@@ -24,10 +23,9 @@ class LogoutCommand extends Command {
|
|
|
24
23
|
if (this.debug) {
|
|
25
24
|
await logger.logToStderr(new CommandError(error));
|
|
26
25
|
}
|
|
26
|
+
throw new CommandError(error);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
deactivate();
|
|
30
|
-
}
|
|
28
|
+
auth.connection.deactivate();
|
|
31
29
|
}
|
|
32
30
|
async action(logger, args) {
|
|
33
31
|
try {
|
|
@@ -49,7 +49,7 @@ class EntraM365GroupRemoveCommand extends GraphCommand {
|
|
|
49
49
|
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
50
50
|
// Delete the Microsoft 365 group site. This operation will also delete the group.
|
|
51
51
|
await this.deleteM365GroupSite(logger, siteUrl, spoAdminUrl);
|
|
52
|
-
if (args.options.
|
|
52
|
+
if (args.options.permanent) {
|
|
53
53
|
await this.deleteM365GroupFromRecycleBin(logger, groupId);
|
|
54
54
|
await this.deleteSiteFromRecycleBin(logger, siteUrl, spoAdminUrl);
|
|
55
55
|
}
|
|
@@ -169,7 +169,7 @@ _EntraM365GroupRemoveCommand_instances = new WeakSet(), _EntraM365GroupRemoveCom
|
|
|
169
169
|
this.telemetry.push((args) => {
|
|
170
170
|
Object.assign(this.telemetryProperties, {
|
|
171
171
|
force: (!(!args.options.force)).toString(),
|
|
172
|
-
|
|
172
|
+
permanent: !!args.options.permanent
|
|
173
173
|
});
|
|
174
174
|
});
|
|
175
175
|
}, _EntraM365GroupRemoveCommand_initOptions = function _EntraM365GroupRemoveCommand_initOptions() {
|
|
@@ -180,7 +180,7 @@ _EntraM365GroupRemoveCommand_instances = new WeakSet(), _EntraM365GroupRemoveCom
|
|
|
180
180
|
}, {
|
|
181
181
|
option: '-f, --force'
|
|
182
182
|
}, {
|
|
183
|
-
option: '--
|
|
183
|
+
option: '--permanent'
|
|
184
184
|
});
|
|
185
185
|
}, _EntraM365GroupRemoveCommand_initValidators = function _EntraM365GroupRemoveCommand_initValidators() {
|
|
186
186
|
this.validators.push(async (args) => {
|
|
@@ -193,6 +193,7 @@ _EntraM365GroupRemoveCommand_instances = new WeakSet(), _EntraM365GroupRemoveCom
|
|
|
193
193
|
this.optionSets.push({ options: ['id', 'displayName'] });
|
|
194
194
|
}, _EntraM365GroupRemoveCommand_initTypes = function _EntraM365GroupRemoveCommand_initTypes() {
|
|
195
195
|
this.types.string.push('id', 'displayName');
|
|
196
|
+
this.types.boolean.push('permanent');
|
|
196
197
|
};
|
|
197
198
|
EntraM365GroupRemoveCommand.maxRetries = 10;
|
|
198
199
|
export default new EntraM365GroupRemoveCommand();
|
|
@@ -11,7 +11,7 @@ export const options = z.strictObject({
|
|
|
11
11
|
name: z.string().optional().alias('n'),
|
|
12
12
|
containerTypeId: z.uuid().optional(),
|
|
13
13
|
containerTypeName: z.string().optional(),
|
|
14
|
-
|
|
14
|
+
permanent: z.boolean().optional(),
|
|
15
15
|
force: z.boolean().optional().alias('f')
|
|
16
16
|
});
|
|
17
17
|
class SpeContainerRemoveCommand extends GraphCommand {
|
|
@@ -46,7 +46,7 @@ class SpeContainerRemoveCommand extends GraphCommand {
|
|
|
46
46
|
}
|
|
47
47
|
async commandAction(logger, args) {
|
|
48
48
|
if (!args.options.force) {
|
|
49
|
-
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove container '${args.options.id || args.options.name}'
|
|
49
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to ${args.options.permanent ? 'permanently remove' : 'recycle'} container '${args.options.id || args.options.name}'?` });
|
|
50
50
|
if (!result) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -63,13 +63,12 @@ class SpeContainerRemoveCommand extends GraphCommand {
|
|
|
63
63
|
},
|
|
64
64
|
responseType: 'json'
|
|
65
65
|
};
|
|
66
|
-
if (args.options.
|
|
67
|
-
|
|
66
|
+
if (args.options.permanent) {
|
|
67
|
+
requestOptions.url += '/permanentDelete';
|
|
68
|
+
await request.post(requestOptions);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
requestOptions.url += '/permanentDelete';
|
|
72
|
-
await request.post(requestOptions);
|
|
71
|
+
await request.delete(requestOptions);
|
|
73
72
|
}
|
|
74
73
|
catch (err) {
|
|
75
74
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -1,17 +1,34 @@
|
|
|
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 _SpoAppAddCommand_instances, _SpoAppAddCommand_initTelemetry, _SpoAppAddCommand_initOptions, _SpoAppAddCommand_initValidators;
|
|
7
1
|
import fs from 'fs';
|
|
8
2
|
import path from 'path';
|
|
3
|
+
import { z } from 'zod';
|
|
9
4
|
import { cli } from '../../../../cli/cli.js';
|
|
5
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
10
6
|
import request from '../../../../request.js';
|
|
11
7
|
import { spo } from '../../../../utils/spo.js';
|
|
12
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
|
+
import { zod } from '../../../../utils/zod.js';
|
|
13
10
|
import commands from '../../commands.js';
|
|
14
11
|
import { SpoAppBaseCommand } from './SpoAppBaseCommand.js';
|
|
12
|
+
export const options = z.strictObject({
|
|
13
|
+
...globalOptionsZod.shape,
|
|
14
|
+
filePath: z.string()
|
|
15
|
+
.refine(filePath => fs.existsSync(path.resolve(filePath)), {
|
|
16
|
+
error: e => `File '${path.resolve(e.input)}' not found`,
|
|
17
|
+
abort: true
|
|
18
|
+
})
|
|
19
|
+
.refine(filePath => !fs.lstatSync(path.resolve(filePath)).isDirectory(), {
|
|
20
|
+
error: e => `Path '${path.resolve(e.input)}' points to a directory`
|
|
21
|
+
})
|
|
22
|
+
.alias('p'),
|
|
23
|
+
overwrite: z.boolean().optional(),
|
|
24
|
+
appCatalogScope: zod.coercedEnum({ tenant: 'tenant', sitecollection: 'sitecollection' }).optional().alias('s'),
|
|
25
|
+
appCatalogUrl: z.string()
|
|
26
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, {
|
|
27
|
+
error: e => `'${e.input}' is not a valid SharePoint Online site URL.`
|
|
28
|
+
})
|
|
29
|
+
.optional()
|
|
30
|
+
.alias('u')
|
|
31
|
+
});
|
|
15
32
|
class SpoAppAddCommand extends SpoAppBaseCommand {
|
|
16
33
|
get name() {
|
|
17
34
|
return commands.APP_ADD;
|
|
@@ -19,13 +36,18 @@ class SpoAppAddCommand extends SpoAppBaseCommand {
|
|
|
19
36
|
get description() {
|
|
20
37
|
return 'Adds an app to the specified SharePoint Online app catalog';
|
|
21
38
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
get schema() {
|
|
40
|
+
return options;
|
|
41
|
+
}
|
|
42
|
+
getRefinedSchema(schema) {
|
|
43
|
+
return schema
|
|
44
|
+
.refine(opts => opts.appCatalogScope !== 'sitecollection' || opts.appCatalogUrl !== undefined, {
|
|
45
|
+
error: 'You must specify appCatalogUrl when appCatalogScope is sitecollection',
|
|
46
|
+
path: ['appCatalogUrl'],
|
|
47
|
+
params: {
|
|
48
|
+
customCode: 'required'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
29
51
|
}
|
|
30
52
|
async commandAction(logger, args) {
|
|
31
53
|
const scope = (args.options.appCatalogScope) ? args.options.appCatalogScope.toLowerCase() : 'tenant';
|
|
@@ -60,48 +82,5 @@ class SpoAppAddCommand extends SpoAppBaseCommand {
|
|
|
60
82
|
}
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
|
-
_SpoAppAddCommand_instances = new WeakSet(), _SpoAppAddCommand_initTelemetry = function _SpoAppAddCommand_initTelemetry() {
|
|
64
|
-
this.telemetry.push((args) => {
|
|
65
|
-
Object.assign(this.telemetryProperties, {
|
|
66
|
-
overwrite: !!args.options.overwrite,
|
|
67
|
-
appCatalogScope: args.options.appCatalogScope || 'tenant',
|
|
68
|
-
appCatalogUrl: typeof args.options.appCatalogUrl !== 'undefined'
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}, _SpoAppAddCommand_initOptions = function _SpoAppAddCommand_initOptions() {
|
|
72
|
-
this.options.unshift({
|
|
73
|
-
option: '-p, --filePath <filePath>'
|
|
74
|
-
}, {
|
|
75
|
-
option: '-s, --appCatalogScope [appCatalogScope]',
|
|
76
|
-
autocomplete: this.appCatalogScopeOptions
|
|
77
|
-
}, {
|
|
78
|
-
option: '-u, --appCatalogUrl [appCatalogUrl]'
|
|
79
|
-
}, {
|
|
80
|
-
option: '--overwrite [overwrite]'
|
|
81
|
-
});
|
|
82
|
-
}, _SpoAppAddCommand_initValidators = function _SpoAppAddCommand_initValidators() {
|
|
83
|
-
this.validators.push(async (args) => {
|
|
84
|
-
if (args.options.appCatalogScope) {
|
|
85
|
-
const appCatalogScope = args.options.appCatalogScope.toLowerCase();
|
|
86
|
-
if (this.appCatalogScopeOptions.indexOf(appCatalogScope) === -1) {
|
|
87
|
-
return `${args.options.appCatalogScope} is not a valid appCatalogScope. Allowed values are: ${this.appCatalogScopeOptions.join(', ')}`;
|
|
88
|
-
}
|
|
89
|
-
if (appCatalogScope === 'sitecollection' && !args.options.appCatalogUrl) {
|
|
90
|
-
return `You must specify appCatalogUrl when appCatalogScope is sitecollection`;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const fullPath = path.resolve(args.options.filePath);
|
|
94
|
-
if (!fs.existsSync(fullPath)) {
|
|
95
|
-
return `File '${fullPath}' not found`;
|
|
96
|
-
}
|
|
97
|
-
if (fs.lstatSync(fullPath).isDirectory()) {
|
|
98
|
-
return `Path '${fullPath}' points to a directory`;
|
|
99
|
-
}
|
|
100
|
-
if (args.options.appCatalogUrl) {
|
|
101
|
-
return validation.isValidSharePointUrl(args.options.appCatalogUrl);
|
|
102
|
-
}
|
|
103
|
-
return true;
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
85
|
export default new SpoAppAddCommand();
|
|
107
86
|
//# sourceMappingURL=app-add.js.map
|