Skip to content

@authx-rs/sdk

Generated from packages/authx-sdk-ts/dist/types.

Low-level OIDC, JWKS, PKCE, device, and browser-session helpers.

export interface DeviceAuthorizationResponse {
device_code: string;
user_code: string;
verification_uri: string;
verification_uri_complete?: string;
expires_in: number;
interval: number;
[key: string]: unknown;
}
export interface DeviceAuthorizationOptions {
endpoint: string;
clientId: string;
scope?: string;
}
export interface PollDeviceTokenOptions {
tokenEndpoint: string;
clientId: string;
deviceCode: string;
clientSecret?: string;
}
export declare function startDeviceAuthorization(options: DeviceAuthorizationOptions): Promise<DeviceAuthorizationResponse>;
export declare function pollDeviceToken(options: PollDeviceTokenOptions): Promise<OidcTokenResponse>;
export interface AuthxErrorBody {
error?: string;
message?: string;
error_description?: string;
[key: string]: unknown;
}
export declare class AuthxSdkError extends Error {
readonly status?: number;
readonly code?: string;
readonly details?: unknown;
constructor(message: string, options?: {
status?: number;
code?: string;
details?: unknown;
});
}
export declare function toAuthxSdkError(message: string, options?: {
status?: number;
code?: string;
details?: unknown;
}): AuthxSdkError;
export interface JwtHeader {
alg?: string;
typ?: string;
kid?: string;
[key: string]: unknown;
}
export interface OidcJwk extends JsonWebKey {
kid?: string;
use?: string;
alg?: string;
kty: string;
x5c?: string[];
[key: string]: unknown;
}
export interface JwksDocument {
keys: OidcJwk[];
[key: string]: unknown;
}
export interface SelectJwkOptions {
kid?: string;
alg?: string;
use?: string;
kty?: string;
}
export declare function fetchJwks(jwksUri: string): Promise<JwksDocument>;
export declare function fetchIssuerJwks(issuer: string): Promise<JwksDocument>;
export declare function decodeJwtHeader(token: string): JwtHeader;
export declare function selectJwk(jwks: JwksDocument, options: SelectJwkOptions): OidcJwk | undefined;
export declare function getJwkForJwt(jwks: JwksDocument, token: string): OidcJwk | undefined;
export interface OidcDiscoveryDocument {
issuer: string;
authorization_endpoint: string;
token_endpoint: string;
userinfo_endpoint?: string;
jwks_uri?: string;
revocation_endpoint?: string;
introspection_endpoint?: string;
device_authorization_endpoint?: string;
token_endpoint_auth_methods_supported?: string[];
response_types_supported?: string[];
grant_types_supported?: string[];
scopes_supported?: string[];
id_token_signing_alg_values_supported?: string[];
[key: string]: unknown;
}
export interface OidcTokenResponse {
access_token: string;
token_type: string;
expires_in: number;
refresh_token?: string;
scope?: string;
id_token?: string;
[key: string]: unknown;
}
export interface IntrospectionResponse {
active: boolean;
scope?: string;
client_id?: string;
username?: string;
token_type?: string;
exp?: number;
iat?: number;
sub?: string;
iss?: string;
[key: string]: unknown;
}
export interface BuildAuthorizationUrlOptions {
authorizationEndpoint: string;
clientId: string;
redirectUri: string;
scope?: string;
state?: string;
nonce?: string;
codeChallenge?: string;
codeChallengeMethod?: "S256";
extraParams?: Record<string, string | undefined>;
}
export interface ExchangeCodeOptions {
tokenEndpoint: string;
clientId: string;
code: string;
redirectUri: string;
codeVerifier?: string;
clientSecret?: string;
}
export interface RefreshTokenOptions {
tokenEndpoint: string;
clientId: string;
refreshToken: string;
scope?: string;
clientSecret?: string;
}
export interface RevokeTokenOptions {
revocationEndpoint: string;
clientId: string;
token: string;
tokenTypeHint?: string;
clientSecret?: string;
}
export interface IntrospectTokenOptions {
introspectionEndpoint: string;
clientId: string;
token: string;
tokenTypeHint?: string;
clientSecret?: string;
}
export interface UserInfoClaims {
sub: string;
email?: string;
email_verified?: boolean;
preferred_username?: string;
[key: string]: unknown;
}
export declare function discoverIssuer(issuer: string): Promise<OidcDiscoveryDocument>;
export declare function buildAuthorizationUrl(options: BuildAuthorizationUrlOptions): string;
export declare function exchangeAuthorizationCode(options: ExchangeCodeOptions): Promise<OidcTokenResponse>;
export declare function refreshToken(options: RefreshTokenOptions): Promise<OidcTokenResponse>;
export declare function revokeToken(options: RevokeTokenOptions): Promise<void>;
export declare function introspectToken(options: IntrospectTokenOptions): Promise<IntrospectionResponse>;
export declare function fetchUserInfo(userInfoEndpoint: string, accessToken: string): Promise<UserInfoClaims>;
export interface PkcePair {
codeVerifier: string;
codeChallenge: string;
codeChallengeMethod: "S256";
}
export declare function randomString(byteLength?: number): string;
export declare function createPkcePair(byteLength?: number): Promise<PkcePair>;
export declare function randomState(byteLength?: number): string;
export interface SessionUser {
id?: string;
user_id?: string;
email?: string;
email_verified?: boolean;
username?: string | null;
[key: string]: unknown;
}
export interface SessionRecord {
id?: string;
session_id?: string;
user_id?: string;
ip_address?: string;
org_id?: string | null;
expires_at?: string;
created_at?: string;
[key: string]: unknown;
}
export interface SignInResult {
user_id: string;
session_id: string;
token: string;
[key: string]: unknown;
}
export interface SignUpResult {
user_id: string;
email: string;
[key: string]: unknown;
}
export interface SessionEnvelope {
user?: SessionUser;
session?: SessionRecord;
[key: string]: unknown;
}
export interface BrowserSessionClientOptions {
baseUrl: string;
credentials?: RequestCredentials;
headers?: HeadersInit;
}
export interface CredentialInput {
email: string;
password: string;
}
export declare class BrowserSessionClient {
constructor(options: BrowserSessionClientOptions);
signUp(body: CredentialInput): Promise<SignUpResult>;
signIn(body: CredentialInput): Promise<SignInResult>;
signOut(): Promise<void>;
signOutAll(): Promise<void>;
session(): Promise<SessionEnvelope>;
sessions(): Promise<SessionRecord[]>;
}