UNPKG

@paroicms/server

Version:
37 lines (36 loc) 1.39 kB
import type { Knex } from "knex"; import type { SiteContext } from "../site-context/site-context.types.js"; export interface PersonalAccessToken { id: string; accountId: string; tokenPreview: string; description?: string; createdAt: Date; lastUsedAt?: Date; expiresAt?: Date; active: boolean; } export interface CreatePatOptions { accountId: string; description?: string; expiresAt?: Date; } export interface UpdatePatOptions { description?: string; active?: boolean; } export declare function generatePat(): { token: string; tokenHash: string; tokenPreview: string; }; export declare function hashToken(token: string): string; export declare function createPat(siteContext: SiteContext, options: CreatePatOptions): Promise<{ token: string; pat: PersonalAccessToken; }>; export declare function listPatsByAccount(siteContext: SiteContext, accountId: string): Promise<PersonalAccessToken[]>; export declare function getPat(siteContext: SiteContext, patId: string): Promise<PersonalAccessToken | undefined>; export declare function updatePat(siteContext: SiteContext, patId: string, options: UpdatePatOptions): Promise<void>; export declare function deletePat(siteContext: SiteContext, patId: string): Promise<void>; export declare function updateLastUsedAt(cn: Knex, tokenHash: string, timestamp: Date): Promise<void>;