(id: string, secret: string | null)
| 103 | } |
| 104 | |
| 105 | export async function setRemoteWorkspaceSecret(id: string, secret: string | null): Promise<boolean> { |
| 106 | const normalizedId = id.trim() |
| 107 | if (!normalizedId) return false |
| 108 | |
| 109 | const keytar = await loadKeytar() |
| 110 | if (keytar) { |
| 111 | if (secret && secret.trim()) { |
| 112 | await keytar.setPassword(KEYTAR_SERVICE, accountName(normalizedId), secret.trim()) |
| 113 | } else { |
| 114 | await keytar.deletePassword(KEYTAR_SERVICE, accountName(normalizedId)) |
| 115 | } |
| 116 | return Boolean(secret && secret.trim()) |
| 117 | } |
| 118 | |
| 119 | const fallback = await loadFallbackSecrets() |
| 120 | if (secret && secret.trim()) { |
| 121 | const encoded = encodeSecret(secret.trim()) |
| 122 | if (!encoded) return false |
| 123 | fallback[normalizedId] = encoded |
| 124 | } else { |
| 125 | delete fallback[normalizedId] |
| 126 | } |
| 127 | await saveFallbackSecrets(fallback) |
| 128 | return Boolean(secret && secret.trim()) |
| 129 | } |
| 130 | |
| 131 | export async function deleteRemoteWorkspaceSecret(id: string): Promise<void> { |
| 132 | const normalizedId = id.trim() |
no test coverage detected