import type { CustomerSigningCapture, CustomerSigningConfig, CustomerGender, CustomerMaritalStatus, AgentDeviceAttestationMode, AgentDeviceAttestationPayload, AgentDeviceAttestationPlatform, AgentDeviceAttestationProvider, AgentFlowConfig, AgentFlowStepDefinition, AgentLoginChallenge, AgentLoginChallengeRequest, AgentScreenType, AgentWorkflowDetail, AgentWorkflowDefinitionSummary, AgentWorkflowHistoryItem, AgentWorkflowHistoryPage, AgentWorkflowLaunchFlowConfig, AgentWorkflowLaunchResult } from '@mikashboks/agent-flow-contract'; export interface AgentSDKConfig { /** Base URL of the Ballerine API (e.g., "https://api.verify.example.com/api/v1") */ baseUrl: string; /** Project ID sent as x-project-id header */ projectId: string; /** Custom fetch implementation (defaults to globalThis.fetch) */ fetch?: typeof globalThis.fetch; /** Timeout in milliseconds (default: 60000) */ timeoutMs?: number; /** Called when access token is refreshed (persist new tokens) */ onTokenRefresh?: (tokens: { accessToken: string; refreshToken: string; }) => void; /** Called when auth fails irrecoverably (e.g., refresh token expired) */ onAuthFailure?: () => void; } export interface LoginParams { phone: string; password: string; deviceId?: string; attestation?: AgentDeviceAttestationPayload; } export interface LoginRequestOptions { projectId?: string | null; } export interface LoginWithProjectResolutionOptions { persistTokens?: boolean; } export type LoginChallengeParams = AgentLoginChallengeRequest; export type LoginChallengeResult = AgentLoginChallenge; /** Slim agent summary returned from login (not the full profile). */ export interface LoginAgentSummary { id: string; externalId: string; firstName: string; lastName: string; employerName: string; status: 'Active' | 'Suspended' | 'Revoked'; } export interface LoginResult { accessToken: string; refreshToken: string; mustChangePassword: boolean; agent: LoginAgentSummary; tenantConfig?: LoginTenantConfig; } export interface LoginTenantConfig { tenantAlias: string; tenantLabel: string; projectId: string; projectName?: string; workflowDefinitionId: string; apiBaseUrl?: string; } export interface LoginProjectSelectionResult { requiresProjectSelection: true; projects: LoginTenantConfig[]; } export type LoginWithProjectResolutionResult = LoginResult | LoginProjectSelectionResult; export interface RefreshResult { accessToken: string; refreshToken: string; } export interface ChangePasswordParams { currentPassword: string; newPassword: string; } export interface LogoutParams { refreshToken?: string; allSessions?: boolean; } export interface RegisterPushTokenParams { expoPushToken: string; nativePushToken?: string; deviceId?: string; platform?: AgentDeviceAttestationPlatform; } export interface PushTokenRegistration { id: string; expoPushToken: string; nativePushToken?: string; deviceId?: string; platform?: string; enabled: boolean; lastRegisteredAt: string; } export interface UnregisterPushTokenParams { expoPushToken?: string; deviceId?: string; } export interface UnregisterPushTokenResult { success: boolean; } export interface AgentProfile { id: string; externalId: string; firstName: string; lastName: string; phone: string; email?: string; employerName: string; employerCode?: string; status: 'Active' | 'Suspended' | 'Revoked'; location?: string; mustChangePassword: boolean; availableWorkflows?: AgentWorkflowDefinitionSummary[]; defaultWorkflowDefinitionId?: string | null; dailyCaptureLimit?: number | null; agentFlowConfig?: AgentFlowConfig | null; promotionConfig?: AgentPromotionConfig | null; } export type AgentPromotionPlacement = 'kyc_final' | 'kyc_status_card' | 'agent_dashboard' | 'agent_settings'; export interface AgentPromotionCtaConfig { enabled: boolean; title: string; body: string; label: string; url: string; placements: AgentPromotionPlacement[]; } export interface AgentPromotionSmsConfig { poweredByFooterEnabled?: boolean; marketingCtaEnabled: false; } export interface AgentPromotionConfig { enabled: boolean; poweredByLabel?: string; cta?: AgentPromotionCtaConfig; sms?: AgentPromotionSmsConfig; } export interface CustomerInfo { maritalStatus?: CustomerMaritalStatus | null; firstName?: string; lastName?: string; phone?: string; nationalId?: string; email?: string; dateOfBirth?: string; gender?: CustomerGender | null; /** Holder nationality, ISO 3166 alpha-3; never residence/issuing country. */ nationality?: string | null; } export interface GeoLocation { lat: number; lng: number; accuracy?: number; } export interface CreateWorkflowParams { applicationReference?: string; signingPolicyDigest?: string; customerInfo?: CustomerInfo | null; subjectType?: 'individual' | 'business'; subjectData?: Record | null; metadata?: Record | null; externalEntityId?: string; workflowDefinitionId: string; workflowDefinitionVersion?: number; idempotencyKey?: string; geoLocation?: GeoLocation; captureReason?: string; } export type CreateWorkflowResult = AgentWorkflowLaunchResult & { applicationReference?: string; signingPolicyDigest?: string; }; export interface SigningSession { applicationRevision: string; signingRevision: number; agentFlowConfig: AgentFlowConfig; applicationContext: Record; workflowDefinitionId: string; workflowDefinitionVersion: number; sessionId: string; applicationReference: string; applicationSnapshot: string; applicationDigest: string; policyDigest: string; expiresAt: string; config: CustomerSigningConfig; } export type SigningEvidenceRole = 'original' | 'specimen' | 'witness'; export interface SigningSpecimenCrop { sourceEvidenceId: string; x: number; y: number; width: number; height: number; } export interface SigningEvidenceUploadParams { sessionId: string; captureId: string; role: SigningEvidenceRole; crop?: SigningSpecimenCrop; } export interface SigningEvidenceUploadResult { id: string; fileId: string; role: SigningEvidenceRole; sha256: string; mimeType: string; } export interface SigningReceipt { id: string; applicationReference: string; applicationDigest: string; captureId: string; receivedAt: string; artifactStatus?: 'pending' | 'ready' | 'failed'; current?: boolean; } export type SigningSubmissionCapture = CustomerSigningCapture & { sessionId: string; }; export interface GraduateWorkflowParams { workflowDefinitionVersion?: number; idempotencyKey?: string; metadata?: Record | null; subjectData?: Record | null; geoLocation?: GeoLocation; captureReason?: string; } export type GraduateWorkflowResult = AgentWorkflowLaunchResult; export interface ReissueWorkflowTokenResult { workflowId: string; workflowToken: string; expiresAt: string; } export interface AbandonWorkflowParams { workflowId: string; workflowToken?: string | null; reason: 'capture_changed' | 'submit_mismatch'; } export interface AbandonWorkflowResult { workflowId: string; abandoned: true; } export type WorkflowSummary = AgentWorkflowHistoryItem; export interface ListWorkflowsParams { limit?: number; cursor?: string | null; } export type WorkflowSummaryPage = AgentWorkflowHistoryPage; export type WorkflowDetail = AgentWorkflowDetail & { customerSigning?: { enabled: boolean; requiresAcceptance: boolean; canResign: boolean; applicationReference?: string; policyDigest?: string; }; }; export interface AgentStats { todayCount: number; last24HoursCount?: number; totalCount: number; activeCount: number; completedCount: number; failedCount: number; } /** Periods the agent scorecard accepts. The server reads any other value as 30. */ export type AgentScorecardDays = 7 | 30 | 90; export interface GetAgentScorecardParams { /** Last N days up to now. Defaults to 30 on the server. */ days?: AgentScorecardDays; } export interface GetAgentScorecardOptions { timeoutMs?: number; /** Cancels the request. An aborted request rejects with an Error named 'AbortError'. */ signal?: AbortSignal; } export interface AgentScorecardReason { code: string; label: string; count: number; } /** * The average of the agent's branch (the branch of their latest case). Both * rates are fractions 0..1 of the branch's decided cases; null when the branch * has no decided case in the period. */ export interface AgentScorecardBranch { approvedFirstTimeRate: number | null; rejectedRate: number | null; } /** GET /external/agents/workflows/scorecard: the signed-in agent's own figures. */ export interface AgentScorecard { days: number; /** ISO timestamp of the start of the window. */ from: string; /** ISO timestamp of the end of the window. */ to: string; submitted: number; decided: number; approved: number; rejected: number; correctionsAsked: number; approvedFirstTime: number; medianHoursToDecision: number | null; /** At most three, most frequent first. */ topReasons: AgentScorecardReason[]; /** Null when the agent has no case with a branch. */ branch: AgentScorecardBranch | null; } export interface WorkflowStatus { id: string; status: string; state?: string; createdAt: string; resolvedAt?: string; } export interface DocumentMetadata { type: string; side?: 'front' | 'back'; category?: string; issuingCountry?: string; issuingVersion?: string | number; pageNumber?: number; endUserId?: string; businessId?: string; documentType?: string; /** * 'liveness_frame' is a record-only selfie burst frame (selfie documents, * pages 3000+). The server attaches it to the existing selfie and never uses * it as the selfie itself. */ documentVariant?: 'front' | 'back' | 'other' | 'liveness_frame'; /** * File id of the selfie a 'liveness_frame' belongs to. Sent (trimmed) only * for 'liveness_frame' uploads and ignored for every other variant; the * server rejects a frame whose selfie was superseded (HTTP 409 * LIVENESS_FRAME_SELFIE_SUPERSEDED). */ selfieFileId?: string; captureSource?: 'in_app_camera' | 'system_camera' | 'gallery'; geoLocation?: GeoLocation; [key: string]: unknown; } export interface UploadResult { id: string; files?: Array<{ id?: string; fileId?: string; documentId?: string; type?: string; variant?: 'front' | 'back' | 'other' | string; page?: number; [key: string]: unknown; }>; [key: string]: unknown; } export interface UploadProgress { loaded: number; total: number | null; } export interface RequestTimeoutOptions { timeoutMs?: number; } export interface UploadDocumentOptions extends RequestTimeoutOptions { onUploadProgress?: (progress: UploadProgress) => void; /** * Cancels the upload. An aborted upload rejects with an Error whose name is * 'AbortError' (not a NetworkError), so callers can tell it from a failure. */ signal?: AbortSignal; } export interface ReactNativeUploadFile { uri: string; name?: string; type?: string; } export type UploadDocumentInput = Blob | ReactNativeUploadFile; export interface FlowContext { entity?: Record; documents?: Array>; metadata?: Record; [key: string]: unknown; } export interface PreSubmissionCheckIssue { code: string; target: string; severity: 'retake' | 'warning'; message: string; [key: string]: unknown; } export type PreSubmissionCheckOutcome = 'BLOCK_RETAKE' | 'WARN_ALLOW_SUBMIT' | 'UNAVAILABLE_ALLOW_SUBMIT'; export interface PreSubmissionCheckResult { status: 'READY' | 'RETAKE_REQUIRED' | 'CHECK_UNAVAILABLE'; canSubmit: boolean; issues: PreSubmissionCheckIssue[]; outcome?: PreSubmissionCheckOutcome; normalized?: { identityDocumentType?: string; country?: string; [key: string]: unknown; }; preSubmissionCheckId?: string; [key: string]: unknown; } export interface PreSubmissionCheckOptions extends RequestTimeoutOptions { } export interface SubmitFlowOptions extends RequestTimeoutOptions { preSubmissionCheckId?: string; } export interface ClientTimingPayload { eventName: string; workflowId?: string | null; mode?: string; timings?: Record; [key: string]: unknown; } export type { AgentDeviceAttestationMode, AgentDeviceAttestationPayload, AgentDeviceAttestationPlatform, AgentDeviceAttestationProvider, AgentFlowConfig, AgentFlowStepDefinition, AgentLoginChallenge, AgentLoginChallengeRequest, AgentScreenType, AgentWorkflowDetail, AgentWorkflowDefinitionSummary, AgentWorkflowLaunchFlowConfig, AgentWorkflowLaunchResult, }; //# sourceMappingURL=types.d.ts.map