Keep a token where this store keeps tokens; false when it was refused.
(connection, token)
| 198 | |
| 199 | /** Keep a token where this store keeps tokens; false when it was refused. */ |
| 200 | function storeToken(connection, token) { |
| 201 | memoryTokens.set(connection.id, token); |
| 202 | if (!secrets) { |
| 203 | connection.token = encrypt(token); |
| 204 | return true; |
| 205 | } |
| 206 | try { |
| 207 | secrets.write( |
| 208 | secretAccountFor(connection.id), |
| 209 | JSON.stringify({ v: SECRET_VERSION, kind: connection.kind, token }), |
| 210 | ); |
| 211 | return true; |
| 212 | } catch (error) { |
| 213 | // Usable for this run; the UI says it was not saved. |
| 214 | log(error instanceof Error ? error.message : String(error)); |
| 215 | return false; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | function forgetToken(id) { |
| 220 | memoryTokens.delete(id); |