| 7 | export class SecretsSessionStore implements CredentialsStore { |
| 8 | constructor(private readonly logger: Logger) {} |
| 9 | |
| 10 | async load(): Promise<Credentials | null> { |
| 11 | this.logger.debug(`Loading session ${CREDENTIALS_NAME} from secrets`); |
| 12 | let raw; |
| 13 | try { |
| 14 | raw = await Bun.secrets.get({ service: CREDENTIALS_SERVICE, name: CREDENTIALS_NAME }); |
| 15 | } catch (error: unknown) { |
| 16 | const message = error instanceof Error ? error.message : String(error); |
| 17 | throw new ValidationError( |
| 18 | `Failed to load session from secrets (ensure you have secrets available, read the README for more information): ${message}`, |
| 19 | undefined, |
| 20 | { cause: error }, |
| 21 | ); |
| 22 | } |
| 23 | return parseStoredSnapshot(raw); |
| 24 | } |
| 25 | |
| 26 | async save(snapshot: Credentials): Promise<void> { |
| 27 | this.logger.debug(`Saving session ${CREDENTIALS_NAME} to secrets`); |
| 28 | await Bun.secrets.set({ |
| 29 | service: CREDENTIALS_SERVICE, |
| 30 | name: CREDENTIALS_NAME, |
| 31 | value: JSON.stringify(snapshot), |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | async remove(): Promise<void> { |
| 36 | this.logger.debug(`Removing session ${CREDENTIALS_NAME} from secrets`); |
| 37 | await Bun.secrets.delete({ service: CREDENTIALS_SERVICE, name: CREDENTIALS_NAME }); |
| 38 | } |
| 39 | } |
nothing calls this directly
no outgoing calls
no test coverage detected