(dataDir: string, token: string)
| 47 | }; |
| 48 | |
| 49 | const writeToken = (dataDir: string, token: string): string => { |
| 50 | const dir = serverControlDir(dataDir); |
| 51 | mkdirSync(dir, { recursive: true }); |
| 52 | const path = join(dir, "auth.json"); |
| 53 | // `mode` only applies when the file is created; chmod afterwards covers the |
| 54 | // case where an older world-readable file already exists. |
| 55 | writeFileSync(path, `${JSON.stringify({ token }, null, 2)}\n`, { mode: 0o600 }); |
| 56 | chmodSync(path, 0o600); |
| 57 | return token; |
| 58 | }; |
| 59 | |
| 60 | /** |
| 61 | * Return the stable local bearer token, minting and persisting one on first |
no test coverage detected