@dynamicore/jumio-sdk 1.0.0 → 1.0.2

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,4 +1,4 @@
1
- import { a as JumioClientConfig, J as JumioClient, e as JumioStatusResolvedCallback, d as JumioStatusErrorCallback, c as JumioProgressCallback, i as VerifyIneResult, V as VerifyIneInput } from '../client-BR1xIZ0X.mjs';
1
+ import { a as JumioClientConfig, J as JumioClient, e as JumioStatusResolvedCallback, d as JumioStatusErrorCallback, c as JumioProgressCallback, l as VerifyIneResult, V as VerifyIneInput, W as WebflowResult, j as StartWebflowInput, k as StartWebflowResult, m as WebflowReturnParams } from '../client-BwEiGMPy.mjs';
2
2
  import 'axios';
3
3
 
4
4
  /**
@@ -87,6 +87,110 @@ interface UseJumioVerificationReturn extends UseJumioVerificationState {
87
87
  */
88
88
  client: JumioClient;
89
89
  }
90
+ /**
91
+ * Opciones para configurar el hook `useJumioWebflow`.
92
+ */
93
+ interface UseJumioWebflowOptions extends JumioClientConfig {
94
+ /**
95
+ * Instancia existente de `JumioClient` (opcional). Si se pasa, reutiliza dicha instancia.
96
+ */
97
+ client?: JumioClient;
98
+ /**
99
+ * Callback ejecutado cuando el sondeo de resultados resuelve un veredicto final.
100
+ */
101
+ onResult?: (result: WebflowResult) => void;
102
+ /**
103
+ * Callback ejecutado si ocurre un error durante el inicio o el sondeo del flujo.
104
+ */
105
+ onError?: (error: Error) => void;
106
+ }
107
+ /**
108
+ * Estado reactivo expuesto por el hook `useJumioWebflow`.
109
+ */
110
+ interface UseJumioWebflowState {
111
+ /**
112
+ * `true` mientras se esté realizando la solicitud de inicio del flujo (POST).
113
+ */
114
+ isStarting: boolean;
115
+ /**
116
+ * `true` mientras se esté sondeando el estado de la verificación (GET polling).
117
+ */
118
+ isChecking: boolean;
119
+ /**
120
+ * `true` mientras cualquiera de los dos procesos esté activo.
121
+ */
122
+ isLoading: boolean;
123
+ /**
124
+ * Resultado de la verificación si ya está disponible.
125
+ */
126
+ result: WebflowResult | null;
127
+ /**
128
+ * Error más reciente ocurrido durante el inicio o el sondeo.
129
+ */
130
+ error: Error | null;
131
+ /**
132
+ * `true` si la verificación resultó válida (aprobada).
133
+ */
134
+ isValid: boolean;
135
+ /**
136
+ * `true` si la verificación fue rechazada o si ocurrió un error no recuperable.
137
+ */
138
+ isRejected: boolean;
139
+ }
140
+ /**
141
+ * Retorno del hook `useJumioWebflow`.
142
+ */
143
+ interface UseJumioWebflowReturn extends UseJumioWebflowState {
144
+ /**
145
+ * Inicia el flujo Hosted Webflow: solicita la URL de verificación al backend
146
+ * y opcionalmente redirige al usuario automáticamente.
147
+ *
148
+ * @param input Parámetros del flujo. Si `autoRedirect` es `true`, el navegador
149
+ * se redirigirá automáticamente a la URL de Jumio.
150
+ * @returns `StartWebflowResult` con el `href` de Jumio.
151
+ */
152
+ startWebflow: (input: StartWebflowInput) => Promise<StartWebflowResult>;
153
+ /**
154
+ * Consulta o sondea el estado de verificación tras el retorno de Jumio.
155
+ * Usa los `accountId` y `workflowId` obtenidos de la URL de retorno.
156
+ *
157
+ * @param params `accountId`, `workflowId`, y `clientId` opcional.
158
+ * @param options Opciones de sondeo (maxAttempts, pollingIntervalMs, etc.).
159
+ * @returns `WebflowResult` con el veredicto final.
160
+ */
161
+ checkResult: (params: {
162
+ accountId: string;
163
+ workflowId: string;
164
+ clientId?: string;
165
+ }, options?: {
166
+ maxAttempts?: number;
167
+ pollingIntervalMs?: number;
168
+ signal?: AbortSignal;
169
+ }) => Promise<WebflowResult>;
170
+ /**
171
+ * Extrae los parámetros de retorno de Jumio de la URL actual o provista.
172
+ * Util para leer `accountId` y `workflowId` al montar el componente de retorno.
173
+ *
174
+ * @param source URL completa, `URLSearchParams`, o nada para usar `window.location`.
175
+ * @returns `WebflowReturnParams`.
176
+ */
177
+ parseReturnParams: (source?: string | URLSearchParams | {
178
+ search?: string;
179
+ href?: string;
180
+ }) => WebflowReturnParams;
181
+ /**
182
+ * Cancela cualquier operación activa en curso.
183
+ */
184
+ cancel: () => void;
185
+ /**
186
+ * Reinicia el estado del hook a sus valores iniciales.
187
+ */
188
+ reset: () => void;
189
+ /**
190
+ * Instancia subyacente de `JumioClient`.
191
+ */
192
+ client: JumioClient;
193
+ }
90
194
 
