@bluestep-systems/b6p-core 0.1.0
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/README.md +75 -0
- package/dist/B6PCore.d.ts +109 -0
- package/dist/B6PCore.js +470 -0
- package/dist/B6PCore.js.map +1 -0
- package/dist/B6PUri.d.ts +31 -0
- package/dist/B6PUri.js +110 -0
- package/dist/B6PUri.js.map +1 -0
- package/dist/Err.d.ts +470 -0
- package/dist/Err.js +800 -0
- package/dist/Err.js.map +1 -0
- package/dist/auth/BasicAuthProvider.d.ts +39 -0
- package/dist/auth/BasicAuthProvider.js +106 -0
- package/dist/auth/BasicAuthProvider.js.map +1 -0
- package/dist/cache/OrgCache.d.ts +66 -0
- package/dist/cache/OrgCache.js +220 -0
- package/dist/cache/OrgCache.js.map +1 -0
- package/dist/cache/ScriptMetaDataStore.d.ts +39 -0
- package/dist/cache/ScriptMetaDataStore.js +83 -0
- package/dist/cache/ScriptMetaDataStore.js.map +1 -0
- package/dist/constants/ApiEndpoints.d.ts +13 -0
- package/dist/constants/ApiEndpoints.js +18 -0
- package/dist/constants/ApiEndpoints.js.map +1 -0
- package/dist/constants/AuthTypes.d.ts +9 -0
- package/dist/constants/AuthTypes.js +14 -0
- package/dist/constants/AuthTypes.js.map +1 -0
- package/dist/constants/BlueHQ.d.ts +20 -0
- package/dist/constants/BlueHQ.js +36 -0
- package/dist/constants/BlueHQ.js.map +1 -0
- package/dist/constants/CryptoAlgorithms.d.ts +8 -0
- package/dist/constants/CryptoAlgorithms.js +13 -0
- package/dist/constants/CryptoAlgorithms.js.map +1 -0
- package/dist/constants/ExtensionConfig.d.ts +11 -0
- package/dist/constants/ExtensionConfig.js +16 -0
- package/dist/constants/ExtensionConfig.js.map +1 -0
- package/dist/constants/FileExtensions.d.ts +13 -0
- package/dist/constants/FileExtensions.js +18 -0
- package/dist/constants/FileExtensions.js.map +1 -0
- package/dist/constants/FolderNames.d.ts +12 -0
- package/dist/constants/FolderNames.js +17 -0
- package/dist/constants/FolderNames.js.map +1 -0
- package/dist/constants/GitHubUrls.d.ts +12 -0
- package/dist/constants/GitHubUrls.js +17 -0
- package/dist/constants/GitHubUrls.js.map +1 -0
- package/dist/constants/Http.d.ts +57 -0
- package/dist/constants/Http.js +67 -0
- package/dist/constants/Http.js.map +1 -0
- package/dist/constants/MimeTypes.d.ts +9 -0
- package/dist/constants/MimeTypes.js +14 -0
- package/dist/constants/MimeTypes.js.map +1 -0
- package/dist/constants/Numerical.d.ts +14 -0
- package/dist/constants/Numerical.js +32 -0
- package/dist/constants/Numerical.js.map +1 -0
- package/dist/constants/OutputChannels.d.ts +8 -0
- package/dist/constants/OutputChannels.js +13 -0
- package/dist/constants/OutputChannels.js.map +1 -0
- package/dist/constants/SettingsKeys.d.ts +11 -0
- package/dist/constants/SettingsKeys.js +16 -0
- package/dist/constants/SettingsKeys.js.map +1 -0
- package/dist/constants/SpecialFiles.d.ts +10 -0
- package/dist/constants/SpecialFiles.js +15 -0
- package/dist/constants/SpecialFiles.js.map +1 -0
- package/dist/constants/WebDAVElements.d.ts +10 -0
- package/dist/constants/WebDAVElements.js +15 -0
- package/dist/constants/WebDAVElements.js.map +1 -0
- package/dist/constants/index.d.ts +22 -0
- package/dist/constants/index.js +41 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/data/DownstairsPathParser.d.ts +20 -0
- package/dist/data/DownstairsPathParser.js +132 -0
- package/dist/data/DownstairsPathParser.js.map +1 -0
- package/dist/data/GlobMatcher.d.ts +23 -0
- package/dist/data/GlobMatcher.js +135 -0
- package/dist/data/GlobMatcher.js.map +1 -0
- package/dist/data/IdUtility.d.ts +22 -0
- package/dist/data/IdUtility.js +119 -0
- package/dist/data/IdUtility.js.map +1 -0
- package/dist/data/OrgWorker.d.ts +14 -0
- package/dist/data/OrgWorker.js +54 -0
- package/dist/data/OrgWorker.js.map +1 -0
- package/dist/data/ScriptKey.d.ts +93 -0
- package/dist/data/ScriptKey.js +123 -0
- package/dist/data/ScriptKey.js.map +1 -0
- package/dist/data/ScriptUrlParser.d.ts +42 -0
- package/dist/data/ScriptUrlParser.js +258 -0
- package/dist/data/ScriptUrlParser.js.map +1 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/index.js +14 -0
- package/dist/data/index.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/network/HttpClient.d.ts +32 -0
- package/dist/network/HttpClient.js +65 -0
- package/dist/network/HttpClient.js.map +1 -0
- package/dist/network/HttpClientProvider.d.ts +216 -0
- package/dist/network/HttpClientProvider.js +256 -0
- package/dist/network/HttpClientProvider.js.map +1 -0
- package/dist/network/StatusCodes.d.ts +101 -0
- package/dist/network/StatusCodes.js +121 -0
- package/dist/network/StatusCodes.js.map +1 -0
- package/dist/persistence/Persistable.d.ts +9 -0
- package/dist/persistence/Persistable.js +3 -0
- package/dist/persistence/Persistable.js.map +1 -0
- package/dist/persistence/PersistablePseudoMap.d.ts +50 -0
- package/dist/persistence/PersistablePseudoMap.js +62 -0
- package/dist/persistence/PersistablePseudoMap.js.map +1 -0
- package/dist/persistence/PersistenceKeys.d.ts +38 -0
- package/dist/persistence/PersistenceKeys.js +44 -0
- package/dist/persistence/PersistenceKeys.js.map +1 -0
- package/dist/persistence/PrivatePersistanceMap.d.ts +30 -0
- package/dist/persistence/PrivatePersistanceMap.js +67 -0
- package/dist/persistence/PrivatePersistanceMap.js.map +1 -0
- package/dist/persistence/PseudoMap.d.ts +65 -0
- package/dist/persistence/PseudoMap.js +96 -0
- package/dist/persistence/PseudoMap.js.map +1 -0
- package/dist/persistence/PublicPersistanceMap.d.ts +25 -0
- package/dist/persistence/PublicPersistanceMap.js +38 -0
- package/dist/persistence/PublicPersistanceMap.js.map +1 -0
- package/dist/persistence/Serializable.d.ts +40 -0
- package/dist/persistence/Serializable.js +54 -0
- package/dist/persistence/Serializable.js.map +1 -0
- package/dist/persistence/SharedFilePersistence.d.ts +70 -0
- package/dist/persistence/SharedFilePersistence.js +277 -0
- package/dist/persistence/SharedFilePersistence.js.map +1 -0
- package/dist/persistence/TypedMap.d.ts +73 -0
- package/dist/persistence/TypedMap.js +104 -0
- package/dist/persistence/TypedMap.js.map +1 -0
- package/dist/persistence/TypedPersistable.d.ts +36 -0
- package/dist/persistence/TypedPersistable.js +42 -0
- package/dist/persistence/TypedPersistable.js.map +1 -0
- package/dist/persistence/TypedPrivatePersistable.d.ts +124 -0
- package/dist/persistence/TypedPrivatePersistable.js +164 -0
- package/dist/persistence/TypedPrivatePersistable.js.map +1 -0
- package/dist/persistence/dirLockdown.d.ts +12 -0
- package/dist/persistence/dirLockdown.js +73 -0
- package/dist/persistence/dirLockdown.js.map +1 -0
- package/dist/persistence/index.d.ts +11 -0
- package/dist/persistence/index.js +27 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/providers.d.ts +133 -0
- package/dist/providers.js +3 -0
- package/dist/providers.js.map +1 -0
- package/dist/push.d.ts +20 -0
- package/dist/push.js +245 -0
- package/dist/push.js.map +1 -0
- package/dist/script/ScriptContext.d.ts +24 -0
- package/dist/script/ScriptContext.js +3 -0
- package/dist/script/ScriptContext.js.map +1 -0
- package/dist/script/ScriptFactory.d.ts +44 -0
- package/dist/script/ScriptFactory.js +130 -0
- package/dist/script/ScriptFactory.js.map +1 -0
- package/dist/script/ScriptFile.d.ts +62 -0
- package/dist/script/ScriptFile.js +373 -0
- package/dist/script/ScriptFile.js.map +1 -0
- package/dist/script/ScriptFolder.d.ts +43 -0
- package/dist/script/ScriptFolder.js +109 -0
- package/dist/script/ScriptFolder.js.map +1 -0
- package/dist/script/ScriptNode.d.ts +87 -0
- package/dist/script/ScriptNode.js +273 -0
- package/dist/script/ScriptNode.js.map +1 -0
- package/dist/script/ScriptPathElement.d.ts +30 -0
- package/dist/script/ScriptPathElement.js +3 -0
- package/dist/script/ScriptPathElement.js.map +1 -0
- package/dist/script/ScriptRoot.d.ts +61 -0
- package/dist/script/ScriptRoot.js +331 -0
- package/dist/script/ScriptRoot.js.map +1 -0
- package/dist/script/ScriptTranspiler.d.ts +18 -0
- package/dist/script/ScriptTranspiler.js +122 -0
- package/dist/script/ScriptTranspiler.js.map +1 -0
- package/dist/script/SnapshotHistoryRecorder.d.ts +12 -0
- package/dist/script/SnapshotHistoryRecorder.js +175 -0
- package/dist/script/SnapshotHistoryRecorder.js.map +1 -0
- package/dist/script/TsConfig.d.ts +26 -0
- package/dist/script/TsConfig.js +110 -0
- package/dist/script/TsConfig.js.map +1 -0
- package/dist/session/SessionManager.d.ts +77 -0
- package/dist/session/SessionManager.js +290 -0
- package/dist/session/SessionManager.js.map +1 -0
- package/dist/testing/MockFileSystem.d.ts +37 -0
- package/dist/testing/MockFileSystem.js +249 -0
- package/dist/testing/MockFileSystem.js.map +1 -0
- package/dist/testing/TestableFactory.d.ts +61 -0
- package/dist/testing/TestableFactory.js +3 -0
- package/dist/testing/TestableFactory.js.map +1 -0
- package/dist/types.d.ts +577 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/update/UpdateService.d.ts +126 -0
- package/dist/update/UpdateService.js +351 -0
- package/dist/update/UpdateService.js.map +1 -0
- package/dist/update/index.d.ts +2 -0
- package/dist/update/index.js +6 -0
- package/dist/update/index.js.map +1 -0
- package/dist/update/types.d.ts +96 -0
- package/dist/update/types.js +3 -0
- package/dist/update/types.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PseudoMap } from "./PseudoMap";
|
|
2
|
+
import type { Serializable } from "./Serializable";
|
|
3
|
+
/**
|
|
4
|
+
* A typed map that ensures type safety for object property access with string keys.
|
|
5
|
+
* Extends {@link PseudoMap} to provide strongly-typed persistence storage.
|
|
6
|
+
* @lastreviewed 2025-10-01
|
|
7
|
+
*/
|
|
8
|
+
export declare class TypedMap<T extends Record<string, Serializable>> extends PseudoMap<keyof T & string, T[keyof T]> {
|
|
9
|
+
constructor(initialData?: T);
|
|
10
|
+
/**
|
|
11
|
+
* Sets a value for the specified key with type safety.
|
|
12
|
+
* @param key The key to set
|
|
13
|
+
* @param value The value to set
|
|
14
|
+
* @returns This instance for method chaining
|
|
15
|
+
* @lastreviewed 2025-10-01
|
|
16
|
+
*/
|
|
17
|
+
set<K extends keyof T & string>(key: K, value: T[K]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets a value for the specified key with type safety.
|
|
20
|
+
* @param key The key to get
|
|
21
|
+
* @param defaultValue The default value if key doesn't exist
|
|
22
|
+
* @returns The value or default value
|
|
23
|
+
* @lastreviewed 2025-10-01
|
|
24
|
+
*/
|
|
25
|
+
get<K extends keyof T & string>(key: K, defaultValue: T[K]): T[K];
|
|
26
|
+
get<K extends keyof T & string>(key: K): T[K] | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the map has the specified key.
|
|
29
|
+
* @param key The key to check
|
|
30
|
+
* @returns True if the key exists
|
|
31
|
+
* @lastreviewed 2025-10-01
|
|
32
|
+
*/
|
|
33
|
+
has<K extends keyof T>(key: K): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Deletes the specified key from the map.
|
|
36
|
+
* @param key The key to delete
|
|
37
|
+
* @returns This instance for method chaining
|
|
38
|
+
* @lastreviewed 2025-10-01
|
|
39
|
+
*/
|
|
40
|
+
delete<K extends keyof T & string>(key: K): void;
|
|
41
|
+
/**
|
|
42
|
+
* Iterates over all key-value pairs in the map.
|
|
43
|
+
* @param callback Function to call for each key-value pair
|
|
44
|
+
* @lastreviewed 2025-10-01
|
|
45
|
+
*/
|
|
46
|
+
forEach<K extends keyof T>(callback: (value: T[K], key: K, map: this) => void): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns an array of all keys in the map.
|
|
49
|
+
* @lastreviewed 2025-10-01
|
|
50
|
+
*/
|
|
51
|
+
keys(): (keyof T & string)[];
|
|
52
|
+
/**
|
|
53
|
+
* Returns an array of all values in the map.
|
|
54
|
+
* @lastreviewed 2025-10-01
|
|
55
|
+
*/
|
|
56
|
+
values(): T[keyof T][];
|
|
57
|
+
/**
|
|
58
|
+
* @returns An array of [key, value] tuples
|
|
59
|
+
* @lastreviewed 2025-10-01
|
|
60
|
+
*/
|
|
61
|
+
entries(): [keyof T & string, T[keyof T]][];
|
|
62
|
+
/**
|
|
63
|
+
* Returns the number of key-value pairs in the map.
|
|
64
|
+
* @returns The size of the map
|
|
65
|
+
* @lastreviewed 2025-10-01
|
|
66
|
+
*/
|
|
67
|
+
get size(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Removes all key-value pairs from the map.
|
|
70
|
+
* @lastreviewed 2025-10-01
|
|
71
|
+
*/
|
|
72
|
+
clear(): void;
|
|
73
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypedMap = void 0;
|
|
4
|
+
const PseudoMap_1 = require("./PseudoMap");
|
|
5
|
+
const Err_1 = require("../Err");
|
|
6
|
+
/**
|
|
7
|
+
* A typed map that ensures type safety for object property access with string keys.
|
|
8
|
+
* Extends {@link PseudoMap} to provide strongly-typed persistence storage.
|
|
9
|
+
* @lastreviewed 2025-10-01
|
|
10
|
+
*/
|
|
11
|
+
class TypedMap extends PseudoMap_1.PseudoMap {
|
|
12
|
+
constructor(initialData) {
|
|
13
|
+
super();
|
|
14
|
+
if (initialData) {
|
|
15
|
+
this.obj = initialData;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets a value for the specified key with type safety.
|
|
20
|
+
* @param key The key to set
|
|
21
|
+
* @param value The value to set
|
|
22
|
+
* @returns This instance for method chaining
|
|
23
|
+
* @lastreviewed 2025-10-01
|
|
24
|
+
*/
|
|
25
|
+
set(key, value) {
|
|
26
|
+
this.obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
get(key, defaultValue) {
|
|
29
|
+
const value = this.obj[key];
|
|
30
|
+
return value !== undefined ? value : defaultValue;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the map has the specified key.
|
|
34
|
+
* @param key The key to check
|
|
35
|
+
* @returns True if the key exists
|
|
36
|
+
* @lastreviewed 2025-10-01
|
|
37
|
+
*/
|
|
38
|
+
has(key) {
|
|
39
|
+
return key in this.obj;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Deletes the specified key from the map.
|
|
43
|
+
* @param key The key to delete
|
|
44
|
+
* @returns This instance for method chaining
|
|
45
|
+
* @lastreviewed 2025-10-01
|
|
46
|
+
*/
|
|
47
|
+
delete(key) {
|
|
48
|
+
if (key in this.obj) {
|
|
49
|
+
delete this.obj[key];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
throw new Err_1.Err.KeyNotFoundInMapError(key);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Iterates over all key-value pairs in the map.
|
|
57
|
+
* @param callback Function to call for each key-value pair
|
|
58
|
+
* @lastreviewed 2025-10-01
|
|
59
|
+
*/
|
|
60
|
+
forEach(callback) {
|
|
61
|
+
for (const k in this.obj) {
|
|
62
|
+
const value = this.obj[k];
|
|
63
|
+
callback(value, k, this);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns an array of all keys in the map.
|
|
68
|
+
* @lastreviewed 2025-10-01
|
|
69
|
+
*/
|
|
70
|
+
keys() {
|
|
71
|
+
return Object.keys(this.obj);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns an array of all values in the map.
|
|
75
|
+
* @lastreviewed 2025-10-01
|
|
76
|
+
*/
|
|
77
|
+
values() {
|
|
78
|
+
return Object.values(this.obj).filter((v) => v !== undefined);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @returns An array of [key, value] tuples
|
|
82
|
+
* @lastreviewed 2025-10-01
|
|
83
|
+
*/
|
|
84
|
+
entries() {
|
|
85
|
+
return this.keys().map((key) => [key, this.obj[key]]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the number of key-value pairs in the map.
|
|
89
|
+
* @returns The size of the map
|
|
90
|
+
* @lastreviewed 2025-10-01
|
|
91
|
+
*/
|
|
92
|
+
get size() {
|
|
93
|
+
return this.keys().length;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Removes all key-value pairs from the map.
|
|
97
|
+
* @lastreviewed 2025-10-01
|
|
98
|
+
*/
|
|
99
|
+
clear() {
|
|
100
|
+
Object.keys(this.obj).forEach((key) => delete this.obj[key]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.TypedMap = TypedMap;
|
|
104
|
+
//# sourceMappingURL=TypedMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedMap.js","sourceRoot":"","sources":["../../src/persistence/TypedMap.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,gCAA6B;AAE7B;;;;GAIG;AACH,MAAa,QAAiD,SAAQ,qBAAuC;IAC3G,YAAY,WAAe;QACzB,KAAK,EAAE,CAAC;QACR,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACa,GAAG,CAA6B,GAAM,EAAE,KAAW;QACjE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC;IAWe,GAAG,CAA6B,GAAM,EAAE,YAAmB;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAE,KAAc,CAAC,CAAC,CAAC,YAAY,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACa,GAAG,CAAoB,GAAM;QAC3C,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACa,MAAM,CAA6B,GAAM;QACvD,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,SAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACa,OAAO,CAAoB,QAAkD;QAC3F,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1B,QAAQ,CAAC,KAAwB,EAAE,CAAiB,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED;;;OAGG;IACa,IAAI;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAyB,CAAC;IACvD,CAAC;IAED;;;OAGG;IACa,MAAM;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAiB,CAAC;IAChF,CAAC;IAED;;;OAGG;IACa,OAAO;QACrB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACa,KAAK;QACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;CACF;AA7GD,4BA6GC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IPersistence } from "../providers";
|
|
2
|
+
import { TypedMap } from "./TypedMap";
|
|
3
|
+
import { Persistable } from "./Persistable";
|
|
4
|
+
import { PrivateKeys, PublicKeys } from "./PersistenceKeys";
|
|
5
|
+
import type { Serializable } from "./Serializable";
|
|
6
|
+
/**
|
|
7
|
+
* A persistable version of {@link TypedMap} that automatically handles loading and storing
|
|
8
|
+
* using the IPersistence interface.
|
|
9
|
+
* @lastreviewed 2025-10-01
|
|
10
|
+
*/
|
|
11
|
+
export declare class TypedPersistable<T extends Record<string, Serializable>> extends TypedMap<T> implements Persistable {
|
|
12
|
+
readonly key: PublicKeys | PrivateKeys;
|
|
13
|
+
protected persistence: IPersistence;
|
|
14
|
+
protected initialized: boolean;
|
|
15
|
+
constructor({ key, persistence, defaultValue, }: {
|
|
16
|
+
key: PublicKeys | PrivateKeys;
|
|
17
|
+
persistence: IPersistence;
|
|
18
|
+
defaultValue: T;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the map has finished initializing.
|
|
22
|
+
*/
|
|
23
|
+
isInitialized(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Sets a value with type safety and automatic persistence.
|
|
26
|
+
* @param key The key to set
|
|
27
|
+
* @param value The value to set
|
|
28
|
+
* @param update Whether to immediately store the updated map. This is primarily intended to allow you to await store() after multiple sets
|
|
29
|
+
* so it doesn't get called multiple times in a row.
|
|
30
|
+
* @returns This instance for chaining
|
|
31
|
+
* @lastreviewed 2025-10-01
|
|
32
|
+
*/
|
|
33
|
+
set<K extends keyof T & string>(key: K, value: T[K]): Promise<void>;
|
|
34
|
+
toJSON(): string;
|
|
35
|
+
store(): PromiseLike<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypedPersistable = void 0;
|
|
4
|
+
const TypedMap_1 = require("./TypedMap");
|
|
5
|
+
const Serializable_1 = require("./Serializable");
|
|
6
|
+
/**
|
|
7
|
+
* A persistable version of {@link TypedMap} that automatically handles loading and storing
|
|
8
|
+
* using the IPersistence interface.
|
|
9
|
+
* @lastreviewed 2025-10-01
|
|
10
|
+
*/
|
|
11
|
+
class TypedPersistable extends TypedMap_1.TypedMap {
|
|
12
|
+
key;
|
|
13
|
+
persistence;
|
|
14
|
+
initialized = false;
|
|
15
|
+
constructor({ key, persistence, defaultValue, }) {
|
|
16
|
+
super();
|
|
17
|
+
this.key = key;
|
|
18
|
+
this.persistence = persistence;
|
|
19
|
+
this.persistence.get(this.key).then((data) => {
|
|
20
|
+
this.obj = (0, Serializable_1.revive)(data || defaultValue);
|
|
21
|
+
this.initialized = true;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the map has finished initializing.
|
|
26
|
+
*/
|
|
27
|
+
isInitialized() {
|
|
28
|
+
return this.initialized;
|
|
29
|
+
}
|
|
30
|
+
async set(key, value, update = true) {
|
|
31
|
+
super.set(key, value);
|
|
32
|
+
update && this.store();
|
|
33
|
+
}
|
|
34
|
+
toJSON() {
|
|
35
|
+
return JSON.stringify(this.obj);
|
|
36
|
+
}
|
|
37
|
+
store() {
|
|
38
|
+
return this.persistence.set(this.key, JSON.stringify(this.obj));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.TypedPersistable = TypedPersistable;
|
|
42
|
+
//# sourceMappingURL=TypedPersistable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedPersistable.js","sourceRoot":"","sources":["../../src/persistence/TypedPersistable.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AAItC,iDAAwC;AAExC;;;;GAIG;AACH,MAAa,gBAAyD,SAAQ,mBAAW;IACvE,GAAG,CAA2B;IACpC,WAAW,CAAe;IAC1B,WAAW,GAAY,KAAK,CAAC;IAEvC,YAAY,EACV,GAAG,EACH,WAAW,EACX,YAAY,GAKb;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAI,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAC9C,IAAI,CAAC,GAAG,GAAG,IAAA,qBAAM,EAAC,IAAI,IAAI,YAAY,CAAC,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAYQ,KAAK,CAAC,GAAG,CAA6B,GAAM,EAAE,KAAW,EAAE,SAAkB,IAAI;QACxF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AApDD,4CAoDC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { IPersistence } from "../providers";
|
|
2
|
+
import { PrivateKeys } from "./PersistenceKeys";
|
|
3
|
+
import type { Serializable } from "./Serializable";
|
|
4
|
+
import { TypedPersistable } from "./TypedPersistable";
|
|
5
|
+
/**
|
|
6
|
+
* A typed private persistable pseudomap that uses IPersistence secret storage.
|
|
7
|
+
*
|
|
8
|
+
* Extends TypedPersistable to provide secure storage for sensitive data
|
|
9
|
+
* such as credentials, tokens, and other private information that should
|
|
10
|
+
* not be stored in workspace state.
|
|
11
|
+
*
|
|
12
|
+
* @template T The type of the object being persisted
|
|
13
|
+
* @lastreviewed 2025-10-01
|
|
14
|
+
*/
|
|
15
|
+
export declare class PrivateTypedPersistable<T extends Record<string, Serializable>> extends TypedPersistable<T> {
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for {@link PrivateTypedPersistable}.
|
|
18
|
+
*
|
|
19
|
+
* @param key The private persistence key for secret storage
|
|
20
|
+
* @param persistence The persistence provider
|
|
21
|
+
* @param defaultValue The default value if no stored data exists
|
|
22
|
+
* @lastreviewed 2025-10-01
|
|
23
|
+
*/
|
|
24
|
+
constructor({ key, persistence, defaultValue }: {
|
|
25
|
+
key: PrivateKeys;
|
|
26
|
+
persistence: IPersistence;
|
|
27
|
+
defaultValue: T;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Type guard that ensures the map is fully initialized.
|
|
31
|
+
*
|
|
32
|
+
* Throws an error if not initialized. While this doesn't provide compile-time
|
|
33
|
+
* type narrowing, it ensures runtime safety for all map operations.
|
|
34
|
+
*
|
|
35
|
+
* @throws an {@link Err.PersistenceNotInitializedError} if the map is not fully initialized
|
|
36
|
+
* @lastreviewed 2025-10-01
|
|
37
|
+
*/
|
|
38
|
+
private checkIsInitialized;
|
|
39
|
+
/**
|
|
40
|
+
* Sets a value with type safety and automatic persistence.
|
|
41
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
42
|
+
* @param key The key to set
|
|
43
|
+
* @param value The value to set
|
|
44
|
+
* @param update Whether to immediately store the updated map
|
|
45
|
+
* @returns This instance for chaining
|
|
46
|
+
* @lastreviewed 2025-10-01
|
|
47
|
+
*/
|
|
48
|
+
set<K extends keyof T & string>(key: K, value: T[K]): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets a value for the specified key with type safety.
|
|
51
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
52
|
+
* @param key The key to get
|
|
53
|
+
* @param defaultValue The default value if key doesn't exist
|
|
54
|
+
* @returns The value or default value
|
|
55
|
+
* @lastreviewed 2025-10-01
|
|
56
|
+
*/
|
|
57
|
+
get<K extends keyof T & string>(key: K, defaultValue: T[K]): T[K];
|
|
58
|
+
get<K extends keyof T & string>(key: K): T[K] | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if the map has the specified key.
|
|
61
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
62
|
+
* @param key The key to check
|
|
63
|
+
* @returns True if the key exists
|
|
64
|
+
* @lastreviewed 2025-10-01
|
|
65
|
+
*/
|
|
66
|
+
has<K extends keyof T>(key: K): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Deletes the specified key from the map.
|
|
69
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
70
|
+
* @param key The key to delete
|
|
71
|
+
* @returns This instance for method chaining
|
|
72
|
+
* @lastreviewed 2025-10-01
|
|
73
|
+
*/
|
|
74
|
+
delete<K extends keyof T & string>(key: K): void;
|
|
75
|
+
/**
|
|
76
|
+
* Iterates over all key-value pairs in the map.
|
|
77
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
78
|
+
* @param callback Function to call for each key-value pair
|
|
79
|
+
* @lastreviewed 2025-10-01
|
|
80
|
+
*/
|
|
81
|
+
forEach<K extends keyof T>(callback: (value: T[K], key: K, map: this) => void): void;
|
|
82
|
+
/**
|
|
83
|
+
* Returns an array of all keys in the map.
|
|
84
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
85
|
+
* @lastreviewed 2025-10-01
|
|
86
|
+
*/
|
|
87
|
+
keys(): (keyof T & string)[];
|
|
88
|
+
/**
|
|
89
|
+
* Returns an array of all values in the map.
|
|
90
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
91
|
+
* @lastreviewed 2025-10-01
|
|
92
|
+
*/
|
|
93
|
+
values(): T[keyof T][];
|
|
94
|
+
/**
|
|
95
|
+
* Returns an array of all key-value pairs.
|
|
96
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
97
|
+
* @lastreviewed 2025-10-01
|
|
98
|
+
*/
|
|
99
|
+
entries(): [keyof T & string, T[keyof T]][];
|
|
100
|
+
/**
|
|
101
|
+
* Returns the number of key-value pairs in the map.
|
|
102
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
103
|
+
* @lastreviewed 2025-10-01
|
|
104
|
+
*/
|
|
105
|
+
get size(): number;
|
|
106
|
+
/**
|
|
107
|
+
* Removes all key-value pairs from the map.
|
|
108
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
109
|
+
* @lastreviewed 2025-10-01
|
|
110
|
+
*/
|
|
111
|
+
clear(): void;
|
|
112
|
+
/**
|
|
113
|
+
* Converts the map to a JSON string.
|
|
114
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
115
|
+
* @lastreviewed 2025-10-01
|
|
116
|
+
*/
|
|
117
|
+
toJSON(): string;
|
|
118
|
+
/**
|
|
119
|
+
* Stores the current state using the persistence provider's secret storage.
|
|
120
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
121
|
+
* @lastreviewed 2025-10-01
|
|
122
|
+
*/
|
|
123
|
+
store(): PromiseLike<void>;
|
|
124
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivateTypedPersistable = void 0;
|
|
4
|
+
const Serializable_1 = require("./Serializable");
|
|
5
|
+
const TypedPersistable_1 = require("./TypedPersistable");
|
|
6
|
+
const Err_1 = require("../Err");
|
|
7
|
+
/**
|
|
8
|
+
* A typed private persistable pseudomap that uses IPersistence secret storage.
|
|
9
|
+
*
|
|
10
|
+
* Extends TypedPersistable to provide secure storage for sensitive data
|
|
11
|
+
* such as credentials, tokens, and other private information that should
|
|
12
|
+
* not be stored in workspace state.
|
|
13
|
+
*
|
|
14
|
+
* @template T The type of the object being persisted
|
|
15
|
+
* @lastreviewed 2025-10-01
|
|
16
|
+
*/
|
|
17
|
+
class PrivateTypedPersistable extends TypedPersistable_1.TypedPersistable {
|
|
18
|
+
/**
|
|
19
|
+
* Constructor for {@link PrivateTypedPersistable}.
|
|
20
|
+
*
|
|
21
|
+
* @param key The private persistence key for secret storage
|
|
22
|
+
* @param persistence The persistence provider
|
|
23
|
+
* @param defaultValue The default value if no stored data exists
|
|
24
|
+
* @lastreviewed 2025-10-01
|
|
25
|
+
*/
|
|
26
|
+
constructor({ key, persistence, defaultValue }) {
|
|
27
|
+
// Call super with persistence
|
|
28
|
+
super({ key, persistence, defaultValue });
|
|
29
|
+
this.persistence.getSecret(this.key).then((jsonString) => {
|
|
30
|
+
this.obj = (0, Serializable_1.revive)(JSON.parse(jsonString || "{}"));
|
|
31
|
+
this.initialized = true;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type guard that ensures the map is fully initialized.
|
|
36
|
+
*
|
|
37
|
+
* Throws an error if not initialized. While this doesn't provide compile-time
|
|
38
|
+
* type narrowing, it ensures runtime safety for all map operations.
|
|
39
|
+
*
|
|
40
|
+
* @throws an {@link Err.PersistenceNotInitializedError} if the map is not fully initialized
|
|
41
|
+
* @lastreviewed 2025-10-01
|
|
42
|
+
*/
|
|
43
|
+
checkIsInitialized() {
|
|
44
|
+
if (!this.isInitialized()) {
|
|
45
|
+
throw new Err_1.Err.PersistenceNotInitializedError("PrivateTypedPersistable", this.key);
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets a value with type safety and automatic persistence.
|
|
51
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
52
|
+
* @param key The key to set
|
|
53
|
+
* @param value The value to set
|
|
54
|
+
* @param update Whether to immediately store the updated map
|
|
55
|
+
* @returns This instance for chaining
|
|
56
|
+
* @lastreviewed 2025-10-01
|
|
57
|
+
*/
|
|
58
|
+
async set(key, value) {
|
|
59
|
+
this.checkIsInitialized();
|
|
60
|
+
await super.set(key, value);
|
|
61
|
+
await this.store();
|
|
62
|
+
}
|
|
63
|
+
get(key, defaultValue) {
|
|
64
|
+
this.checkIsInitialized();
|
|
65
|
+
return defaultValue !== undefined ? super.get(key, defaultValue) : super.get(key);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Checks if the map has the specified key.
|
|
69
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
70
|
+
* @param key The key to check
|
|
71
|
+
* @returns True if the key exists
|
|
72
|
+
* @lastreviewed 2025-10-01
|
|
73
|
+
*/
|
|
74
|
+
has(key) {
|
|
75
|
+
this.checkIsInitialized();
|
|
76
|
+
return super.has(key);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Deletes the specified key from the map.
|
|
80
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
81
|
+
* @param key The key to delete
|
|
82
|
+
* @returns This instance for method chaining
|
|
83
|
+
* @lastreviewed 2025-10-01
|
|
84
|
+
*/
|
|
85
|
+
delete(key) {
|
|
86
|
+
this.checkIsInitialized();
|
|
87
|
+
return super.delete(key);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Iterates over all key-value pairs in the map.
|
|
91
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
92
|
+
* @param callback Function to call for each key-value pair
|
|
93
|
+
* @lastreviewed 2025-10-01
|
|
94
|
+
*/
|
|
95
|
+
forEach(callback) {
|
|
96
|
+
this.checkIsInitialized();
|
|
97
|
+
super.forEach(callback);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns an array of all keys in the map.
|
|
101
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
102
|
+
* @lastreviewed 2025-10-01
|
|
103
|
+
*/
|
|
104
|
+
keys() {
|
|
105
|
+
this.checkIsInitialized();
|
|
106
|
+
return super.keys();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns an array of all values in the map.
|
|
110
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
111
|
+
* @lastreviewed 2025-10-01
|
|
112
|
+
*/
|
|
113
|
+
values() {
|
|
114
|
+
this.checkIsInitialized();
|
|
115
|
+
return super.values();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns an array of all key-value pairs.
|
|
119
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
120
|
+
* @lastreviewed 2025-10-01
|
|
121
|
+
*/
|
|
122
|
+
entries() {
|
|
123
|
+
this.checkIsInitialized();
|
|
124
|
+
return super.entries();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Returns the number of key-value pairs in the map.
|
|
128
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
129
|
+
* @lastreviewed 2025-10-01
|
|
130
|
+
*/
|
|
131
|
+
get size() {
|
|
132
|
+
this.checkIsInitialized();
|
|
133
|
+
return super.size;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Removes all key-value pairs from the map.
|
|
137
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
138
|
+
* @lastreviewed 2025-10-01
|
|
139
|
+
*/
|
|
140
|
+
clear() {
|
|
141
|
+
this.checkIsInitialized();
|
|
142
|
+
super.clear();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Converts the map to a JSON string.
|
|
146
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
147
|
+
* @lastreviewed 2025-10-01
|
|
148
|
+
*/
|
|
149
|
+
toJSON() {
|
|
150
|
+
this.checkIsInitialized();
|
|
151
|
+
return super.toJSON();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Stores the current state using the persistence provider's secret storage.
|
|
155
|
+
* Ensures the map is fully initialized before delegating to parent implementation.
|
|
156
|
+
* @lastreviewed 2025-10-01
|
|
157
|
+
*/
|
|
158
|
+
store() {
|
|
159
|
+
this.checkIsInitialized();
|
|
160
|
+
return this.persistence.setSecret(this.key, JSON.stringify(this.obj));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.PrivateTypedPersistable = PrivateTypedPersistable;
|
|
164
|
+
//# sourceMappingURL=TypedPrivatePersistable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedPrivatePersistable.js","sourceRoot":"","sources":["../../src/persistence/TypedPrivatePersistable.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restrict a directory so only the current OS user can read/write/list it.
|
|
3
|
+
*
|
|
4
|
+
* - POSIX: `chmod 700`.
|
|
5
|
+
* - Windows: `icacls` with inheritance disabled and a single grant to the
|
|
6
|
+
* current user. `icacls` ships with Windows Vista and later, no install
|
|
7
|
+
* required. Failure to lock down is logged but not fatal — the directory
|
|
8
|
+
* still functions, just without the access restriction.
|
|
9
|
+
*
|
|
10
|
+
* The directory must already exist.
|
|
11
|
+
*/
|
|
12
|
+
export declare function lockdownDir(dir: string): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.lockdownDir = lockdownDir;
|
|
37
|
+
const child_process_1 = require("child_process");
|
|
38
|
+
const fs = __importStar(require("fs/promises"));
|
|
39
|
+
const util_1 = require("util");
|
|
40
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
41
|
+
/**
|
|
42
|
+
* Restrict a directory so only the current OS user can read/write/list it.
|
|
43
|
+
*
|
|
44
|
+
* - POSIX: `chmod 700`.
|
|
45
|
+
* - Windows: `icacls` with inheritance disabled and a single grant to the
|
|
46
|
+
* current user. `icacls` ships with Windows Vista and later, no install
|
|
47
|
+
* required. Failure to lock down is logged but not fatal — the directory
|
|
48
|
+
* still functions, just without the access restriction.
|
|
49
|
+
*
|
|
50
|
+
* The directory must already exist.
|
|
51
|
+
*/
|
|
52
|
+
async function lockdownDir(dir) {
|
|
53
|
+
if (process.platform === "win32") {
|
|
54
|
+
const user = process.env.USERNAME || process.env.USER;
|
|
55
|
+
if (!user) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
await execFileAsync("icacls", [dir, "/inheritance:r", "/grant:r", `${user}:(OI)(CI)F`]);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Best-effort: if icacls is missing or fails, leave the directory alone.
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
await fs.chmod(dir, 0o700);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Best-effort.
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=dirLockdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dirLockdown.js","sourceRoot":"","sources":["../../src/persistence/dirLockdown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,kCAmBC;AApCD,iDAAyC;AACzC,gDAAkC;AAClC,+BAAiC;AAEjC,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACtD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC;QAC1F,CAAC;QAAC,MAAM,CAAC;YACP,yEAAyE;QAC3E,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PseudoMap } from "./PseudoMap";
|
|
2
|
+
export { TypedMap } from "./TypedMap";
|
|
3
|
+
export { Persistable } from "./Persistable";
|
|
4
|
+
export type { SerializableClass, Serializable } from "./Serializable";
|
|
5
|
+
export { registerSerializable, revive } from "./Serializable";
|
|
6
|
+
export { PrivateKeys, PublicKeys } from "./PersistenceKeys";
|
|
7
|
+
export { PersistablePseudoMap } from "./PersistablePseudoMap";
|
|
8
|
+
export { PublicPersistanceMap } from "./PublicPersistanceMap";
|
|
9
|
+
export { PrivateGenericMap } from "./PrivatePersistanceMap";
|
|
10
|
+
export { TypedPersistable } from "./TypedPersistable";
|
|
11
|
+
export { PrivateTypedPersistable } from "./TypedPrivatePersistable";
|