cf-auth0
Version:
🔐 Auth0 Client on Cloudflare Pages
70 lines (69 loc) • 2.36 kB
TypeScript
import type { Cookies } from '@sveltejs/kit';
import type { JWTPayload } from 'jose';
export declare class CfAuth0 {
private auth0ClientId;
private auth0ClientSecret;
private auth0Domain;
private auth0CustomDomain;
private baseUrl;
private auth0CookieName;
private sessionSecret;
private callbackPath;
private loginPath;
private logoutPath;
private isSvelteKit;
private jwtPayload;
private cachedKey;
constructor({ auth0CookieName, sessionSecret, auth0ClientId, auth0ClientSecret, auth0Domain, auth0CustomDomain, baseUrl, callbackPath, loginPath, logoutPath, isSvelteKit }: {
auth0ClientId: string;
auth0ClientSecret: string;
/** @example 'example.us.auth0.com' */
auth0Domain: string;
/** @example 'auth.example.com' */
auth0CustomDomain?: string;
/** @example 'http://localhost:3000' */
baseUrl: string;
/** @example '/api/auth/callback' */
callbackPath: string;
/** @example '/api/auth/login' */
loginPath: string;
/** @example '/api/auth/logout' */
logoutPath: string;
auth0CookieName?: string;
sessionSecret: string;
isSvelteKit?: boolean;
});
/** Please redirect to return URL after calling this function */
auth({ cookies, url }: {
cookies: Cookies;
/** @description current location */
url: URL;
}): Promise<string | JWTPayload>;
/** Please redirect to return URL after calling this function */
login({ cookies, url }: {
cookies: Cookies;
/** @description current location */
url: URL;
}): string;
private verifyToken;
private getToken;
private getAuthUser;
/** Please redirect to return URL after calling this function */
logout({ cookies, returnUrl }: {
cookies: Cookies;
returnUrl?: string;
}): string;
callback({ cookies, url }: {
cookies: Cookies;
/** @description current location */
url: URL;
}): Promise<string>;
delete(): Promise<string>;
changeEmail(newEmail: string): Promise<string>;
changePassword(newPassword: string): Promise<string>;
private getManagementApiToken;
private deleteAuth0User;
private changeUserEmail;
private changeUserPassword;
private setAuthCookie;
}