Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/evil-aliens-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/shared': patch
---

Move clientTrustState to SignIn
5 changes: 0 additions & 5 deletions packages/clerk-js/src/core/resources/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
ClientJSON,
ClientJSONSnapshot,
ClientResource,
ClientTrustState,
LastAuthenticationStrategy,
SignedInSessionResource,
SignInResource,
Expand All @@ -27,7 +26,6 @@ export class Client extends BaseResource implements ClientResource {
cookieExpiresAt: Date | null = null;
/** Last authentication strategy used by this client; `null` when unknown/disabled. */
lastAuthenticationStrategy: LastAuthenticationStrategy | null = null;
clientTrustState?: ClientTrustState = undefined;
createdAt: Date | null = null;
updatedAt: Date | null = null;

Expand Down Expand Up @@ -88,7 +86,6 @@ export class Client extends BaseResource implements ClientResource {
this.signIn = new SignIn(null);
this.lastActiveSessionId = null;
this.lastAuthenticationStrategy = null;
this.clientTrustState = undefined;
this.cookieExpiresAt = null;
this.createdAt = null;
this.updatedAt = null;
Expand Down Expand Up @@ -138,7 +135,6 @@ export class Client extends BaseResource implements ClientResource {
this.captchaBypass = data.captcha_bypass || false;
this.cookieExpiresAt = data.cookie_expires_at ? unixEpochToDate(data.cookie_expires_at) : null;
this.lastAuthenticationStrategy = data.last_authentication_strategy || null;
this.clientTrustState = data.client_trust_state;
this.createdAt = unixEpochToDate(data.created_at || undefined);
this.updatedAt = unixEpochToDate(data.updated_at || undefined);
}
Expand All @@ -157,7 +153,6 @@ export class Client extends BaseResource implements ClientResource {
captcha_bypass: this.captchaBypass,
cookie_expires_at: this.cookieExpiresAt ? this.cookieExpiresAt.getTime() : null,
last_authentication_strategy: this.lastAuthenticationStrategy ?? null,
...(this.clientTrustState && { client_trust_state: this.clientTrustState }),
created_at: this.createdAt?.getTime() ?? null,
updated_at: this.updatedAt?.getTime() ?? null,
};
Expand Down
3 changes: 3 additions & 0 deletions packages/clerk-js/src/core/resources/SignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
AuthenticateWithPopupParams,
AuthenticateWithRedirectParams,
AuthenticateWithWeb3Params,
ClientTrustState,
CreateEmailLinkFlowReturn,
EmailCodeConfig,
EmailCodeFactor,
Expand Down Expand Up @@ -109,6 +110,7 @@ export class SignIn extends BaseResource implements SignInResource {
identifier: string | null = null;
createdSessionId: string | null = null;
userData: UserData = new UserData(null);
clientTrustState?: ClientTrustState;

/**
* The current status of the sign-in process.
Expand Down Expand Up @@ -532,6 +534,7 @@ export class SignIn extends BaseResource implements SignInResource {
this.secondFactorVerification = new Verification(data.second_factor_verification);
this.createdSessionId = data.created_session_id;
this.userData = new UserData(data.user_data);
this.clientTrustState = data.client_trust_state ?? undefined;
}

eventBus.emit('resource:update', { resource: this });
Expand Down
3 changes: 1 addition & 2 deletions packages/shared/src/types/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClientTrustState, LastAuthenticationStrategy } from './json';
import type { LastAuthenticationStrategy } from './json';
import type { ClerkResource } from './resource';
import type { ActiveSessionResource, SessionResource, SignedInSessionResource } from './session';
import type { SignInResource } from './signIn';
Expand All @@ -20,7 +20,6 @@ export interface ClientResource extends ClerkResource {
lastActiveSessionId: string | null;
/** Last authentication strategy used by this client; `null` when unknown or feature disabled. */
lastAuthenticationStrategy: LastAuthenticationStrategy | null;
clientTrustState?: ClientTrustState;
captchaBypass: boolean;
cookieExpiresAt: Date | null;
createdAt: Date | null;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/types/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export interface ClientJSON extends ClerkResourceJSON {
captcha_bypass?: boolean; // this is used by the @clerk/testing package
last_active_session_id: string | null;
last_authentication_strategy: LastAuthenticationStrategy | null;
client_trust_state?: ClientTrustState;
cookie_expires_at: number | null;
created_at: number;
updated_at: number;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/types/signIn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
ClerkResourceJSON,
ClientTrustState,
SignInFirstFactorJSON,
SignInSecondFactorJSON,
UserDataJSON,
Expand Down Expand Up @@ -94,6 +95,7 @@ export interface SignInJSON extends ClerkResourceJSON {
object: 'sign_in';
id: string;
status: SignInStatus;
client_trust_state?: ClientTrustState;
/**
* @deprecated This attribute will be removed in the next major version.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/types/signInCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export type SignInFirstFactor =
| SamlFactor
| EnterpriseSSOFactor;

export type SignInSecondFactor = PhoneCodeFactor | TOTPFactor | BackupCodeFactor;
export type SignInSecondFactor = PhoneCodeFactor | TOTPFactor | BackupCodeFactor | EmailCodeFactor;

export interface UserData {
firstName?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/types/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { DisplayConfigJSON } from './displayConfig';
import type {
AuthConfigJSON,
ClientJSON,
ClientTrustState,
EmailAddressJSON,
EnterpriseAccountConnectionJSON,
EnterpriseAccountJSON,
Expand Down Expand Up @@ -40,6 +41,7 @@ export type SignInJSONSnapshot = Override<
first_factor_verification: VerificationJSONSnapshot;
second_factor_verification: VerificationJSONSnapshot;
user_data: UserDataJSONSnapshot;
client_trust_state?: ClientTrustState;
}
>;

Expand Down
Loading