@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,5 +1,5 @@
1
- import { f as JumioVerificationData, I as ImageSource, S as S3SignerFunction, a as JumioClientConfig, P as PollStatusOptions, i as VerifyIneResult } from '../client-BR1xIZ0X.js';
2
- export { A as AuthTokenProvider, J as JumioClient, b as JumioIneStartData, c as JumioProgressCallback, d as JumioStatusErrorCallback, e as JumioStatusResolvedCallback, g as JumioVerificationPayload, h as JumioWorkflowStatus, V as VerifyIneInput, j as createJumioClient } from '../client-BR1xIZ0X.js';
1
+ import { f as JumioVerificationData, I as ImageSource, S as S3SignerFunction, a as JumioClientConfig, P as PollStatusOptions, l as VerifyIneResult, m as WebflowReturnParams, i as PollWebflowOptions, W as WebflowResult, j as StartWebflowInput, k as StartWebflowResult } from '../client-BwEiGMPy.js';
2
+ export { A as AuthTokenProvider, G as GetWebflowStatusInput, J as JumioClient, b as JumioIneStartData, c as JumioProgressCallback, d as JumioStatusErrorCallback, e as JumioStatusResolvedCallback, g as JumioVerificationPayload, h as JumioWorkflowStatus, V as VerifyIneInput, n as createJumioClient } from '../client-BwEiGMPy.js';
3
3
  import 'axios';
4
4
 
5
5
  /**
@@ -81,7 +81,8 @@ declare function toLowerText(value: unknown): string;
81
81
  */
82
82
  declare function toUpperText(value: unknown): string;
83
83
  /**
84
- * Desempaqueta el envoltorio estándar `{ data: ... }` si está presente en la respuesta.
84
+ * Desempaqueta el envoltorio estándar `{ data: ... }` o `{ values: ... }` si están presentes en la respuesta.
85
+ * Soporta ambas formas de envelope usadas por los distintos endpoints de DynamiCore/Jumio.
85
86
  */
86
87
  declare function extractEnvelopeData<T>(responseData: unknown): T;
87
88
  /**
@@ -115,6 +116,18 @@ declare function isPassedJumioDecision(decision: unknown): boolean;
115
116
  * 3. Fallback conservador basado en el estado del workflow.
116
117
  */
117
118
  declare function resolveVerificationValidity(data: Pick<JumioVerificationData, "valid" | "decision">, fallbackStatus: unknown): boolean;
119
+ /**
120
+ * Codifica una URL en Base64 URL-safe (sin `+`, `/` ni `=`).
121
+ *
122
+ * Compatible con:
123
+ * - **Node.js ≥ 18**: Usa `Buffer.from(url).toString("base64")`.
124
+ * - **Navegadores modernos**: Usa `TextEncoder` + `btoa`.
125
+ * - **Navegadores legacy**: Usa `btoa` directamente.
126
+ *
127
+ * @param url La URL a codificar.
128
+ * @returns La cadena codificada en Base64 URL-safe, o `null` si ocurre un error.
129
+ */
130
+ declare function encodeUrlToBase64UrlSafe(url: string): string | null;
118
131
 
119
132
  interface RetryOptions {
120
133
  maxRetries?: number;
@@ -188,10 +201,12 @@ declare class JumioHttpClient {
188
201
  }): Promise<T>;
189
202
  /**
190
203
  * Ejecuta una petición GET para consultar el estado actual de una verificación de INE.
204
+ * Soporta un `clientId` opcional requerido por algunos endpoints de DynamiCore (p. ej. Hosted Webflow).
191
205
  */
192
206
  getVerificationStatus<T>(accountId: string, workflowId: string, options?: {
193
207
  signal?: AbortSignal;
194
208
  timeout?: number;
209
+ clientId?: string;
195
210
  }): Promise<T>;
196
211
  getConfig(): Readonly<JumioClientConfig>;
197
212
  }
