@abaxx_tech/v-integration-react 1.2.0-dev.6 → 1.2.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -257,21 +257,21 @@ Email input authentication component only. Provides a standalone email/Abaxx ID
257
257
 
258
258
  ## Error Handling
259
259
 
260
+ The library provides comprehensive error handling through two mechanisms: React Error Boundary for component errors and `authError` in the context for authentication flow errors.
261
+
260
262
  ### React Error Boundary
261
263
 
262
264
  All authentication components (`VerifierAuth`, `VerifierAuthQr`, and `VerifierAuthEmail`) are automatically wrapped with an `AuthErrorBoundary` component that catches React errors during rendering or in lifecycle methods.
263
265
 
264
266
  #### Features:
265
267
  - **Automatic Error Catching**: Catches errors that occur in the component tree during rendering
266
- - **User-Friendly Error UI**: Displays a centered error message with a dark overlay background
267
- - **Error Recovery**: Provides a "Try Again" button to reset the error state and retry
268
+ - **User-Friendly Error UI**: Displays a centered error message with a fixed overlay background
268
269
  - **Error Logging**: Automatically logs errors to the console for debugging
269
270
 
270
271
  #### Error Display:
271
- When an error occurs, users will see:
272
+ When a React error occurs, users will see:
272
273
  - A centered error message: "Something went wrong"
273
- - A descriptive message: "An unexpected error occurred during authentication. Please try again."
274
- - A "Try Again" button to reset the error state
274
+ - A descriptive message: "An unexpected error occurred. Please try again later."
275
275
 
276
276
  The error boundary uses a fixed position overlay that covers the entire viewport, ensuring the error message is always visible and centered both vertically and horizontally.
277
277
 
@@ -287,7 +287,330 @@ const LoginPage = () => {
287
287
  };
