diff --git a/.changeset/plenty-peas-pretend.md b/.changeset/plenty-peas-pretend.md new file mode 100644 index 00000000000..d52fe008d5c --- /dev/null +++ b/.changeset/plenty-peas-pretend.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Initialize `tasks` on `Session` resource diff --git a/packages/clerk-js/src/core/resources/Session.ts b/packages/clerk-js/src/core/resources/Session.ts index 2a6c1b6e3aa..d10845636f2 100644 --- a/packages/clerk-js/src/core/resources/Session.ts +++ b/packages/clerk-js/src/core/resources/Session.ts @@ -12,6 +12,7 @@ import type { SessionJSONSnapshot, SessionResource, SessionStatus, + SessionTask, SessionVerificationJSON, SessionVerificationResource, SessionVerifyAttemptFirstFactorParams, @@ -42,6 +43,7 @@ export class Session extends BaseResource implements SessionResource { user!: UserResource | null; publicUserData!: PublicUserData; factorVerificationAge: [number, number] | null = null; + tasks: Array | null = null; expireAt!: Date; abandonAt!: Date; createdAt!: Date; @@ -224,6 +226,7 @@ export class Session extends BaseResource implements SessionResource { this.createdAt = unixEpochToDate(data.created_at); this.updatedAt = unixEpochToDate(data.updated_at); this.user = new User(data.user); + this.tasks = data.tasks; if (data.public_user_data) { this.publicUserData = new PublicUserData(data.public_user_data); @@ -245,6 +248,7 @@ export class Session extends BaseResource implements SessionResource { last_active_at: this.lastActiveAt.getTime(), last_active_organization_id: this.lastActiveOrganizationId, actor: this.actor, + tasks: this.tasks, user: this.user?.__internal_toSnapshot() || null, public_user_data: this.publicUserData.__internal_toSnapshot(), last_active_token: this.lastActiveToken?.__internal_toSnapshot() || null, diff --git a/packages/types/src/json.ts b/packages/types/src/json.ts index 663a4303d0e..32dada36382 100644 --- a/packages/types/src/json.ts +++ b/packages/types/src/json.ts @@ -12,7 +12,7 @@ import type { OrganizationCustomRoleKey, OrganizationPermissionKey } from './org import type { OrganizationSettingsJSON } from './organizationSettings'; import type { OrganizationSuggestionStatus } from './organizationSuggestion'; import type { SamlIdpSlug } from './saml'; -import type { SessionStatus } from './session'; +import type { SessionStatus, SessionTask } from './session'; import type { SessionVerificationLevel, SessionVerificationStatus } from './sessionVerification'; import type { SignInFirstFactor, SignInJSON, SignInSecondFactor } from './signIn'; import type { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUp'; @@ -76,29 +76,6 @@ export interface ClientJSON extends ClerkResourceJSON { created_at: number; updated_at: number; } -// export type ClientJSON = ClerkResourceJSON & { -// object: 'client'; -// id: string; -// status: any; -// sessions: SessionJSON[]; -// sign_up: SignUpJSON | null; -// sign_in: SignInJSON | null; -// last_active_session_id: string | null; -// cookie_expires_at: number | null; -// created_at: number; -// updated_at: number; -// } | { -// object: 'client'; -// id: null; -// status: null; -// sessions: null -// sign_up: null -// sign_in: null -// last_active_session_id: null -// cookie_expires_at: null -// created_at: null; -// updated_at: null; -// } export interface SignUpJSON extends ClerkResourceJSON { object: 'sign_up'; @@ -133,13 +110,14 @@ export interface SessionJSON extends ClerkResourceJSON { * This API is experimental and may change at any moment. * @experimental */ - factor_verification_age: [fistFactorAge: number, secondFactorAge: number] | null; + factor_verification_age: [firstFactorAge: number, secondFactorAge: number] | null; expire_at: number; abandon_at: number; last_active_at: number; last_active_token: TokenJSON; last_active_organization_id: string | null; actor: ActJWTClaim | null; + tasks: Array | null; user: UserJSON; public_user_data: PublicUserDataJSON; created_at: number; diff --git a/packages/types/src/session.ts b/packages/types/src/session.ts index 75fa93e6b92..32f18a93260 100644 --- a/packages/types/src/session.ts +++ b/packages/types/src/session.ts @@ -96,13 +96,14 @@ export interface SessionResource extends ClerkResource { /** * Factor Verification Age * Each item represents the minutes that have passed since the last time a first or second factor were verified. - * [fistFactorAge, secondFactorAge] + * [firstFactorAge, secondFactorAge] */ - factorVerificationAge: [fistFactorAge: number, secondFactorAge: number] | null; + factorVerificationAge: [firstFactorAge: number, secondFactorAge: number] | null; lastActiveToken: TokenResource | null; lastActiveOrganizationId: string | null; lastActiveAt: Date; actor: ActJWTClaim | null; + tasks: Array | null; user: UserResource | null; publicUserData: PublicUserData; end: () => Promise; @@ -169,6 +170,10 @@ export interface PublicUserData { userId?: string; } +export interface SessionTask { + key: 'orgs'; +} + export type GetTokenOptions = { template?: string; organizationId?: string;