@azure/msal-node-extensions 1.0.0-alpha.34 → 1.0.0-alpha.35

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 (35) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +192 -192
  3. package/binding.gyp +39 -39
  4. package/dist/msal-node-extensions.cjs.development.js +2 -2
  5. package/dist/msal-node-extensions.cjs.development.js.map +1 -1
  6. package/dist/msal-node-extensions.cjs.production.min.js +1 -1
  7. package/dist/msal-node-extensions.cjs.production.min.js.map +1 -1
  8. package/dist/msal-node-extensions.esm.js +2 -2
  9. package/dist/msal-node-extensions.esm.js.map +1 -1
  10. package/dist/packageMetadata.d.ts +1 -1
  11. package/package.json +69 -69
  12. package/src/Dpapi.ts +12 -12
  13. package/src/broker/NativeBrokerPlugin.ts +418 -418
  14. package/src/dpapi-addon/dpapi_addon.h +7 -7
  15. package/src/dpapi-addon/dpapi_not_supported.cpp +13 -13
  16. package/src/dpapi-addon/dpapi_win.cpp +106 -106
  17. package/src/dpapi-addon/main.cpp +30 -30
  18. package/src/error/NativeAuthError.ts +19 -19
  19. package/src/error/PersistenceError.ts +101 -101
  20. package/src/index.ts +17 -17
  21. package/src/lock/CrossPlatformLock.ts +89 -89
  22. package/src/lock/CrossPlatformLockOptions.ts +15 -15
  23. package/src/packageMetadata.ts +3 -3
  24. package/src/persistence/BasePersistence.ts +43 -43
  25. package/src/persistence/DataProtectionScope.ts +20 -20
  26. package/src/persistence/FilePersistence.ts +140 -140
  27. package/src/persistence/FilePersistenceWithDataProtection.ts +92 -92
  28. package/src/persistence/IPersistence.ts +17 -17
  29. package/src/persistence/IPersistenceConfiguration.ts +17 -17
  30. package/src/persistence/KeychainPersistence.ts +89 -89
  31. package/src/persistence/LibSecretPersistence.ts +90 -90
  32. package/src/persistence/PersistenceCachePlugin.ts +106 -106
  33. package/src/persistence/PersistenceCreator.ts +78 -78
  34. package/src/utils/Constants.ts +67 -67
  35. package/src/utils/Environment.ts +101 -101
