{"version":3,"file":"exchange-oauth-token.cjs","names":["z","action"],"sources":["../../src/actions/exchange-oauth-token.ts"],"sourcesContent":["import type { AppAction } from \"@keystrokehq/keystroke/app\";\nimport { z } from \"zod\";\n\nimport { action } from \"../action\";\nimport { supabase } from \"../app\";\n\nexport const SupabaseExchangeOauthTokenInput = z.object({\n  code: z.string().describe(\"Authorization code from the server; required if `grant_type` is 'authorization_code'.\").optional(),\n  client_id: z.string().describe(\"Application's client ID.\"),\n  grant_type: z.enum([\"authorization_code\", \"refresh_token\"]).describe(\"OAuth 2.0 grant type that dictates the token exchange flow.\"),\n  redirect_uri: z.string().describe(\"Redirect URI from the initial authorization; required if `grant_type` is 'authorization_code' and it was part of the original request.\").optional(),\n  client_secret: z.string().describe(\"Application's client secret.\"),\n  code_verifier: z.string().describe(\"PKCE code verifier; required if PKCE was used with an 'authorization_code' grant type.\").optional(),\n  refresh_token: z.string().describe(\"Refresh token for acquiring a new access token; required if `grant_type` is 'refresh_token'.\").optional(),\n}).describe(\"Parameters for exchanging an OAuth 2.0 authorization code or refresh token for an access token.\");\nconst SupabaseExchangeOauthToken_TokenTypeSchema = z.enum([\"Bearer\"]);\nexport const SupabaseExchangeOauthTokenOutput = z.object({\n  expires_in: z.number().int().describe(\"Lifetime of the issued access_token in seconds.\").nullable(),\n  token_type: SupabaseExchangeOauthToken_TokenTypeSchema.nullable(),\n  access_token: z.string().describe(\"Short-lived OAuth 2.0 access token to authenticate subsequent requests (sent as Authorization: Bearer <access_token>).\").nullable(),\n  refresh_token: z.string().describe(\"Opaque token that can be exchanged to obtain a new access token (and refresh token) when the current access token expires.\").nullable(),\n}).passthrough().describe(\"Exchange OAuth Token Response\\n\\nDirect response from POST /v1/oauth/token when exchanging an auth code or refresh token.\");\n\nexport const supabaseExchangeOauthToken: AppAction<\n  typeof SupabaseExchangeOauthTokenInput,\n  typeof SupabaseExchangeOauthTokenOutput,\n  typeof supabase.credential\n> = action(\"SUPABASE_EXCHANGE_OAUTH_TOKEN\", {\n  slug: \"supabase-exchange-oauth-token\",\n  name: \"Exchange auth code for access and refresh token\",\n  description: \"(Beta) Implements the OAuth 2.0 token endpoint to exchange an authorization code or refresh token for access/refresh tokens, based on `grant_type`. This is a standard OAuth 2.0 token endpoint that uses application/x-www-form-urlencoded content type as per OAuth 2.0 specification. Requires a valid registered OAuth application client_id and client_secret. For authorization_code grant type: - Requires valid authorization code obtained from the OAuth authorization flow - Optionally requires code_verifier if PKCE was used during authorization For refresh_token grant type: - Requires valid refresh_token from a previous token exchange\",\n  input: SupabaseExchangeOauthTokenInput,\n  output: SupabaseExchangeOauthTokenOutput,\n});\n"],"mappings":";;;;AAMA,MAAa,kCAAkCA,IAAAA,EAAE,OAAO;CACtD,MAAMA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,uFAAuF,CAAC,CAAC,SAAS;CAC5H,WAAWA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,0BAA0B;CACzD,YAAYA,IAAAA,EAAE,KAAK,CAAC,sBAAsB,eAAe,CAAC,CAAC,CAAC,SAAS,6DAA6D;CAClI,cAAcA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,wIAAwI,CAAC,CAAC,SAAS;CACrL,eAAeA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,8BAA8B;CACjE,eAAeA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,wFAAwF,CAAC,CAAC,SAAS;CACtI,eAAeA,IAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,8FAA8F,CAAC,CAAC,SAAS;AAC9I,CAAC,CAAC,CAAC,SAAS,iGAAiG;AAC7G,MAAM,6CAA6CA,IAAAA,EAAE,KAAK,CAAC,QAAQ,CAAC;AACpE,MAAa,mCAAmCA,IAAAA,EAAE,OAAO;CACvD,YAAYA,IAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,iDAAiD,CAAC,CAAC,SAAS;CAClG,YAAY,2CAA2C,SAAS;CAChE,cAAcA,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