UNPKG

@datalayer/core

Version:

[![Datalayer](https://assets.datalayer.tech/datalayer-25.svg)](https://datalayer.io)

116 lines (115 loc) 4.81 kB
/** * OAuth2 provider types supported by the platform */ export type OAuth2Provider = 'github' | 'linkedin' | 'okta'; /** * Response from the OAuth2 authorization URL endpoint */ export interface OAuth2AuthzUrlResponse { success: boolean; message: string; loginURL: string; } /** * OAuth2 callback parameters */ export interface OAuth2CallbackParams { code?: string; state: string; error?: string; error_description?: string; error_uri?: string; } /** * OAuth2 callback response (HTML content) */ export type OAuth2CallbackResponse = string; /** * Get the OAuth2 authorization URL for a specific provider * @param provider - OAuth2 provider (bluesky, github, linkedin, okta) * @param callbackUri - Server endpoint to call with the authz token * @param nonce - Optional nonce for security * @param baseUrl - Base URL for the API (defaults to production IAM URL) * @returns OAuth2 authorization URL response * @throws {Error} If required parameters are missing or invalid * * @remarks * This endpoint generates the OAuth2 authorization URL for the specified provider. * Users should be redirected to the returned loginURL to begin the OAuth2 flow. * * Expected status codes: * - 200: Successfully generated authorization URL * - 400: Invalid parameters * - 404: Provider not found or not configured */ export declare const getOAuth2AuthzUrl: (provider: OAuth2Provider, callbackUri: string, nonce?: string, baseUrl?: string) => Promise<OAuth2AuthzUrlResponse>; /** * Get the OAuth2 authorization URL for linking a provider to an existing account * @param provider - OAuth2 provider (bluesky, github, linkedin, okta) * @param callbackUri - Server endpoint to call with the authz token * @param baseUrl - Base URL for the API (defaults to production IAM URL) * @returns OAuth2 authorization URL response * @throws {Error} If required parameters are missing or invalid * * @remarks * This endpoint generates the OAuth2 authorization URL for linking a provider to an existing account. * Users should be redirected to the returned loginURL to begin the OAuth2 linking flow. * This is different from the regular OAuth2 login flow as it links the provider to an existing account. * * Expected status codes: * - 200: Successfully generated authorization URL * - 400: Invalid parameters * - 404: Provider not found or not configured */ export declare const getOAuth2AuthzUrlForLink: (provider: OAuth2Provider, callbackUri: string, baseUrl?: string) => Promise<OAuth2AuthzUrlResponse>; /** * Handle GitHub OAuth2 callback * @param params - OAuth2 callback parameters * @param baseUrl - Base URL for the API (defaults to production IAM URL) * @returns HTML response from the callback handler * @throws {Error} If state parameter is missing * @throws {Error} If the callback fails * * @remarks * This endpoint handles the callback from GitHub after the user authorizes the application. * It returns HTML content that typically includes JavaScript to handle the OAuth flow completion. * * Expected status codes: * - 200: Callback processed successfully (returns HTML) * - 403: Unauthorized */ export declare const handleGitHubOAuth2Callback: (params: OAuth2CallbackParams, baseUrl?: string) => Promise<OAuth2CallbackResponse>; /** * Handle LinkedIn OAuth2 callback * @param params - OAuth2 callback parameters * @param baseUrl - Base URL for the API (defaults to production IAM URL) * @returns HTML response from the callback handler * @throws {Error} If state parameter is missing * @throws {Error} If the callback fails * * @remarks * This endpoint handles the callback from LinkedIn after the user authorizes the application. * It returns HTML content that typically includes JavaScript to handle the OAuth flow completion. * * Expected status codes: * - 200: Callback processed successfully (returns HTML) * - 403: Unauthorized */ export declare const handleLinkedInOAuth2Callback: (params: OAuth2CallbackParams, baseUrl?: string) => Promise<OAuth2CallbackResponse>; /** * Handle Okta OAuth2 callback * @param params - OAuth2 callback parameters * @param baseUrl - Base URL for the API (defaults to production IAM URL) * @returns HTML response from the callback handler * @throws {Error} If state parameter is missing * @throws {Error} If the callback fails * * @remarks * This endpoint handles the callback from Okta after the user authorizes the application. * It returns HTML content that typically includes JavaScript to handle the OAuth flow completion. * * Expected status codes: * - 200: Callback processed successfully (returns HTML) * - 403: Unauthorized */ export declare const handleOktaOAuth2Callback: (params: OAuth2CallbackParams, baseUrl?: string) => Promise<OAuth2CallbackResponse>;