/**
 * TokenStore — Focused responsibility: token persistence.
 *
 * Owns all read/write/clear operations on a `GoodVibesTokenStore`. Consumers
 * that only need token storage can interact with this class directly rather
 * than going through the full auth client.
 */
export class TokenStore {
    #store;
    constructor(store) {
        this.#store = store;
    }
    /** Return the current token, or null if none is stored. */
    async getToken() {
        return this.#store.getToken();
    }
    /** Persist a new token, or clear storage when null. */
    async setToken(token) {
        return this.#store.setToken(token);
    }
    /**
     * Persist a new token alongside its expiry timestamp (unix ms).
     * Falls back to `setToken` when the store does not implement `setTokenEntry`.
     */
    async setTokenEntry(token, expiresAt) {
        const store = this.#store;
        if (typeof store.setTokenEntry === 'function') {
            return store.setTokenEntry(token, expiresAt);
        }
        return this.#store.setToken(token);
    }
    /**
     * Return the current token entry, including optional expiry.
     * Falls back to token-only when the store does not implement `getTokenEntry`.
     */
    async getTokenEntry() {
        const store = this.#store;
        if (typeof store.getTokenEntry === 'function') {
            return store.getTokenEntry();
        }
        const token = await this.#store.getToken();
        return { token };
    }
    /** Clear the stored token. */
    async clearToken() {
        return this.#store.clearToken();
    }
    /** Return true when a non-empty token is currently stored. */
    async hasToken() {
        const token = await this.#store.getToken();
        return typeof token === 'string' && token.length > 0;
    }
    /** Expose the underlying store for integrations that need direct storage access. */
    get store() {
        return this.#store;
    }
}