91
195
  /**
92
196
  * Hook de React para integrar validación de documentos e INE con Jumio.
@@ -104,4 +208,44 @@ interface UseJumioVerificationReturn extends UseJumioVerificationState {
104
208
  */
105
209
  declare function useJumioVerification(options?: UseJumioVerificationOptions): UseJumioVerificationReturn;
106
210
 
107
- export { type UseJumioVerificationOptions, type UseJumioVerificationReturn, type UseJumioVerificationState, useJumioVerification };
211
+ /**
212
+ * Hook de React para integrar el flujo Hosted Webflow de Jumio (verificacion por redireccion).
213
+ *
214
+ * @example Paso 1 - Iniciar el flujo (componente de inicio):
215
+ * ```tsx
216
+ * const { startWebflow, isStarting, error } = useJumioWebflow({
217
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL,
218
+ * context: process.env.NEXT_PUBLIC_DYNAMICORE_CONTEXT,
219
+ * });
220
+ *
221
+ * const handleStart = async () => {
222
+ * const { href } = await startWebflow({
223
+ * clientId: "usr_123",
224
+ * successUrl: `${window.location.origin}/verify/return`,
225
+ * errorUrl: `${window.location.origin}/verify/return`,
226
+ * autoRedirect: true, // redirige automaticamente
227
+ * });
228
+ * // si autoRedirect es false, redirigir manualmente:
229
+ * // window.location.href = href;
230
+ * };
231
+ * ```
232
+ *
233
+ * @example Paso 2 - Verificar resultado (componente de retorno, en /verify/return):
234
+ * ```tsx
235
+ * const { parseReturnParams, checkResult, isChecking, result, isValid } = useJumioWebflow({
236
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL,
237
+ * context: process.env.NEXT_PUBLIC_DYNAMICORE_CONTEXT,
238
+ * onResult: (r) => { if (r.valid) router.push("/dashboard"); },
239
+ * });
240
+ *
241
+ * useEffect(() => {
242
+ * const { accountId, workflowId } = parseReturnParams();
243
+ * if (accountId && workflowId) {
244
+ * checkResult({ accountId, workflowId, clientId: "usr_123" });
245
+ * }
246
+ * }, []);
247
+ * ```
248
+ */
249
+ declare function useJumioWebflow(options?: UseJumioWebflowOptions): UseJumioWebflowReturn;
250
+
251
+ export { type UseJumioVerificationOptions, type UseJumioVerificationReturn, type UseJumioVerificationState, type UseJumioWebflowOptions, type UseJumioWebflowReturn, type UseJumioWebflowState, useJumioVerification, useJumioWebflow };
@@ -1,4 +1,4 @@
1
- import { a as JumioClientConfig, J as JumioClient, e as JumioStatusResolvedCallback, d as JumioStatusErrorCallback, c as JumioProgressCallback, i as VerifyIneResult, V as VerifyIneInput } from '../client-BR1xIZ0X.js';
1
+ import { a as JumioClientConfig, J as JumioClient, e as JumioStatusResolvedCallback, d as JumioStatusErrorCallback, c as JumioProgressCallback, l as VerifyIneResult, V as VerifyIneInput, W as WebflowResult, j as StartWebflowInput, k as StartWebflowResult, m as WebflowReturnParams } from '../client-BwEiGMPy.js';
2
2
  import 'axios';
