(token: string, options?: { userId?: string; orgId?: string })
| 13 | } |
| 14 | |
| 15 | export async function saveToken(token: string, options?: { userId?: string; orgId?: string }): Promise<void> { |
| 16 | await fs.mkdir(getConfigDir(), { recursive: true }) |
| 17 | |
| 18 | const credentials: Credentials = { |
| 19 | token, |
| 20 | createdAt: new Date().toISOString(), |
| 21 | userId: options?.userId, |
| 22 | orgId: options?.orgId, |
| 23 | } |
| 24 | |
| 25 | await fs.writeFile(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2), { |
| 26 | mode: 0o600, // Read/write for owner only |
| 27 | }) |
| 28 | } |
| 29 | |
| 30 | export async function loadToken(): Promise<string | null> { |
| 31 | try { |
no test coverage detected