(connection)
| 181 | } |
| 182 | |
| 183 | function decrypt(connection) { |
| 184 | const cached = memoryTokens.get(connection.id); |
| 185 | if (cached !== undefined) return cached; |
| 186 | if (!canEncrypt || !connection.token) return null; |
| 187 | try { |
| 188 | const token = safeStorage.decryptString( |
| 189 | Buffer.from(connection.token, "base64"), |
| 190 | ); |
| 191 | memoryTokens.set(connection.id, token); |
| 192 | return token; |
| 193 | } catch { |
| 194 | // Keychain rotated or the profile moved between machines. |
| 195 | return null; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | /** Keep a token where this store keeps tokens; false when it was refused. */ |
| 200 | function storeToken(connection, token) { |
no test coverage detected