{"version":3,"file":"authconnection-CynFBIv8.mjs","names":[],"sources":["../src/runtime/authconnection.ts"],"sourcesContent":["/**\n * Auth connection utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.authconnection` runtime API.\n * At runtime this delegates to `globalThis.tailor.authconnection`. Use\n * `mockAuthconnection` from `@tailor-platform/sdk/vitest` to mock in unit tests.\n *\n * `connectionName` is narrowed to the connection names defined in `defineAuth()`'s\n * `connections` once `tailor.d.ts` has been generated (via `tailor deploy`/`generate`).\n * @example\n * import { authconnection } from \"@tailor-platform/sdk/runtime\";\n *\n * const token = await authconnection.getConnectionToken(\"my-connection\");\n */\n\nimport type { AuthConnectionTokenResult } from \"#/configure/services/auth/types\";\n// Import from the public entry (not `#/configure/types/connection-name`) so this d.ts\n// references `@tailor-platform/sdk` externally instead of inlining the registry — a single\n// generated `declare module \"@tailor-platform/sdk\"` then narrows this entry too.\nimport type { ConnectionName } from \"@tailor-platform/sdk\";\n\n/**\n * Platform API surface for `tailor.authconnection`. Describes the shape the\n * platform runtime injects on `globalThis.tailor.authconnection`.\n */\nexport interface TailorAuthconnectionAPI {\n  /**\n   * Returns the access token for the given auth connection.\n   * @param connectionName - Auth connection name as defined in tailor.config\n   * @returns Token payload\n   */\n  getConnectionToken(connectionName: ConnectionName): Promise<AuthConnectionTokenResult>;\n}\n\nconst api = (): TailorAuthconnectionAPI =>\n  (globalThis as unknown as { tailor: { authconnection: TailorAuthconnectionAPI } }).tailor\n    .authconnection;\n\nconst getConnectionToken: TailorAuthconnectionAPI[\"getConnectionToken\"] = (...args) =>\n  api().getConnectionToken(...args);\n\n/** Runtime wrapper namespace for `tailor.authconnection`. */\nexport const authconnection = { getConnectionToken } as const satisfies TailorAuthconnectionAPI;\n"],"mappings":"AAkCA,MAAM,QACH,WAAkF,OAChF,eAMQ,EAAiB,CAAE,oBAJ2C,GAAG,IAC5E,IAAI,CAAC,CAAC,mBAAmB,GAAG,CAAI,CAGiB"}