返回 AiToEarn
aitoearn-auth.config.ts
根目录 / project / aitoearn-backend / libs / aitoearn-auth / src / aitoearn-auth.config.ts
1 import { createZodDto } from '@yikart/common'
2 import { z } from 'zod'
3
4 export const AITOEARN_AUTH_OPTIONS = Symbol('AITOEARN_AUTH_OPTIONS')
5
6 export const aitoearnAuthConfigSchema = z.object({
7 secret: z.string().default(''),
8 internalToken: z.string().min(1),
9 })
10
11 export class AitoearnAuthConfig extends createZodDto(aitoearnAuthConfigSchema) {}
12
13 export interface TokenPayload {
14 readonly id: string
15 readonly mail?: string
16 readonly name?: string
17 readonly shopDomain?: string
18 readonly exp?: number
19 }
20
21 export type AitoearnAuthOptions<TTokenInfo = unknown> = AitoearnAuthConfig & {
22 getTokenInfo: (payload: TokenPayload) => TTokenInfo | Promise<TTokenInfo>
23 getTokenInfoByApiKey?: (apiKey: string) => TTokenInfo | Promise<TTokenInfo>
24 }
25
25 lines TYPESCRIPT