claude-scionos 4.1.5 → 4.1.7

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/routerlab.js +27 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-scionos",
3
- "version": "4.1.5",
3
+ "version": "4.1.7",
4
4
  "description": "RouterLab launcher, strategy proxy and secure token wrapper for Claude Code CLI",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/routerlab.js CHANGED
@@ -207,6 +207,10 @@ function hasNonEmptyWindowsTokenFile(tokenFile) {
207
207
  }
208
208
  }
209
209
 
210
+ function encodeTokenForPowerShell(token) {
211
+ return Buffer.from(token, 'utf8').toString('base64');
212
+ }
213
+
210
214
  function getServiceStrategies(serviceValue = DEFAULT_SERVICE) {
211
215
  const service = getServiceConfig(serviceValue);
212
216
  if (!service?.strategyValues?.length) {
@@ -386,16 +390,21 @@ function commandExists(command) {
386
390
  return !result.error;
387
391
  }
388
392
 
389
- function runPowerShell(command, env = {}) {
390
- const powershell = process.env.SystemRoot
391
- ? path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
392
- : 'powershell.exe';
393
-
394
- const result = spawnSync(powershell, ['-NoProfile', '-NonInteractive', '-Command', command], {
395
- encoding: 'utf8',
396
- env: {
397
- ...process.env,
398
- ...env,
393
+ function runPowerShell(command, options = {}) {
394
+ const {
395
+ env = {},
396
+ input,
397
+ } = options;
398
+ const powershell = process.env.SystemRoot
399
+ ? path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')
400
+ : 'powershell.exe';
401
+
402
+ const result = spawnSync(powershell, ['-NoProfile', '-NonInteractive', '-Command', command], {
403
+ encoding: 'utf8',
404
+ input,
405
+ env: {
406
+ ...process.env,
407
+ ...env,
399
408
  },
400
409
  });
401
410
 
@@ -437,12 +446,14 @@ function storeToken(token, serviceValue = DEFAULT_SERVICE) {
437
446
 
438
447
  if (process.platform === 'win32') {
439
448
  const tokenFile = getWindowsTokenFile(service.value);
449
+ const encodedToken = encodeTokenForPowerShell(token);
440
450
  fs.mkdirSync(path.dirname(tokenFile), {recursive: true});
441
451
  runPowerShell(
442
- '$secure = ConvertTo-SecureString $env:SCIONOS_TOKEN -AsPlainText -Force; $encrypted = ConvertFrom-SecureString $secure; Set-Content -Path $env:SCIONOS_TOKEN_FILE -Value $encrypted -NoNewline',
452
+ `$token = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedToken}')); if ([string]::IsNullOrEmpty($token)) { throw "Token input is empty" }; $secure = ConvertTo-SecureString $token -AsPlainText -Force; $encrypted = ConvertFrom-SecureString $secure; Set-Content -Path $env:SCIONOS_TOKEN_FILE -Value $encrypted -NoNewline`,
443
453
  {
444
- SCIONOS_TOKEN: token,
445
- SCIONOS_TOKEN_FILE: tokenFile,
454
+ env: {
455
+ SCIONOS_TOKEN_FILE: tokenFile,
456
+ },
446
457
  },
447
458
  );
448
459
 
@@ -514,7 +525,9 @@ function getStoredToken(serviceValue = DEFAULT_SERVICE) {
514
525
  const token = runPowerShell(
515
526
  '$secure = Get-Content -Path $env:SCIONOS_TOKEN_FILE -Raw | ConvertTo-SecureString; $ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure); try { [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ptr) } finally { [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) }',
516
527
  {
517
- SCIONOS_TOKEN_FILE: tokenFile,
528
+ env: {
529
+ SCIONOS_TOKEN_FILE: tokenFile,
530
+ },
518
531
  },
519
532
  );
520
533
  return token || null;