288
288
  ```
289
289
 
290
- **Note**: The error boundary only catches errors in React components. For network errors or API errors, use the `authError` property from `VContext` to handle them in your application logic.
290
+ **Note**: The error boundary only catches errors in React components. For network errors, API errors, or authentication flow errors, use the `authError` property from `VContext` to handle them in your application logic.
291
+
292
+ ### Authentication Error States (`authError`)
293
+
294
+ The `authError` property in `VContext` contains error messages for authentication flow failures. All error states are documented below with their causes, recovery strategies, and handling examples.
295
+
296
+ #### Error Categories
297
+
298
+ ##### 1. Input Validation Errors
299
+
300
+ These errors occur when user input is invalid or missing.
301
+
302
+ | Error Message | Cause | When It Occurs |
303
+ |--------------|-------|----------------|
304
+ | `"Invalid login. Email or Abaxx ID is required."` | Empty alias field | User attempts to authenticate without entering email/Abaxx ID |
305
+ | `"Invalid login. Please use your existing Email or Abaxx ID."` | Invalid or non-existent alias | Server responds with "Unable to request auth." |
306
+
307
+ **Recovery Strategy:**
308
+ - Clear the error message
309
+ - Allow user to re-enter their email/Abaxx ID
310
+ - Provide helpful validation feedback before submission
311
+ - No need to reset the entire authentication state
312
+
313
+ **Example:**
314
+ ```tsx
315
+ import { useContext, useEffect } from 'react';
316
+ import { VContext } from "@abaxx_tech/v-integration-react";
317
+
318
+ const LoginForm = () => {
319
+ const { authError, setAuthError } = useContext(VContext);
320
+
321
+ useEffect(() => {
322
+ if (authError?.includes("Invalid login")) {
323
+ // Clear error when user starts typing
324
+ const timer = setTimeout(() => setAuthError(null), 5000);
325
+ return () => clearTimeout(timer);
326
+ }
327
+ }, [authError, setAuthError]);
328
+
329
+ return (
330
+ <div>
331
+ {authError && (
332
+ <div className="error-message">
333
+ {authError}
334
+ <button onClick={() => setAuthError(null)}>Dismiss</button>
335
+ </div>
336
+ )}
337
+ {/* Your login form */}
338
+ </div>
339
+ );
340
+ };
341
+ ```
342
+
343
+ ##### 2. Authentication Request Errors
344
+
345
+ These errors occur when the authentication request to the server fails.
346
+
347
+ | Error Message | Cause | When It Occurs |
348
+ |--------------|-------|----------------|
349
+ | `"Auth request failed: ${message}"` | Server rejected the request | HTTP response is not OK or `data.ok === false` |
350
+ | `"Auth request failed: ${error}"` | Network or fetch exception | Exception thrown during fetch request |
351
+ | `"Something went wrong. Please try again later."` | Unexpected error | Generic catch-all error in authentication flow |
352
+
353
+ **Recovery Strategy:**
354
+ - For network errors: Retry the request after a short delay
355
+ - For server errors: Check API configuration and server status
356
+ - Provide a "Retry" button to allow manual retry
357
+ - Consider resetting authentication state if multiple retries fail
358
+
359
+ **Example:**
360
+ ```tsx
361
+ import { useContext, useState } from 'react';
362
+ import { VContext, useVerifierReset } from "@abaxx_tech/v-integration-react";
363
+
364
+ const ErrorHandler = () => {
365
+ const { authError, setAuthError } = useContext(VContext);
366
+ const resetState = useVerifierReset();
367
+ const [retryCount, setRetryCount] = useState(0);
368
+
369
+ const handleRetry = () => {
370
+ setAuthError(null);
371
+ setRetryCount(prev => prev + 1);
372
+ // Trigger re-authentication
373
+ window.location.reload(); // Or use your retry logic
374
+ };
375
+
376
+ const handleReset = () => {
377
+ resetState();
378
+ setRetryCount(0);
379
+ };
380
+
381
+ if (!authError) return null;
382
+
383
+ const isNetworkError = authError.includes("Auth request failed");
384
+ const isGenericError = authError.includes("Something went wrong");
385
+
386
+ return (
387
+ <div className="error-container">
388
+ <div className="error-message">{authError}</div>
389
+ {isNetworkError && retryCount < 3 && (
390
+ <button onClick={handleRetry}>
391
+ Retry ({retryCount}/3)
392
+ </button>
393
+ )}
394
+ <button onClick={handleReset}>
395
+ Start Over
396
+ </button>
397
+ </div>
398
+ );
399
+ };
400
+ ```
401
+
402
+ ##### 3. SSE Connection Errors
403
+
404
+ These errors occur when the Server-Sent Events (SSE) connection fails or is interrupted.
405
+
406
+ | Error Message | Cause | When It Occurs |
407
+ |--------------|-------|----------------|
408
+ | `"Connection lost. Reconnecting... (attempt X/3)"` | SSE connection interrupted | Connection lost during authentication flow (automatic retry in progress) |
409
+ | `"Unable to establish connection. Please check your network and try again."` | Maximum retries exceeded | SSE connection failed after 3 retry attempts |
410
+ | `"Connection setup failed: ${error}"` | SSE initialization failure | Failed to create EventSource connection |
411
+
412
+ **Recovery Strategy:**
413
+ - For reconnection errors: Wait for automatic retry (library handles this)
414
+ - For connection failures: Check network connectivity and API URL configuration
415
+ - Provide user feedback about connection status
416
+ - Allow manual retry by resetting state and restarting authentication
417
+ - Consider implementing exponential backoff for manual retries
418
+
419
+ **Example:**
420
+ ```tsx
421
+ import { useContext, useEffect } from 'react';
422
+ import { VContext, useVerifierReset } from "@abaxx_tech/v-integration-react";
423
+
424
+ const ConnectionStatus = () => {
425
+ const { authError, setAuthError } = useContext(VContext);
426
+ const resetState = useVerifierReset();
427
+
428
+ useEffect(() => {
429
+ if (authError?.includes("Connection lost")) {
430
+ // Connection is being retried automatically
431
+ // Just show status, no action needed
432
+ return;
433
+ }
434
+
435
+ if (authError?.includes("Unable to establish connection")) {
436
+ // Maximum retries exceeded
437
+ // User should manually retry
438
+ }
439
+ }, [authError]);
440
+
441
+ const handleManualRetry = () => {
442
+ resetState();
443
+ setAuthError(null);
444
+ // State reset will trigger new SSE connection
445
+ };
446
+
447
+ if (!authError) return null;
448
+
449
+ const isReconnecting = authError.includes("Reconnecting");
450
+ const isConnectionFailed = authError.includes("Unable to establish");
451
+
452
+ return (
453
+ <div className="connection-status">
454
+ {isReconnecting && (
455
+ <div className="reconnecting">
456
+ <Spinner />
457
+ <span>{authError}</span>
458
+ </div>
459
+ )}
460
+ {isConnectionFailed && (
461
+ <div className="connection-failed">
462
+ <p>{authError}</p>
463
+ <button onClick={handleManualRetry}>
464
+ Try Again
465
+ </button>
466
+ </div>
467
+ )}
468
+ </div>
469
+ );
470
+ };
471
+ ```
472
+
473
+ ##### 4. Token Exchange Errors
474
+
475
+ These errors occur when exchanging the authorization code for an access token fails.
476
+
477
+ | Error Message | Cause | When It Occurs |
478
+ |--------------|-------|----------------|
479
+ | `"Failed to obtain auth token: ${error}"` | Token exchange failed | Server rejected token exchange request or network error occurred |
480
+
481
+ **Recovery Strategy:**
482
+ - This is a critical error - authentication cannot complete
483
+ - Reset authentication state to start fresh
484
+ - Check server logs and API configuration
485
+ - Verify PKCE code verifier is correctly generated
486
+ - Consider logging this error for debugging
487
+
488
+ **Example:**
489
+ ```tsx
490
+ import { useContext, useEffect } from 'react';
491
+ import { VContext, useVerifierReset } from "@abaxx_tech/v-integration-react";
492
+
493
+ const TokenErrorHandler = () => {
494
+ const { authError, setAuthError } = useContext(VContext);
495
+ const resetState = useVerifierReset();
496
+
497
+ useEffect(() => {
498
+ if (authError?.includes("Failed to obtain auth token")) {
499
+ // Log critical error for debugging
500
+ console.error("Token exchange failed:", authError);
501
+
502
+ // Optionally send to error tracking service
503
+ // errorTrackingService.log(authError);
504
+ }
505
+ }, [authError]);
506
+
507
+ const handleRecovery = () => {
508
+ resetState();
509
+ setAuthError(null);
510
+ // User will need to restart authentication flow
511
+ };
512
+
513
+ if (!authError?.includes("Failed to obtain auth token")) {
514
+ return null;
515
+ }
516
+
517
+ return (
518
+ <div className="critical-error">
519
+ <h3>Authentication Failed</h3>
520
+ <p>{authError}</p>
521
+ <p>Please try logging in again.</p>
522
+ <button onClick={handleRecovery}>
523
+ Start Over
524
+ </button>
525
+ </div>
526
+ );
527
+ };
528
+ ```
529
+
530
+ ### Complete Error Handling Example
531
+
532
+ Here's a comprehensive example showing how to handle all error types in a consumer application:
533
+
534
+ ```tsx
535
+ import { useContext, useEffect, useState } from 'react';
536
+ import { VContext, useVerifierReset } from "@abaxx_tech/v-integration-react";
537
+
538
+ const AuthErrorHandler = () => {
539
+ const { authError, setAuthError, isAuthenticating, token } = useContext(VContext);
540
+ const resetState = useVerifierReset();
541
+ const [errorType, setErrorType] = useState<'validation' | 'network' | 'connection' | 'token' | null>(null);
542
+
543
+ // Categorize error type
544
+ useEffect(() => {
545
+ if (!authError) {
546
+ setErrorType(null);
547
+ return;
548
+ }
549
+
550
+ if (authError.includes("Invalid login")) {
551
+ setErrorType('validation');
552
+ } else if (authError.includes("Auth request failed") || authError.includes("Something went wrong")) {
553
+ setErrorType('network');
554
+ } else if (authError.includes("Connection") || authError.includes("Reconnecting")) {
555
+ setErrorType('connection');
556
+ } else if (authError.includes("Failed to obtain auth token")) {
557
+ setErrorType('token');
558
+ }
559
+ }, [authError]);
560
+
561
+ // Auto-dismiss validation errors after user interaction
562
+ useEffect(() => {
563
+ if (errorType === 'validation') {
564
+ const timer = setTimeout(() => setAuthError(null), 5000);
565
+ return () => clearTimeout(timer);
566
+ }
567
+ }, [errorType, setAuthError]);
568
+
569
+ const handleRetry = () => {
570
+ setAuthError(null);
571
+ // Trigger retry logic based on error type
572
+ if (errorType === 'connection' || errorType === 'token') {
573
+ resetState();
574
+ }
575
+ };
576
+
577
+ const handleDismiss = () => {
578
+ setAuthError(null);
579
+ };
580
+
581
+ if (!authError || !errorType) return null;
582
+
583
+ return (
584
+ <div className={`error-banner error-${errorType}`}>
585
+ <div className="error-content">
586
+ <span className="error-icon">⚠️</span>
587
+ <span className="error-message">{authError}</span>
588
+ </div>
589
+ <div className="error-actions">
590
+ {errorType === 'validation' && (
591
+ <button onClick={handleDismiss}>Dismiss</button>
592
+ )}
593
+ {(errorType === 'network' || errorType === 'connection') && (
594
+ <button onClick={handleRetry}>Retry</button>
595
+ )}
596
+ {errorType === 'token' && (
597
+ <button onClick={() => resetState()}>Start Over</button>
598
+ )}
599
+ </div>
600
+ </div>
601
+ );
602
+ };
603
+
604
+ // Usage in your app
605
+ const App = () => {
606
+ return (
607
+ <VerifierProvider apiUrl={API_URL} clientId={CLIENT_ID}>
608
+ <AuthErrorHandler />
609
+ <VerifierAuth title="My App" />
610
+ </VerifierProvider>
611
+ );
612
+ };
613
+ ```
291
614
 
292
615
  ## Context API
293
616
 
@@ -1,33 +1,166 @@
1
1
  import { default as default_2 } from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
+ /**
5
+ * Options for authentication request.
6
+ *
7
+ * @interface AuthOptions
8
+ * @property {string} alias - User's email or Abaxx ID
9
+ * @property {string} code_challenge - PKCE code challenge for secure authentication
10
+ * @property {string} request_id - Unique authentication request identifier
11
+ */
4
12
  export declare interface AuthOptions {
5
13
  alias: string;
6
14
  code_challenge: string;
7
15
  request_id: string;
8
16
  }
9
17
 
18
+ /**
19
+ * Response from authentication request.
20
+ *
21
+ * @interface AuthResponse
22
+ * @property {boolean} ok - Whether the authentication request was successful
23
+ * @property {string} [message] - Optional message describing the result or error
24
+ */
10
25
  export declare interface AuthResponse {
11
26
  ok: boolean;
12
27
  message?: string;
13
28
  }
14
29
 
30
+ /**
31
+ * Encodes a Uint8Array to a base64url string (URL-safe base64 encoding).
32
+ * Base64url uses '-' and '_' instead of '+' and '/', and removes padding '=' characters.
33
+ *
34
+ * @param {Uint8Array} buffer - The buffer to encode
35
+ * @returns {string} A base64url-encoded string
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const bytes = new Uint8Array([255, 254, 253]);
40
+ * const encoded = base64urlEncode(bytes); // Returns base64url string
41
+ * ```
42
+ */
15
43
  export declare function base64urlEncode(buffer: Uint8Array): string;
