(config: Config)
| 13 | }; |
| 14 | |
| 15 | export function readCredentials(config: Config): Credentials | null { |
| 16 | try { |
| 17 | const raw = readFileSync(config.credentialPath, 'utf-8'); |
| 18 | const parsed = JSON.parse(raw) as { token: string; secret: string }; |
| 19 | if (!parsed.token || !parsed.secret) return null; |
| 20 | const secret = decodeBase64(parsed.secret); |
| 21 | const contentKeyPair = deriveContentKeyPair(secret); |
| 22 | return { |
| 23 | token: parsed.token, |
| 24 | secret, |
| 25 | contentKeyPair, |
| 26 | }; |
| 27 | } catch { |
| 28 | return null; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | export function writeCredentials(config: Config, token: string, secret: Uint8Array): void { |
| 33 | mkdirSync(dirname(config.credentialPath), { recursive: true, mode: 0o700 }); |
no test coverage detected