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.
- package/package.json +1 -1
- package/src/routerlab.js +27 -14
package/package.json
CHANGED
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,
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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 $
|
|
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
|
-
|
|
445
|
-
|
|
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
|
-
|
|
528
|
+
env: {
|
|
529
|
+
SCIONOS_TOKEN_FILE: tokenFile,
|
|
530
|
+
},
|
|
518
531
|
},
|
|
519
532
|
);
|
|
520
533
|
return token || null;
|