{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/http/util/auth.ts"],"sourcesContent":["import type { ObRequest } from '../router'\n\nexport type BasicAuth = { clientId: string; clientSecret: string }\n\nexport function parseBasicAuth(req: ObRequest): BasicAuth | null {\n  const header = req.headers['authorization']\n  if (!header || typeof header !== 'string') return null\n  const [scheme, value] = header.split(' ')\n  if (!scheme || scheme.toLowerCase() !== 'basic' || !value) return null\n  try {\n    const decoded = Buffer.from(value, 'base64').toString('utf8')\n    const idx = decoded.indexOf(':')\n    if (idx === -1) return null\n    const clientId = decoded.slice(0, idx)\n    const clientSecret = decoded.slice(idx + 1)\n    return { clientId, clientSecret }\n  } catch {\n    return null\n  }\n}\n\nexport function parseBodyClientAuth(req: ObRequest): BasicAuth | null {\n  const clientId = req.body?.client_id\n  const clientSecret = req.body?.client_secret\n  if (typeof clientId === 'string' && typeof clientSecret === 'string') return { clientId, clientSecret }\n  return null\n}\n\nexport function isScopeSubset(requested: string | undefined, allowed: string | undefined) {\n  if (!requested) return true\n  const reqSet = new Set(requested.split(/\\s+/).filter(Boolean))\n  const allowSet = new Set((allowed ?? '').split(/\\s+/).filter(Boolean))\n  for (const s of reqSet) if (!allowSet.has(s)) return false\n  return true\n}\n\n"],"mappings":";AAIA,SAAgB,eAAe,KAAkC;CAC/D,MAAM,SAAS,IAAI,QAAQ;AAC3B,KAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;CAClD,MAAM,CAAC,QAAQ,SAAS,OAAO,MAAM,IAAI;AACzC,KAAI,CAAC,UAAU,OAAO,aAAa,KAAK,WAAW,CAAC,MAAO,QAAO;AAClE,KAAI;EACF,MAAM,UAAU,OAAO,KAAK,OAAO,SAAS,CAAC,SAAS,OAAO;EAC7D,MAAM,MAAM,QAAQ,QAAQ,IAAI;AAChC,MAAI,QAAQ,GAAI,QAAO;AAGvB,SAAO;GAAE,UAFQ,QAAQ,MAAM,GAAG,IAAI;GAEnB,cADE,QAAQ,MAAM,MAAM,EAAE;GACV;SAC3B;AACN,SAAO;;;AAIX,SAAgB,oBAAoB,KAAkC;CACpE,MAAM,WAAW,IAAI,MAAM;CAC3B,MAAM,eAAe,IAAI,MAAM;AAC/B,KAAI,OAAO,aAAa,YAAY,OAAO,iBAAiB,SAAU,QAAO;EAAE;EAAU;EAAc;AACvG,QAAO;;AAGT,SAAgB,cAAc,WAA+B,SAA6B;AACxF,KAAI,CAAC,UAAW,QAAO;CACvB,MAAM,SAAS,IAAI,IAAI,UAAU,MAAM,MAAM,CAAC,OAAO,QAAQ,CAAC;CAC9D,MAAM,WAAW,IAAI,KAAK,WAAW,IAAI,MAAM,MAAM,CAAC,OAAO,QAAQ,CAAC;AACtE,MAAK,MAAM,KAAK,OAAQ,KAAI,CAAC,SAAS,IAAI,EAAE,CAAE,QAAO;AACrD,QAAO"}