{"version":3,"file":"api-keys.mjs","names":[],"sources":["../src/api/api-keys.ts"],"sourcesContent":["import type {\n\tApiKeyOwnership,\n\tCreateApiKeyRequestDto,\n\tUpdateApiKeyRequestDto,\n\tApiKeyList,\n\tApiKeyWithRawValue,\n} from '@n8n/api-types';\nimport type { ApiKeyScope } from '@n8n/permissions';\n\nimport type { IRestApiContext } from '../types';\nimport { makeRestApiRequest } from '../utils';\n\nexport async function getApiKeys(\n\tcontext: IRestApiContext,\n\toptions: {\n\t\ttake?: number;\n\t\tskip?: number;\n\t\townership?: ApiKeyOwnership;\n\t\tlabel?: string;\n\t\townerIds?: string[];\n\t\tsortBy?: string;\n\t} = {},\n): Promise<ApiKeyList> {\n\tconst { ownerIds, ...rest } = options;\n\treturn await makeRestApiRequest(context, 'GET', '/api-keys', {\n\t\t...rest,\n\t\t// Comma-joined so it survives query-string serialization; the backend\n\t\t// splits it back into an array.\n\t\t...(ownerIds?.length ? { ownerIds: ownerIds.join(',') } : {}),\n\t});\n}\n\nexport async function getApiKeyScopes(context: IRestApiContext): Promise<ApiKeyScope[]> {\n\treturn await makeRestApiRequest(context, 'GET', '/api-keys/scopes');\n}\n\nexport async function createApiKey(\n\tcontext: IRestApiContext,\n\tpayload: CreateApiKeyRequestDto,\n): Promise<ApiKeyWithRawValue> {\n\treturn await makeRestApiRequest(context, 'POST', '/api-keys', payload);\n}\n\nexport async function deleteApiKey(\n\tcontext: IRestApiContext,\n\tid: string,\n): Promise<{ success: boolean }> {\n\treturn await makeRestApiRequest(context, 'DELETE', `/api-keys/${id}`);\n}\n\nexport async function updateApiKey(\n\tcontext: IRestApiContext,\n\tid: string,\n\tpayload: UpdateApiKeyRequestDto,\n): Promise<{ success: boolean }> {\n\treturn await makeRestApiRequest(context, 'PATCH', `/api-keys/${id}`, payload);\n}\n\nexport async function rotateApiKey(\n\tcontext: IRestApiContext,\n\tid: string,\n): Promise<ApiKeyWithRawValue> {\n\treturn await makeRestApiRequest(context, 'POST', `/api-keys/${id}/rotate`);\n}\n"],"mappings":";;;AAYA,eAAsB,WACrB,SACA,UAOI,EAAE,EACgB;CACtB,MAAM,EAAE,UAAU,GAAG,SAAS;AAC9B,QAAO,MAAM,mBAAmB,SAAS,OAAO,aAAa;EAC5D,GAAG;EAGH,GAAI,UAAU,SAAS,EAAE,UAAU,SAAS,KAAK,IAAI,EAAE,GAAG,EAAE;EAC5D,CAAC;;AAGH,eAAsB,gBAAgB,SAAkD;AACvF,QAAO,MAAM,mBAAmB,SAAS,OAAO,mBAAmB;;AAGpE,eAAsB,aACrB,SACA,SAC8B;AAC9B,QAAO,MAAM,mBAAmB,SAAS,QAAQ,aAAa,QAAQ;;AAGvE,eAAsB,aACrB,SACA,IACgC;AAChC,QAAO,MAAM,mBAAmB,SAAS,UAAU,aAAa,KAAK;;AAGtE,eAAsB,aACrB,SACA,IACA,SACgC;AAChC,QAAO,MAAM,mBAAmB,SAAS,SAAS,aAAa,MAAM,QAAQ;;AAG9E,eAAsB,aACrB,SACA,IAC8B;AAC9B,QAAO,MAAM,mBAAmB,SAAS,QAAQ,aAAa,GAAG,SAAS"}