@@ -201,4 +216,79 @@ declare class JumioHttpClient {
201
216
  */
202
217
  declare function pollJumioStatus(http: JumioHttpClient, accountId: string, workflowId: string, options?: PollStatusOptions): Promise<VerifyIneResult>;
203
218
 
204
- export { APPROVED_JUMIO_STATUSES, FINAL_JUMIO_STATUSES, ImageSource, JumioAbortError, JumioClientConfig, JumioError, JumioHttpClient, JumioImageProcessingError, JumioNetworkError, JumioPollingTimeoutError, JumioTimeoutError, JumioValidationError, JumioVerificationData, PollStatusOptions, type RetryOptions, S3SignerFunction, VerifyIneResult, arrayBufferToBase64, blobToBase64, delay, extractEnvelopeData, extractJumioMessage, extractNestedData, fetchUrlAsBase64, isApprovedJumioStatus, isBase64String, isFinalJumioStatus, isJumioError, isPassedJumioDecision, normalizeSignedUrl, pollJumioStatus, resolveImageSourceToBase64, resolveVerificationValidity, shouldRetryJumio, stripDataUrlPrefix, toLowerText, toUpperText, withRetry };
219
+ /**
220
+ * Construye la URL de redirección para el flujo Hosted Webflow.
221
+ *
222
+ * Si se provee un `proxyUrl`, la URL de retorno se codifica en Base64 URL-safe y
223
+ * se adjunta al proxy. Esto es util cuando la gateway de Jumio o el backend requiere
224
+ * un intermediario para manejar la redireccion.
225
+ *
226
+ * Si no se provee `proxyUrl`, la URL de retorno se usa directamente tal cual.
227
+ *
228
+ * @param returnUrl La URL de la aplicacion a la que Jumio redirigira al usuario.
229
+ * @param proxyUrl URL base del proxy de redireccion (opcional).
230
+ * @returns La URL final construida.
231
+ */
232
+ declare function buildRedirectUrl(returnUrl: string, proxyUrl?: string): string;
233
+ /**
234
+ * Extrae los parametros de seguimiento de Jumio de la URL de retorno.
235
+ *
236
+ * Jumio redirige al usuario de vuelta a la aplicacion anadiendo `accountId` y
237
+ * `workflowExecutionId` (o `workflowId`) como query params. Este helper los
238
+ * extrae correctamente, manejando:
239
+ *
240
+ * - Parametros directos: `?accountId=...&workflowExecutionId=...`
241
+ * - Parametros anidados dentro de `?status=...?workflowExecutionId=...`
242
+ * - Alias `workflowId` ademas de `workflowExecutionId`
243
+ *
244
+ * @param source URL completa, `URLSearchParams`, o un objeto similar a `window.location`.
245
+ * Si se omite, usa `window.location.search` (solo en navegador).
246
+ * @returns `WebflowReturnParams` con los parametros extraidos.
247
+ */
248
+ declare function parseWebflowReturnParams(source?: string | URLSearchParams | {
249
+ search?: string;
250
+ href?: string;
251
+ }): WebflowReturnParams;
252
+ /**
253
+ * Evalua los datos de respuesta del backend para determinar si la verificacion
254
+ * del flujo Hosted Webflow fue exitosa.
255
+ *
256
+ * Logica de decision (por prioridad):
257
+ * 1. `valid: true` explicito → aprobado.
258
+ * 2. `valid: false` explicito → rechazado.
259
+ * 3. `decision.type === "REJECTED"` → rechazado.
260
+ * 4. Extraccion con datos + (`decision.type === "PASSED"` o `"WARNING"`) → aprobado.
261
+ * 5. Sin datos de extraccion → pendiente (retorna null).
262
+ *
263
+ * @returns `WebflowResult | null` -- null indica que la verificacion aun esta pendiente.
264
+ */
265
+ declare function resolveWebflowResult(rawData: unknown, accountId: string, workflowId: string): WebflowResult | null;
266
+ /**
267
+ * Sondea periodicamente el estado de verificacion de un flujo Hosted Webflow de Jumio.
268
+ *
269
+ * Continua consultando hasta:
270
+ * - Obtener un resultado definitivo (aprobado, rechazado o `valid` explicito).
271
+ * - Agotar el numero maximo de intentos (lanza `JumioPollingTimeoutError`).
272
+ * - Recibir una senal de cancelacion (lanza `JumioAbortError`).
273
+ *
274
+ * @param http Instancia del cliente HTTP de Jumio.
275
+ * @param params Parametros de la verificacion.
276
+ * @param options Opciones de configuracion del sondeo.
277
+ * @returns `WebflowResult` con el resultado definitivo.
278
+ */
279
+ declare function pollWebflowStatus(http: JumioHttpClient, params: {
280
+ accountId: string;
281
+ workflowId: string;
282
+ clientId?: string;
283
+ }, options?: PollWebflowOptions): Promise<WebflowResult>;
284
+ /**
285
+ * Inicia el flujo Hosted Webflow solicitando al backend la URL de verificacion de Jumio.
286
+ *
287
+ * @param http Instancia del cliente HTTP de Jumio.
288
+ * @param config Configuracion del cliente (para leer `redirectProxyUrl`).
289
+ * @param input Parametros de inicio del flujo.
290
+ * @returns `StartWebflowResult` con el `href` de Jumio y datos adicionales.
291
+ */
292
+ declare function startWebflowSession(http: JumioHttpClient, config: JumioClientConfig, input: StartWebflowInput): Promise<StartWebflowResult>;
293
+
294
+ export { APPROVED_JUMIO_STATUSES, FINAL_JUMIO_STATUSES, ImageSource, JumioAbortError, JumioClientConfig, JumioError, JumioHttpClient, JumioImageProcessingError, JumioNetworkError, JumioPollingTimeoutError, JumioTimeoutError, JumioValidationError, JumioVerificationData, PollStatusOptions, PollWebflowOptions, type RetryOptions, S3SignerFunction, StartWebflowInput, StartWebflowResult, VerifyIneResult, WebflowResult, WebflowReturnParams, arrayBufferToBase64, blobToBase64, buildRedirectUrl, delay, encodeUrlToBase64UrlSafe, extractEnvelopeData, extractJumioMessage, extractNestedData, fetchUrlAsBase64, isApprovedJumioStatus, isBase64String, isFinalJumioStatus, isJumioError, isPassedJumioDecision, normalizeSignedUrl, parseWebflowReturnParams, pollJumioStatus, pollWebflowStatus, resolveImageSourceToBase64, resolveVerificationValidity, resolveWebflowResult, shouldRetryJumio, startWebflowSession, stripDataUrlPrefix, toLowerText, toUpperText, withRetry };