Skip to content

Commit bcbe5f6

Browse files
authored
chore(clerk-js,types): Initialize tasks on Session resource (#5170)
1 parent b9a9db5 commit bcbe5f6

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

.changeset/plenty-peas-pretend.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Initialize `tasks` on `Session` resource

packages/clerk-js/src/core/resources/Session.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
SessionJSONSnapshot,
1313
SessionResource,
1414
SessionStatus,
15+
SessionTask,
1516
SessionVerificationJSON,
1617
SessionVerificationResource,
1718
SessionVerifyAttemptFirstFactorParams,
@@ -42,6 +43,7 @@ export class Session extends BaseResource implements SessionResource {
4243
user!: UserResource | null;
4344
publicUserData!: PublicUserData;
4445
factorVerificationAge: [number, number] | null = null;
46+
tasks: Array<SessionTask> | null = null;
4547
expireAt!: Date;
4648
abandonAt!: Date;
4749
createdAt!: Date;
@@ -224,6 +226,7 @@ export class Session extends BaseResource implements SessionResource {
224226
this.createdAt = unixEpochToDate(data.created_at);
225227
this.updatedAt = unixEpochToDate(data.updated_at);
226228
this.user = new User(data.user);
229+
this.tasks = data.tasks;
227230

228231
if (data.public_user_data) {
229232
this.publicUserData = new PublicUserData(data.public_user_data);
@@ -245,6 +248,7 @@ export class Session extends BaseResource implements SessionResource {
245248
last_active_at: this.lastActiveAt.getTime(),
246249
last_active_organization_id: this.lastActiveOrganizationId,
247250
actor: this.actor,
251+
tasks: this.tasks,
248252
user: this.user?.__internal_toSnapshot() || null,
249253
public_user_data: this.publicUserData.__internal_toSnapshot(),
250254
last_active_token: this.lastActiveToken?.__internal_toSnapshot() || null,

packages/types/src/json.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { OrganizationCustomRoleKey, OrganizationPermissionKey } from './org
1212
import type { OrganizationSettingsJSON } from './organizationSettings';
1313
import type { OrganizationSuggestionStatus } from './organizationSuggestion';
1414
import type { SamlIdpSlug } from './saml';
15-
import type { SessionStatus } from './session';
15+
import type { SessionStatus, SessionTask } from './session';
1616
import type { SessionVerificationLevel, SessionVerificationStatus } from './sessionVerification';
1717
import type { SignInFirstFactor, SignInJSON, SignInSecondFactor } from './signIn';
1818
import type { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUp';
@@ -76,29 +76,6 @@ export interface ClientJSON extends ClerkResourceJSON {
7676
created_at: number;
7777
updated_at: number;
7878
}
79-
// export type ClientJSON = ClerkResourceJSON & {
80-
// object: 'client';
81-
// id: string;
82-
// status: any;
83-
// sessions: SessionJSON[];
84-
// sign_up: SignUpJSON | null;
85-
// sign_in: SignInJSON | null;
86-
// last_active_session_id: string | null;
87-
// cookie_expires_at: number | null;
88-
// created_at: number;
89-
// updated_at: number;
90-
// } | {
91-
// object: 'client';
92-
// id: null;
93-
// status: null;
94-
// sessions: null
95-
// sign_up: null
96-
// sign_in: null
97-
// last_active_session_id: null
98-
// cookie_expires_at: null
99-
// created_at: null;
100-
// updated_at: null;
101-
// }
10279

10380
export interface SignUpJSON extends ClerkResourceJSON {
10481
object: 'sign_up';
@@ -133,13 +110,14 @@ export interface SessionJSON extends ClerkResourceJSON {
133110
* This API is experimental and may change at any moment.
134111
* @experimental
135112
*/
136-
factor_verification_age: [fistFactorAge: number, secondFactorAge: number] | null;
113+
factor_verification_age: [firstFactorAge: number, secondFactorAge: number] | null;
137114
expire_at: number;
138115
abandon_at: number;
139116
last_active_at: number;
140117
last_active_token: TokenJSON;
141118
last_active_organization_id: string | null;
142119
actor: ActJWTClaim | null;
120+
tasks: Array<SessionTask> | null;
143121
user: UserJSON;
144122
public_user_data: PublicUserDataJSON;
145123
created_at: number;

packages/types/src/session.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ export interface SessionResource extends ClerkResource {
9696
/**
9797
* Factor Verification Age
9898
* Each item represents the minutes that have passed since the last time a first or second factor were verified.
99-
* [fistFactorAge, secondFactorAge]
99+
* [firstFactorAge, secondFactorAge]
100100
*/
101-
factorVerificationAge: [fistFactorAge: number, secondFactorAge: number] | null;
101+
factorVerificationAge: [firstFactorAge: number, secondFactorAge: number] | null;
102102
lastActiveToken: TokenResource | null;
103103
lastActiveOrganizationId: string | null;
104104
lastActiveAt: Date;
105105
actor: ActJWTClaim | null;
106+
tasks: Array<SessionTask> | null;
106107
user: UserResource | null;
107108
publicUserData: PublicUserData;
108109
end: () => Promise<SessionResource>;
@@ -169,6 +170,10 @@ export interface PublicUserData {
169170
userId?: string;
170171
}
171172

173+
export interface SessionTask {
174+
key: 'orgs';
175+
}
176+
172177
export type GetTokenOptions = {
173178
template?: string;
174179
organizationId?: string;

0 commit comments

Comments
 (0)