declare const ALLOWED_ROLES_LIST: readonly ["user", "admin", "agent"]; declare type ALLOWED_USER_ROLES = typeof ALLOWED_ROLES_LIST[number]; /** * Configuration options for Gateman */ export interface GatemanOptions { /** * Name of the service initializing Gateman */ service: string; /** * Auth scheme used for headless inter-service calls */ authScheme: string; /** * Redis client object */ redis: IRedisService; /** * Secret key for sealing & unsealing objects */ secret: string; /** * Default duration period used for persisting tokens. Defaults to `600` seconds (10 minutes) */ sessionDuration?: number; } /** * Options for creating a session token */ export interface CreateSessionOptions { /** * The user's id */ id: string; /** * The user's role. Either `user` or `admin` */ role?: ALLOWED_USER_ROLES; /** * How long the token should be peristed to Redis in seconds. Overwrites the default session duration provided in the constructor. */ sessionDuration?: number; /** * Additional data to be encrypted in the token */ data?: any; } /** * Options for creating a headless token */ export interface CreateHeadlessTokenOptions { /** * The user's id */ id: string; /** * Additional data to be encrypted in the token */ data?: any; } export interface ValidateRoleOptions { /** * Auth scheme used for headless inter-service calls */ serviceAuthScheme: string; /** * The scheme contained in the request authorization header */ scheme: string; /** * The recognized role(s) to perform the authorization/validation against */ roles: Role | Role[]; /** * The recognized service(s) to perform the authorization/validation against */ service: string | string[]; /** * Data gotten from decoding the token */ data: IDecoded; } /** * Valid roles found within a token */ export declare type Role = ALLOWED_USER_ROLES | "service" | "*"; /** * Redis service contract */ export interface IRedisService { hdel: (hash: string, field: string) => Promise; hget: (hash: string, field: string) => Promise; hgetall: (key: string) => Promise; hset: (hash: string, field: string, value: any) => Promise; quit: () => Promise; set: (key: string, value: any, mode?: string, duration?: number) => Promise; get: (key: string) => Promise; del: (key: string) => Promise; } /** * Data gotten back from decoding a token */ export interface IDecoded { id: string; role: ALLOWED_USER_ROLES | "service"; service?: string; data?: any; } export {};