@trymellon/js 1.7.6 → 2.0.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-NM6i2RKa.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-NM6i2RKa.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 = {
@@ -141,6 +157,8 @@ type RecoveryCompleteResponse = {
141
157
  metadata?: Record<string, unknown>;
142
158
  };
143
159
  credential_id: string;
160
+ /** Set when successUrl was passed and allowed by application allowlist. */
161
+ redirect_url?: string;
144
162
  };
145
163
  type RecoverAccountOptions = {
146
164
  /** The external user ID of the account being recovered. */
@@ -163,6 +181,8 @@ interface RecoverAccountResult {
163
181
  email?: string;
164
182
  metadata?: Record<string, unknown>;
165
183
  };
184
+ /** Set when successUrl was passed and allowed by application allowlist. */
185
+ redirectUrl?: string;
166
186
  }
167
187
  type OnboardingStartOptions = {
168
188
  user_role: 'maintainer' | 'app_user';
@@ -180,11 +200,15 @@ type CrossDeviceInitResult = {
180
200
  expires_at: string;
181
201
  /** Opaque token; send in X-Polling-Token header when calling GET status. Not included in qr_url. */
182
202
  polling_token: string;
203
+ /** Set when backend returns it (e.g. after anonymous init-registration). */
204
+ external_user_id?: string;
183
205
  };
184
206
  type CrossDeviceStatusResult = {
185
207
  status: 'pending' | 'authenticated' | 'completed';
186
208
  user_id?: string;
187
209
  session_token?: string;
210
+ /** Set when backend allows redirect; returned in GET cross-device/status when status=completed. */
211
+ redirect_url?: string;
188
212
  };
189
213
  /** Context for auth: request options (get). */
190
214
  type CrossDeviceContextAuth = {
@@ -316,7 +340,7 @@ interface AuthFinishResponse {
316
340
  email?: string;
317
341
  metadata?: Record<string, unknown>;
318
342
  };
319
- signals: {
343
+ signals?: {
320
344
  userVerification?: boolean;
321
345
  backupEligible?: boolean;
322
346
  backupStatus?: boolean;
@@ -329,8 +353,8 @@ interface RegisterResult {
329
353
  success: true;
330
354
  credentialId: string;
331
355
  /**
332
- * Alias para compatibilidad con versiones anteriores que usaban snake_case.
333
- * Preferir `credentialId` en código nuevo.
356
+ * Alias for backward compatibility with snake_case.
357
+ * Prefer `credentialId` in new code.
334
358
  */
335
359
  credential_id?: string;
336
360
  status: string;
@@ -465,8 +489,8 @@ declare class ApiClient {
465
489
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
466
490
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
467
491
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
468
- initCrossDeviceRegistration(options: {
469
- externalUserId: string;
492
+ initCrossDeviceRegistration(options?: {
493
+ externalUserId?: string;
470
494
  }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
471
495
  getCrossDeviceStatus(sessionId: string, pollingToken?: string | null): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
472
496
  /**
@@ -494,7 +518,7 @@ declare class OnboardingManager {
494
518
  */
495
519
  startFlow(options: OnboardingStartOptions & {
496
520
  company_name?: string;
497
- }): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
521
+ }, signal?: AbortSignal): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
498
522
  }
499
523
 
500
524
  declare class TryMellon {
@@ -504,11 +528,13 @@ declare class TryMellon {
504
528
  private eventEmitter;
505
529
  private telemetrySender;
506
530
  private crossDeviceManager;
531
+ private authService;
532
+ private recoveryService;
507
533
  onboarding: OnboardingManager;
508
534
  /**
509
- * Configura una nueva instancia de TryMellon.
510
- * Valida la configuración y retorna un Result.
511
- * @param config Configuración del SDK
535
+ * Creates a new TryMellon instance.
536
+ * Validates config and returns a Result.
537
+ * @param config SDK configuration
512
538
  */
513
539
  static create(config: TryMellonConfig): Result<TryMellon, TryMellonError>;
514
540
  /**
@@ -517,11 +543,6 @@ declare class TryMellon {
517
543
  */
518
544
  constructor(config: TryMellonConfig);
519
545
  static isSupported(): boolean;
520
- /**
521
- * Returns a successful Result for sandbox mode (register or authenticate).
522
- * Single place for sandbox contract; used by register() and authenticate().
523
- */
524
- private sandboxAuthResult;
525
546
  register(options: RegisterOptions): Promise<Result<RegisterResult, TryMellonError>>;
526
547
  authenticate(options: AuthenticateOptions): Promise<Result<AuthenticateResult, TryMellonError>>;
527
548
  validateSession(sessionToken: string): Promise<Result<SessionValidateResponse, TryMellonError>>;
@@ -537,12 +558,13 @@ declare class TryMellon {
537
558
  auth: {
538
559
  crossDevice: {
539
560
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
540
- initRegistration: (options: {
541
- externalUserId: string;
561
+ initRegistration: (options?: {
562
+ externalUserId?: string;
542
563
  }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
543
564
  waitForSession: (sessionId: string, signal?: AbortSignal, pollingToken?: string | null) => Promise<Result<{
544
565
  session_token: string;
545
566
  user_id: string;
567
+ redirectUrl?: string;
546
568
  }, TryMellonError>>;
547
569
  getContext: (sessionId: string) => Promise<Result<CrossDeviceContextResult, TryMellonError>>;
548
570
  approve: (sessionId: string) => Promise<Result<void, TryMellonError>>;
@@ -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 = {
@@ -141,6 +157,8 @@ type RecoveryCompleteResponse = {
141
157
  metadata?: Record<string, unknown>;
142
158
  };
143
159
  credential_id: string;
160
+ /** Set when successUrl was passed and allowed by application allowlist. */
161
+ redirect_url?: string;
144
162
  };
145
163
  type RecoverAccountOptions = {
146
164
  /** The external user ID of the account being recovered. */
@@ -163,6 +181,8 @@ interface RecoverAccountResult {
163
181
  email?: string;
164
182
  metadata?: Record<string, unknown>;
165
183
  };
184
+ /** Set when successUrl was passed and allowed by application allowlist. */
185
+ redirectUrl?: string;
166
186
  }
167
187
  type OnboardingStartOptions = {
168
188
  user_role: 'maintainer' | 'app_user';
@@ -180,11 +200,15 @@ type CrossDeviceInitResult = {
180
200
  expires_at: string;
181
201
  /** Opaque token; send in X-Polling-Token header when calling GET status. Not included in qr_url. */
182
202
  polling_token: string;
203
+ /** Set when backend returns it (e.g. after anonymous init-registration). */
204
+ external_user_id?: string;
183
205
  };
184
206
  type CrossDeviceStatusResult = {
185
207
  status: 'pending' | 'authenticated' | 'completed';
186
208
  user_id?: string;
187
209
  session_token?: string;
210
+ /** Set when backend allows redirect; returned in GET cross-device/status when status=completed. */
211
+ redirect_url?: string;
188
212
  };
189
213
  /** Context for auth: request options (get). */
190
214
  type CrossDeviceContextAuth = {
@@ -316,7 +340,7 @@ interface AuthFinishResponse {
316
340
  email?: string;
317
341
  metadata?: Record<string, unknown>;
318
342
  };
319
- signals: {
343
+ signals?: {
320
344
  userVerification?: boolean;
321
345
  backupEligible?: boolean;
322
346
  backupStatus?: boolean;
@@ -329,8 +353,8 @@ interface RegisterResult {
329
353
  success: true;
330
354
  credentialId: string;
331
355
  /**
332
- * Alias para compatibilidad con versiones anteriores que usaban snake_case.
333
- * Preferir `credentialId` en código nuevo.
356
+ * Alias for backward compatibility with snake_case.
357
+ * Prefer `credentialId` in new code.
334
358
  */
335
359
  credential_id?: string;
336
360
  status: string;
@@ -465,8 +489,8 @@ declare class ApiClient {
465
489
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
466
490
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
467
491
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
468
- initCrossDeviceRegistration(options: {
469
- externalUserId: string;
492
+ initCrossDeviceRegistration(options?: {
493
+ externalUserId?: string;
470
494
  }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
471
495
  getCrossDeviceStatus(sessionId: string, pollingToken?: string | null): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
472
496
  /**
@@ -494,7 +518,7 @@ declare class OnboardingManager {
494
518
  */
495
519
  startFlow(options: OnboardingStartOptions & {
496
520
  company_name?: string;
497
- }): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
521
+ }, signal?: AbortSignal): Promise<Result<OnboardingCompleteResult, TryMellonError>>;
498
522
  }
499
523
 
500
524
  declare class TryMellon {
@@ -504,11 +528,13 @@ declare class TryMellon {
504
528
  private eventEmitter;
505
529
  private telemetrySender;
506
530
  private crossDeviceManager;
531
+ private authService;
532
+ private recoveryService;
507
533
  onboarding: OnboardingManager;
508
534
  /**
509
- * Configura una nueva instancia de TryMellon.
510
- * Valida la configuración y retorna un Result.
511
- * @param config Configuración del SDK
535
+ * Creates a new TryMellon instance.
536
+ * Validates config and returns a Result.
537
+ * @param config SDK configuration
512
538
  */
513
539
  static create(config: TryMellonConfig): Result<TryMellon, TryMellonError>;
514
540
  /**
@@ -517,11 +543,6 @@ declare class TryMellon {
517
543
  */
518
544
  constructor(config: TryMellonConfig);
519
545
  static isSupported(): boolean;
520
- /**
521
- * Returns a successful Result for sandbox mode (register or authenticate).
522
- * Single place for sandbox contract; used by register() and authenticate().
523
- */
524
- private sandboxAuthResult;
525
546
  register(options: RegisterOptions): Promise<Result<RegisterResult, TryMellonError>>;
526
547
  authenticate(options: AuthenticateOptions): Promise<Result<AuthenticateResult, TryMellonError>>;
527
548
  validateSession(sessionToken: string): Promise<Result<SessionValidateResponse, TryMellonError>>;
@@ -537,12 +558,13 @@ declare class TryMellon {
537
558
  auth: {
538
559
  crossDevice: {
539
560
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
540
- initRegistration: (options: {
541
- externalUserId: string;
561
+ initRegistration: (options?: {
562
+ externalUserId?: string;
542
563
  }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
543
564
  waitForSession: (sessionId: string, signal?: AbortSignal, pollingToken?: string | null) => Promise<Result<{
544
565
  session_token: string;
545
566
  user_id: string;
567
+ redirectUrl?: string;
546
568
  }, TryMellonError>>;
547
569
  getContext: (sessionId: string) => Promise<Result<CrossDeviceContextResult, TryMellonError>>;
548
570
  approve: (sessionId: string) => Promise<Result<void, TryMellonError>>;