@trymellon/js 1.3.2 → 1.3.4

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-Dwut7nw8.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-B9rvhe53.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-Dwut7nw8.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-B9rvhe53.js';
4
4
 
5
5
  declare function TryMellonProvider(props: {
6
6
  client: TryMellon;
@@ -55,6 +55,12 @@ type TryMellonConfig = {
55
55
  * Only used when sandbox is true.
56
56
  */
57
57
  sandboxToken?: string;
58
+ /**
59
+ * Origin to send in the Origin header for WebAuthn and cross-device API calls.
60
+ * If not set, the SDK uses window.location.origin in browser environments.
61
+ * Set this in Node or when the document origin is not the correct one (e.g. SSR).
62
+ */
63
+ origin?: string;
58
64
  };
59
65
  interface RegisterOptions {
60
66
  /**
@@ -133,13 +139,32 @@ type CrossDeviceStatusResult = {
133
139
  user_id?: string;
134
140
  session_token?: string;
135
141
  };
136
- type CrossDeviceContextResult = {
142
+ /** Context for auth: request options (get). */
143
+ type CrossDeviceContextAuth = {
144
+ type: 'auth';
137
145
  options: AuthStartResponse['challenge'];
138
146
  };
147
+ /** Context for registration: creation options (create). */
148
+ type CrossDeviceContextRegistration = {
149
+ type: 'registration';
150
+ options: RegisterStartResponse['challenge'];
151
+ };
152
+ /**
153
+ * Contract: response of getCrossDeviceContext.
154
+ * Single source of truth for branching in approve(): use context.type to decide
155
+ * whether to run credentials.get (auth) or credentials.create (registration).
156
+ * Validators must return only CrossDeviceContextAuth | CrossDeviceContextRegistration.
157
+ */
158
+ type CrossDeviceContextResult = CrossDeviceContextAuth | CrossDeviceContextRegistration;
139
159
  type CrossDeviceVerifyRequest = {
140
160
  session_id: string;
141
161
  credential: AuthFinishRequest['credential'];
142
162
  };
163
+ /** Same shape as RegisterFinishRequest; used for POST verify-registration. */
164
+ type CrossDeviceVerifyRegistrationRequest = {
165
+ session_id: string;
166
+ credential: RegisterFinishRequest['credential'];
167
+ };
143
168
  type RegisterStartRequest = {
144
169
  external_user_id: string;
145
170
  };
@@ -373,9 +398,19 @@ declare class ApiClient {
373
398
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
374
399
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
375
400
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
401
+ initCrossDeviceRegistration(options: {
402
+ externalUserId: string;
403
+ }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
376
404
  getCrossDeviceStatus(sessionId: string): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
405
+ /**
406
+ * Fetches WebAuthn options for the cross-device session.
407
+ * Contract: response is CrossDeviceContextResult (auth | registration).
408
+ * Use result.value.type to branch: 'auth' → credentials.get + verify;
409
+ * 'registration' → credentials.create + verify-registration.
410
+ */
377
411
  getCrossDeviceContext(sessionId: string): Promise<Result<CrossDeviceContextResult, TryMellonError>>;
378
412
  verifyCrossDeviceAuth(request: CrossDeviceVerifyRequest): Promise<Result<void, TryMellonError>>;
413
+ verifyCrossDeviceRegistration(request: CrossDeviceVerifyRegistrationRequest): Promise<Result<void, TryMellonError>>;
379
414
  }
380
415
 
381
416
  declare class OnboardingManager {
@@ -428,6 +463,9 @@ declare class TryMellon {
428
463
  auth: {
429
464
  crossDevice: {
430
465
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
466
+ initRegistration: (options: {
467
+ externalUserId: string;
468
+ }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
431
469
  waitForSession: (sessionId: string, signal?: AbortSignal) => Promise<Result<{
432
470
  session_token: string;
433
471
  user_id: string;
@@ -55,6 +55,12 @@ type TryMellonConfig = {
55
55
  * Only used when sandbox is true.
56
56
  */
57
57
  sandboxToken?: string;
58
+ /**
59
+ * Origin to send in the Origin header for WebAuthn and cross-device API calls.
60
+ * If not set, the SDK uses window.location.origin in browser environments.
61
+ * Set this in Node or when the document origin is not the correct one (e.g. SSR).
62
+ */
63
+ origin?: string;
58
64
  };
59
65
  interface RegisterOptions {
60
66
  /**
@@ -133,13 +139,32 @@ type CrossDeviceStatusResult = {
133
139
  user_id?: string;
134
140
  session_token?: string;
135
141
  };
136
- type CrossDeviceContextResult = {
142
+ /** Context for auth: request options (get). */
143
+ type CrossDeviceContextAuth = {
144
+ type: 'auth';
137
145
  options: AuthStartResponse['challenge'];
138
146
  };
147
+ /** Context for registration: creation options (create). */
148
+ type CrossDeviceContextRegistration = {
149
+ type: 'registration';
150
+ options: RegisterStartResponse['challenge'];
151
+ };
152
+ /**
153
+ * Contract: response of getCrossDeviceContext.
154
+ * Single source of truth for branching in approve(): use context.type to decide
155
+ * whether to run credentials.get (auth) or credentials.create (registration).
156
+ * Validators must return only CrossDeviceContextAuth | CrossDeviceContextRegistration.
157
+ */
158
+ type CrossDeviceContextResult = CrossDeviceContextAuth | CrossDeviceContextRegistration;
139
159
  type CrossDeviceVerifyRequest = {
140
160
  session_id: string;
141
161
  credential: AuthFinishRequest['credential'];
142
162
  };
163
+ /** Same shape as RegisterFinishRequest; used for POST verify-registration. */
164
+ type CrossDeviceVerifyRegistrationRequest = {
165
+ session_id: string;
166
+ credential: RegisterFinishRequest['credential'];
167
+ };
143
168
  type RegisterStartRequest = {
144
169
  external_user_id: string;
145
170
  };
@@ -373,9 +398,19 @@ declare class ApiClient {
373
398
  registerOnboardingPasskey(sessionId: string, request: OnboardingRegisterPasskeyRequest): Promise<Result<OnboardingRegisterPasskeyResponse, TryMellonError>>;
374
399
  completeOnboarding(sessionId: string, request: OnboardingCompleteRequest): Promise<Result<OnboardingCompleteResponse, TryMellonError>>;
375
400
  initCrossDeviceAuth(): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
401
+ initCrossDeviceRegistration(options: {
402
+ externalUserId: string;
403
+ }): Promise<Result<CrossDeviceInitResult, TryMellonError>>;
376
404
  getCrossDeviceStatus(sessionId: string): Promise<Result<CrossDeviceStatusResult, TryMellonError>>;
405
+ /**
406
+ * Fetches WebAuthn options for the cross-device session.
407
+ * Contract: response is CrossDeviceContextResult (auth | registration).
408
+ * Use result.value.type to branch: 'auth' → credentials.get + verify;
409
+ * 'registration' → credentials.create + verify-registration.
410
+ */
377
411
  getCrossDeviceContext(sessionId: string): Promise<Result<CrossDeviceContextResult, TryMellonError>>;
378
412
  verifyCrossDeviceAuth(request: CrossDeviceVerifyRequest): Promise<Result<void, TryMellonError>>;
413
+ verifyCrossDeviceRegistration(request: CrossDeviceVerifyRegistrationRequest): Promise<Result<void, TryMellonError>>;
379
414
  }
380
415
 
381
416
  declare class OnboardingManager {
@@ -428,6 +463,9 @@ declare class TryMellon {
428
463
  auth: {
429
464
  crossDevice: {
430
465
  init: () => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
466
+ initRegistration: (options: {
467
+ externalUserId: string;
468
+ }) => Promise<Result<CrossDeviceInitResult, TryMellonError>>;
431
469
  waitForSession: (sessionId: string, signal?: AbortSignal) => Promise<Result<{
432
470
  session_token: string;
433
471
  user_id: string;
package/dist/vue.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InjectionKey, Ref } from 'vue';
2
- import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-Dwut7nw8.cjs';
2
+ import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-B9rvhe53.cjs';
3
3
 
4
4
  declare const TryMellonKey: InjectionKey<TryMellon>;
5
5
  declare function provideTryMellon(client: TryMellon): void;
package/dist/vue.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { InjectionKey, Ref } from 'vue';
2
- import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-Dwut7nw8.js';
2
+ import { T as TryMellon, R as Result, a as RegisterResult, b as TryMellonError, c as RegisterOptions, A as AuthenticateResult, d as AuthenticateOptions } from './trymellon-B9rvhe53.js';
3
3
 
4
4
  declare const TryMellonKey: InjectionKey<TryMellon>;
5
5
  declare function provideTryMellon(client: TryMellon): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trymellon/js",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "SDK oficial de TryMellon para integrar autenticación passwordless con Passkeys / WebAuthn",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",