firebase-auth-cloudflare-workers
Version:
Zero-dependencies firebase auth library for Cloudflare Workers.
51 lines (50 loc) • 1.55 kB
TypeScript
/**
* Type representing a Firebase OAuth access token (derived from a Google OAuth2 access token) which
* can be used to authenticate to Firebase services such as the Realtime Database and Auth.
*/
export interface FirebaseAccessToken {
accessToken: string;
expirationTime: number;
}
/**
* Interface for Google OAuth 2.0 access tokens.
*/
export interface GoogleOAuthAccessToken {
access_token: string;
expires_in: number;
}
/**
* Interface that provides Google OAuth2 access tokens used to authenticate
* with Firebase services.
*
* In most cases, you will not need to implement this yourself and can instead
* use the default implementations provided by the `firebase-admin/app` module.
*/
export interface Credential {
/**
* Returns a Google OAuth2 access token object used to authenticate with
* Firebase services.
*
* @returns A Google OAuth2 access token object.
*/
getAccessToken(): Promise<GoogleOAuthAccessToken>;
}
/**
* Implementation of Credential that uses a service account.
*/
export declare class ServiceAccountCredential implements Credential {
readonly projectId: string;
readonly privateKey: string;
readonly clientEmail: string;
/**
* Creates a new ServiceAccountCredential from the given parameters.
*
* @param serviceAccountJson - Service account json content.
*
* @constructor
*/
constructor(serviceAccountJson: string);
getAccessToken(): Promise<GoogleOAuthAccessToken>;
private sign;
private str2ab;
}