@nowcrew/daemon 0.5.49 → 0.5.50
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/dist/computer-profile.js +9 -4
- package/package.json +1 -1
package/dist/computer-profile.js
CHANGED
|
@@ -131,8 +131,13 @@ export function validateProfileName(name) {
|
|
|
131
131
|
export function profilePath(name, home = daemonHome()) {
|
|
132
132
|
return resolve(home, "profiles", `${validateProfileName(name)}.json`);
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
const
|
|
134
|
+
const POWERSHELL_SECURITY_ASSEMBLY = "[void](Add-Type -AssemblyName System.Security);";
|
|
135
|
+
const DPAPI_PROTECT = `${POWERSHELL_SECURITY_ASSEMBLY}$p=[Console]::In.ReadToEnd();$b=[Text.Encoding]::UTF8.GetBytes($p);$e=[Security.Cryptography.ProtectedData]::Protect($b,$null,[Security.Cryptography.DataProtectionScope]::CurrentUser);[Convert]::ToBase64String($e)`;
|
|
136
|
+
const DPAPI_UNPROTECT = `${POWERSHELL_SECURITY_ASSEMBLY}$p=[Console]::In.ReadToEnd();$b=[Convert]::FromBase64String($p);$d=[Security.Cryptography.ProtectedData]::Unprotect($b,$null,[Security.Cryptography.DataProtectionScope]::CurrentUser);[Console]::Out.Write([Text.Encoding]::UTF8.GetString($d))`;
|
|
137
|
+
export const windowsDpapiScripts = {
|
|
138
|
+
protect: DPAPI_PROTECT,
|
|
139
|
+
unprotect: DPAPI_UNPROTECT,
|
|
140
|
+
};
|
|
136
141
|
async function powershellStdin(script, input) {
|
|
137
142
|
return new Promise((resolvePromise, reject) => {
|
|
138
143
|
const child = spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
@@ -155,8 +160,8 @@ async function powershellStdin(script, input) {
|
|
|
155
160
|
});
|
|
156
161
|
}
|
|
157
162
|
export const windowsDpapiProtector = {
|
|
158
|
-
protect: (plaintext) => powershellStdin(
|
|
159
|
-
unprotect: (ciphertext) => powershellStdin(
|
|
163
|
+
protect: (plaintext) => powershellStdin(windowsDpapiScripts.protect, plaintext),
|
|
164
|
+
unprotect: (ciphertext) => powershellStdin(windowsDpapiScripts.unprotect, ciphertext),
|
|
160
165
|
};
|
|
161
166
|
function storageOptions(options) {
|
|
162
167
|
const platform = options.platform ?? process.platform;
|