@maxlkatze/cms
Version:
A git based Nuxt Module CMS - zero effort, zero cost
34 lines (33 loc) • 1.27 kB
TypeScript
import { type JWTPayload } from 'jose';
/**
* Authentication utilities composable
* Provides functions for token generation, verification, and storage
* Syncs token between localStorage and cookies for universal authentication
*/
export declare const useAuthentication: () => {
generateToken: (payload: JWTPayload, secretKey: string, expiresIn?: string) => Promise<string>;
verifyToken: (token: string, secretKey: string) => Promise<boolean>;
decodeToken: (token: string) => JWTPayload | null;
setToken: (token: string, expiresInDays?: number) => void;
getToken: () => string | null;
removeToken: () => void;
user: import("vue").Ref<{
[x: string]: unknown;
iss?: string | undefined;
sub?: string | undefined;
aud?: string | string[] | undefined;
jti?: string | undefined;
nbf?: number | undefined;
exp?: number | undefined;
iat?: number | undefined;
} | null, JWTPayload | {
[x: string]: unknown;
iss?: string | undefined;
sub?: string | undefined;
aud?: string | string[] | undefined;
jti?: string | undefined;
nbf?: number | undefined;
exp?: number | undefined;
iat?: number | undefined;
} | null>;
};