11import { ForbiddenError , StreamNotFoundError } from "@secondlayer/shared" ;
22import type { Database } from "@secondlayer/shared/db" ;
33import { getDb } from "@secondlayer/shared/db" ;
4+ import type { Context } from "hono" ;
45import type { Kysely } from "kysely" ;
56
67/**
@@ -74,18 +75,18 @@ export async function assertSubgraphOwnership(
7475}
7576
7677/** Extract api_key_id from Hono context, or undefined in DEV_MODE */
77- export function getApiKeyId ( c : any ) : string | undefined {
78- const apiKey = c . get ( "apiKey" ) ;
78+ export function getApiKeyId ( c : Context ) : string | undefined {
79+ const apiKey = c . get ( "apiKey" ) as { id : string } | undefined ;
7980 return apiKey ?. id ;
8081}
8182
8283/** Extract account_id from Hono context, or undefined in DEV_MODE */
83- export function getAccountId ( c : any ) : string | undefined {
84+ export function getAccountId ( c : Context ) : string | undefined {
8485 return c . get ( "accountId" ) as string | undefined ;
8586}
8687
8788/** Resolve all active API key IDs for the current request's account. */
88- export async function resolveKeyIds ( c : any ) : Promise < string [ ] | undefined > {
89+ export async function resolveKeyIds ( c : Context ) : Promise < string [ ] | undefined > {
8990 const accountId = getAccountId ( c ) ;
9091 if ( ! accountId ) return undefined ;
9192 const ids = await getAccountKeyIds ( getDb ( ) , accountId ) ;
@@ -108,7 +109,7 @@ export async function resolveKeyIds(c: any): Promise<string[] | undefined> {
108109 * - the account has zero active API keys (caller should 403 with NO_API_KEY)
109110 */
110111export async function resolveApiKeyIdForWrite (
111- c : any ,
112+ c : Context ,
112113) : Promise < string | undefined > {
113114 const direct = getApiKeyId ( c ) ;
114115 if ( direct ) return direct ;
0 commit comments