3
3
 
4
4
  /**
@@ -87,6 +87,110 @@ interface UseJumioVerificationReturn extends UseJumioVerificationState {
87
87
  */
88
88
  client: JumioClient;
89
89
  }
90
+ /**
91
+ * Opciones para configurar el hook `useJumioWebflow`.
92
+ */
93
+ interface UseJumioWebflowOptions extends JumioClientConfig {
94
+ /**
95
+ * Instancia existente de `JumioClient` (opcional). Si se pasa, reutiliza dicha instancia.
96
+ */
97
+ client?: JumioClient;
98
+ /**
99
+ * Callback ejecutado cuando el sondeo de resultados resuelve un veredicto final.
100
+ */
101
+ onResult?: (result: WebflowResult) => void;
102
+ /**
103
+ * Callback ejecutado si ocurre un error durante el inicio o el sondeo del flujo.
104
+ */
105
+ onError?: (error: Error) => void;
106
+ }
107
+ /**
108
+ * Estado reactivo expuesto por el hook `useJumioWebflow`.
109
+ */
110
+ interface UseJumioWebflowState {
111
+ /**
112
+ * `true` mientras se esté realizando la solicitud de inicio del flujo (POST).
113
+ */
114
+ isStarting: boolean;
115
+ /**
116
+ * `true` mientras se esté sondeando el estado de la verificación (GET polling).
117
+ */
118
+ isChecking: boolean;
119
+ /**
120
+ * `true` mientras cualquiera de los dos procesos esté activo.
121
+ */
122
+ isLoading: boolean;
123
+ /**
124
+ * Resultado de la verificación si ya está disponible.
125
+ */
126
+ result: WebflowResult | null;
127
+ /**
128
+ * Error más reciente ocurrido durante el inicio o el sondeo.
129
+ */
130
+ error: Error | null;
131
+ /**
132
+ * `true` si la verificación resultó válida (aprobada).
133
+ */
134
+ isValid: boolean;
135
+ /**
136
+ * `true` si la verificación fue rechazada o si ocurrió un error no recuperable.
137
+ */
138
+ isRejected: boolean;
139
+ }
140
+ /**
141
+ * Retorno del hook `useJumioWebflow`.
142
+ */
143
+ interface UseJumioWebflowReturn extends UseJumioWebflowState {
144
+ /**
145
+ * Inicia el flujo Hosted Webflow: solicita la URL de verificación al backend
146
+ * y opcionalmente redirige al usuario automáticamente.
147
+ *
148
+ * @param input Parámetros del flujo. Si `autoRedirect` es `true`, el navegador
149
+ * se redirigirá automáticamente a la URL de Jumio.
150
+ * @returns `StartWebflowResult` con el `href` de Jumio.
151
+ */
152
+ startWebflow: (input: StartWebflowInput) => Promise<StartWebflowResult>;
153
+ /**
154
+ * Consulta o sondea el estado de verificación tras el retorno de Jumio.
155
+ * Usa los `accountId` y `workflowId` obtenidos de la URL de retorno.
156
+ *
157
+ * @param params `accountId`, `workflowId`, y `clientId` opcional.
158
+ * @param options Opciones de sondeo (maxAttempts, pollingIntervalMs, etc.).
159
+ * @returns `WebflowResult` con el veredicto final.
160
+ */
161
+ checkResult: (params: {
162
+ accountId: string;
163
+ workflowId: string;
164
+ clientId?: string;
165
+ }, options?: {
166
+ maxAttempts?: number;
167
+ pollingIntervalMs?: number;
168
+ signal?: AbortSignal;
169
+ }) => Promise<WebflowResult>;
170
+ /**
171
+ * Extrae los parámetros de retorno de Jumio de la URL actual o provista.
172
+ * Util para leer `accountId` y `workflowId` al montar el componente de retorno.
173
+ *
174
+ * @param source URL completa, `URLSearchParams`, o nada para usar `window.location`.
175
+ * @returns `WebflowReturnParams`.
176
+ */
177
+ parseReturnParams: (source?: string | URLSearchParams | {
178
+ search?: string;
179
+ href?: string;
180
+ }) => WebflowReturnParams;
181
+ /**
182
+ * Cancela cualquier operación activa en curso.
183
+ */
184
+ cancel: () => void;
185
+ /**
186
+ * Reinicia el estado del hook a sus valores iniciales.
187
+ */
188
+ reset: () => void;
189
+ /**
190
+ * Instancia subyacente de `JumioClient`.
191
+ */
192
+ client: JumioClient;
193
+ }
90
194
 