16
44
 
45
+ /**
46
+ * Generates a cryptographically secure random code verifier for PKCE (Proof Key for Code Exchange).
47
+ *
48
+ * @param {number} length - The length of the code verifier in bytes (typically 64 for PKCE)
49
+ * @returns {Uint8Array} A Uint8Array containing random bytes for the code verifier
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const verifier = generateCodeVerifier(64);
54
+ * const verifierString = base64urlEncode(verifier);
55
+ * ```
56
+ */
17
57
  export declare function generateCodeVerifier(length: number): Uint8Array;
18
58
 
59
+ /**
60
+ * Props for the VContextProvider component.
61
+ *
62
+ * @type {Object} Props
63
+ * @property {string} clientId - Client identifier for authentication
64
+ * @property {string} apiUrl - API URL for authentication endpoints
65
+ * @property {ReactNode} children - Child components to be wrapped with context
66
+ */
19
67
  declare type Props = {
20
68
  clientId: string;
21
69
  apiUrl: string;
22
70
  children: ReactNode;
23
71
  };
24
72
 
73
+ /**
74
+ * Unsafe function to reset authentication state directly from a context object.
75
+ *
76
+ * **Warning**: This function should only be used when you have direct access to the context object.
77
+ * Prefer using `useVerifierReset()` hook in React components.
78
+ *
79
+ * @param {React.ContextType<typeof VContext>} ctx - The authentication context object
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // Not recommended - use useVerifierReset() hook instead
84
+ * const context = useContext(VContext);
85
+ * resetVerifierStateUnsafe(context);
86
+ * ```
87
+ */
25
88
  export declare function resetVerifierStateUnsafe(ctx: default_2.ContextType<typeof VContext>): void;
