How rpo-pay/threedsecure-react works
Main System Type and Purpose
• This is a frontend‐only React library (written in TypeScript) that provides hooks to implement the full 3D Secure (3DS) authentication flow.
• It also includes a demo application under src/ for local development and testing.
Break Down the File Structure into Logical Components
A. Library Package (lib/)
1. Hooks Submodule (lib/hooks/):
• useThreeDSecure (core hook)
• useApi, useBase64Encoder, useChallenge, useDsMethod, useThreeDSecure
2. Models Submodule (lib/models/):
• Domain classes/interfaces (e.g., Bucket)
3. Types Submodule (lib/types/):
• TypeScript definitions for requests/responses (authentication, threedsecure‐parameters, threedsecure‐result)
4. Main Entry Point (lib/main.ts):
• Exports all public hooks/models/types for consumers
B. Demo Application (src/)
• src/App.tsx and src/main.tsx
• Demonstrates library usage and renders challenge container
C. Public Assets (public/ / index.html)
• Static HTML shell for the Vite dev server
D. Build & Config
• Vite config (vite.config.ts), TypeScript configs (tsconfig.*.json)
• NPM publishing pipeline (.github/workflows/npm-publish.yml)
• ESLint, Biome, GitHub Actions
External Services
• 3DS Core API (baseUrl: https://api.sqala.tech/core/v1/threedsecure)
• Directory Server interactions
• Challenge rendering (IFRAME container)
• Result callbacks
Architectural Patterns & Data Flows
• Library Build Pipeline (build‐time):
• Source .ts/.tsx → Vite compiles → outputs ESM/CJS in dist/ → NPM publish
• Runtime Flow:
• Consumer app calls useThreeDSecure.execute()
• Hook uses useApi to send requests to 3DS Core API
• Core API returns HTML challenge → injected into the containerRef (IFRAME)
• Hook listens for responses (postMessage or polling via useDsMethod)
• Final result passed back to the React component
• Build Tools (Vite, TS Compiler, GitHub Actions)
• Library Modules (Hooks, Models, Types, Entry Point)
• Demo App (React Components)
• Static Assets (public/index.html)
• External 3DS Core API (Directory Server, Challenge Endpoint)
• Consumer Application (could be any React app importing the library)
c. Architectural Patterns:
• Modular Library Design: clear separation into hooks, models, types
• Hook‐based API: encapsulates side effects and state management
• External Service Integration: plug‐and‐play via baseUrl
d. Key Technologies (label next to components):
• React, TypeScript, Vite, ESM/CJS, GitHub Actions
Essential Elements to Capture
• Build pipeline from source → dist → NPM
• Separation between library code and demo app
• Hook invocation flow → external 3DS API → challenge container → result handling
• Configuration boundaries (Vite, TS configs)