/** * OAuth strategy that uses stateful (persisted) tokens from the same store as sfcc-ci. * Uses stateful auth only when present and valid; on 401 attempts refresh when renew * credentials or refresh_token are stored. * * @module auth/stateful-oauth-strategy */ import type { AuthStrategy, AccessTokenResponse, DecodedJWT, FetchInit } from './types.js'; import { type StatefulSession } from './stateful-store.js'; export interface StatefulOAuthStrategyOptions { accountManagerHost: string; scopes?: string[]; } /** * Auth strategy that uses the stateful store (sfcc-ci compatible). * On 401, attempts to refresh using stored refresh_token or client_credentials (renew base); * on refresh failure clears the stored session. */ export declare class StatefulOAuthStrategy implements AuthStrategy { private accountManagerHost; private scopes; private _session; private _hasHadSuccess; /** * Creates a new StatefulOAuthStrategy instance. * * @param session - The stateful session containing clientId, accessToken, and optional refresh/renew credentials * @param options - Strategy configuration options * @param options.accountManagerHost - The Account Manager hostname (defaults to DEFAULT_ACCOUNT_MANAGER_HOST) * @param options.scopes - Optional OAuth scopes to request during token refresh */ constructor(session: StatefulSession, options: StatefulOAuthStrategyOptions); fetch(url: string, init?: FetchInit): Promise; getAuthorizationHeader(): Promise; /** * Returns the current token as AccessTokenResponse (expires/scopes from JWT). */ getTokenResponse(): Promise; getJWT(): Promise; invalidateToken(): void; private getAccessToken; /** * Attempts to refresh the access token using stored refresh_token or client_credentials (renew base). * Requires SFCC_CLIENT_RENEW_BASE (client:secret) for both flows; updates store on success. */ private tryRefresh; }