26
89
 
90
+ /**
91
+ * Hook to reset all authentication state back to initial values.
92
+ *
93
+ * This hook provides access to the resetState function from the authentication context.
94
+ * When called, it resets all authentication-related state including:
95
+ * - identity, authRequestId, isAuthenticating
96
+ * - codeVerifier, codeChallenge, authCode
97
+ * - authRequestIdExpires, token, authError
98
+ *
99
+ * @returns {() => void} A function that resets all authentication state to initial values
100
+ *
101
+ * @example
102
+ * ```tsx
103
+ * import { useVerifierReset } from "@abaxx_tech/v-integration-react";
104
+ *
105
+ * const LogoutButton = () => {
106
+ * const resetState = useVerifierReset();
107
+ *
108
+ * const handleLogout = () => {
109
+ * resetState(); // Resets all authentication state
110
+ * };
111
+ *
112
+ * return <button onClick={handleLogout}>Logout</button>;
113
+ * };
114
+ * ```
115
+ */
27
116
  export declare function useVerifierReset(): () => void;
28
117
 
118
+ /**
119
+ * React context for authentication state and functions.
120
+ *
121
+ * This context provides access to all authentication-related state and functions
122
+ * throughout the component tree. Use `useContext(VContext)` to access the context
123
+ * in your components.
124
+ *
125
+ * @example
126
+ * ```tsx
127
+ * import { useContext } from 'react';
128
+ * import { VContext } from '@abaxx_tech/v-integration-react';
129
+ *
130
+ * const MyComponent = () => {
131
+ * const { token, identity, isAuthenticating } = useContext(VContext);
132
+ * // Use authentication state...
133
+ * };
134
+ * ```
135
+ */
29
136
  export declare const VContext: default_2.Context<VContextObj>;
