Middleware API reference
Exports of @anymux/middleware. Back to the module
Classes
MemoryTokenStore
classclass MemoryTokenStore
get
methodget(key: string): Promise<TokenData | undefined>
set
methodset(key: string, token: TokenData): Promise<void>
delete
methoddelete(key: string): Promise<boolean>
clear
methodclear(): Promise<void>
DatabaseTokenStore
classclass DatabaseTokenStore
constructor
constructorconstructor(db: KeyValueDB, prefix?: string): DatabaseTokenStore
get
methodget(key: string): Promise<TokenData | undefined>
set
methodset(key: string, token: TokenData): Promise<void>
delete
methoddelete(key: string): Promise<boolean>
clear
methodclear(): Promise<void>
Functions
createOAuthMiddleware
functioncreateOAuthMiddleware(config: OAuthConfig, store: TokenStore): Hono<import("/home/andrew/gits/github/AnyFileSystem/AnyFsMnoorepo-sf-phase3-npmf/node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/types/types").BlankEnv, import("/home/andrew/gits/github/AnyFileSystem/AnyFsMnoorepo-sf-phase3-npmf/node_modules/.pnpm/hono@4.12.5/node_modules/hono/dist/types/types").BlankSchema, "/">createCorsProxy
functioncreateCorsProxy(config: CorsConfig): MiddlewareHandler
createTokenRefresh
functioncreateTokenRefresh(config: TokenRefreshConfig): MiddlewareHandler
toExpressMiddleware
functiontoExpressMiddleware(honoApp: Hono): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>
toNextHandler
functiontoNextHandler(honoApp: Hono): { GET: (req: Request) => Promise<Response>; POST: (req: Request) => Promise<Response>; PUT: (req: Request) => Promise<Response>; DELETE: (req: Request) => Promise<Response>; PATCH: (req: Request) => Promise<Response>; OPTIONS: (req: Request) => Promise<Response>; HEAD: (req: Request) => Promise<Response>; }Types
OAuthConfig
typetype OAuthConfig = { clientId?: string; clientSecret?: string; authorizationUrl?: string; tokenUrl?: string; callbackUrl?: string; scopes?: string[]; state?: string; }CorsConfig
typetype CorsConfig = { allowedOrigins?: string[]; allowedMethods?: string[]; allowedHeaders?: string[]; credentials?: boolean; maxAge?: number; }Interfaces
TokenData
interfaceinterface TokenData
accessToken
propertyaccessToken: string
refreshToken
propertyrefreshToken: string
expiresAt
propertyexpiresAt: number
tokenType
propertytokenType: string
scope
propertyscope: string
TokenStore
interfaceinterface TokenStore
get
methodget(key: string): Promise<TokenData | undefined>
set
methodset(key: string, token: TokenData): Promise<void>
delete
methoddelete(key: string): Promise<boolean>
clear
methodclear(): Promise<void>
KeyValueDB
interfaceinterface KeyValueDB
get
methodget(key: string): Promise<string | undefined>
set
methodset(key: string, value: string): Promise<void>
delete
methoddelete(key: string): Promise<boolean>
keys
methodkeys(): Promise<string[]>
TokenRefreshConfig
interfaceinterface TokenRefreshConfig
tokenUrl
propertytokenUrl: string
clientId
propertyclientId: string
clientSecret
propertyclientSecret: string
store
propertystore: TokenStore
Constants
OAuthConfigSchema
constconst OAuthConfigSchema: z.ZodObject<{ clientId: z.ZodString; clientSecret: z.ZodString; authorizationUrl: z.ZodString; tokenUrl: z.ZodString; callbackUrl: z.ZodString; scopes: z.ZodArray<z.ZodString, "many">; state: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { clientId?: string; clientSecret?: string; authorizationUrl?: string; tokenUrl?: string; callbackUrl?: string; scopes?: string[]; state?: string; }, { clientId?: string; clientSecret?: string; authorizationUrl?: string; tokenUrl?: string; callbackUrl?: string; scopes?: string[]; state?: string; }>CorsConfigSchema
constconst CorsConfigSchema: z.ZodObject<{ allowedOrigins: z.ZodArray<z.ZodString, "many">; allowedMethods: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; allowedHeaders: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; credentials: z.ZodDefault<z.ZodBoolean>; maxAge: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { allowedOrigins?: string[]; allowedMethods?: string[]; allowedHeaders?: string[]; credentials?: boolean; maxAge?: number; }, { allowedOrigins?: string[]; allowedMethods?: string[]; allowedHeaders?: string[]; credentials?: boolean; maxAge?: number; }>