@@ -1,101 +1,101 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import path from "path";
7
- import { Constants, Platform } from "./Constants";
8
- import { PersistenceError } from "../error/PersistenceError";
9
- import { StringUtils } from "@azure/msal-common";
10
-
11
- export class Environment {
12
- static get homeEnvVar(): string {
13
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.HOME);
14
- }
15
-
16
- static get lognameEnvVar(): string {
17
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.LOGNAME);
18
- }
19
-
20
- static get userEnvVar(): string {
21
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.USER);
22
- }
23
-
24
- static get lnameEnvVar(): string {
25
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.LNAME);
26
- }
27
-
28
- static get usernameEnvVar(): string {
29
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.USERNAME);
30
- }
31
-
32
- static getEnvironmentVariable(name: string): string {
33
- return process.env[name];
34
- }
35
-
36
- static getEnvironmentPlatform(): string {
37
- return process.platform;
38
- }
39
-
40
- static isWindowsPlatform(): boolean {
41
- return this.getEnvironmentPlatform() === Platform.WINDOWS;
42
- }
43
-
44
- static isLinuxPlatform(): boolean {
45
- return this.getEnvironmentPlatform() === Platform.LINUX;
46
- }
47
-
48
- static isMacPlatform(): boolean {
49
- return this.getEnvironmentPlatform() === Platform.MACOS;
50
- }
51
-
52
- static isLinuxRootUser(): boolean {
53
- return process.getuid() === Constants.LINUX_ROOT_USER_GUID;
54
- }
55
-
56
- static getUserRootDirectory(): string {
57
- return !this.isWindowsPlatform ?
58
- this.getUserHomeDirOnUnix() :
59
- this.getUserHomeDirOnWindows();
60
- }
61
-
62
- static getUserHomeDirOnWindows(): string {
63
- return this.getEnvironmentVariable(Constants.ENVIRONMENT.LOCAL_APPLICATION_DATA);
64
- }
65
-
66
- static getUserHomeDirOnUnix(): string | null {
67
- if (this.isWindowsPlatform()) {
68
- throw PersistenceError.createNotSupportedError(
69
- "Getting the user home directory for unix is not supported in windows");
70
- }
71
-
72
- if (!StringUtils.isEmpty(this.homeEnvVar)) {
73
- return this.homeEnvVar;
74
- }
75
-
76
- let username = null;
77
- if (!StringUtils.isEmpty(this.lognameEnvVar)) {
78
- username = this.lognameEnvVar;
79
- } else if (!StringUtils.isEmpty(this.userEnvVar)) {
80
- username = this.userEnvVar;
81
- } else if (!StringUtils.isEmpty(this.lnameEnvVar)) {
82
- username = this.lnameEnvVar;
83
- } else if (!StringUtils.isEmpty(this.usernameEnvVar)) {
84
- username = this.usernameEnvVar;
85
- }
86
-
87
- if (this.isMacPlatform()) {
88
- return !StringUtils.isEmpty(username) ? path.join("/Users", username) : null;
89
- } else if (this.isLinuxPlatform()) {
90
- if (this.isLinuxRootUser()) {
91
- return "/root";
92
- } else {
93
- return !StringUtils.isEmpty(username) ? path.join("/home", username) : null;
94
- }
95
- } else {
96
- throw PersistenceError.createNotSupportedError(
97
- "Getting the user home directory for unix is not supported in windows");
98
- }
99
-
100
- }
101
- }
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import path from "path";
7
+ import { Constants, Platform } from "./Constants";
8
+ import { PersistenceError } from "../error/PersistenceError";
9
+ import { StringUtils } from "@azure/msal-common";
10
+
11
+ export class Environment {
12
+ static get homeEnvVar(): string {
13
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.HOME);
14
+ }
15
+
16
+ static get lognameEnvVar(): string {
17
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.LOGNAME);
18
+ }
19
+
20
+ static get userEnvVar(): string {
21
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.USER);
22
+ }
23
+
24
+ static get lnameEnvVar(): string {
25
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.LNAME);
26
+ }
27
+
28
+ static get usernameEnvVar(): string {
29
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.USERNAME);
30
+ }
31
+
32
+ static getEnvironmentVariable(name: string): string {
33
+ return process.env[name];
34
+ }
35
+
36
+ static getEnvironmentPlatform(): string {
37
+ return process.platform;
38
+ }
39
+
40
+ static isWindowsPlatform(): boolean {
41
+ return this.getEnvironmentPlatform() === Platform.WINDOWS;
42
+ }
43
+
44
+ static isLinuxPlatform(): boolean {
45
+ return this.getEnvironmentPlatform() === Platform.LINUX;
46
+ }
47
+
48
+ static isMacPlatform(): boolean {
49
+ return this.getEnvironmentPlatform() === Platform.MACOS;
50
+ }
51
+
52
+ static isLinuxRootUser(): boolean {
53
+ return process.getuid() === Constants.LINUX_ROOT_USER_GUID;
54
+ }
55
+
56
+ static getUserRootDirectory(): string {
57
+ return !this.isWindowsPlatform ?
58
+ this.getUserHomeDirOnUnix() :
59
+ this.getUserHomeDirOnWindows();
60
+ }
61
+
62
+ static getUserHomeDirOnWindows(): string {
63
+ return this.getEnvironmentVariable(Constants.ENVIRONMENT.LOCAL_APPLICATION_DATA);
64
+ }
65
+
66
+ static getUserHomeDirOnUnix(): string | null {
67
+ if (this.isWindowsPlatform()) {
68
+ throw PersistenceError.createNotSupportedError(
69
+ "Getting the user home directory for unix is not supported in windows");
70
+ }
71
+
72
+ if (!StringUtils.isEmpty(this.homeEnvVar)) {
73
+ return this.homeEnvVar;
74
+ }
75
+
76
+ let username = null;
77
+ if (!StringUtils.isEmpty(this.lognameEnvVar)) {
78
+ username = this.lognameEnvVar;
79
+ } else if (!StringUtils.isEmpty(this.userEnvVar)) {
80
+ username = this.userEnvVar;
81
+ } else if (!StringUtils.isEmpty(this.lnameEnvVar)) {
82
+ username = this.lnameEnvVar;
83
+ } else if (!StringUtils.isEmpty(this.usernameEnvVar)) {
84
+ username = this.usernameEnvVar;
85
+ }
86
+
87
+ if (this.isMacPlatform()) {
88
+ return !StringUtils.isEmpty(username) ? path.join("/Users", username) : null;
89
+ } else if (this.isLinuxPlatform()) {
90
+ if (this.isLinuxRootUser()) {
91
+ return "/root";
92
+ } else {
93
+ return !StringUtils.isEmpty(username) ? path.join("/home", username) : null;
94
+ }
95
+ } else {
96
+ throw PersistenceError.createNotSupportedError(
97
+ "Getting the user home directory for unix is not supported in windows");
98
+ }
99
+
100
+ }
101
+ }