{"version":3,"sources":["../../../../src/server/requests-auth-methods/apiKeys.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http2'\n\nimport { BaseRequestAuthMethod } from './base'\nimport { NotAuthenticatedError } from '../../errors'\n\nexport abstract class BaseApiKeyRequestAuthMethod<T extends { id: string }> extends BaseRequestAuthMethod<T> {\n\tprotected readonly headerName: string\n\tprotected abstract verify(apiKey: string): Promise<T>\n\n\tconstructor(headerName: string) {\n\t\tsuper()\n\t\tthis.headerName = headerName\n\t}\n\n\tasync parse(headers: IncomingHttpHeaders) {\n\t\tconst headerValue = headers[this.headerName]\n\t\tif (!headerValue || typeof headerValue !== 'string') throw new NotAuthenticatedError()\n\t\treturn this.verify(headerValue)\n\t}\n\n\trouteSecuritySchemeName() {\n\t\treturn this.headerName\n\t}\n}\n"],"mappings":"AAEA,OAAS,yBAAAA,MAA6B,SACtC,OAAS,yBAAAC,MAA6B,eAE/B,MAAeC,UAA8DF,CAAyB,CACzF,WAGnB,YAAYG,EAAoB,CAC/B,MAAM,EACN,KAAK,WAAaA,CACnB,CAEA,MAAM,MAAMC,EAA8B,CACzC,MAAMC,EAAcD,EAAQ,KAAK,UAAU,EAC3C,GAAI,CAACC,GAAe,OAAOA,GAAgB,SAAU,MAAM,IAAIJ,EAC/D,OAAO,KAAK,OAAOI,CAAW,CAC/B,CAEA,yBAA0B,CACzB,OAAO,KAAK,UACb,CACD","names":["BaseRequestAuthMethod","NotAuthenticatedError","BaseApiKeyRequestAuthMethod","headerName","headers","headerValue"]}