forked from boos/BoosAPI
feat: implement proxy input file resolution and storage
- Added `inputFiles.ts` for handling input file resolution, including validation and normalization of file types. - Introduced `proxyFileStore.ts` for managing file storage, retrieval, and deletion with owner-based isolation. - Created tests for proxy file storage functionality in `proxyFileStore.test.ts`. - Developed `proxyInputFileResolver.ts` to resolve input files in OpenAI and response formats. - Added utility functions for handling reasoning signatures in `reasoningTransport.ts` and corresponding tests. - Enhanced shared input file transformers in `inputFile.ts` for better file handling and type inference.
This commit is contained in:
@@ -11,6 +11,11 @@ export interface ProxyAuthContext {
|
||||
policy: DownstreamRoutingPolicy;
|
||||
}
|
||||
|
||||
export interface ProxyResourceOwner {
|
||||
ownerType: 'managed_key' | 'global_proxy_token';
|
||||
ownerId: string;
|
||||
}
|
||||
|
||||
const proxyAuthContextByRequest = new WeakMap<FastifyRequest, ProxyAuthContext>();
|
||||
|
||||
function normalizeIp(rawIp: string | null | undefined): string {
|
||||
@@ -107,3 +112,20 @@ export async function proxyAuthMiddleware(request: FastifyRequest, reply: Fastif
|
||||
export function getProxyAuthContext(request: FastifyRequest): ProxyAuthContext | null {
|
||||
return proxyAuthContextByRequest.get(request) || null;
|
||||
}
|
||||
|
||||
export function getProxyResourceOwner(request: FastifyRequest): ProxyResourceOwner | null {
|
||||
const auth = getProxyAuthContext(request);
|
||||
if (!auth) return null;
|
||||
|
||||
if (auth.source === 'managed') {
|
||||
return {
|
||||
ownerType: 'managed_key',
|
||||
ownerId: auth.keyId === null ? auth.token : String(auth.keyId),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
ownerType: 'global_proxy_token',
|
||||
ownerId: 'global',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user