@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.
@@ -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 DPAPI_PROTECT = "$p=[Console]::In.ReadToEnd();$b=[Text.Encoding]::UTF8.GetBytes($p);$e=[Security.Cryptography.ProtectedData]::Protect($b,$null,[Security.Cryptography.DataProtectionScope]::CurrentUser);[Convert]::ToBase64String($e)";
135
- const DPAPI_UNPROTECT = "$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))";
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(DPAPI_PROTECT, plaintext),
159
- unprotect: (ciphertext) => powershellStdin(DPAPI_UNPROTECT, ciphertext),
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nowcrew/daemon",
3
- "version": "0.5.49",
3
+ "version": "0.5.50",
4
4
  "type": "module",
5
5
  "description": "crew daemon — 运行在用户机器:拉起/管理 agent 进程,注入 crew CLI,归一化 runtime 事件",
6
6
  "license": "Apache-2.0",