@trymellon/js 1.7.7 → 2.1.0

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/dist/react.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-CItwBg_1.cjs';
3
+ import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-P7BPxIry.cjs';
4
4
 
5
5
  declare function TryMellonProvider(props: {
6
6
  client: TryMellon;
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-CItwBg_1.js';
3
+ import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-P7BPxIry.js';
4
4
 
5
5
  declare function TryMellonProvider(props: {
6
6
  client: TryMellon;
@@ -98,18 +98,34 @@ type ClientStatus = {
98
98
  recommendedFlow: 'passkey' | 'fallback';
99
99
  };
100
100
  type TryMellonEvent = 'start' | 'success' | 'error' | 'cancelled';
101
+ /** User info in success event (aligns with API user payload). */
102
+ type SuccessEventUserInfo = {
103
+ userId: string;
104
+ externalUserId?: string;
105
+ email?: string;
106
+ metadata?: Record<string, unknown>;
107
+ };
108
+ /** Success payload: token always present (03-eventos-seguridad). Nonce when flow generates it. */
109
+ type SuccessEventPayload = {
110
+ type: 'success';
111
+ operation: 'register' | 'authenticate';
112
+ token: string;
113
+ user?: SuccessEventUserInfo;
114
+ nonce?: string;
115
+ };
101
116
  type EventPayload = {
102
117
  type: 'start';
103
118
  operation: 'register' | 'authenticate';
104
- } | {
105
- type: 'success';
106
- operation: 'register' | 'authenticate';
107
- } | {
119
+ nonce?: string;
120
+ } | SuccessEventPayload | {
108
121
  type: 'error';
109
122
  error: TryMellonError;
123
+ operation?: 'register' | 'authenticate';
124
+ nonce?: string;
110
125
  } | {
111
126
  type: 'cancelled';
112
127
  operation: 'register' | 'authenticate';
128
+ nonce?: string;
113
129
  };
114
130
  type EventHandler = (payload: EventPayload) => void;
115
131
  type EmailFallbackStartOptions = {
@@ -184,6 +200,8 @@ type CrossDeviceInitResult = {
184
200
  expires_at: string;
185
201
  /** Opaque token; send in X-Polling-Token header when calling GET status. Not included in qr_url. */
186
202
  polling_token: string;
203
+ /** Set when backend returns it (e.g. after anonymous init-registration). */
204
+ external_user_id?: string;
187
205
  };
188
206
  type CrossDeviceStatusResult = {
189
207
  status: 'pending' | 'authenticated' | 'completed';
@@ -335,8 +353,8 @@ interface RegisterResult {
335
353
  success: true;
336
354
  credentialId: string;
337
355
  /**
338
- * Alias para compatibilidad con versiones anteriores que usaban snake_case.
339
- * Preferir `credentialId` en código nuevo.
356
+ * Alias for backward compatibility with snake_case.
357
+ * Prefer `credentialId` in new code.
340
358
  */
341
359
  credential_id?: string;
342
360
  status: string;
@@ -471,8 +489,8 @@ declare class ApiClient {
471
489
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
472
490
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
473
491
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
474
- initCrossDeviceRegistration(options: {
475
- externalUserId: string;
492
+ initCrossDeviceRegistration(options?: {
493
+ externalUserId?: string;
476
494
  }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
477
495
  getCrossDeviceStatus(sessionId: string, pollingToken?: string | null): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
478
496
  /**
@@ -500,7 +518,7 @@ declare class OnboardingManager {
500
518
  */
501
519
  startFlow(options: OnboardingStartOptions & {
502
520
  company_name?: string;
503
- }): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
521
+ }, signal?: AbortSignal): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
504
522
  }
505
523
 
506
524
  declare class TryMellon {
@@ -510,11 +528,13 @@ declare class TryMellon {
510
528
  private eventEmitter;
511
529
  private telemetrySender;
512
530
  private crossDeviceManager;
531
+ private authService;
532
+ private recoveryService;
513
533
  onboarding: OnboardingManager;
514
534
  /**
515
- * Configura una nueva instancia de TryMellon.
516
- * Valida la configuración y retorna un Result.
517
- * @param config Configuración del SDK
535
+ * Creates a new TryMellon instance.
536
+ * Validates config and returns a Result.
537
+ * @param config SDK configuration
518
538
  */
519
539
  static create(config: TryMellonConfig): Result<TryMellon, TryMellonError>;
520
540
  /**
@@ -523,11 +543,6 @@ declare class TryMellon {
523
543
  */
524
544
  constructor(config: TryMellonConfig);
525
545
  static isSupported(): boolean;
526
- /**
527
- * Returns a successful Result for sandbox mode (register or authenticate).
528
- * Single place for sandbox contract; used by register() and authenticate().
529
- */
530
- private sandboxAuthResult;
531
546
  register(options: RegisterOptions): Promise<Result<RegisterResult, TryMellonError>>;
532
547
  authenticate(options: AuthenticateOptions): Promise<Result<AuthenticateResult, TryMellonError>>;
533
548
  validateSession(sessionToken: string): Promise<Result<SessionValidateResponse, TryMellonError>>;
@@ -543,8 +558,8 @@ declare class TryMellon {
543
558
  auth: {
544
559
  crossDevice: {
545
560
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
546
- initRegistration: (options: {
547
- externalUserId: string;
561
+ initRegistration: (options?: {
562
+ externalUserId?: string;
548
563
  }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
549
564
  waitForSession: (sessionId: string, signal?: AbortSignal, pollingToken?: string | null) => Promise<Result<{
550
565
  session_token: string;
@@ -98,18 +98,34 @@ type ClientStatus = {
98
98
  recommendedFlow: 'passkey' | 'fallback';
99
99
  };
100
100
  type TryMellonEvent = 'start' | 'success' | 'error' | 'cancelled';
101
+ /** User info in success event (aligns with API user payload). */
102
+ type SuccessEventUserInfo = {
103
+ userId: string;
104
+ externalUserId?: string;
105
+ email?: string;
106
+ metadata?: Record<string, unknown>;
107
+ };
108
+ /** Success payload: token always present (03-eventos-seguridad). Nonce when flow generates it. */
109
+ type SuccessEventPayload = {
110
+ type: 'success';
111
+ operation: 'register' | 'authenticate';
112
+ token: string;
113
+ user?: SuccessEventUserInfo;
114
+ nonce?: string;
115
+ };
101
116
  type EventPayload = {
102
117
  type: 'start';
103
118
  operation: 'register' | 'authenticate';
104
- } | {
105
- type: 'success';
106
- operation: 'register' | 'authenticate';
107
- } | {
119
+ nonce?: string;
120
+ } | SuccessEventPayload | {
108
121
  type: 'error';
109
122
  error: TryMellonError;
123
+ operation?: 'register' | 'authenticate';
124
+ nonce?: string;
110
125
  } | {
111
126
  type: 'cancelled';
112
127
  operation: 'register' | 'authenticate';
128
+ nonce?: string;
113
129
  };
114
130
  type EventHandler = (payload: EventPayload) => void;
115
131
  type EmailFallbackStartOptions = {
@@ -184,6 +200,8 @@ type CrossDeviceInitResult = {
184
200
  expires_at: string;
185
201
  /** Opaque token; send in X-Polling-Token header when calling GET status. Not included in qr_url. */
186
202
  polling_token: string;
203
+ /** Set when backend returns it (e.g. after anonymous init-registration). */
204
+ external_user_id?: string;
187
205
  };
188
206
  type CrossDeviceStatusResult = {
189
207
  status: 'pending' | 'authenticated' | 'completed';
@@ -335,8 +353,8 @@ interface RegisterResult {
335
353
  success: true;
336
354
  credentialId: string;
337
355
  /**
338
- * Alias para compatibilidad con versiones anteriores que usaban snake_case.
339
- * Preferir `credentialId` en código nuevo.
356
+ * Alias for backward compatibility with snake_case.
357
+ * Prefer `credentialId` in new code.
340
358
  */
341
359
  credential_id?: string;
342
360
  status: string;
@@ -471,8 +489,8 @@ declare class ApiClient {
471
489
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
472
490
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
473
491
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
474
- initCrossDeviceRegistration(options: {
475
- externalUserId: string;
492
+ initCrossDeviceRegistration(options?: {
493
+ externalUserId?: string;
476
494
  }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
477
495
  getCrossDeviceStatus(sessionId: string, pollingToken?: string | null): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
478
496
  /**
@@ -500,7 +518,7 @@ declare class OnboardingManager {
500
518
  */
501
519
  startFlow(options: OnboardingStartOptions & {
502
520
  company_name?: string;
503
- }): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
521
+ }, signal?: AbortSignal): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
504
522
  }
505
523
 
506
524
  declare class TryMellon {
@@ -510,11 +528,13 @@ declare class TryMellon {
510
528
  private eventEmitter;
511
529
  private telemetrySender;
512
530
  private crossDeviceManager;
531
+ private authService;
532
+ private recoveryService;
513
533
  onboarding: OnboardingManager;
514
534
  /**
515
- * Configura una nueva instancia de TryMellon.
516
- * Valida la configuración y retorna un Result.
517
- * @param config Configuración del SDK
535
+ * Creates a new TryMellon instance.
536
+ * Validates config and returns a Result.
537
+ * @param config SDK configuration
518
538
  */
519
539
  static create(config: TryMellonConfig): Result<TryMellon, TryMellonError>;
520
540
  /**
@@ -523,11 +543,6 @@ declare class TryMellon {
523
543
  */
524
544
  constructor(config: TryMellonConfig);
525
545
  static isSupported(): boolean;
526
- /**
527
- * Returns a successful Result for sandbox mode (register or authenticate).
528
- * Single place for sandbox contract; used by register() and authenticate().
529
- */
530
- private sandboxAuthResult;
531
546
  register(options: RegisterOptions): Promise<Result<RegisterResult, TryMellonError>>;
532
547
  authenticate(options: AuthenticateOptions): Promise<Result<AuthenticateResult, TryMellonError>>;
533
548
  validateSession(sessionToken: string): Promise<Result<SessionValidateResponse, TryMellonError>>;
@@ -543,8 +558,8 @@ declare class TryMellon {
543
558
  auth: {
544
559
  crossDevice: {
545
560
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
546
- initRegistration: (options: {
547
- externalUserId: string;
561
+ initRegistration: (options?: {
562
+ externalUserId?: string;
548
563
  }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
549
564
  waitForSession: (sessionId: string, signal?: AbortSignal, pollingToken?: string | null) => Promise<Result<{
550
565
  session_token: string;