@crowdin/app-project-module
Version:
Module that generates for you all common endpoints for serving standalone Crowdin App
102 lines (101 loc) • 2.42 kB
TypeScript
import Crowdin from '@crowdin/crowdin-api-client';
import { CrowdinContextInfo, Environments, ModuleKey, UiModule } from '../../types';
/**
* Auth Guard verification type
*/
export type AuthGuardVerificationType = 'direct' | 'redirect' | 'iframe';
/**
* Auth Guard module options
*/
export interface AuthGuardOptions {
/**
* Verification type: direct (backend-only), redirect (external page), or iframe (embedded iframe)
* @default 'direct'
*/
type?: AuthGuardVerificationType;
/**
* Whether to apply this check to organization administrators
* @default false
*/
applyToAdmin?: boolean;
/**
* User-facing URL for redirect and iframe types
* Required if type is not 'direct'
*/
url?: string;
}
/**
* Request body for auth guard verification
*/
export interface AuthGuardVerifyRequest {
/**
* User ID
*/
userId: number;
/**
* Organization ID
*/
organizationId: number;
/**
* User's IP address
*/
ipAddress: string;
/**
* Module key to identify which auth-guard module to invoke
*/
moduleKey: string;
/**
* Verification code (provided for redirect/iframe types after user interaction)
*/
code?: string;
}
/**
* Response for auth guard verification
*/
export interface AuthGuardVerifyResponse {
/**
* Whether verification was successful
*/
success: boolean;
/**
* Optional error or informational message
*/
message?: string;
}
/**
* Auth Guard module configuration
*/
export interface AuthGuardModule extends ModuleKey, Environments {
/**
* Module name displayed to users during verification
*/
name?: string;
/**
* Module description (primarily for iframe type)
*/
description?: string;
/**
* Endpoint URL for verification (relative to baseUrl or absolute)
*/
url?: string;
/**
* Module configuration options
*/
options?: AuthGuardOptions;
/**
* Settings UI module for configuration
*/
settingsUiModule?: UiModule;
/**
* Verification logic function
*/
verify: (params: {
client?: Crowdin;
context?: CrowdinContextInfo;
userId: number;
organizationId: number;
ipAddress: string;
moduleKey: string;
code?: string;
}) => Promise<AuthGuardVerifyResponse>;
}