@meistrari/auth-core 1.7.4 → 1.9.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/index.d.mts +69 -9
- package/dist/index.d.ts +69 -9
- package/dist/index.mjs +56 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -176,6 +176,18 @@ declare const organizationAdditionalFields: {
|
|
|
176
176
|
required: false;
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
+
declare const memberAdditionalFields: {
|
|
180
|
+
deletedAt: {
|
|
181
|
+
type: "date";
|
|
182
|
+
required: false;
|
|
183
|
+
defaultValue: null;
|
|
184
|
+
};
|
|
185
|
+
lastActiveAt: {
|
|
186
|
+
type: "date";
|
|
187
|
+
required: false;
|
|
188
|
+
defaultValue: null;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
179
191
|
type JWTTokenPayload = JWTPayload & {
|
|
180
192
|
email: string;
|
|
181
193
|
user: {
|
|
@@ -214,6 +226,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
214
226
|
name: string;
|
|
215
227
|
image?: string | undefined;
|
|
216
228
|
};
|
|
229
|
+
deletedAt?: Date | undefined;
|
|
230
|
+
lastActiveAt?: Date | undefined;
|
|
217
231
|
}[];
|
|
218
232
|
invitations: {
|
|
219
233
|
id: string;
|
|
@@ -367,13 +381,16 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
367
381
|
metadata?: any;
|
|
368
382
|
} & {
|
|
369
383
|
metadata: any;
|
|
370
|
-
members: ({
|
|
384
|
+
members: (({
|
|
371
385
|
id: string;
|
|
372
386
|
organizationId: string;
|
|
373
387
|
userId: string;
|
|
374
388
|
role: string;
|
|
375
389
|
createdAt: Date;
|
|
376
|
-
}
|
|
390
|
+
} & {} & {
|
|
391
|
+
deletedAt?: Date | undefined;
|
|
392
|
+
lastActiveAt?: Date | undefined;
|
|
393
|
+
}) | undefined)[];
|
|
377
394
|
}, {
|
|
378
395
|
code?: string | undefined;
|
|
379
396
|
message?: string | undefined;
|
|
@@ -457,6 +474,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
457
474
|
name: string;
|
|
458
475
|
image?: string | undefined;
|
|
459
476
|
};
|
|
477
|
+
deletedAt?: Date | undefined;
|
|
478
|
+
lastActiveAt?: Date | undefined;
|
|
460
479
|
}[];
|
|
461
480
|
invitations: {
|
|
462
481
|
id: string;
|
|
@@ -515,6 +534,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
515
534
|
name: string;
|
|
516
535
|
image?: string | undefined;
|
|
517
536
|
};
|
|
537
|
+
deletedAt?: Date | undefined;
|
|
538
|
+
lastActiveAt?: Date | undefined;
|
|
518
539
|
}[];
|
|
519
540
|
invitations: {
|
|
520
541
|
id: string;
|
|
@@ -645,6 +666,9 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
645
666
|
userId: string;
|
|
646
667
|
role: string;
|
|
647
668
|
createdAt: Date;
|
|
669
|
+
} & {} & {
|
|
670
|
+
deletedAt?: Date | undefined;
|
|
671
|
+
lastActiveAt?: Date | undefined;
|
|
648
672
|
};
|
|
649
673
|
}, {
|
|
650
674
|
code?: string | undefined;
|
|
@@ -746,6 +770,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
746
770
|
name: string;
|
|
747
771
|
image?: string | undefined;
|
|
748
772
|
};
|
|
773
|
+
deletedAt?: Date | undefined;
|
|
774
|
+
lastActiveAt?: Date | undefined;
|
|
749
775
|
} & {
|
|
750
776
|
user: better_auth.User;
|
|
751
777
|
}, "user"> & {
|
|
@@ -799,6 +825,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
799
825
|
name: string;
|
|
800
826
|
image?: string | undefined;
|
|
801
827
|
};
|
|
828
|
+
deletedAt?: Date | undefined;
|
|
829
|
+
lastActiveAt?: Date | undefined;
|
|
802
830
|
};
|
|
803
831
|
}, {
|
|
804
832
|
code?: string | undefined;
|
|
@@ -855,6 +883,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
855
883
|
name: string;
|
|
856
884
|
image?: string | undefined;
|
|
857
885
|
};
|
|
886
|
+
deletedAt?: Date | undefined;
|
|
887
|
+
lastActiveAt?: Date | undefined;
|
|
858
888
|
} & {
|
|
859
889
|
user: better_auth.User;
|
|
860
890
|
}, "user"> & {
|
|
@@ -943,6 +973,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
943
973
|
name: string;
|
|
944
974
|
image?: string | undefined;
|
|
945
975
|
};
|
|
976
|
+
deletedAt?: Date | undefined;
|
|
977
|
+
lastActiveAt?: Date | undefined;
|
|
946
978
|
} & {
|
|
947
979
|
user: {
|
|
948
980
|
id: string;
|
|
@@ -2739,6 +2771,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2739
2771
|
data: CompleteAuthorizationFlowResponse;
|
|
2740
2772
|
error: null;
|
|
2741
2773
|
}>;
|
|
2774
|
+
logout: (refreshToken: string) => Promise<{
|
|
2775
|
+
data: null;
|
|
2776
|
+
error: {
|
|
2777
|
+
message?: string | undefined;
|
|
2778
|
+
status: number;
|
|
2779
|
+
statusText: string;
|
|
2780
|
+
};
|
|
2781
|
+
} | {
|
|
2782
|
+
data: void;
|
|
2783
|
+
error: null;
|
|
2784
|
+
}>;
|
|
2742
2785
|
};
|
|
2743
2786
|
} & {
|
|
2744
2787
|
$Infer: {
|
|
@@ -2756,6 +2799,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2756
2799
|
name: string;
|
|
2757
2800
|
image?: string | undefined;
|
|
2758
2801
|
};
|
|
2802
|
+
deletedAt?: Date | undefined;
|
|
2803
|
+
lastActiveAt?: Date | undefined;
|
|
2759
2804
|
}[];
|
|
2760
2805
|
invitations: {
|
|
2761
2806
|
id: string;
|
|
@@ -2815,6 +2860,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2815
2860
|
name: string;
|
|
2816
2861
|
image?: string | undefined;
|
|
2817
2862
|
};
|
|
2863
|
+
deletedAt?: Date | undefined;
|
|
2864
|
+
lastActiveAt?: Date | undefined;
|
|
2818
2865
|
};
|
|
2819
2866
|
Team: {
|
|
2820
2867
|
id: string;
|
|
@@ -3161,11 +3208,6 @@ type Organization = stub['$Infer']['Organization'];
|
|
|
3161
3208
|
type Team = stub['$Infer']['Team'];
|
|
3162
3209
|
type Invitation = stub['$Infer']['Invitation'];
|
|
3163
3210
|
type Member = stub['$Infer']['Member'];
|
|
3164
|
-
type ExtendedMember = Omit<Member, 'user'> & {
|
|
3165
|
-
user: Member['user'] & {
|
|
3166
|
-
id: string;
|
|
3167
|
-
};
|
|
3168
|
-
};
|
|
3169
3211
|
type OrganizationSettings = {
|
|
3170
3212
|
disableStorage?: boolean;
|
|
3171
3213
|
dataRetentionHours?: number;
|
|
@@ -3232,6 +3274,9 @@ declare class RefreshTokenExpiredError extends ApplicationError {
|
|
|
3232
3274
|
declare class AuthorizationFlowError extends ApplicationError {
|
|
3233
3275
|
constructor(message: string, options?: ErrorOptions);
|
|
3234
3276
|
}
|
|
3277
|
+
declare class UserNotLoggedInError extends ApplicationError {
|
|
3278
|
+
constructor(message: string, options?: ErrorOptions);
|
|
3279
|
+
}
|
|
3235
3280
|
|
|
3236
3281
|
/**
|
|
3237
3282
|
* Service for managing applications and their candidate organizations.
|
|
@@ -3306,6 +3351,15 @@ declare class ApplicationService {
|
|
|
3306
3351
|
* @returns New authentication tokens and user/organization details
|
|
3307
3352
|
*/
|
|
3308
3353
|
switchOrganization(organizationId: string, accessToken: string): Promise<CompleteAuthorizationFlowResponse>;
|
|
3354
|
+
/**
|
|
3355
|
+
* Logs out the user by invalidating their refresh token.
|
|
3356
|
+
*
|
|
3357
|
+
* Revokes the refresh token on the server, preventing further token refreshes
|
|
3358
|
+
* and effectively ending the user's session.
|
|
3359
|
+
*
|
|
3360
|
+
* @param refreshToken - The refresh token to invalidate
|
|
3361
|
+
*/
|
|
3362
|
+
logout(refreshToken: string): Promise<void>;
|
|
3309
3363
|
}
|
|
3310
3364
|
|
|
3311
3365
|
type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
|
|
@@ -3370,6 +3424,8 @@ declare class OrganizationService {
|
|
|
3370
3424
|
name: string;
|
|
3371
3425
|
image?: string | undefined;
|
|
3372
3426
|
};
|
|
3427
|
+
deletedAt?: Date | undefined;
|
|
3428
|
+
lastActiveAt?: Date | undefined;
|
|
3373
3429
|
}[];
|
|
3374
3430
|
invitations: {
|
|
3375
3431
|
id: string;
|
|
@@ -3440,6 +3496,8 @@ declare class OrganizationService {
|
|
|
3440
3496
|
name: string;
|
|
3441
3497
|
image?: string | undefined;
|
|
3442
3498
|
};
|
|
3499
|
+
deletedAt?: Date | undefined;
|
|
3500
|
+
lastActiveAt?: Date | undefined;
|
|
3443
3501
|
} & {
|
|
3444
3502
|
user: {
|
|
3445
3503
|
id: string;
|
|
@@ -3466,6 +3524,8 @@ declare class OrganizationService {
|
|
|
3466
3524
|
name: string;
|
|
3467
3525
|
image?: string | undefined;
|
|
3468
3526
|
};
|
|
3527
|
+
deletedAt?: Date | undefined;
|
|
3528
|
+
lastActiveAt?: Date | undefined;
|
|
3469
3529
|
} & {
|
|
3470
3530
|
user: better_auth.User;
|
|
3471
3531
|
}, "user"> & {
|
|
@@ -4010,5 +4070,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
4010
4070
|
*/
|
|
4011
4071
|
declare function extractTokenPayload(token: string): JWTTokenPayload;
|
|
4012
4072
|
|
|
4013
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, ac, createAPIClient, extractTokenPayload, isTokenExpired, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
4014
|
-
export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions,
|
|
4073
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
4074
|
+
export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,18 @@ declare const organizationAdditionalFields: {
|
|
|
176
176
|
required: false;
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
+
declare const memberAdditionalFields: {
|
|
180
|
+
deletedAt: {
|
|
181
|
+
type: "date";
|
|
182
|
+
required: false;
|
|
183
|
+
defaultValue: null;
|
|
184
|
+
};
|
|
185
|
+
lastActiveAt: {
|
|
186
|
+
type: "date";
|
|
187
|
+
required: false;
|
|
188
|
+
defaultValue: null;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
179
191
|
type JWTTokenPayload = JWTPayload & {
|
|
180
192
|
email: string;
|
|
181
193
|
user: {
|
|
@@ -214,6 +226,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
214
226
|
name: string;
|
|
215
227
|
image?: string | undefined;
|
|
216
228
|
};
|
|
229
|
+
deletedAt?: Date | undefined;
|
|
230
|
+
lastActiveAt?: Date | undefined;
|
|
217
231
|
}[];
|
|
218
232
|
invitations: {
|
|
219
233
|
id: string;
|
|
@@ -367,13 +381,16 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
367
381
|
metadata?: any;
|
|
368
382
|
} & {
|
|
369
383
|
metadata: any;
|
|
370
|
-
members: ({
|
|
384
|
+
members: (({
|
|
371
385
|
id: string;
|
|
372
386
|
organizationId: string;
|
|
373
387
|
userId: string;
|
|
374
388
|
role: string;
|
|
375
389
|
createdAt: Date;
|
|
376
|
-
}
|
|
390
|
+
} & {} & {
|
|
391
|
+
deletedAt?: Date | undefined;
|
|
392
|
+
lastActiveAt?: Date | undefined;
|
|
393
|
+
}) | undefined)[];
|
|
377
394
|
}, {
|
|
378
395
|
code?: string | undefined;
|
|
379
396
|
message?: string | undefined;
|
|
@@ -457,6 +474,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
457
474
|
name: string;
|
|
458
475
|
image?: string | undefined;
|
|
459
476
|
};
|
|
477
|
+
deletedAt?: Date | undefined;
|
|
478
|
+
lastActiveAt?: Date | undefined;
|
|
460
479
|
}[];
|
|
461
480
|
invitations: {
|
|
462
481
|
id: string;
|
|
@@ -515,6 +534,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
515
534
|
name: string;
|
|
516
535
|
image?: string | undefined;
|
|
517
536
|
};
|
|
537
|
+
deletedAt?: Date | undefined;
|
|
538
|
+
lastActiveAt?: Date | undefined;
|
|
518
539
|
}[];
|
|
519
540
|
invitations: {
|
|
520
541
|
id: string;
|
|
@@ -645,6 +666,9 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
645
666
|
userId: string;
|
|
646
667
|
role: string;
|
|
647
668
|
createdAt: Date;
|
|
669
|
+
} & {} & {
|
|
670
|
+
deletedAt?: Date | undefined;
|
|
671
|
+
lastActiveAt?: Date | undefined;
|
|
648
672
|
};
|
|
649
673
|
}, {
|
|
650
674
|
code?: string | undefined;
|
|
@@ -746,6 +770,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
746
770
|
name: string;
|
|
747
771
|
image?: string | undefined;
|
|
748
772
|
};
|
|
773
|
+
deletedAt?: Date | undefined;
|
|
774
|
+
lastActiveAt?: Date | undefined;
|
|
749
775
|
} & {
|
|
750
776
|
user: better_auth.User;
|
|
751
777
|
}, "user"> & {
|
|
@@ -799,6 +825,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
799
825
|
name: string;
|
|
800
826
|
image?: string | undefined;
|
|
801
827
|
};
|
|
828
|
+
deletedAt?: Date | undefined;
|
|
829
|
+
lastActiveAt?: Date | undefined;
|
|
802
830
|
};
|
|
803
831
|
}, {
|
|
804
832
|
code?: string | undefined;
|
|
@@ -855,6 +883,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
855
883
|
name: string;
|
|
856
884
|
image?: string | undefined;
|
|
857
885
|
};
|
|
886
|
+
deletedAt?: Date | undefined;
|
|
887
|
+
lastActiveAt?: Date | undefined;
|
|
858
888
|
} & {
|
|
859
889
|
user: better_auth.User;
|
|
860
890
|
}, "user"> & {
|
|
@@ -943,6 +973,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
943
973
|
name: string;
|
|
944
974
|
image?: string | undefined;
|
|
945
975
|
};
|
|
976
|
+
deletedAt?: Date | undefined;
|
|
977
|
+
lastActiveAt?: Date | undefined;
|
|
946
978
|
} & {
|
|
947
979
|
user: {
|
|
948
980
|
id: string;
|
|
@@ -2739,6 +2771,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2739
2771
|
data: CompleteAuthorizationFlowResponse;
|
|
2740
2772
|
error: null;
|
|
2741
2773
|
}>;
|
|
2774
|
+
logout: (refreshToken: string) => Promise<{
|
|
2775
|
+
data: null;
|
|
2776
|
+
error: {
|
|
2777
|
+
message?: string | undefined;
|
|
2778
|
+
status: number;
|
|
2779
|
+
statusText: string;
|
|
2780
|
+
};
|
|
2781
|
+
} | {
|
|
2782
|
+
data: void;
|
|
2783
|
+
error: null;
|
|
2784
|
+
}>;
|
|
2742
2785
|
};
|
|
2743
2786
|
} & {
|
|
2744
2787
|
$Infer: {
|
|
@@ -2756,6 +2799,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2756
2799
|
name: string;
|
|
2757
2800
|
image?: string | undefined;
|
|
2758
2801
|
};
|
|
2802
|
+
deletedAt?: Date | undefined;
|
|
2803
|
+
lastActiveAt?: Date | undefined;
|
|
2759
2804
|
}[];
|
|
2760
2805
|
invitations: {
|
|
2761
2806
|
id: string;
|
|
@@ -2815,6 +2860,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2815
2860
|
name: string;
|
|
2816
2861
|
image?: string | undefined;
|
|
2817
2862
|
};
|
|
2863
|
+
deletedAt?: Date | undefined;
|
|
2864
|
+
lastActiveAt?: Date | undefined;
|
|
2818
2865
|
};
|
|
2819
2866
|
Team: {
|
|
2820
2867
|
id: string;
|
|
@@ -3161,11 +3208,6 @@ type Organization = stub['$Infer']['Organization'];
|
|
|
3161
3208
|
type Team = stub['$Infer']['Team'];
|
|
3162
3209
|
type Invitation = stub['$Infer']['Invitation'];
|
|
3163
3210
|
type Member = stub['$Infer']['Member'];
|
|
3164
|
-
type ExtendedMember = Omit<Member, 'user'> & {
|
|
3165
|
-
user: Member['user'] & {
|
|
3166
|
-
id: string;
|
|
3167
|
-
};
|
|
3168
|
-
};
|
|
3169
3211
|
type OrganizationSettings = {
|
|
3170
3212
|
disableStorage?: boolean;
|
|
3171
3213
|
dataRetentionHours?: number;
|
|
@@ -3232,6 +3274,9 @@ declare class RefreshTokenExpiredError extends ApplicationError {
|
|
|
3232
3274
|
declare class AuthorizationFlowError extends ApplicationError {
|
|
3233
3275
|
constructor(message: string, options?: ErrorOptions);
|
|
3234
3276
|
}
|
|
3277
|
+
declare class UserNotLoggedInError extends ApplicationError {
|
|
3278
|
+
constructor(message: string, options?: ErrorOptions);
|
|
3279
|
+
}
|
|
3235
3280
|
|
|
3236
3281
|
/**
|
|
3237
3282
|
* Service for managing applications and their candidate organizations.
|
|
@@ -3306,6 +3351,15 @@ declare class ApplicationService {
|
|
|
3306
3351
|
* @returns New authentication tokens and user/organization details
|
|
3307
3352
|
*/
|
|
3308
3353
|
switchOrganization(organizationId: string, accessToken: string): Promise<CompleteAuthorizationFlowResponse>;
|
|
3354
|
+
/**
|
|
3355
|
+
* Logs out the user by invalidating their refresh token.
|
|
3356
|
+
*
|
|
3357
|
+
* Revokes the refresh token on the server, preventing further token refreshes
|
|
3358
|
+
* and effectively ending the user's session.
|
|
3359
|
+
*
|
|
3360
|
+
* @param refreshToken - The refresh token to invalidate
|
|
3361
|
+
*/
|
|
3362
|
+
logout(refreshToken: string): Promise<void>;
|
|
3309
3363
|
}
|
|
3310
3364
|
|
|
3311
3365
|
type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
|
|
@@ -3370,6 +3424,8 @@ declare class OrganizationService {
|
|
|
3370
3424
|
name: string;
|
|
3371
3425
|
image?: string | undefined;
|
|
3372
3426
|
};
|
|
3427
|
+
deletedAt?: Date | undefined;
|
|
3428
|
+
lastActiveAt?: Date | undefined;
|
|
3373
3429
|
}[];
|
|
3374
3430
|
invitations: {
|
|
3375
3431
|
id: string;
|
|
@@ -3440,6 +3496,8 @@ declare class OrganizationService {
|
|
|
3440
3496
|
name: string;
|
|
3441
3497
|
image?: string | undefined;
|
|
3442
3498
|
};
|
|
3499
|
+
deletedAt?: Date | undefined;
|
|
3500
|
+
lastActiveAt?: Date | undefined;
|
|
3443
3501
|
} & {
|
|
3444
3502
|
user: {
|
|
3445
3503
|
id: string;
|
|
@@ -3466,6 +3524,8 @@ declare class OrganizationService {
|
|
|
3466
3524
|
name: string;
|
|
3467
3525
|
image?: string | undefined;
|
|
3468
3526
|
};
|
|
3527
|
+
deletedAt?: Date | undefined;
|
|
3528
|
+
lastActiveAt?: Date | undefined;
|
|
3469
3529
|
} & {
|
|
3470
3530
|
user: better_auth.User;
|
|
3471
3531
|
}, "user"> & {
|
|
@@ -4010,5 +4070,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
4010
4070
|
*/
|
|
4011
4071
|
declare function extractTokenPayload(token: string): JWTTokenPayload;
|
|
4012
4072
|
|
|
4013
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, ac, createAPIClient, extractTokenPayload, isTokenExpired, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
4014
|
-
export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions,
|
|
4073
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
4074
|
+
export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { decodeJwt, createRemoteJWKSet, jwtVerify } from 'jose';
|
|
2
2
|
import { ssoClient } from '@better-auth/sso/client';
|
|
3
3
|
import { createAuthClient } from 'better-auth/client';
|
|
4
|
-
import { organizationClient, twoFactorClient, jwtClient, apiKeyClient, adminClient, inferAdditionalFields } from 'better-auth/client/plugins';
|
|
4
|
+
import { organizationClient, inferOrgAdditionalFields, twoFactorClient, jwtClient, apiKeyClient, adminClient, inferAdditionalFields } from 'better-auth/client/plugins';
|
|
5
5
|
import { createAccessControl } from 'better-auth/plugins/access';
|
|
6
6
|
import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
7
7
|
export { BetterFetchError as APIError } from '@better-fetch/fetch';
|
|
8
8
|
|
|
9
|
-
const version = "1.
|
|
9
|
+
const version = "1.9.0";
|
|
10
10
|
|
|
11
11
|
const statements = {
|
|
12
12
|
...defaultStatements,
|
|
@@ -47,6 +47,18 @@ const organizationAdditionalFields = {
|
|
|
47
47
|
required: false
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
const memberAdditionalFields = {
|
|
51
|
+
deletedAt: {
|
|
52
|
+
type: "date",
|
|
53
|
+
required: false,
|
|
54
|
+
defaultValue: null
|
|
55
|
+
},
|
|
56
|
+
lastActiveAt: {
|
|
57
|
+
type: "date",
|
|
58
|
+
required: false,
|
|
59
|
+
defaultValue: null
|
|
60
|
+
}
|
|
61
|
+
};
|
|
50
62
|
|
|
51
63
|
function applicationsPluginClient() {
|
|
52
64
|
return {
|
|
@@ -122,6 +134,14 @@ function applicationsPluginClient() {
|
|
|
122
134
|
organizationId
|
|
123
135
|
}
|
|
124
136
|
});
|
|
137
|
+
},
|
|
138
|
+
logout: async (refreshToken) => {
|
|
139
|
+
const headers = new Headers();
|
|
140
|
+
headers.set("x-tela-refresh-token", refreshToken);
|
|
141
|
+
return await $fetch("/applications/logout", {
|
|
142
|
+
method: "POST",
|
|
143
|
+
headers
|
|
144
|
+
});
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
};
|
|
@@ -152,19 +172,22 @@ function createAPIClient(apiUrl, fetchOptions = {}) {
|
|
|
152
172
|
roles: rolesAccessControl,
|
|
153
173
|
teams: {
|
|
154
174
|
enabled: true
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
},
|
|
176
|
+
schema: inferOrgAdditionalFields({
|
|
177
|
+
// TODO: check if this is fixed in the next version
|
|
178
|
+
// organization: {
|
|
179
|
+
// additionalFields: {
|
|
180
|
+
// settings: {
|
|
181
|
+
// type: 'json' as const,
|
|
182
|
+
// input: true,
|
|
183
|
+
// required: false,
|
|
184
|
+
// }
|
|
185
|
+
// },
|
|
186
|
+
// }
|
|
187
|
+
member: {
|
|
188
|
+
additionalFields: memberAdditionalFields
|
|
189
|
+
}
|
|
190
|
+
})
|
|
168
191
|
}),
|
|
169
192
|
customEndpointsPluginClient(),
|
|
170
193
|
handshakePluginClient(),
|
|
@@ -215,6 +238,12 @@ class AuthorizationFlowError extends ApplicationError {
|
|
|
215
238
|
this.code = "AUTHORIZATION_FLOW_ERROR";
|
|
216
239
|
}
|
|
217
240
|
}
|
|
241
|
+
class UserNotLoggedInError extends ApplicationError {
|
|
242
|
+
constructor(message, options) {
|
|
243
|
+
super(message, options);
|
|
244
|
+
this.code = "USER_NOT_LOGGED_IN";
|
|
245
|
+
}
|
|
246
|
+
}
|
|
218
247
|
|
|
219
248
|
class ApplicationService {
|
|
220
249
|
/**
|
|
@@ -319,6 +348,17 @@ class ApplicationService {
|
|
|
319
348
|
}
|
|
320
349
|
return response.data;
|
|
321
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Logs out the user by invalidating their refresh token.
|
|
353
|
+
*
|
|
354
|
+
* Revokes the refresh token on the server, preventing further token refreshes
|
|
355
|
+
* and effectively ending the user's session.
|
|
356
|
+
*
|
|
357
|
+
* @param refreshToken - The refresh token to invalidate
|
|
358
|
+
*/
|
|
359
|
+
async logout(refreshToken) {
|
|
360
|
+
await this.client.applications.logout(refreshToken);
|
|
361
|
+
}
|
|
322
362
|
}
|
|
323
363
|
|
|
324
364
|
class OrganizationService {
|
|
@@ -837,4 +877,4 @@ function extractTokenPayload(token) {
|
|
|
837
877
|
return payload;
|
|
838
878
|
}
|
|
839
879
|
|
|
840
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, ac, extractTokenPayload, isTokenExpired, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
880
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|