@meistrari/auth-core 1.35.0 → 1.37.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/README.md +6 -0
- package/dist/index.d.mts +230 -53
- package/dist/index.d.ts +230 -53
- package/dist/index.mjs +233 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ type AssuranceFields = {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
declare const ac: {
|
|
95
|
-
newRole<K extends "
|
|
95
|
+
newRole<K extends "organization" | "ac" | "member" | "access" | "invitation" | "team">(statements: better_auth_plugins.Subset<K, {
|
|
96
96
|
access: string[];
|
|
97
97
|
organization: readonly ["update", "delete"];
|
|
98
98
|
member: readonly ["create", "update", "delete"];
|
|
@@ -166,7 +166,7 @@ type Role = typeof Roles[keyof typeof Roles];
|
|
|
166
166
|
*/
|
|
167
167
|
declare const rolesAccessControl: {
|
|
168
168
|
"org:admin": {
|
|
169
|
-
authorize<K_1 extends "
|
|
169
|
+
authorize<K_1 extends "organization" | "member" | "access" | "invitation" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins.Subset<"organization" | "member" | "access" | "invitation" | "team", {
|
|
170
170
|
access: string[];
|
|
171
171
|
organization: readonly ["update", "delete"];
|
|
172
172
|
member: readonly ["create", "update", "delete"];
|
|
@@ -174,7 +174,7 @@ declare const rolesAccessControl: {
|
|
|
174
174
|
team: readonly ["create", "update", "delete"];
|
|
175
175
|
ac: readonly ["create", "read", "update", "delete"];
|
|
176
176
|
}>[key] | {
|
|
177
|
-
actions: better_auth_plugins.Subset<"
|
|
177
|
+
actions: better_auth_plugins.Subset<"organization" | "member" | "access" | "invitation" | "team", {
|
|
178
178
|
access: string[];
|
|
179
179
|
organization: readonly ["update", "delete"];
|
|
180
180
|
member: readonly ["create", "update", "delete"];
|
|
@@ -184,7 +184,7 @@ declare const rolesAccessControl: {
|
|
|
184
184
|
}>[key];
|
|
185
185
|
connector: "OR" | "AND";
|
|
186
186
|
} | undefined; } : never, connector?: "OR" | "AND"): better_auth_plugins.AuthorizeResponse;
|
|
187
|
-
statements: better_auth_plugins.Subset<"
|
|
187
|
+
statements: better_auth_plugins.Subset<"organization" | "member" | "access" | "invitation" | "team", {
|
|
188
188
|
access: string[];
|
|
189
189
|
organization: readonly ["update", "delete"];
|
|
190
190
|
member: readonly ["create", "update", "delete"];
|
|
@@ -370,6 +370,30 @@ type JWTPayloadData = {
|
|
|
370
370
|
declare const JWTPayload: z$1.ZodType<JWTPayloadData>;
|
|
371
371
|
type JWTPayload = JWTPayload$1 & JWTPayloadData;
|
|
372
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Checks if a JWT token has expired or will expire within a specified time window.
|
|
375
|
+
*
|
|
376
|
+
* @param token - The JWT token string to check
|
|
377
|
+
* @param expiresInMs - Optional time window in milliseconds. If provided, returns `true` if the token will expire within this time window
|
|
378
|
+
* @returns `true` if the token is expired (or will expire within the specified window), `false` otherwise
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
383
|
+
*
|
|
384
|
+
* // Check if token is already expired
|
|
385
|
+
* if (isTokenExpired(token)) {
|
|
386
|
+
* console.log('Token has expired')
|
|
387
|
+
* }
|
|
388
|
+
*
|
|
389
|
+
* // Check if token will expire in the next 5 minutes
|
|
390
|
+
* if (isTokenExpired(token, 5 * 60 * 1000)) {
|
|
391
|
+
* console.log('Token will expire in the next 5 minutes')
|
|
392
|
+
* }
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
declare function isTokenExpired(token: string, expiresInMs?: number): boolean;
|
|
396
|
+
|
|
373
397
|
declare const OAuthStepUpProvider: z.ZodEnum<{
|
|
374
398
|
google: "google";
|
|
375
399
|
microsoft: "microsoft";
|
|
@@ -631,6 +655,24 @@ type CompleteAuthorizationFlowResponse = {
|
|
|
631
655
|
/** Assurance context embedded in the issued access token. */
|
|
632
656
|
assurance: JWTPayload['assurance'];
|
|
633
657
|
};
|
|
658
|
+
/**
|
|
659
|
+
* Credentials used to authenticate an application service account.
|
|
660
|
+
*/
|
|
661
|
+
type ClientCredentialsGrant = {
|
|
662
|
+
/** The application identifier. */
|
|
663
|
+
clientId: string;
|
|
664
|
+
/** A valid secret issued for the application. */
|
|
665
|
+
clientSecret: string;
|
|
666
|
+
/** The organization to scope the access token to. */
|
|
667
|
+
organizationId: string;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Response returned after a successful client credentials exchange.
|
|
671
|
+
*
|
|
672
|
+
* Client credentials issue only a short-lived access token, so this response
|
|
673
|
+
* intentionally does not include a refresh token.
|
|
674
|
+
*/
|
|
675
|
+
type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'refreshToken'>;
|
|
634
676
|
/**
|
|
635
677
|
* Response returned by the "who am I" endpoint.
|
|
636
678
|
*
|
|
@@ -815,6 +857,7 @@ declare function isSessionAssuranceSufficient(sessionAssurance: JWTPayload['assu
|
|
|
815
857
|
* Provides functionality for:
|
|
816
858
|
* - OAuth authorization code flow (PKCE)
|
|
817
859
|
* - Device authorization flow (RFC 8628)
|
|
860
|
+
* - Client credentials flow for service accounts
|
|
818
861
|
* - Token management (refresh, exchange)
|
|
819
862
|
* - Organization switching
|
|
820
863
|
*/
|
|
@@ -905,6 +948,16 @@ declare class ApplicationService {
|
|
|
905
948
|
* @throws {ApplicationSessionAssuranceError} Assurance policy changed or is no longer met — start a new flow
|
|
906
949
|
*/
|
|
907
950
|
exchangeDeviceCodeForTokens(deviceCode: string): Promise<CompleteAuthorizationFlowResponse>;
|
|
951
|
+
/**
|
|
952
|
+
* Exchanges application client credentials for a service-account access token.
|
|
953
|
+
*
|
|
954
|
+
* The returned token is scoped to the requested organization and cannot be
|
|
955
|
+
* refreshed. Exchange the credentials again when a new token is needed.
|
|
956
|
+
*
|
|
957
|
+
* @param credentials - Application credentials and target organization
|
|
958
|
+
* @returns A short-lived access token with service-account and organization details
|
|
959
|
+
*/
|
|
960
|
+
exchangeClientCredentialsForToken(credentials: ClientCredentialsGrant): Promise<ClientCredentialsTokenResponse>;
|
|
908
961
|
/**
|
|
909
962
|
* Completes an authorization flow for a specific application.
|
|
910
963
|
*
|
|
@@ -2667,10 +2720,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2667
2720
|
} & {
|
|
2668
2721
|
preferredLanguage: string;
|
|
2669
2722
|
} & {
|
|
2670
|
-
lastActiveAt?: Date | null | undefined;
|
|
2671
2723
|
displayName?: string | null | undefined;
|
|
2672
2724
|
title?: string | null | undefined;
|
|
2673
2725
|
pronouns?: string | null | undefined;
|
|
2726
|
+
lastActiveAt?: Date | null | undefined;
|
|
2674
2727
|
}>;
|
|
2675
2728
|
}, {
|
|
2676
2729
|
code?: string | undefined;
|
|
@@ -2740,10 +2793,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2740
2793
|
} & {
|
|
2741
2794
|
preferredLanguage: string;
|
|
2742
2795
|
} & {
|
|
2743
|
-
lastActiveAt?: Date | null | undefined;
|
|
2744
2796
|
displayName?: string | null | undefined;
|
|
2745
2797
|
title?: string | null | undefined;
|
|
2746
2798
|
pronouns?: string | null | undefined;
|
|
2799
|
+
lastActiveAt?: Date | null | undefined;
|
|
2747
2800
|
}>;
|
|
2748
2801
|
}) | (Omit<{
|
|
2749
2802
|
token: string;
|
|
@@ -2776,10 +2829,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2776
2829
|
} & {
|
|
2777
2830
|
preferredLanguage: string;
|
|
2778
2831
|
} & {
|
|
2779
|
-
lastActiveAt?: Date | null | undefined;
|
|
2780
2832
|
displayName?: string | null | undefined;
|
|
2781
2833
|
title?: string | null | undefined;
|
|
2782
2834
|
pronouns?: string | null | undefined;
|
|
2835
|
+
lastActiveAt?: Date | null | undefined;
|
|
2783
2836
|
}>;
|
|
2784
2837
|
}), {
|
|
2785
2838
|
code?: string | undefined;
|
|
@@ -2834,10 +2887,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2834
2887
|
} & {
|
|
2835
2888
|
preferredLanguage: string;
|
|
2836
2889
|
} & {
|
|
2837
|
-
lastActiveAt?: Date | null | undefined;
|
|
2838
2890
|
displayName?: string | null | undefined;
|
|
2839
2891
|
title?: string | null | undefined;
|
|
2840
2892
|
pronouns?: string | null | undefined;
|
|
2893
|
+
lastActiveAt?: Date | null | undefined;
|
|
2841
2894
|
}>;
|
|
2842
2895
|
}) | (Omit<{
|
|
2843
2896
|
token: string;
|
|
@@ -2870,10 +2923,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2870
2923
|
} & {
|
|
2871
2924
|
preferredLanguage: string;
|
|
2872
2925
|
} & {
|
|
2873
|
-
lastActiveAt?: Date | null | undefined;
|
|
2874
2926
|
displayName?: string | null | undefined;
|
|
2875
2927
|
title?: string | null | undefined;
|
|
2876
2928
|
pronouns?: string | null | undefined;
|
|
2929
|
+
lastActiveAt?: Date | null | undefined;
|
|
2877
2930
|
}>;
|
|
2878
2931
|
}), {
|
|
2879
2932
|
code?: string | undefined;
|
|
@@ -3501,10 +3554,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3501
3554
|
} & {
|
|
3502
3555
|
preferredLanguage: string;
|
|
3503
3556
|
} & {
|
|
3504
|
-
lastActiveAt?: Date | null | undefined;
|
|
3505
3557
|
displayName?: string | null | undefined;
|
|
3506
3558
|
title?: string | null | undefined;
|
|
3507
3559
|
pronouns?: string | null | undefined;
|
|
3560
|
+
lastActiveAt?: Date | null | undefined;
|
|
3508
3561
|
}>;
|
|
3509
3562
|
}) | (Omit<{
|
|
3510
3563
|
status: boolean;
|
|
@@ -3538,10 +3591,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3538
3591
|
} & {
|
|
3539
3592
|
preferredLanguage: string;
|
|
3540
3593
|
} & {
|
|
3541
|
-
lastActiveAt?: Date | null | undefined;
|
|
3542
3594
|
displayName?: string | null | undefined;
|
|
3543
3595
|
title?: string | null | undefined;
|
|
3544
3596
|
pronouns?: string | null | undefined;
|
|
3597
|
+
lastActiveAt?: Date | null | undefined;
|
|
3545
3598
|
}>;
|
|
3546
3599
|
}), {
|
|
3547
3600
|
code?: string | undefined;
|
|
@@ -3593,10 +3646,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3593
3646
|
} & {
|
|
3594
3647
|
preferredLanguage: string;
|
|
3595
3648
|
} & {
|
|
3596
|
-
lastActiveAt?: Date | null | undefined;
|
|
3597
3649
|
displayName?: string | null | undefined;
|
|
3598
3650
|
title?: string | null | undefined;
|
|
3599
3651
|
pronouns?: string | null | undefined;
|
|
3652
|
+
lastActiveAt?: Date | null | undefined;
|
|
3600
3653
|
}>;
|
|
3601
3654
|
}, {
|
|
3602
3655
|
code?: string | undefined;
|
|
@@ -3760,10 +3813,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3760
3813
|
} & {
|
|
3761
3814
|
preferredLanguage: string;
|
|
3762
3815
|
} & {
|
|
3763
|
-
lastActiveAt?: Date | null | undefined;
|
|
3764
3816
|
displayName?: string | null | undefined;
|
|
3765
3817
|
title?: string | null | undefined;
|
|
3766
3818
|
pronouns?: string | null | undefined;
|
|
3819
|
+
lastActiveAt?: Date | null | undefined;
|
|
3767
3820
|
}>;
|
|
3768
3821
|
}), {
|
|
3769
3822
|
code?: string | undefined;
|
|
@@ -3797,11 +3850,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3797
3850
|
callbackURL?: string | undefined;
|
|
3798
3851
|
fetchOptions?: FetchOptions | undefined;
|
|
3799
3852
|
} & {} & {} & {} & {} & {} & {
|
|
3800
|
-
lastActiveAt?: Date | null | undefined;
|
|
3801
3853
|
displayName?: string | null | undefined;
|
|
3802
3854
|
title?: string | null | undefined;
|
|
3803
3855
|
pronouns?: string | null | undefined;
|
|
3804
3856
|
preferredLanguage?: string | null | undefined;
|
|
3857
|
+
lastActiveAt?: Date | null | undefined;
|
|
3805
3858
|
}>, data_1?: FetchOptions | undefined) => Promise<better_auth_client.BetterFetchResponse<(Omit<{
|
|
3806
3859
|
token: null;
|
|
3807
3860
|
user: {
|
|
@@ -3833,10 +3886,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3833
3886
|
} & {
|
|
3834
3887
|
preferredLanguage: string;
|
|
3835
3888
|
} & {
|
|
3836
|
-
lastActiveAt?: Date | null | undefined;
|
|
3837
3889
|
displayName?: string | null | undefined;
|
|
3838
3890
|
title?: string | null | undefined;
|
|
3839
3891
|
pronouns?: string | null | undefined;
|
|
3892
|
+
lastActiveAt?: Date | null | undefined;
|
|
3840
3893
|
}>;
|
|
3841
3894
|
}) | (Omit<{
|
|
3842
3895
|
token: string;
|
|
@@ -3869,10 +3922,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3869
3922
|
} & {
|
|
3870
3923
|
preferredLanguage: string;
|
|
3871
3924
|
} & {
|
|
3872
|
-
lastActiveAt?: Date | null | undefined;
|
|
3873
3925
|
displayName?: string | null | undefined;
|
|
3874
3926
|
title?: string | null | undefined;
|
|
3875
3927
|
pronouns?: string | null | undefined;
|
|
3928
|
+
lastActiveAt?: Date | null | undefined;
|
|
3876
3929
|
}>;
|
|
3877
3930
|
}), {
|
|
3878
3931
|
code?: string | undefined;
|
|
@@ -3926,10 +3979,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3926
3979
|
} & {
|
|
3927
3980
|
preferredLanguage: string;
|
|
3928
3981
|
} & {
|
|
3929
|
-
lastActiveAt?: Date | null | undefined;
|
|
3930
3982
|
displayName?: string | null | undefined;
|
|
3931
3983
|
title?: string | null | undefined;
|
|
3932
3984
|
pronouns?: string | null | undefined;
|
|
3985
|
+
lastActiveAt?: Date | null | undefined;
|
|
3933
3986
|
}>;
|
|
3934
3987
|
}, {
|
|
3935
3988
|
code?: string | undefined;
|
|
@@ -4049,10 +4102,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4049
4102
|
} & {
|
|
4050
4103
|
preferredLanguage: string;
|
|
4051
4104
|
} & {
|
|
4052
|
-
lastActiveAt?: Date | null | undefined;
|
|
4053
4105
|
displayName?: string | null | undefined;
|
|
4054
4106
|
title?: string | null | undefined;
|
|
4055
4107
|
pronouns?: string | null | undefined;
|
|
4108
|
+
lastActiveAt?: Date | null | undefined;
|
|
4056
4109
|
}>;
|
|
4057
4110
|
}, {
|
|
4058
4111
|
code?: string | undefined;
|
|
@@ -4085,11 +4138,11 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4085
4138
|
name?: string | undefined;
|
|
4086
4139
|
fetchOptions?: FetchOptions | undefined;
|
|
4087
4140
|
} & Partial<{} & {} & {} & {} & {} & {
|
|
4088
|
-
lastActiveAt?: Date | null | undefined;
|
|
4089
4141
|
displayName?: string | null | undefined;
|
|
4090
4142
|
title?: string | null | undefined;
|
|
4091
4143
|
pronouns?: string | null | undefined;
|
|
4092
4144
|
preferredLanguage?: string | null | undefined;
|
|
4145
|
+
lastActiveAt?: Date | null | undefined;
|
|
4093
4146
|
}>> | undefined, data_1?: FetchOptions | undefined) => Promise<better_auth_client.BetterFetchResponse<{
|
|
4094
4147
|
status: boolean;
|
|
4095
4148
|
}, {
|
|
@@ -4375,10 +4428,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4375
4428
|
} & {
|
|
4376
4429
|
preferredLanguage: string;
|
|
4377
4430
|
} & {
|
|
4378
|
-
lastActiveAt?: Date | null | undefined;
|
|
4379
4431
|
displayName?: string | null | undefined;
|
|
4380
4432
|
title?: string | null | undefined;
|
|
4381
4433
|
pronouns?: string | null | undefined;
|
|
4434
|
+
lastActiveAt?: Date | null | undefined;
|
|
4382
4435
|
}>;
|
|
4383
4436
|
session: better_auth.StripEmptyObjects<{
|
|
4384
4437
|
id: string;
|
|
@@ -4402,15 +4455,15 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4402
4455
|
} & {
|
|
4403
4456
|
applications: {
|
|
4404
4457
|
getApplicationAuthContext: (applicationId: string) => Promise<{
|
|
4405
|
-
data: ApplicationAuthContextResponse;
|
|
4406
|
-
error: null;
|
|
4407
|
-
} | {
|
|
4408
4458
|
data: null;
|
|
4409
4459
|
error: {
|
|
4410
4460
|
message?: string | undefined;
|
|
4411
4461
|
status: number;
|
|
4412
4462
|
statusText: string;
|
|
4413
4463
|
};
|
|
4464
|
+
} | {
|
|
4465
|
+
data: ApplicationAuthContextResponse;
|
|
4466
|
+
error: null;
|
|
4414
4467
|
}>;
|
|
4415
4468
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
4416
4469
|
data: ListCandidateOrganizationsResponse;
|
|
@@ -4482,6 +4535,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4482
4535
|
data: CompleteAuthorizationFlowResponse;
|
|
4483
4536
|
error: null;
|
|
4484
4537
|
}>;
|
|
4538
|
+
exchangeClientCredentialsForToken: (credentials: ClientCredentialsGrant) => Promise<{
|
|
4539
|
+
data: ClientCredentialsTokenResponse;
|
|
4540
|
+
error: null;
|
|
4541
|
+
} | {
|
|
4542
|
+
data: null;
|
|
4543
|
+
error: {
|
|
4544
|
+
message?: string | undefined;
|
|
4545
|
+
status: number;
|
|
4546
|
+
statusText: string;
|
|
4547
|
+
};
|
|
4548
|
+
}>;
|
|
4485
4549
|
completeAuthorizationFlow: (code: string, codeVerifier: string) => Promise<{
|
|
4486
4550
|
data: null;
|
|
4487
4551
|
error: {
|
|
@@ -4759,10 +4823,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4759
4823
|
} & {
|
|
4760
4824
|
preferredLanguage: string;
|
|
4761
4825
|
} & {
|
|
4762
|
-
lastActiveAt?: Date | null | undefined;
|
|
4763
4826
|
displayName?: string | null | undefined;
|
|
4764
4827
|
title?: string | null | undefined;
|
|
4765
4828
|
pronouns?: string | null | undefined;
|
|
4829
|
+
lastActiveAt?: Date | null | undefined;
|
|
4766
4830
|
}>;
|
|
4767
4831
|
session: better_auth.StripEmptyObjects<{
|
|
4768
4832
|
id: string;
|
|
@@ -4879,10 +4943,10 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4879
4943
|
} & {
|
|
4880
4944
|
preferredLanguage: string;
|
|
4881
4945
|
} & {
|
|
4882
|
-
lastActiveAt?: Date | null | undefined;
|
|
4883
4946
|
displayName?: string | null | undefined;
|
|
4884
4947
|
title?: string | null | undefined;
|
|
4885
4948
|
pronouns?: string | null | undefined;
|
|
4949
|
+
lastActiveAt?: Date | null | undefined;
|
|
4886
4950
|
}>;
|
|
4887
4951
|
session: better_auth.StripEmptyObjects<{
|
|
4888
4952
|
id: string;
|
|
@@ -5767,6 +5831,39 @@ type CreateAdminApplicationEntitlementOptions = {
|
|
|
5767
5831
|
/** Organization that should be entitled to the application. */
|
|
5768
5832
|
organizationId: string;
|
|
5769
5833
|
};
|
|
5834
|
+
/**
|
|
5835
|
+
* Options accepted when creating a client secret for an application.
|
|
5836
|
+
*/
|
|
5837
|
+
type CreateAdminApplicationSecretOptions = {
|
|
5838
|
+
/** Optional display name for the secret. */
|
|
5839
|
+
name?: string;
|
|
5840
|
+
};
|
|
5841
|
+
/**
|
|
5842
|
+
* Client secret metadata returned by application management endpoints.
|
|
5843
|
+
*/
|
|
5844
|
+
type AdminApplicationSecret = {
|
|
5845
|
+
id: string;
|
|
5846
|
+
applicationId: string;
|
|
5847
|
+
name: string | null;
|
|
5848
|
+
/** First characters of the secret, kept for later identification. */
|
|
5849
|
+
start: string;
|
|
5850
|
+
createdAt: string;
|
|
5851
|
+
lastUsedAt: string | null;
|
|
5852
|
+
};
|
|
5853
|
+
/**
|
|
5854
|
+
* Service-account identity backing client-credentials tokens for an application.
|
|
5855
|
+
*/
|
|
5856
|
+
type AdminApplicationIdentity = {
|
|
5857
|
+
id: string;
|
|
5858
|
+
email: string;
|
|
5859
|
+
};
|
|
5860
|
+
/**
|
|
5861
|
+
* Newly-created client secret. The plaintext secret is returned only once.
|
|
5862
|
+
*/
|
|
5863
|
+
type CreatedAdminApplicationSecret = AdminApplicationSecret & {
|
|
5864
|
+
secret: string;
|
|
5865
|
+
serviceAccountUser: AdminApplicationIdentity;
|
|
5866
|
+
};
|
|
5770
5867
|
/**
|
|
5771
5868
|
* Options accepted when fetching a single organization as a global admin.
|
|
5772
5869
|
*/
|
|
@@ -6193,6 +6290,8 @@ type AdminApplication = {
|
|
|
6193
6290
|
redirectUris: string[];
|
|
6194
6291
|
homeUrl: string | null;
|
|
6195
6292
|
config: ApplicationConfig | null;
|
|
6293
|
+
serviceAccountUserId: string | null;
|
|
6294
|
+
serviceAccountUser?: AdminApplicationIdentity | null;
|
|
6196
6295
|
createdBy: string;
|
|
6197
6296
|
updatedBy: string;
|
|
6198
6297
|
createdAt: string;
|
|
@@ -6368,6 +6467,36 @@ declare class AdminService {
|
|
|
6368
6467
|
* @returns The created entitlement
|
|
6369
6468
|
*/
|
|
6370
6469
|
createApplicationEntitlement(applicationId: string, options: CreateAdminApplicationEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6470
|
+
/**
|
|
6471
|
+
* Lists client secrets for an application.
|
|
6472
|
+
*
|
|
6473
|
+
* @param applicationId - ID of the application to inspect
|
|
6474
|
+
* @returns Secret metadata without plaintext values
|
|
6475
|
+
*/
|
|
6476
|
+
listApplicationSecrets(applicationId: string): Promise<AdminApplicationSecret[]>;
|
|
6477
|
+
/**
|
|
6478
|
+
* Creates a client secret for an application.
|
|
6479
|
+
*
|
|
6480
|
+
* @param applicationId - ID of the application to update
|
|
6481
|
+
* @param options - Optional secret display name
|
|
6482
|
+
* @returns The created secret, including the plaintext value shown only once
|
|
6483
|
+
*/
|
|
6484
|
+
createApplicationSecret(applicationId: string, options?: CreateAdminApplicationSecretOptions): Promise<CreatedAdminApplicationSecret>;
|
|
6485
|
+
/**
|
|
6486
|
+
* Deletes one client secret for an application.
|
|
6487
|
+
*
|
|
6488
|
+
* @param applicationId - ID of the application to update
|
|
6489
|
+
* @param secretId - ID of the secret to delete
|
|
6490
|
+
* @returns The deleted secret metadata
|
|
6491
|
+
*/
|
|
6492
|
+
deleteApplicationSecret(applicationId: string, secretId: string): Promise<AdminApplicationSecret>;
|
|
6493
|
+
/**
|
|
6494
|
+
* Retires an application's service-account identity.
|
|
6495
|
+
*
|
|
6496
|
+
* @param applicationId - ID of the application to update
|
|
6497
|
+
* @returns The updated application
|
|
6498
|
+
*/
|
|
6499
|
+
retireApplicationServiceAccount(applicationId: string): Promise<AdminApplicationRecord>;
|
|
6371
6500
|
/**
|
|
6372
6501
|
* Lists all organizations, optionally with member and application previews
|
|
6373
6502
|
* and totals when a preview size is requested.
|
|
@@ -6604,6 +6733,25 @@ declare class AdminService {
|
|
|
6604
6733
|
} | null>;
|
|
6605
6734
|
}
|
|
6606
6735
|
|
|
6736
|
+
/**
|
|
6737
|
+
* Optional related data that can be included when listing organizations.
|
|
6738
|
+
*/
|
|
6739
|
+
type ListOrganizationsOptions = {
|
|
6740
|
+
/** Additional organization data to include in the response. */
|
|
6741
|
+
include?: readonly 'role'[];
|
|
6742
|
+
};
|
|
6743
|
+
/**
|
|
6744
|
+
* Organization list options that guarantee the current user's membership role.
|
|
6745
|
+
*/
|
|
6746
|
+
type ListOrganizationsWithRoleOptions = {
|
|
6747
|
+
include: readonly ['role', ...'role'[]];
|
|
6748
|
+
};
|
|
6749
|
+
/**
|
|
6750
|
+
* An organization with the current user's membership role.
|
|
6751
|
+
*/
|
|
6752
|
+
type OrganizationWithRole = ExtendedOrganization & {
|
|
6753
|
+
role: string;
|
|
6754
|
+
};
|
|
6607
6755
|
/**
|
|
6608
6756
|
* Result of accepting an organization invitation.
|
|
6609
6757
|
*/
|
|
@@ -6748,9 +6896,11 @@ declare class OrganizationService {
|
|
|
6748
6896
|
/**
|
|
6749
6897
|
* Lists all organizations accessible to the current user.
|
|
6750
6898
|
*
|
|
6899
|
+
* @param options - Optional related organization data to include
|
|
6751
6900
|
* @returns An array of organizations
|
|
6752
6901
|
*/
|
|
6753
|
-
listOrganizations(): Promise<
|
|
6902
|
+
listOrganizations(options: ListOrganizationsWithRoleOptions): Promise<OrganizationWithRole[]>;
|
|
6903
|
+
listOrganizations(options?: ListOrganizationsOptions): Promise<ExtendedOrganization[]>;
|
|
6754
6904
|
/**
|
|
6755
6905
|
* Sets the active organization for the current user session.
|
|
6756
6906
|
*
|
|
@@ -7045,10 +7195,10 @@ declare class SessionService {
|
|
|
7045
7195
|
} & {
|
|
7046
7196
|
preferredLanguage: string;
|
|
7047
7197
|
} & {
|
|
7048
|
-
lastActiveAt?: Date | null | undefined;
|
|
7049
7198
|
displayName?: string | null | undefined;
|
|
7050
7199
|
title?: string | null | undefined;
|
|
7051
7200
|
pronouns?: string | null | undefined;
|
|
7201
|
+
lastActiveAt?: Date | null | undefined;
|
|
7052
7202
|
}>;
|
|
7053
7203
|
session: better_auth.StripEmptyObjects<{
|
|
7054
7204
|
id: string;
|
|
@@ -7286,10 +7436,10 @@ declare class EmailOTPService {
|
|
|
7286
7436
|
} & {
|
|
7287
7437
|
preferredLanguage: string;
|
|
7288
7438
|
} & {
|
|
7289
|
-
lastActiveAt?: Date | null | undefined;
|
|
7290
7439
|
displayName?: string | null | undefined;
|
|
7291
7440
|
title?: string | null | undefined;
|
|
7292
7441
|
pronouns?: string | null | undefined;
|
|
7442
|
+
lastActiveAt?: Date | null | undefined;
|
|
7293
7443
|
}>;
|
|
7294
7444
|
}>;
|
|
7295
7445
|
}
|
|
@@ -7339,10 +7489,10 @@ declare class UserService {
|
|
|
7339
7489
|
} & {
|
|
7340
7490
|
preferredLanguage: string;
|
|
7341
7491
|
} & {
|
|
7342
|
-
lastActiveAt?: Date | null | undefined;
|
|
7343
7492
|
displayName?: string | null | undefined;
|
|
7344
7493
|
title?: string | null | undefined;
|
|
7345
7494
|
pronouns?: string | null | undefined;
|
|
7495
|
+
lastActiveAt?: Date | null | undefined;
|
|
7346
7496
|
}>;
|
|
7347
7497
|
}>;
|
|
7348
7498
|
updateProfile(profile: UpdateUserProfilePayload): Promise<{
|
|
@@ -7478,32 +7628,59 @@ declare class AuthClient {
|
|
|
7478
7628
|
constructor(apiUrl: string, fetchOptions?: BetterFetchOption);
|
|
7479
7629
|
}
|
|
7480
7630
|
|
|
7481
|
-
|
|
7482
|
-
|
|
7631
|
+
/** Configuration for an in-memory application token cache. */
|
|
7632
|
+
type ApplicationTokenStorageOptions = {
|
|
7633
|
+
/** Base URL of the Auth API. */
|
|
7634
|
+
authApiUrl: string;
|
|
7635
|
+
/** Application identifier used for client-credentials exchanges. */
|
|
7636
|
+
clientId: string;
|
|
7637
|
+
/** Application secret used for client-credentials exchanges. */
|
|
7638
|
+
clientSecret: string;
|
|
7639
|
+
/** Full-jitter upper bound for the first retry delay. Defaults to 100 milliseconds. */
|
|
7640
|
+
initialBackoffMs?: number;
|
|
7641
|
+
/** Maximum number of exchange attempts, including the initial request. Defaults to 3. */
|
|
7642
|
+
maxAttempts?: number;
|
|
7643
|
+
/** Maximum number of organization tokens retained in memory. Defaults to 300. */
|
|
7644
|
+
maxOrganizations?: number;
|
|
7645
|
+
};
|
|
7646
|
+
/** Per-call retry overrides for {@link ApplicationTokenStorage.getToken}. */
|
|
7647
|
+
type GetTokenOptions = {
|
|
7648
|
+
/** Full-jitter upper bound for the first retry delay. */
|
|
7649
|
+
initialBackoffMs?: number;
|
|
7650
|
+
/** Maximum number of exchange attempts, including the initial request. */
|
|
7651
|
+
maxAttempts?: number;
|
|
7483
7652
|
};
|
|
7484
7653
|
/**
|
|
7485
|
-
*
|
|
7486
|
-
*
|
|
7487
|
-
* @param token - The JWT token string to check
|
|
7488
|
-
* @param expiresInMs - Optional time window in milliseconds. If provided, returns `true` if the token will expire within this time window
|
|
7489
|
-
* @returns `true` if the token is expired (or will expire within the specified window), `false` otherwise
|
|
7654
|
+
* Caches organization-scoped application tokens in memory.
|
|
7490
7655
|
*
|
|
7491
|
-
*
|
|
7492
|
-
*
|
|
7493
|
-
*
|
|
7494
|
-
*
|
|
7495
|
-
* // Check if token is already expired
|
|
7496
|
-
* if (isTokenExpired(token)) {
|
|
7497
|
-
* console.log('Token has expired')
|
|
7498
|
-
* }
|
|
7499
|
-
*
|
|
7500
|
-
* // Check if token will expire in the next 5 minutes
|
|
7501
|
-
* if (isTokenExpired(token, 5 * 60 * 1000)) {
|
|
7502
|
-
* console.log('Token will expire in the next 5 minutes')
|
|
7503
|
-
* }
|
|
7504
|
-
* ```
|
|
7656
|
+
* Tokens are reissued one minute before expiry. Cache hits promote their
|
|
7657
|
+
* organization to the most-recently-used position, and insertions beyond the
|
|
7658
|
+
* configured limit evict the least recently used organization. Transient
|
|
7659
|
+
* exchange failures use full-jitter exponential backoff.
|
|
7505
7660
|
*/
|
|
7506
|
-
declare
|
|
7661
|
+
declare class ApplicationTokenStorage {
|
|
7662
|
+
private readonly auth;
|
|
7663
|
+
private readonly clientId;
|
|
7664
|
+
private readonly clientSecret;
|
|
7665
|
+
private readonly initialBackoffMs;
|
|
7666
|
+
private readonly inFlight;
|
|
7667
|
+
private readonly maxAttempts;
|
|
7668
|
+
private readonly maxOrganizations;
|
|
7669
|
+
private readonly tokens;
|
|
7670
|
+
/** Creates an application token cache for one client-credentials identity. */
|
|
7671
|
+
constructor({ authApiUrl, clientId, clientSecret, initialBackoffMs, maxAttempts, maxOrganizations, }: ApplicationTokenStorageOptions);
|
|
7672
|
+
/** Returns a fresh access token scoped to the requested organization. */
|
|
7673
|
+
getToken(organizationId: string, { initialBackoffMs, maxAttempts, }?: GetTokenOptions): Promise<string>;
|
|
7674
|
+
private exchangeTokenWithRetry;
|
|
7675
|
+
/** Performs the client-credentials exchange for one organization. */
|
|
7676
|
+
protected exchangeToken(organizationId: string): Promise<string>;
|
|
7677
|
+
/** Waits before the next exchange attempt. */
|
|
7678
|
+
protected wait(delayMs: number): Promise<void>;
|
|
7679
|
+
}
|
|
7680
|
+
|
|
7681
|
+
type DecodedJWTPayload = Omit<JWTPayload, 'assurance'> & {
|
|
7682
|
+
assurance?: JWTPayloadAssurance;
|
|
7683
|
+
};
|
|
7507
7684
|
/**
|
|
7508
7685
|
* Validates a JWT token by checking its expiration and verifying its signature
|
|
7509
7686
|
* against the JWKS endpoint.
|
|
@@ -7542,5 +7719,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7542
7719
|
*/
|
|
7543
7720
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7544
7721
|
|
|
7545
|
-
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
7546
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, Invitation, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
7722
|
+
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, ApplicationTokenStorage, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
7723
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithRoleOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|