Interface StateStore

StateStore defines methods for generating and verifying OAuth state.

This interface is implemented internally for the default state store; however, it can also be implemented and passed to an OAuth client as well.

interface StateStore {
    generateState(): MaybePromise<string>;
    verifyState(state: string): MaybePromise<void>;
}

Methods

  • Generate a new state string, which is directly appended to the OAuth state parameter.

    Returns MaybePromise<string>

  • Verify that the state received during OAuth callback is valid and not forged.

    If state verification fails, OAuthStateVerificationFailedError should be thrown.

    Parameters

    • state: string

      The state parameter that was received during OAuth callback

    Returns MaybePromise<void>