91
195
  /**
92
196
  * Hook de React para integrar validación de documentos e INE con Jumio.
@@ -104,4 +208,44 @@ interface UseJumioVerificationReturn extends UseJumioVerificationState {
104
208
  */
105
209
  declare function useJumioVerification(options?: UseJumioVerificationOptions): UseJumioVerificationReturn;
106
210
 
107
- export { type UseJumioVerificationOptions, type UseJumioVerificationReturn, type UseJumioVerificationState, useJumioVerification };
211
+ /**
212
+ * Hook de React para integrar el flujo Hosted Webflow de Jumio (verificacion por redireccion).
213
+ *
214
+ * @example Paso 1 - Iniciar el flujo (componente de inicio):
215
+ * ```tsx
216
+ * const { startWebflow, isStarting, error } = useJumioWebflow({
217
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL,
218
+ * context: process.env.NEXT_PUBLIC_DYNAMICORE_CONTEXT,
219
+ * });
220
+ *
221
+ * const handleStart = async () => {
222
+ * const { href } = await startWebflow({
223
+ * clientId: "usr_123",
224
+ * successUrl: `${window.location.origin}/verify/return`,
225
+ * errorUrl: `${window.location.origin}/verify/return`,
226
+ * autoRedirect: true, // redirige automaticamente
227
+ * });
228
+ * // si autoRedirect es false, redirigir manualmente:
229
+ * // window.location.href = href;
230
+ * };
231
+ * ```
232
+ *
233
+ * @example Paso 2 - Verificar resultado (componente de retorno, en /verify/return):
234
+ * ```tsx
235
+ * const { parseReturnParams, checkResult, isChecking, result, isValid } = useJumioWebflow({
236
+ * baseUrl: process.env.NEXT_PUBLIC_API_URL,
237
+ * context: process.env.NEXT_PUBLIC_DYNAMICORE_CONTEXT,
238
+ * onResult: (r) => { if (r.valid) router.push("/dashboard"); },
239
+ * });
240
+ *
241
+ * useEffect(() => {
242
+ * const { accountId, workflowId } = parseReturnParams();
243
+ * if (accountId && workflowId) {
244
+ * checkResult({ accountId, workflowId, clientId: "usr_123" });
245
+ * }
246
+ * }, []);
247
+ * ```
248
+ */
249
+ declare function useJumioWebflow(options?: UseJumioWebflowOptions): UseJumioWebflowReturn;
250
+
251
+ export { type UseJumioVerificationOptions, type UseJumioVerificationReturn, type UseJumioVerificationState, type UseJumioWebflowOptions, type UseJumioWebflowReturn, type UseJumioWebflowState, useJumioVerification, useJumioWebflow };