30
137
 
138
+ /**
139
+ * Authentication context object providing access to all authentication-related state and functions.
140
+ *
141
+ * @typedef {Object} VContextObj@typedef {Object} VContextObj
142
+ * @property {string} apiUrl - API base URL for authentication endpoints
143
+ * @property {string} clientId - Client identifier for authentication
144
+ * @property {string} authRequestId - Current authentication request ID
145
+ * @property {React.Dispatch<React.SetStateAction<string>>} setAuthRequestId - Function to set the authentication request ID
146
+ * @property {string} identity - User identity after successful authentication
147
+ * @property {React.Dispatch<React.SetStateAction<string>>} setIdentity - Function to set the user identity
148
+ * @property {boolean} isAuthenticating - Whether authentication is currently in progress
149
+ * @property {React.Dispatch<React.SetStateAction<boolean>>} setIsAuthenticating - Function to set authentication status
150
+ * @property {string} codeVerifier - PKCE code verifier for secure authentication
151
+ * @property {React.Dispatch<React.SetStateAction<string>>} setCodeVerifier - Function to set the code verifier
152
+ * @property {string} codeChallenge - PKCE code challenge for secure authentication
153
+ * @property {React.Dispatch<React.SetStateAction<string>>} setCodeChallenge - Function to set the code challenge
154
+ * @property {string} authCode - Authorization code from successful authentication
155
+ * @property {React.Dispatch<React.SetStateAction<string>>} setAuthCode - Function to set the authorization code
156
+ * @property {Date} authRequestIdExpires - Expiration time for the authentication request
157
+ * @property {React.Dispatch<React.SetStateAction<Date>>} setAuthRequestIdExpires - Function to set the request expiration time
158
+ * @property {string | null} token - Authentication token, null if not authenticated
159
+ * @property {React.Dispatch<React.SetStateAction<string | null>>} setToken - Function to set the authentication token
160
+ * @property {string | null} authError - Authentication error message, null if no error
161
+ * @property {React.Dispatch<React.SetStateAction<string | null>>} setAuthError - Function to set authentication error
162
+ * @property {() => void} resetState - Resets all mutable state back to initial values
163
+ */
31
164
  export declare type VContextObj = {
32
165
  apiUrl: string;
33
166
  clientId: string;
@@ -52,12 +185,103 @@ export declare type VContextObj = {
52
185
  resetState: () => void;
53
186
  };
54
187
 
55
- export declare const VContextProvider: default_2.FC<Props>;
188
+ /* Excluded from this release type: VContextProvider */
56
189
 
190
+ /**
191
+ * Complete authentication UI component with QR code and email input.
192
+ *
193
+ * This component provides a full-screen authentication experience with:
194
+ * - Background image and branding
195
+ * - QR code generation with Abaxx branding
196
+ * - Email/Abaxx ID input field
197
+ * - Real-time authentication status updates
198
+ * - Loading states and error handling
199
+ * - Responsive design with grid layout
200
+ * - Automatic error boundary protection
201
+ *
202
+ * @param {VerifierAuthProps} props - The component props
203
+ * @param {string} props.title - Title displayed in the login UI (e.g., "Abaxx Drive")
204
+ * @param {string} [props.containerClass] - Additional CSS classes for the container
205
+ * @returns {JSX.Element} The complete authentication UI component
206
+ *
207
+ * @example
208
+ * ```tsx
209
+ * import { VerifierAuth } from "@abaxx_tech/v-integration-react";
210
+ * import "v-integration-react/index.css";
211
+ *
212
+ * const LoginPage = () => {
213
+ * return <VerifierAuth title="Abaxx Drive" />;
214
+ * };
215
+ * ```
216
+ */
57
217
  export declare const VerifierAuth: default_2.FC<VerifierAuthProps>;
58
218
 
219
+ /**
220
+ * Email input authentication component only.
221
+ *
222
+ * Provides a standalone email/Abaxx ID input field with authentication functionality.
223
+ * Features include:
224
+ * - Email/Abaxx ID input validation
225
+ * - Loading states with spinner animation
226
+ * - Real-time authentication status updates
227
+ * - Customizable styling with support for both Tailwind classes and hex colors
228
+ * - Error handling with user feedback
229
+ * - Success state with checkmark icon
230
+ * - Automatic error boundary protection
231
+ *
232
+ * @param {VerifierAuthEmailProps} props - The component props
233
+ * @param {string} [props.inputPlaceholder="Enter Email or Abaxx ID"] - Placeholder text for the input field
234
+ * @param {string} [props.buttonText="Sign In"] - Text displayed on the button
235
+ * @param {string} [props.inputHeight="v-h-10"] - Height class for the input field
236
+ * @param {string} [props.inputWidth="v-w-full"] - Width class for the input field
237
+ * @param {string} [props.inputTextColor="v-text-gray-600"] - Text color for the input field
238
+ * @param {string} [props.inputBorderColor="v-border-gray-400"] - Border color for the input field
239
+ * @param {string} [props.inputBackgroundColor="v-bg-transparent"] - Background color for the input field
240
+ * @param {string} [props.buttonHeight="v-h-10"] - Height class for the button
241
+ * @param {string} [props.buttonWidth="v-w-full"] - Width class for the button
242
+ * @param {string} [props.buttonBackgroundColor="v-bg-red"] - Background color for the button
243
+ * @param {string} [props.buttonTextColor="v-text-white"] - Text color for the button
244
+ * @param {string} [props.containerClass=""] - Additional CSS classes for the container
245
+ * @param {string} [props.checkmarkColor="#c40808"] - Color of the checkmark icon
246
+ * @returns {JSX.Element} The email authentication component
247
+ *
248
+ * @example
249
+ * ```tsx
250
+ * import { VerifierAuthEmail } from "@abaxx_tech/v-integration-react";
251
+ * import "v-integration-react/index.css";
252
+ *
253
+ * const EmailLoginAuth = () => {
254
+ * return (
255
+ * <VerifierAuthEmail
256
+ * inputPlaceholder="Enter your email"
257
+ * buttonText="Sign In"
258
+ * buttonBackgroundColor="#0b981"
259
+ * checkmarkColor="#0b981"
260
+ * />
261
+ * );
262
+ * };
263
+ * ```
264
+ */
59
265
  export declare const VerifierAuthEmail: default_2.FC<VerifierAuthEmailProps>;
60
266
 
267
+ /**
268
+ * Props for the VerifierAuthEmail component.
269
+ *
270
+ * @interface VerifierAuthEmailProps
271
+ * @property {string} [inputPlaceholder="Enter Email or Abaxx ID"] - Placeholder text for the input field
272
+ * @property {string} [buttonText="Sign In"] - Text displayed on the button
273
+ * @property {string} [inputHeight="v-h-10"] - Height class for the input field
274
+ * @property {string} [inputWidth="v-w-full"] - Width class for the input field
275
+ * @property {string} [inputTextColor="v-text-gray-600"] - Text color for the input field (Tailwind class or hex color)
276
+ * @property {string} [inputBorderColor="v-border-gray-400"] - Border color for the input field (Tailwind class or hex color)
277
+ * @property {string} [inputBackgroundColor="v-bg-transparent"] - Background color for the input field (Tailwind class or hex color)
278
+ * @property {string} [buttonHeight="v-h-10"] - Height class for the button
279
+ * @property {string} [buttonWidth="v-w-full"] - Width class for the button
280
+ * @property {string} [buttonBackgroundColor="v-bg-red"] - Background color for the button (Tailwind class or hex color)
281
+ * @property {string} [buttonTextColor="v-text-white"] - Text color for the button (Tailwind class or hex color)
282
+ * @property {string} [containerClass=""] - Additional CSS classes for the container
283
+ * @property {string} [checkmarkColor="#c40808"] - Color of the checkmark icon (hex color)
284
+ */
61
285
  export declare interface VerifierAuthEmailProps {
62
286
  inputPlaceholder?: string;
63
287
  buttonText?: string;
@@ -74,13 +298,75 @@ export declare interface VerifierAuthEmailProps {
74
298
  checkmarkColor?: string;
75
299
  }
76
300
 
301
+ /**
302
+ * Props for the VerifierAuth component.
303
+ *
304
+ * @interface VerifierAuthProps
305
+ * @property {string} title - Title displayed in the login UI
306
+ * @property {string} [containerClass] - Additional CSS classes for the container
307
+ */
77
308
  export declare interface VerifierAuthProps {
78
309
  title: string;
79
310
  containerClass?: string;
80
311
  }
81
312
 
313
+ /**
314
+ * QR code authentication component only.
315
+ *
316
+ * Displays a QR code that users can scan with the Verifier+ app for authentication.
317
+ * Features include:
318
+ * - Dynamic QR code generation with authentication parameters
319
+ * - Loading spinner while QR code is being generated
320
+ * - Optional status display with success/pending states
321
+ * - Customizable styling and branding
322
+ * - Automatic QR code updates when authentication parameters change
323
+ * - Automatic error boundary protection
324
+ *
325
+ * @param {VerifierAuthQrProps} props - The component props
326
+ * @param {number} [props.size=130] - QR code size in pixels
327
+ * @param {string} [props.qrColor="#e60100"] - QR code foreground color
328
+ * @param {string} [props.logoImage] - Logo URL to display in QR center
329
+ * @param {number} [props.logoWidth=40] - Logo width in pixels
330
+ * @param {number} [props.logoHeight=20] - Logo height in pixels
331
+ * @param {number} [props.quietZone=0] - Quiet zone around QR code
332
+ * @param {string} [props.containerClass=""] - Additional CSS classes for container
333
+ * @param {boolean} [props.showStatus=true] - Whether to show authentication status
334
+ * @param {string} [props.checkmarkColor="#c40808"] - Color of the checkmark icon
335
+ * @returns {JSX.Element} The QR code authentication component
336
+ *
337
+ * @example
338
+ * ```tsx
339
+ * import { VerifierAuthQr } from "@abaxx_tech/v-integration-react";
340
+ * import "v-integration-react/index.css";
341
+ *
342
+ * const QRLoginAuth = () => {
343
+ * return (
344
+ * <VerifierAuthQr
345
+ * size={150}
346
+ * qrColor="#e60100"
347
+ * checkmarkColor="#0b981"
348
+ * showStatus={true}
349
+ * />
350
+ * );
351
+ * };
352
+ * ```
353
+ */
82
354
  export declare const VerifierAuthQr: default_2.FC<VerifierAuthQrProps>;
83
355
 
356
+ /**
357
+ * Props for the VerifierAuthQr component.
358
+ *
359
+ * @interface VerifierAuthQrProps
360
+ * @property {number} [size=130] - QR code size in pixels
361
+ * @property {string} [qrColor="#e60100"] - QR code foreground color (hex color)
362
+ * @property {string} [logoImage="https://content.abaxx.com/assets/static/qr-logo.png"] - Logo URL to display in QR center
363
+ * @property {number} [logoWidth=40] - Logo width in pixels
364
+ * @property {number} [logoHeight=20] - Logo height in pixels
365
+ * @property {number} [quietZone=0] - Quiet zone around QR code
366
+ * @property {string} [containerClass=""] - Additional CSS classes for container
367
+ * @property {boolean} [showStatus=true] - Whether to show authentication status (success/pending)
368
+ * @property {string} [checkmarkColor="#c40808"] - Color of the checkmark icon (hex color)
369
+ */
84
370
  export declare interface VerifierAuthQrProps {
85
371
  size?: number;
86
372
  qrColor?: string;
@@ -93,8 +379,47 @@ export declare interface VerifierAuthQrProps {
93
379
  checkmarkColor?: string;
94
380
  }
95
381
 
382
+ /**
383
+ * Main provider component that wraps your application and manages authentication context.
384
+ *
385
+ * This component automatically handles:
386
+ * - PKCE code verifier and challenge generation
387
+ * - Server-Sent Events (SSE) connection for real-time authentication updates
388
+ * - Authentication state and token lifecycle management
389
+ * - Background authentication service
390
+ *
391
+ * @param {VerifierProviderProps} props - The provider props
392
+ * @param {string} props.apiUrl - API URL for authentication endpoints
393
+ * @param {string} props.clientId - Client identifier for authentication
394
+ * @param {ReactNode} props.children - Child components to be wrapped
395
+ * @returns {JSX.Element} The provider component with authentication context
396
+ *
397
+ * @example
398
+ * ```tsx
399
+ * import { VerifierProvider } from "@abaxx_tech/v-integration-react";
400
+ *
401
+ * const App = () => {
402
+ * return (
403
+ * <VerifierProvider
404
+ * apiUrl="https://api.example.com"
405
+ * clientId="your-client-id"
406
+ * >
407
+ * <YourApp />
408
+ * </VerifierProvider>
409
+ * );
410
+ * };
411
+ * ```
412
+ */
96
413
  export declare const VerifierProvider: default_2.FC<VerifierProviderProps>;
97
414
 
415
+ /**
416
+ * Props for the VerifierProvider component.
417
+ *
418
+ * @interface VerifierProviderProps
419
+ * @property {string} clientId - Client identifier for authentication
420
+ * @property {string} apiUrl - API URL for authentication endpoints
421
+ * @property {ReactNode} children - Child components to be wrapped with authentication context
422
+ */
98
423
  export declare interface VerifierProviderProps {
99
424
  clientId: string;
100
425
  apiUrl: string;
@@ -1978,12 +1978,26 @@ class gt extends Fr {
1978
1978
  error: null
1979
1979
  };
1980
1980
  }
1981
+ /**
1982
+ * Static method called when an error is thrown in a child component.
1983
+ * Updates the state to indicate an error has occurred.
1984
+ *
1985
+ * @param {Error} error - The error that was thrown
1986
+ * @returns {State} The new state with error information
1987
+ */
1981
1988
  static getDerivedStateFromError(Q) {
1982
1989
  return {
1983
1990
  hasError: !0,
1984
1991
  error: Q
1985
1992
  };
1986
1993
  }
1994
+ /**
1995
+ * Called after an error has been thrown by a descendant component.
1996
+ * Logs the error for debugging purposes.
1997
+ *
1998
+ * @param {Error} error - The error that was thrown
1999
+ * @param {ErrorInfo} errorInfo - Additional error information
2000
+ */
1987
2001
  componentDidCatch(Q, ee) {
1988
2002
  console.error("Authentication component error:", Q, ee);
1989
2003
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaxx_tech/v-integration-react",
3
- "version": "1.2.0-dev.6",
3
+ "version": "1.2.0-dev.8",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },