UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account v3.0, ZNS with Full Type Safety, Consultation Service, Broadcast Service, Group Messaging with List APIs, Social APIs, Enhanced Article Management, Promotion Service v3.0 with Multip

250 lines 4.43 kB
/** * Authentication related types and interfaces */ /** * Access token information */ export interface AccessToken { /** * Access token string */ access_token: string; /** * Token expiration time in seconds */ expires_in: number; /** * Refresh token (if available) */ refresh_token?: string; } /** * Refresh token response */ export interface RefreshTokenResponse { /** * New access token */ access_token: string; /** * Token expiration time in seconds */ expires_in: number; /** * New refresh token (if available) */ refresh_token?: string; } /** * OAuth authorization parameters */ export interface OAuthParams { /** * Application ID */ app_id: string; /** * Redirect URI */ redirect_uri: string; /** * OAuth state parameter */ state?: string; /** * Code verifier for PKCE (Social API) */ code_verifier?: string; /** * Code challenge for PKCE (Social API) */ code_challenge?: string; /** * Code challenge method for PKCE (Social API) */ code_challenge_method?: 'S256' | 'plain'; } /** * Authorization code exchange parameters */ export interface AuthCodeParams { /** * Application ID */ app_id: string; /** * Application secret */ app_secret: string; /** * Authorization code */ code: string; /** * Redirect URI (must match the one used in authorization) */ redirect_uri: string; /** * Code verifier for PKCE (supports both Social API and Official Account API) */ code_verifier?: string; } /** * Refresh token parameters */ export interface RefreshTokenParams { /** * Application ID */ app_id: string; /** * Application secret */ app_secret: string; /** * Refresh token */ refresh_token: string; } /** * Social user information from Zalo */ export interface SocialUserInfo { /** * User ID */ id: string; /** * Display name */ name: string; /** * Profile picture */ picture?: { data: { url: string; }; }; /** * Gender */ gender?: string; /** * Birthday */ birthday?: string; /** * Location */ location?: { name: string; }; /** * Whether the account is sensitive (under 18) */ is_sensitive?: boolean; } /** * Token validation result */ export interface TokenValidation { /** * Whether the token is valid */ valid: boolean; /** * Token expiration timestamp */ expires_at?: number; /** * Associated user information (if available) */ user_info?: SocialUserInfo; } /** * Authentication scope for different APIs */ export declare enum AuthScope { /** * Official Account API scope */ OA = "oa", /** * Social API scope */ SOCIAL = "social", /** * ZNS (Zalo Notification Service) scope */ ZNS = "zns" } /** * Authentication method */ export declare enum AuthMethod { /** * OAuth 2.0 Authorization Code flow */ AUTHORIZATION_CODE = "authorization_code", /** * Refresh token flow */ REFRESH_TOKEN = "refresh_token" } /** * PKCE (Proof Key for Code Exchange) configuration */ export interface PKCEConfig { /** * Code verifier */ code_verifier: string; /** * Code challenge */ code_challenge: string; /** * Code challenge method */ code_challenge_method: 'S256' | 'plain'; } /** * Authentication URLs */ export interface AuthUrls { /** * Official Account authorization URL */ oa_auth_url: string; /** * Social API authorization URL */ social_auth_url: string; /** * Token exchange URL */ token_url: string; /** * Token refresh URL */ refresh_url: string; } /** * Official Account authorization result */ export interface OAAuthResult { /** * Authorization URL */ url: string; /** * State parameter used (auto-generated if not provided) */ state: string; /** * PKCE configuration used (if PKCE was enabled) */ pkce?: PKCEConfig; } //# sourceMappingURL=auth.d.ts.map