{"version":3,"file":"consent.mjs","names":[],"sources":["../../src/api/consent.ts"],"sourcesContent":["import type { ConsentUiHints } from '@n8n/api-types';\n\nimport type { IRestApiContext } from '../types';\nimport { makeRestApiRequest } from '../utils';\n\nexport interface ConsentDetailsPicker {\n\tclientName: string;\n\tclientId: string;\n\tredirectUri?: string;\n\tresourceName?: string;\n\t/**\n\t * Scopes the user can grant (already capped by what the client requested).\n\t * Empty = full user delegation (no picker shown).\n\t */\n\tscopes: string[];\n\t/** Scopes this user granted to this client last time, used to preselect the picker. */\n\tpreviousScopes?: string[];\n\t/** Tool names each scope unlocks, shown per scope group in the picker. */\n\tscopeTools?: Record<string, string[]>;\n\t/** Presentation hints from the resource (icon, consent noun) for first-party clients. */\n\tuiHints?: ConsentUiHints;\n\t/** True only for first-party clients (e.g. form triggers) that skip the trust gate. */\n\tisFirstParty?: boolean;\n}\n\nexport type ConsentDetails =\n\t| {\n\t\t\t/**\n\t\t\t * A prior consent already covers this request — e.g. the visitor only\n\t\t\t * authenticated as part of reaching this page. There is nothing left to\n\t\t\t * show a picker for.\n\t\t\t */\n\t\t\tautoApproved: true;\n\t\t\tredirectUrl: string;\n\t\t\t/** Presentation hints from the resource, used for the header icon while redirecting. */\n\t\t\tuiHints?: ConsentUiHints;\n\t  }\n\t| ({ autoApproved?: false } & ConsentDetailsPicker);\n\nexport interface ConsentApprovalResponse {\n\tstatus: string;\n\tredirectUrl: string;\n}\n\nexport async function getConsentDetails(context: IRestApiContext): Promise<ConsentDetails> {\n\treturn await makeRestApiRequest(context, 'GET', '/consent/details');\n}\n\nexport async function approveConsent(\n\tcontext: IRestApiContext,\n\tapproved: boolean,\n\tscopes?: string[],\n): Promise<ConsentApprovalResponse> {\n\treturn await makeRestApiRequest(context, 'POST', '/consent/approve', { approved, scopes });\n}\n"],"mappings":";;;AA4CA,eAAsB,kBAAkB,SAAmD;AAC1F,QAAO,MAAM,mBAAmB,SAAS,OAAO,mBAAmB;;AAGpE,eAAsB,eACrB,SACA,UACA,QACmC;AACnC,QAAO,MAAM,mBAAmB,SAAS,QAAQ,oBAAoB;EAAE;EAAU;EAAQ,CAAC"}