"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),error_1=require("@b/utils/error");exports.metadata={summary:"Lists all API keys",description:"Retrieves all API keys associated with the authenticated user.",operationId:"listApiKeys",tags:["API Key Management"],logModule:"USER",logTitle:"List API keys",responses:{200:{description:"API keys retrieved successfully",content:{"application/json":{schema:{type:"array",items:{type:"object",properties:{id:{type:"string"},name:{type:"string"},key:{type:"string"},permissions:{type:"array",items:{type:"string"}},ipWhitelist:{type:"array",items:{type:"string"}}}}}}}},401:{description:"Unauthorized"},500:{description:"Server error"}},requiresAuth:!0};exports.default=async e=>{const{user:t,ctx:r}=e;if(!t){null==r||r.fail("User not authenticated");throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"})}null==r||r.step("Retrieving API keys");const s=await db_1.models.apiKey.findAll({where:{userId:t.id}});null==r||r.success(`Retrieved ${s.length} API keys`);return s};