Download packages/kap-server/src/services/auth/authTokenService.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 783 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/services/auth/authTokenService.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/kap-server/src/services/auth/authTokenService.ts
-
curl -L -o authTokenService.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/services/auth/authTokenService.ts
783 Bytes
| import { createDecorator } from '@moonshot-ai/agent-core-v2'; | |
| import { verifyPassword } from './password'; | |
| import type { TokenStore } from './tokenStore'; | |
| export interface IAuthTokenService { | |
| readonly _serviceBrand: undefined; | |
| getToken(): string; | |
| isValid(candidate: string): Promise<boolean>; | |
| } | |
| export const IAuthTokenService = | |
| createDecorator<IAuthTokenService>('authTokenService'); | |
| export function createAuthTokenService(deps: { | |
| readonly tokenStore: TokenStore; | |
| readonly passwordHash: string | undefined; | |
| }): IAuthTokenService { | |
| return { | |
| _serviceBrand: undefined, | |
| getToken: () => deps.tokenStore.getToken(), | |
| isValid: async (candidate) => | |
| deps.tokenStore.isValid(candidate) || | |
| (await verifyPassword(candidate, deps.passwordHash)), | |
| }; | |
| } | |