firebase-auth-cloudflare-workers
Version:
Zero-dependencies firebase auth library for Cloudflare Workers.
86 lines (85 loc) • 4.6 kB
TypeScript
import { ApiSettings } from './api-requests';
import { BaseClient } from './client';
import type { EmulatorEnv } from './emulator';
import { UserRecord } from './user-record';
/**
* Instantiates the createSessionCookie endpoint settings.
*
* @internal
*/
export declare const FIREBASE_AUTH_CREATE_SESSION_COOKIE: ApiSettings;
/**
* Instantiates the getAccountInfo endpoint settings.
*
* @internal
*/
export declare const FIREBASE_AUTH_GET_ACCOUNT_INFO: ApiSettings;
/**
* Instantiates the revokeRefreshTokens endpoint settings for updating existing accounts.
*
* @internal
* @link https://github.com/firebase/firebase-admin-node/blob/9955bca47249301aa970679ae99fe01d54adf6a8/src/auth/auth-api-request.ts#L746
*/
export declare const FIREBASE_AUTH_REVOKE_REFRESH_TOKENS: ApiSettings;
/**
* Instantiates the setCustomUserClaims endpoint settings for updating existing accounts.
*
* @internal
* @link https://github.com/firebase/firebase-admin-node/blob/9955bca47249301aa970679ae99fe01d54adf6a8/src/auth/auth-api-request.ts#L746
*/
export declare const FIREBASE_AUTH_SET_CUSTOM_USER_CLAIMS: ApiSettings;
export declare class AuthApiClient extends BaseClient {
/**
* Creates a new Firebase session cookie with the specified duration that can be used for
* session management (set as a server side session cookie with custom cookie policy).
* The session cookie JWT will have the same payload claims as the provided ID token.
*
* @param idToken - The Firebase ID token to exchange for a session cookie.
* @param expiresIn - The session cookie duration in milliseconds.
* @param env - An optional parameter specifying the environment in which the function is running.
* If the function is running in an emulator environment, this should be set to `EmulatorEnv`.
* If not specified, the function will assume it is running in a production environment.
*
* @returns A promise that resolves on success with the created session cookie.
*/
createSessionCookie(idToken: string, expiresIn: number, env?: EmulatorEnv): Promise<string>;
/**
* Looks up a user by uid.
*
* @param uid - The uid of the user to lookup.
* @param env - An optional parameter specifying the environment in which the function is running.
* If the function is running in an emulator environment, this should be set to `EmulatorEnv`.
* If not specified, the function will assume it is running in a production environment.
* @returns A promise that resolves with the user information.
*/
getAccountInfoByUid(uid: string, env?: EmulatorEnv): Promise<UserRecord>;
/**
* Revokes all refresh tokens for the specified user identified by the uid provided.
* In addition to revoking all refresh tokens for a user, all ID tokens issued
* before revocation will also be revoked on the Auth backend. Any request with an
* ID token generated before revocation will be rejected with a token expired error.
* Note that due to the fact that the timestamp is stored in seconds, any tokens minted in
* the same second as the revocation will still be valid. If there is a chance that a token
* was minted in the last second, delay for 1 second before revoking.
*
* @param uid - The user whose tokens are to be revoked.
* @param env - An optional parameter specifying the environment in which the function is running.
* If the function is running in an emulator environment, this should be set to `EmulatorEnv`.
* If not specified, the function will assume it is running in a production environment.
* @returns A promise that resolves when the operation completes
* successfully with the user id of the corresponding user.
*/
revokeRefreshTokens(uid: string, env?: EmulatorEnv): Promise<string>;
/**
* Sets additional developer claims on an existing user identified by provided UID.
*
* @param uid - The user to edit.
* @param customUserClaims - The developer claims to set.
* @param env - An optional parameter specifying the environment in which the function is running.
* If the function is running in an emulator environment, this should be set to `EmulatorEnv`.
* If not specified, the function will assume it is running in a production environment.
* @returns A promise that resolves when the operation completes
* with the user id that was edited.
*/
setCustomUserClaims(uid: string, customUserClaims: object | null, env?: EmulatorEnv): Promise<string>;
}