Build the SecureString for an inline key on Windows too

The vault is written with ConvertFrom-SecureString -SecureString, so the
inline branch has to produce a SecureString as well - it only set the
plain text, and under Set-StrictMode the vault write then failed with
'the variable $secure cannot be retrieved'. Caught by running the new
form on the Windows box rather than assuming it.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
smoido
2026-09-13 00:00:46 +03:00
co-authored by Claude Code
parent 5bf5a6d36e
commit f776ce099e
+3
View File
@@ -380,6 +380,9 @@ function Set-VaultKey {
if ($Key) {
Write-Warn2 'the key was given on the command line, so it is in this shell history - the hidden prompt leaves no trace'
$plain = $Key
# The vault is written from a SecureString (DPAPI), so the inline form
# has to produce one too.
$secure = ConvertTo-SecureString -String $Key -AsPlainText -Force
} else {
Write-Host "Paste the API key for ref '$Ref' (input hidden):"
$secure = Read-Host -AsSecureString