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

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.
@@ -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.7",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },