mirror of
https://github.com/langgenius/dify.git
synced 2026-06-12 11:32:08 +08:00
28 lines
835 B
TypeScript
28 lines
835 B
TypeScript
import type { TokenStore } from '../../src/store/token-store.js'
|
|
|
|
// In-memory TokenStore for tests; mirrors keyring semantics (empty string = missing).
|
|
export class MemStore implements TokenStore {
|
|
readonly entries: Map<string, string>
|
|
|
|
// Seed keys use the composite "<host> <email>" form, e.g. { 'h1 a@x': 'dfoa_a' }.
|
|
constructor(seed: Record<string, string> = {}) {
|
|
this.entries = new Map(Object.entries(seed))
|
|
}
|
|
|
|
private k(host: string, email: string): string {
|
|
return `${host} ${email}`
|
|
}
|
|
|
|
read(host: string, email: string): string {
|
|
return this.entries.get(this.k(host, email)) ?? ''
|
|
}
|
|
|
|
write(host: string, email: string, bearer: string): void {
|
|
this.entries.set(this.k(host, email), bearer)
|
|
}
|
|
|
|
remove(host: string, email: string): void {
|
|
this.entries.delete(this.k(host, email))
|
|
}
|
|
}
|