• Type Parameters

    Parameters

    • param: {
          config: OidcConfig;
          logger?: { custom?: CustomLogger; level: LogLevel };
          requestMiddleware?: RequestMiddleware<ActionType>[];
          storage?: Partial<StorageConfig>;
      }

      configuration object containing the OIDC client configuration, request middleware, logger,

      • config: OidcConfig

        OIDC configuration including server details, client ID, redirect URI, storage options, scope, and response type.

      • Optionallogger?: { custom?: CustomLogger; level: LogLevel }

        optional logger configuration with log level and custom logger.

      • OptionalrequestMiddleware?: RequestMiddleware<ActionType>[]

        optional array of request middleware functions to process requests.

      • Optionalstorage?: Partial<StorageConfig>

        optional storage configuration for persisting OIDC tokens.

    Returns Promise<
        {
            authorize: {
                background: (
                    options?: GetAuthorizationUrlOptions,
                ) => Promise<AuthorizationSuccess | AuthorizationError>;
                url: (
                    options?: GetAuthorizationUrlOptions,
                ) => Promise<string | GenericError>;
            };
            getState: () => {
                oidc: CombinedState<
                    {
                        authorizeFetch: MutationDefinition<
                            { url: string },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            AuthorizeSuccessResponse,
                            "oidc",
                            unknown,
                        >;
                        authorizeIframe: MutationDefinition<
                            { url: string },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            AuthorizationSuccess,
                            "oidc",
                            unknown,
                        >;
                        endSession: MutationDefinition<
                            { endpoint: string; idToken: string },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            null,
                            "oidc",
                            unknown,
                        >;
                        exchange: MutationDefinition<
                            {
                                code: string;
                                config: OidcConfig;
                                endpoint: string;
                                verifier?: string;
                            },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            TokenExchangeResponse,
                            "oidc",
                            unknown,
                        >;
                        revoke: MutationDefinition<
                            { accessToken: string; clientId?: string; endpoint: string },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            object,
                            "oidc",
                            unknown,
                        >;
                        userInfo: MutationDefinition<
                            { accessToken: string; endpoint: string },
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            UserInfoResponse,
                            "oidc",
                            unknown,
                        >;
                    },
                    never,
                    "oidc",
                >;
                wellknown: CombinedState<
                    {
                        configuration: QueryDefinition<
                            string,
                            BaseQueryFn<
                                string
                                | FetchArgs,
                                unknown,
                                FetchBaseQueryError,
                                {},
                                FetchBaseQueryMeta,
                            >,
                            never,
                            WellknownResponse,
                            "wellknown",
                            unknown,
                        >;
                    },
                    never,
                    "wellknown",
                >;
            };
            subscribe: (listener: ListenerCallback) => Unsubscribe;
            token: {
                exchange: (
                    code: string,
                    state: string,
                    options?: Partial<StorageConfig>,
                ) => Promise<OauthTokens | GenericError | TokenExchangeErrorResponse>;
                get: (
                    options?: GetTokensOptions,
                ) => Promise<
                    | OauthTokens
                    | GenericError
                    | TokenExchangeErrorResponse
                    | AuthorizationError,
                >;
                revoke: () => Promise<
                    GenericError
                    | RevokeSuccessResult
                    | RevokeErrorResult,
                >;
            };
            user: {
                info: () => Promise<GenericError | UserInfoResponse>;
                logout: () => Promise<
                    GenericError
                    | LogoutErrorResult
                    | LogoutSuccessResult,
                >;
            };
        },
    >

    • Returns an object with methods for authorization, token exchange, user info retrieval, and logout.

    oidc

    Factory function to create an OIDC client with methods for authorization, token exchange, user info retrieval, and logout. It initializes the client with the provided configuration, request middleware, logger, and storage options.