@meistrari/auth-core 4.1.0 → 4.3.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 +318 -11
- package/dist/index.d.ts +318 -11
- package/dist/index.mjs +77 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -753,16 +753,26 @@ type ClientCredentialsGrant = {
|
|
|
753
753
|
clientId: string;
|
|
754
754
|
/** A valid secret issued for the application. */
|
|
755
755
|
clientSecret: string;
|
|
756
|
-
/**
|
|
757
|
-
|
|
756
|
+
/**
|
|
757
|
+
* The organization to scope the access token to. Omit it for a token that
|
|
758
|
+
* is not scoped to any organization, for endpoints that act on the
|
|
759
|
+
* application itself rather than on one organization.
|
|
760
|
+
*/
|
|
761
|
+
organizationId?: string;
|
|
758
762
|
};
|
|
759
763
|
/**
|
|
760
764
|
* Response returned after a successful client credentials exchange.
|
|
761
765
|
*
|
|
762
766
|
* Client credentials issue only a short-lived access token, so this response
|
|
763
|
-
* intentionally does not include a refresh token.
|
|
767
|
+
* intentionally does not include a refresh token. `organization` is `null`
|
|
768
|
+
* when the grant did not name an organization.
|
|
764
769
|
*/
|
|
765
|
-
type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'refreshToken'
|
|
770
|
+
type ClientCredentialsTokenResponse<TGrant extends ClientCredentialsGrant = ClientCredentialsGrant> = Omit<CompleteAuthorizationFlowResponse, 'refreshToken' | 'organization'> & {
|
|
771
|
+
/** The organization the token is scoped to, or `null` when none was requested. */
|
|
772
|
+
organization: TGrant extends {
|
|
773
|
+
organizationId: string;
|
|
774
|
+
} ? FullOrganization : FullOrganization | null;
|
|
775
|
+
};
|
|
766
776
|
/**
|
|
767
777
|
* Response returned by the "who am I" endpoint.
|
|
768
778
|
*
|
|
@@ -773,8 +783,11 @@ type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'r
|
|
|
773
783
|
type WhoAmIResponse = {
|
|
774
784
|
/** The authenticated user. */
|
|
775
785
|
user: User;
|
|
776
|
-
/**
|
|
777
|
-
|
|
786
|
+
/**
|
|
787
|
+
* The user's active organization, or `null` for a client-credentials token
|
|
788
|
+
* requested without an organization.
|
|
789
|
+
*/
|
|
790
|
+
organization: WhoAmIOrganization | null;
|
|
778
791
|
/** Assurance context embedded in the verified access token. */
|
|
779
792
|
assurance: JWTPayload['assurance'];
|
|
780
793
|
};
|
|
@@ -1100,11 +1113,14 @@ declare class ApplicationService {
|
|
|
1100
1113
|
*
|
|
1101
1114
|
* The returned token is scoped to the requested organization and cannot be
|
|
1102
1115
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1116
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1117
|
+
* call endpoints that act on the application itself, and the response's
|
|
1118
|
+
* `organization` is `null`.
|
|
1103
1119
|
*
|
|
1104
|
-
* @param credentials - Application credentials and target organization
|
|
1120
|
+
* @param credentials - Application credentials and optional target organization
|
|
1105
1121
|
* @returns A short-lived access token with service-account and organization details
|
|
1106
1122
|
*/
|
|
1107
|
-
exchangeClientCredentialsForToken(credentials:
|
|
1123
|
+
exchangeClientCredentialsForToken<TGrant extends ClientCredentialsGrant>(credentials: TGrant): Promise<ClientCredentialsTokenResponse<TGrant>>;
|
|
1108
1124
|
/**
|
|
1109
1125
|
* Completes an authorization flow for a specific application.
|
|
1110
1126
|
*
|
|
@@ -2782,8 +2798,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2782
2798
|
data: CompleteAuthorizationFlowResponse;
|
|
2783
2799
|
error: null;
|
|
2784
2800
|
}>;
|
|
2785
|
-
exchangeClientCredentialsForToken: (credentials:
|
|
2786
|
-
data: ClientCredentialsTokenResponse
|
|
2801
|
+
exchangeClientCredentialsForToken: <TGrant extends ClientCredentialsGrant>(credentials: TGrant) => Promise<{
|
|
2802
|
+
data: ClientCredentialsTokenResponse<TGrant>;
|
|
2787
2803
|
error: null;
|
|
2788
2804
|
} | {
|
|
2789
2805
|
data: null;
|
|
@@ -4000,6 +4016,250 @@ type ListAdminOrganizationApplicationMembersResult = {
|
|
|
4000
4016
|
limit: number;
|
|
4001
4017
|
offset: number;
|
|
4002
4018
|
};
|
|
4019
|
+
/**
|
|
4020
|
+
* OIDC field mapping stored on an SSO provider.
|
|
4021
|
+
*/
|
|
4022
|
+
type AdminSSOProviderOIDCMapping = {
|
|
4023
|
+
email?: string;
|
|
4024
|
+
emailVerified?: string;
|
|
4025
|
+
name?: string;
|
|
4026
|
+
image?: string;
|
|
4027
|
+
extraFields?: Record<string, unknown>;
|
|
4028
|
+
};
|
|
4029
|
+
/**
|
|
4030
|
+
* SAML field mapping stored on an SSO provider.
|
|
4031
|
+
*/
|
|
4032
|
+
type AdminSSOProviderSAMLMapping = {
|
|
4033
|
+
email?: string;
|
|
4034
|
+
emailVerified?: string;
|
|
4035
|
+
name?: string;
|
|
4036
|
+
firstName?: string;
|
|
4037
|
+
lastName?: string;
|
|
4038
|
+
extraFields?: Record<string, unknown>;
|
|
4039
|
+
};
|
|
4040
|
+
/**
|
|
4041
|
+
* OIDC configuration of an SSO provider as exposed to admins. The client
|
|
4042
|
+
* secret never leaves the API; hasClientSecret only signals that one is
|
|
4043
|
+
* stored so an edit surface can offer rotation without echoing the value.
|
|
4044
|
+
*/
|
|
4045
|
+
type AdminSSOProviderOIDCConfig = {
|
|
4046
|
+
clientId?: string;
|
|
4047
|
+
hasClientSecret: boolean;
|
|
4048
|
+
discoveryEndpoint?: string;
|
|
4049
|
+
authorizationEndpoint?: string;
|
|
4050
|
+
tokenEndpoint?: string;
|
|
4051
|
+
userInfoEndpoint?: string;
|
|
4052
|
+
jwksEndpoint?: string;
|
|
4053
|
+
tokenEndpointAuthentication?: 'client_secret_post' | 'client_secret_basic';
|
|
4054
|
+
scopes?: string[];
|
|
4055
|
+
pkce?: boolean;
|
|
4056
|
+
overrideUserInfo?: boolean;
|
|
4057
|
+
mapping?: AdminSSOProviderOIDCMapping;
|
|
4058
|
+
};
|
|
4059
|
+
/**
|
|
4060
|
+
* SAML sp/idp metadata of an SSO provider as exposed to admins, with private
|
|
4061
|
+
* key material stripped by the API.
|
|
4062
|
+
*/
|
|
4063
|
+
type AdminSSOProviderSAMLMetadata = {
|
|
4064
|
+
metadata?: string;
|
|
4065
|
+
entityID?: string;
|
|
4066
|
+
binding?: string;
|
|
4067
|
+
cert?: string;
|
|
4068
|
+
isAssertionEncrypted?: boolean;
|
|
4069
|
+
singleSignOnService?: {
|
|
4070
|
+
Binding: string;
|
|
4071
|
+
Location: string;
|
|
4072
|
+
}[];
|
|
4073
|
+
};
|
|
4074
|
+
/**
|
|
4075
|
+
* SAML configuration of an SSO provider as exposed to admins, with the SP
|
|
4076
|
+
* private keys stripped by the API.
|
|
4077
|
+
*/
|
|
4078
|
+
type AdminSSOProviderSAMLConfig = {
|
|
4079
|
+
entryPoint?: string;
|
|
4080
|
+
cert?: string;
|
|
4081
|
+
callbackUrl?: string;
|
|
4082
|
+
/** Absolute URL or relative path to redirect to when an IdP-initiated response has no safe RelayState. */
|
|
4083
|
+
idpInitiatedCallbackUrl?: string;
|
|
4084
|
+
audience?: string;
|
|
4085
|
+
idpMetadata?: AdminSSOProviderSAMLMetadata;
|
|
4086
|
+
spMetadata?: AdminSSOProviderSAMLMetadata;
|
|
4087
|
+
wantAssertionsSigned?: boolean;
|
|
4088
|
+
authnRequestsSigned?: boolean;
|
|
4089
|
+
/** Whether a key to sign AuthnRequests is stored. The key itself never leaves the API. */
|
|
4090
|
+
hasSpPrivateKey: boolean;
|
|
4091
|
+
signatureAlgorithm?: string;
|
|
4092
|
+
digestAlgorithm?: string;
|
|
4093
|
+
identifierFormat?: string;
|
|
4094
|
+
mapping?: AdminSSOProviderSAMLMapping;
|
|
4095
|
+
};
|
|
4096
|
+
/**
|
|
4097
|
+
* A single claim→role mapping stored on an SSO provider. Mappings are applied
|
|
4098
|
+
* on every SSO login: when the mapped claim matches, the user's organization
|
|
4099
|
+
* role is synced to the mapped role.
|
|
4100
|
+
*/
|
|
4101
|
+
type AdminSSOProviderRoleMapping = {
|
|
4102
|
+
/** OIDC claim or SAML attribute name read from the identity provider. */
|
|
4103
|
+
claim: string;
|
|
4104
|
+
/** Value the claim must equal (or contain, for multi-valued claims). */
|
|
4105
|
+
value: string;
|
|
4106
|
+
/** Organization role applied when the claim matches. */
|
|
4107
|
+
role: string;
|
|
4108
|
+
};
|
|
4109
|
+
/**
|
|
4110
|
+
* SSO provider row returned by the admin SSO listing endpoint.
|
|
4111
|
+
*/
|
|
4112
|
+
type AdminSSOProvider = {
|
|
4113
|
+
id: string;
|
|
4114
|
+
providerId: string;
|
|
4115
|
+
type: 'oidc' | 'saml';
|
|
4116
|
+
issuer: string;
|
|
4117
|
+
domain: string;
|
|
4118
|
+
organizationId: string | null;
|
|
4119
|
+
organizationName: string | null;
|
|
4120
|
+
userId: string | null;
|
|
4121
|
+
};
|
|
4122
|
+
/**
|
|
4123
|
+
* Full sanitized SSO provider returned by the admin SSO get and update
|
|
4124
|
+
* endpoints, carrying the editable configuration fields.
|
|
4125
|
+
*/
|
|
4126
|
+
type AdminSSOProviderDetail = AdminSSOProvider & {
|
|
4127
|
+
oidcConfig?: AdminSSOProviderOIDCConfig;
|
|
4128
|
+
samlConfig?: AdminSSOProviderSAMLConfig;
|
|
4129
|
+
/** Claim→role mappings applied on every SSO login. */
|
|
4130
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4131
|
+
/** Whether signing in through this provider may create a new user. */
|
|
4132
|
+
allowSignUp: boolean;
|
|
4133
|
+
/** Role of users no role mapping matches. Without one, role mappings refuse those users. */
|
|
4134
|
+
defaultRole?: string;
|
|
4135
|
+
};
|
|
4136
|
+
/**
|
|
4137
|
+
* OIDC configuration accepted when registering an SSO provider as a global
|
|
4138
|
+
* admin. Mirrors the SSO plugin's /sso/register body.
|
|
4139
|
+
*/
|
|
4140
|
+
type RegisterAdminSSOProviderOIDCConfig = {
|
|
4141
|
+
clientId: string;
|
|
4142
|
+
clientSecret: string;
|
|
4143
|
+
authorizationEndpoint?: string;
|
|
4144
|
+
tokenEndpoint?: string;
|
|
4145
|
+
userInfoEndpoint?: string;
|
|
4146
|
+
tokenEndpointAuthentication?: 'client_secret_post' | 'client_secret_basic';
|
|
4147
|
+
jwksEndpoint?: string;
|
|
4148
|
+
discoveryEndpoint?: string;
|
|
4149
|
+
/**
|
|
4150
|
+
* Skip OIDC discovery during registration. When true,
|
|
4151
|
+
* authorizationEndpoint, tokenEndpoint, and jwksEndpoint must be
|
|
4152
|
+
* provided manually.
|
|
4153
|
+
*/
|
|
4154
|
+
skipDiscovery?: boolean;
|
|
4155
|
+
scopes?: string[];
|
|
4156
|
+
pkce?: boolean;
|
|
4157
|
+
/**
|
|
4158
|
+
* Where user claims are read from. With 'id_token', the discovered user
|
|
4159
|
+
* info endpoint is not stored.
|
|
4160
|
+
*/
|
|
4161
|
+
claimsSource?: 'id_token' | 'userinfo';
|
|
4162
|
+
mapping?: AdminSSOProviderOIDCMapping;
|
|
4163
|
+
};
|
|
4164
|
+
/**
|
|
4165
|
+
* SAML sp/idp metadata accepted when registering or updating an SSO provider
|
|
4166
|
+
* as a global admin.
|
|
4167
|
+
*/
|
|
4168
|
+
type RegisterAdminSSOProviderSAMLMetadata = AdminSSOProviderSAMLMetadata & {
|
|
4169
|
+
privateKey?: string;
|
|
4170
|
+
privateKeyPass?: string;
|
|
4171
|
+
encPrivateKey?: string;
|
|
4172
|
+
encPrivateKeyPass?: string;
|
|
4173
|
+
};
|
|
4174
|
+
/**
|
|
4175
|
+
* SAML configuration accepted when registering an SSO provider as a global
|
|
4176
|
+
* admin. Mirrors the SSO plugin's /sso/register body.
|
|
4177
|
+
*/
|
|
4178
|
+
type RegisterAdminSSOProviderSAMLConfig = {
|
|
4179
|
+
entryPoint: string;
|
|
4180
|
+
/** IdP signing certificate. Optional when idpMetadata.metadata carries it. */
|
|
4181
|
+
cert?: string;
|
|
4182
|
+
/** Last-resort redirect after sign-in. The assertion consumer service URL is fixed by the API. */
|
|
4183
|
+
callbackUrl?: string;
|
|
4184
|
+
/** Absolute URL or relative path to redirect to when an IdP-initiated response has no safe RelayState. */
|
|
4185
|
+
idpInitiatedCallbackUrl?: string;
|
|
4186
|
+
audience?: string;
|
|
4187
|
+
/** IdP metadata XML, or the entity ID of a manually configured IdP. */
|
|
4188
|
+
idpMetadata: RegisterAdminSSOProviderSAMLMetadata;
|
|
4189
|
+
spMetadata?: RegisterAdminSSOProviderSAMLMetadata;
|
|
4190
|
+
wantAssertionsSigned?: boolean;
|
|
4191
|
+
authnRequestsSigned?: boolean;
|
|
4192
|
+
signatureAlgorithm?: string;
|
|
4193
|
+
digestAlgorithm?: string;
|
|
4194
|
+
identifierFormat?: string;
|
|
4195
|
+
privateKey?: string;
|
|
4196
|
+
mapping?: AdminSSOProviderSAMLMapping;
|
|
4197
|
+
};
|
|
4198
|
+
/**
|
|
4199
|
+
* Options accepted when registering an SSO provider as a global admin.
|
|
4200
|
+
* Provide exactly one of oidcConfig or samlConfig.
|
|
4201
|
+
*/
|
|
4202
|
+
type RegisterAdminSSOProviderOptions = {
|
|
4203
|
+
/** Identifies the provider during login and callback. */
|
|
4204
|
+
providerId: string;
|
|
4205
|
+
/** The issuer URL of the provider. */
|
|
4206
|
+
issuer: string;
|
|
4207
|
+
/** Provider email domain(s); comma-separated for multi-domain SSO. */
|
|
4208
|
+
domain: string;
|
|
4209
|
+
oidcConfig?: RegisterAdminSSOProviderOIDCConfig;
|
|
4210
|
+
samlConfig?: RegisterAdminSSOProviderSAMLConfig;
|
|
4211
|
+
/** The organization the provider belongs to. */
|
|
4212
|
+
organizationId: string;
|
|
4213
|
+
overrideUserInfo?: boolean;
|
|
4214
|
+
/** Claim→role mappings applied on every SSO login. */
|
|
4215
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4216
|
+
/** Whether signing in through this provider may create a new user. Defaults to false. */
|
|
4217
|
+
allowSignUp?: boolean;
|
|
4218
|
+
/**
|
|
4219
|
+
* Role of users no role mapping matches. Without one, role mappings refuse
|
|
4220
|
+
* those users. Required when there are no role mappings.
|
|
4221
|
+
*/
|
|
4222
|
+
defaultRole?: string;
|
|
4223
|
+
};
|
|
4224
|
+
/**
|
|
4225
|
+
* The registered SSO provider, including the redirect URI to configure at the
|
|
4226
|
+
* identity provider.
|
|
4227
|
+
*/
|
|
4228
|
+
type RegisterAdminSSOProviderResult = AdminSSOProviderDetail & {
|
|
4229
|
+
redirectURI: string;
|
|
4230
|
+
};
|
|
4231
|
+
/**
|
|
4232
|
+
* Options accepted when updating an SSO provider as a global admin.
|
|
4233
|
+
* Configuration updates are partial; omitted fields, including the OIDC
|
|
4234
|
+
* client secret, keep their stored values, and null removes a field. Empty
|
|
4235
|
+
* idpMetadata and spMetadata fields are removed as well. Identity fields cannot
|
|
4236
|
+
* change while accounts are linked to the provider.
|
|
4237
|
+
*/
|
|
4238
|
+
type UpdateAdminSSOProviderOptions = {
|
|
4239
|
+
providerId: string;
|
|
4240
|
+
issuer?: string;
|
|
4241
|
+
domain?: string;
|
|
4242
|
+
oidcConfig?: Partial<Omit<RegisterAdminSSOProviderOIDCConfig, 'claimsSource' | 'discoveryEndpoint' | 'scopes' | 'skipDiscovery' | 'userInfoEndpoint'>> & {
|
|
4243
|
+
discoveryEndpoint?: string | null;
|
|
4244
|
+
overrideUserInfo?: boolean;
|
|
4245
|
+
scopes?: string[] | null;
|
|
4246
|
+
userInfoEndpoint?: string | null;
|
|
4247
|
+
};
|
|
4248
|
+
samlConfig?: Partial<Omit<RegisterAdminSSOProviderSAMLConfig, 'audience' | 'callbackUrl' | 'identifierFormat' | 'idpInitiatedCallbackUrl'>> & {
|
|
4249
|
+
audience?: string | null;
|
|
4250
|
+
callbackUrl?: string | null;
|
|
4251
|
+
identifierFormat?: string | null;
|
|
4252
|
+
idpInitiatedCallbackUrl?: string | null;
|
|
4253
|
+
};
|
|
4254
|
+
/** Claim→role mappings applied on every SSO login. Replaces the stored set. */
|
|
4255
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4256
|
+
/** Whether signing in through this provider may create a new user. */
|
|
4257
|
+
allowSignUp?: boolean;
|
|
4258
|
+
/** Role of users no role mapping matches. Null removes it. */
|
|
4259
|
+
defaultRole?: string | null;
|
|
4260
|
+
/** Organization to link a provider that has none. Linked providers cannot move. */
|
|
4261
|
+
organizationId?: string;
|
|
4262
|
+
};
|
|
4003
4263
|
|
|
4004
4264
|
/**
|
|
4005
4265
|
* Service for global admin operations.
|
|
@@ -4017,6 +4277,20 @@ declare class AdminService {
|
|
|
4017
4277
|
* application routes that the Better Auth client cannot address
|
|
4018
4278
|
*/
|
|
4019
4279
|
constructor(client: APIClient, apiUrl: string);
|
|
4280
|
+
/**
|
|
4281
|
+
* Requests a route served by the Better Auth handler.
|
|
4282
|
+
*
|
|
4283
|
+
* better-auth types $fetch without the client's `throw: true` option, under
|
|
4284
|
+
* which it resolves to the parsed response body rather than { data, error }.
|
|
4285
|
+
*
|
|
4286
|
+
* @param path - Path relative to the client's base URL
|
|
4287
|
+
* @param request - Method, body, and path parameters
|
|
4288
|
+
* @param request.method - HTTP method
|
|
4289
|
+
* @param request.body - Request body
|
|
4290
|
+
* @param request.params - Values for the path's `:name` segments
|
|
4291
|
+
* @returns The parsed JSON response
|
|
4292
|
+
*/
|
|
4293
|
+
private requestAuthRoute;
|
|
4020
4294
|
/**
|
|
4021
4295
|
* Requests an application management route.
|
|
4022
4296
|
*
|
|
@@ -4390,6 +4664,39 @@ declare class AdminService {
|
|
|
4390
4664
|
* @returns Per-email invite outcomes
|
|
4391
4665
|
*/
|
|
4392
4666
|
inviteOrganizationUsers(options: InviteAdminOrganizationUsersOptions): Promise<InviteAdminOrganizationUsersResult>;
|
|
4667
|
+
/**
|
|
4668
|
+
* Lists every registered SSO provider as a global admin, with the linked
|
|
4669
|
+
* organization's name resolved for display.
|
|
4670
|
+
*
|
|
4671
|
+
* @returns The SSO providers
|
|
4672
|
+
*/
|
|
4673
|
+
listSSOProviders(): Promise<AdminSSOProvider[]>;
|
|
4674
|
+
/**
|
|
4675
|
+
* Fetches a single SSO provider by provider ID as a global admin, with its
|
|
4676
|
+
* editable configuration. Secrets are stripped by the API.
|
|
4677
|
+
*
|
|
4678
|
+
* @param providerId - The provider ID the provider was registered under
|
|
4679
|
+
* @returns The SSO provider with its sanitized configuration
|
|
4680
|
+
*/
|
|
4681
|
+
getSSOProvider(providerId: string): Promise<AdminSSOProviderDetail>;
|
|
4682
|
+
/**
|
|
4683
|
+
* Registers an OIDC or SAML SSO provider as a global admin. The API
|
|
4684
|
+
* delegates to the SSO plugin's own registration endpoint, so all of its
|
|
4685
|
+
* guards apply unchanged.
|
|
4686
|
+
*
|
|
4687
|
+
* @param options - Provider identity, domain, and exactly one of oidcConfig or samlConfig
|
|
4688
|
+
* @returns The registered provider, including the redirect URI to configure at the identity provider
|
|
4689
|
+
*/
|
|
4690
|
+
registerSSOProvider(options: RegisterAdminSSOProviderOptions): Promise<RegisterAdminSSOProviderResult>;
|
|
4691
|
+
/**
|
|
4692
|
+
* Partially updates an SSO provider as a global admin. Only provided
|
|
4693
|
+
* fields change; omitted configuration fields, including the OIDC client
|
|
4694
|
+
* secret, keep their stored values.
|
|
4695
|
+
*
|
|
4696
|
+
* @param options - Provider ID and the fields to change
|
|
4697
|
+
* @returns The updated provider with its sanitized configuration
|
|
4698
|
+
*/
|
|
4699
|
+
updateSSOProvider(options: UpdateAdminSSOProviderOptions): Promise<AdminSSOProviderDetail>;
|
|
4393
4700
|
}
|
|
4394
4701
|
|
|
4395
4702
|
/**
|
|
@@ -5398,4 +5705,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5398
5705
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
5399
5706
|
|
|
5400
5707
|
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationDisabledError, 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, LOGIN_METHODS, 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, normalizeAmr, organizationAdditionalFields, parseApplicationDisabledPayload, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
5401
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationMemberOrganization, AdminApplicationMemberRecord, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationApplicationAccess, AdminOrganizationApplicationEntitlement, AdminOrganizationApplicationMember, AdminOrganizationApplicationRole, AdminOrganizationEntitledApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationDeprecation, ApplicationDisabledPayload, ApplicationRole, ApplicationScopedMember, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, DisableAdminApplicationOptions, EmailOTPSignInOptions, FullOrganization, FullOrganizationMember, GetAdminOrganizationApplicationOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationMembersOptions, ListAdminApplicationMembersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationApplicationMembersOptions, ListAdminOrganizationApplicationMembersResult, ListAdminOrganizationApplicationsOptions, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsInclude, ListCandidateOrganizationsOptions, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithMemberCountOptions, ListOrganizationsWithRoleAndMemberCountOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithMemberCount, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminOrganizationApplicationRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserPasswordOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
5708
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationMemberOrganization, AdminApplicationMemberRecord, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationApplicationAccess, AdminOrganizationApplicationEntitlement, AdminOrganizationApplicationMember, AdminOrganizationApplicationRole, AdminOrganizationEntitledApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminSSOProvider, AdminSSOProviderDetail, AdminSSOProviderOIDCConfig, AdminSSOProviderOIDCMapping, AdminSSOProviderRoleMapping, AdminSSOProviderSAMLConfig, AdminSSOProviderSAMLMapping, AdminSSOProviderSAMLMetadata, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationDeprecation, ApplicationDisabledPayload, ApplicationRole, ApplicationScopedMember, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, DisableAdminApplicationOptions, EmailOTPSignInOptions, FullOrganization, FullOrganizationMember, GetAdminOrganizationApplicationOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationMembersOptions, ListAdminApplicationMembersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationApplicationMembersOptions, ListAdminOrganizationApplicationMembersResult, ListAdminOrganizationApplicationsOptions, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsInclude, ListCandidateOrganizationsOptions, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithMemberCountOptions, ListOrganizationsWithRoleAndMemberCountOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithMemberCount, OrganizationWithRole, RegisterAdminSSOProviderOIDCConfig, RegisterAdminSSOProviderOptions, RegisterAdminSSOProviderResult, RegisterAdminSSOProviderSAMLConfig, RegisterAdminSSOProviderSAMLMetadata, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminOrganizationApplicationRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserPasswordOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateAdminSSOProviderOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -753,16 +753,26 @@ type ClientCredentialsGrant = {
|
|
|
753
753
|
clientId: string;
|
|
754
754
|
/** A valid secret issued for the application. */
|
|
755
755
|
clientSecret: string;
|
|
756
|
-
/**
|
|
757
|
-
|
|
756
|
+
/**
|
|
757
|
+
* The organization to scope the access token to. Omit it for a token that
|
|
758
|
+
* is not scoped to any organization, for endpoints that act on the
|
|
759
|
+
* application itself rather than on one organization.
|
|
760
|
+
*/
|
|
761
|
+
organizationId?: string;
|
|
758
762
|
};
|
|
759
763
|
/**
|
|
760
764
|
* Response returned after a successful client credentials exchange.
|
|
761
765
|
*
|
|
762
766
|
* Client credentials issue only a short-lived access token, so this response
|
|
763
|
-
* intentionally does not include a refresh token.
|
|
767
|
+
* intentionally does not include a refresh token. `organization` is `null`
|
|
768
|
+
* when the grant did not name an organization.
|
|
764
769
|
*/
|
|
765
|
-
type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'refreshToken'
|
|
770
|
+
type ClientCredentialsTokenResponse<TGrant extends ClientCredentialsGrant = ClientCredentialsGrant> = Omit<CompleteAuthorizationFlowResponse, 'refreshToken' | 'organization'> & {
|
|
771
|
+
/** The organization the token is scoped to, or `null` when none was requested. */
|
|
772
|
+
organization: TGrant extends {
|
|
773
|
+
organizationId: string;
|
|
774
|
+
} ? FullOrganization : FullOrganization | null;
|
|
775
|
+
};
|
|
766
776
|
/**
|
|
767
777
|
* Response returned by the "who am I" endpoint.
|
|
768
778
|
*
|
|
@@ -773,8 +783,11 @@ type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'r
|
|
|
773
783
|
type WhoAmIResponse = {
|
|
774
784
|
/** The authenticated user. */
|
|
775
785
|
user: User;
|
|
776
|
-
/**
|
|
777
|
-
|
|
786
|
+
/**
|
|
787
|
+
* The user's active organization, or `null` for a client-credentials token
|
|
788
|
+
* requested without an organization.
|
|
789
|
+
*/
|
|
790
|
+
organization: WhoAmIOrganization | null;
|
|
778
791
|
/** Assurance context embedded in the verified access token. */
|
|
779
792
|
assurance: JWTPayload['assurance'];
|
|
780
793
|
};
|
|
@@ -1100,11 +1113,14 @@ declare class ApplicationService {
|
|
|
1100
1113
|
*
|
|
1101
1114
|
* The returned token is scoped to the requested organization and cannot be
|
|
1102
1115
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1116
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1117
|
+
* call endpoints that act on the application itself, and the response's
|
|
1118
|
+
* `organization` is `null`.
|
|
1103
1119
|
*
|
|
1104
|
-
* @param credentials - Application credentials and target organization
|
|
1120
|
+
* @param credentials - Application credentials and optional target organization
|
|
1105
1121
|
* @returns A short-lived access token with service-account and organization details
|
|
1106
1122
|
*/
|
|
1107
|
-
exchangeClientCredentialsForToken(credentials:
|
|
1123
|
+
exchangeClientCredentialsForToken<TGrant extends ClientCredentialsGrant>(credentials: TGrant): Promise<ClientCredentialsTokenResponse<TGrant>>;
|
|
1108
1124
|
/**
|
|
1109
1125
|
* Completes an authorization flow for a specific application.
|
|
1110
1126
|
*
|
|
@@ -2782,8 +2798,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2782
2798
|
data: CompleteAuthorizationFlowResponse;
|
|
2783
2799
|
error: null;
|
|
2784
2800
|
}>;
|
|
2785
|
-
exchangeClientCredentialsForToken: (credentials:
|
|
2786
|
-
data: ClientCredentialsTokenResponse
|
|
2801
|
+
exchangeClientCredentialsForToken: <TGrant extends ClientCredentialsGrant>(credentials: TGrant) => Promise<{
|
|
2802
|
+
data: ClientCredentialsTokenResponse<TGrant>;
|
|
2787
2803
|
error: null;
|
|
2788
2804
|
} | {
|
|
2789
2805
|
data: null;
|
|
@@ -4000,6 +4016,250 @@ type ListAdminOrganizationApplicationMembersResult = {
|
|
|
4000
4016
|
limit: number;
|
|
4001
4017
|
offset: number;
|
|
4002
4018
|
};
|
|
4019
|
+
/**
|
|
4020
|
+
* OIDC field mapping stored on an SSO provider.
|
|
4021
|
+
*/
|
|
4022
|
+
type AdminSSOProviderOIDCMapping = {
|
|
4023
|
+
email?: string;
|
|
4024
|
+
emailVerified?: string;
|
|
4025
|
+
name?: string;
|
|
4026
|
+
image?: string;
|
|
4027
|
+
extraFields?: Record<string, unknown>;
|
|
4028
|
+
};
|
|
4029
|
+
/**
|
|
4030
|
+
* SAML field mapping stored on an SSO provider.
|
|
4031
|
+
*/
|
|
4032
|
+
type AdminSSOProviderSAMLMapping = {
|
|
4033
|
+
email?: string;
|
|
4034
|
+
emailVerified?: string;
|
|
4035
|
+
name?: string;
|
|
4036
|
+
firstName?: string;
|
|
4037
|
+
lastName?: string;
|
|
4038
|
+
extraFields?: Record<string, unknown>;
|
|
4039
|
+
};
|
|
4040
|
+
/**
|
|
4041
|
+
* OIDC configuration of an SSO provider as exposed to admins. The client
|
|
4042
|
+
* secret never leaves the API; hasClientSecret only signals that one is
|
|
4043
|
+
* stored so an edit surface can offer rotation without echoing the value.
|
|
4044
|
+
*/
|
|
4045
|
+
type AdminSSOProviderOIDCConfig = {
|
|
4046
|
+
clientId?: string;
|
|
4047
|
+
hasClientSecret: boolean;
|
|
4048
|
+
discoveryEndpoint?: string;
|
|
4049
|
+
authorizationEndpoint?: string;
|
|
4050
|
+
tokenEndpoint?: string;
|
|
4051
|
+
userInfoEndpoint?: string;
|
|
4052
|
+
jwksEndpoint?: string;
|
|
4053
|
+
tokenEndpointAuthentication?: 'client_secret_post' | 'client_secret_basic';
|
|
4054
|
+
scopes?: string[];
|
|
4055
|
+
pkce?: boolean;
|
|
4056
|
+
overrideUserInfo?: boolean;
|
|
4057
|
+
mapping?: AdminSSOProviderOIDCMapping;
|
|
4058
|
+
};
|
|
4059
|
+
/**
|
|
4060
|
+
* SAML sp/idp metadata of an SSO provider as exposed to admins, with private
|
|
4061
|
+
* key material stripped by the API.
|
|
4062
|
+
*/
|
|
4063
|
+
type AdminSSOProviderSAMLMetadata = {
|
|
4064
|
+
metadata?: string;
|
|
4065
|
+
entityID?: string;
|
|
4066
|
+
binding?: string;
|
|
4067
|
+
cert?: string;
|
|
4068
|
+
isAssertionEncrypted?: boolean;
|
|
4069
|
+
singleSignOnService?: {
|
|
4070
|
+
Binding: string;
|
|
4071
|
+
Location: string;
|
|
4072
|
+
}[];
|
|
4073
|
+
};
|
|
4074
|
+
/**
|
|
4075
|
+
* SAML configuration of an SSO provider as exposed to admins, with the SP
|
|
4076
|
+
* private keys stripped by the API.
|
|
4077
|
+
*/
|
|
4078
|
+
type AdminSSOProviderSAMLConfig = {
|
|
4079
|
+
entryPoint?: string;
|
|
4080
|
+
cert?: string;
|
|
4081
|
+
callbackUrl?: string;
|
|
4082
|
+
/** Absolute URL or relative path to redirect to when an IdP-initiated response has no safe RelayState. */
|
|
4083
|
+
idpInitiatedCallbackUrl?: string;
|
|
4084
|
+
audience?: string;
|
|
4085
|
+
idpMetadata?: AdminSSOProviderSAMLMetadata;
|
|
4086
|
+
spMetadata?: AdminSSOProviderSAMLMetadata;
|
|
4087
|
+
wantAssertionsSigned?: boolean;
|
|
4088
|
+
authnRequestsSigned?: boolean;
|
|
4089
|
+
/** Whether a key to sign AuthnRequests is stored. The key itself never leaves the API. */
|
|
4090
|
+
hasSpPrivateKey: boolean;
|
|
4091
|
+
signatureAlgorithm?: string;
|
|
4092
|
+
digestAlgorithm?: string;
|
|
4093
|
+
identifierFormat?: string;
|
|
4094
|
+
mapping?: AdminSSOProviderSAMLMapping;
|
|
4095
|
+
};
|
|
4096
|
+
/**
|
|
4097
|
+
* A single claim→role mapping stored on an SSO provider. Mappings are applied
|
|
4098
|
+
* on every SSO login: when the mapped claim matches, the user's organization
|
|
4099
|
+
* role is synced to the mapped role.
|
|
4100
|
+
*/
|
|
4101
|
+
type AdminSSOProviderRoleMapping = {
|
|
4102
|
+
/** OIDC claim or SAML attribute name read from the identity provider. */
|
|
4103
|
+
claim: string;
|
|
4104
|
+
/** Value the claim must equal (or contain, for multi-valued claims). */
|
|
4105
|
+
value: string;
|
|
4106
|
+
/** Organization role applied when the claim matches. */
|
|
4107
|
+
role: string;
|
|
4108
|
+
};
|
|
4109
|
+
/**
|
|
4110
|
+
* SSO provider row returned by the admin SSO listing endpoint.
|
|
4111
|
+
*/
|
|
4112
|
+
type AdminSSOProvider = {
|
|
4113
|
+
id: string;
|
|
4114
|
+
providerId: string;
|
|
4115
|
+
type: 'oidc' | 'saml';
|
|
4116
|
+
issuer: string;
|
|
4117
|
+
domain: string;
|
|
4118
|
+
organizationId: string | null;
|
|
4119
|
+
organizationName: string | null;
|
|
4120
|
+
userId: string | null;
|
|
4121
|
+
};
|
|
4122
|
+
/**
|
|
4123
|
+
* Full sanitized SSO provider returned by the admin SSO get and update
|
|
4124
|
+
* endpoints, carrying the editable configuration fields.
|
|
4125
|
+
*/
|
|
4126
|
+
type AdminSSOProviderDetail = AdminSSOProvider & {
|
|
4127
|
+
oidcConfig?: AdminSSOProviderOIDCConfig;
|
|
4128
|
+
samlConfig?: AdminSSOProviderSAMLConfig;
|
|
4129
|
+
/** Claim→role mappings applied on every SSO login. */
|
|
4130
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4131
|
+
/** Whether signing in through this provider may create a new user. */
|
|
4132
|
+
allowSignUp: boolean;
|
|
4133
|
+
/** Role of users no role mapping matches. Without one, role mappings refuse those users. */
|
|
4134
|
+
defaultRole?: string;
|
|
4135
|
+
};
|
|
4136
|
+
/**
|
|
4137
|
+
* OIDC configuration accepted when registering an SSO provider as a global
|
|
4138
|
+
* admin. Mirrors the SSO plugin's /sso/register body.
|
|
4139
|
+
*/
|
|
4140
|
+
type RegisterAdminSSOProviderOIDCConfig = {
|
|
4141
|
+
clientId: string;
|
|
4142
|
+
clientSecret: string;
|
|
4143
|
+
authorizationEndpoint?: string;
|
|
4144
|
+
tokenEndpoint?: string;
|
|
4145
|
+
userInfoEndpoint?: string;
|
|
4146
|
+
tokenEndpointAuthentication?: 'client_secret_post' | 'client_secret_basic';
|
|
4147
|
+
jwksEndpoint?: string;
|
|
4148
|
+
discoveryEndpoint?: string;
|
|
4149
|
+
/**
|
|
4150
|
+
* Skip OIDC discovery during registration. When true,
|
|
4151
|
+
* authorizationEndpoint, tokenEndpoint, and jwksEndpoint must be
|
|
4152
|
+
* provided manually.
|
|
4153
|
+
*/
|
|
4154
|
+
skipDiscovery?: boolean;
|
|
4155
|
+
scopes?: string[];
|
|
4156
|
+
pkce?: boolean;
|
|
4157
|
+
/**
|
|
4158
|
+
* Where user claims are read from. With 'id_token', the discovered user
|
|
4159
|
+
* info endpoint is not stored.
|
|
4160
|
+
*/
|
|
4161
|
+
claimsSource?: 'id_token' | 'userinfo';
|
|
4162
|
+
mapping?: AdminSSOProviderOIDCMapping;
|
|
4163
|
+
};
|
|
4164
|
+
/**
|
|
4165
|
+
* SAML sp/idp metadata accepted when registering or updating an SSO provider
|
|
4166
|
+
* as a global admin.
|
|
4167
|
+
*/
|
|
4168
|
+
type RegisterAdminSSOProviderSAMLMetadata = AdminSSOProviderSAMLMetadata & {
|
|
4169
|
+
privateKey?: string;
|
|
4170
|
+
privateKeyPass?: string;
|
|
4171
|
+
encPrivateKey?: string;
|
|
4172
|
+
encPrivateKeyPass?: string;
|
|
4173
|
+
};
|
|
4174
|
+
/**
|
|
4175
|
+
* SAML configuration accepted when registering an SSO provider as a global
|
|
4176
|
+
* admin. Mirrors the SSO plugin's /sso/register body.
|
|
4177
|
+
*/
|
|
4178
|
+
type RegisterAdminSSOProviderSAMLConfig = {
|
|
4179
|
+
entryPoint: string;
|
|
4180
|
+
/** IdP signing certificate. Optional when idpMetadata.metadata carries it. */
|
|
4181
|
+
cert?: string;
|
|
4182
|
+
/** Last-resort redirect after sign-in. The assertion consumer service URL is fixed by the API. */
|
|
4183
|
+
callbackUrl?: string;
|
|
4184
|
+
/** Absolute URL or relative path to redirect to when an IdP-initiated response has no safe RelayState. */
|
|
4185
|
+
idpInitiatedCallbackUrl?: string;
|
|
4186
|
+
audience?: string;
|
|
4187
|
+
/** IdP metadata XML, or the entity ID of a manually configured IdP. */
|
|
4188
|
+
idpMetadata: RegisterAdminSSOProviderSAMLMetadata;
|
|
4189
|
+
spMetadata?: RegisterAdminSSOProviderSAMLMetadata;
|
|
4190
|
+
wantAssertionsSigned?: boolean;
|
|
4191
|
+
authnRequestsSigned?: boolean;
|
|
4192
|
+
signatureAlgorithm?: string;
|
|
4193
|
+
digestAlgorithm?: string;
|
|
4194
|
+
identifierFormat?: string;
|
|
4195
|
+
privateKey?: string;
|
|
4196
|
+
mapping?: AdminSSOProviderSAMLMapping;
|
|
4197
|
+
};
|
|
4198
|
+
/**
|
|
4199
|
+
* Options accepted when registering an SSO provider as a global admin.
|
|
4200
|
+
* Provide exactly one of oidcConfig or samlConfig.
|
|
4201
|
+
*/
|
|
4202
|
+
type RegisterAdminSSOProviderOptions = {
|
|
4203
|
+
/** Identifies the provider during login and callback. */
|
|
4204
|
+
providerId: string;
|
|
4205
|
+
/** The issuer URL of the provider. */
|
|
4206
|
+
issuer: string;
|
|
4207
|
+
/** Provider email domain(s); comma-separated for multi-domain SSO. */
|
|
4208
|
+
domain: string;
|
|
4209
|
+
oidcConfig?: RegisterAdminSSOProviderOIDCConfig;
|
|
4210
|
+
samlConfig?: RegisterAdminSSOProviderSAMLConfig;
|
|
4211
|
+
/** The organization the provider belongs to. */
|
|
4212
|
+
organizationId: string;
|
|
4213
|
+
overrideUserInfo?: boolean;
|
|
4214
|
+
/** Claim→role mappings applied on every SSO login. */
|
|
4215
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4216
|
+
/** Whether signing in through this provider may create a new user. Defaults to false. */
|
|
4217
|
+
allowSignUp?: boolean;
|
|
4218
|
+
/**
|
|
4219
|
+
* Role of users no role mapping matches. Without one, role mappings refuse
|
|
4220
|
+
* those users. Required when there are no role mappings.
|
|
4221
|
+
*/
|
|
4222
|
+
defaultRole?: string;
|
|
4223
|
+
};
|
|
4224
|
+
/**
|
|
4225
|
+
* The registered SSO provider, including the redirect URI to configure at the
|
|
4226
|
+
* identity provider.
|
|
4227
|
+
*/
|
|
4228
|
+
type RegisterAdminSSOProviderResult = AdminSSOProviderDetail & {
|
|
4229
|
+
redirectURI: string;
|
|
4230
|
+
};
|
|
4231
|
+
/**
|
|
4232
|
+
* Options accepted when updating an SSO provider as a global admin.
|
|
4233
|
+
* Configuration updates are partial; omitted fields, including the OIDC
|
|
4234
|
+
* client secret, keep their stored values, and null removes a field. Empty
|
|
4235
|
+
* idpMetadata and spMetadata fields are removed as well. Identity fields cannot
|
|
4236
|
+
* change while accounts are linked to the provider.
|
|
4237
|
+
*/
|
|
4238
|
+
type UpdateAdminSSOProviderOptions = {
|
|
4239
|
+
providerId: string;
|
|
4240
|
+
issuer?: string;
|
|
4241
|
+
domain?: string;
|
|
4242
|
+
oidcConfig?: Partial<Omit<RegisterAdminSSOProviderOIDCConfig, 'claimsSource' | 'discoveryEndpoint' | 'scopes' | 'skipDiscovery' | 'userInfoEndpoint'>> & {
|
|
4243
|
+
discoveryEndpoint?: string | null;
|
|
4244
|
+
overrideUserInfo?: boolean;
|
|
4245
|
+
scopes?: string[] | null;
|
|
4246
|
+
userInfoEndpoint?: string | null;
|
|
4247
|
+
};
|
|
4248
|
+
samlConfig?: Partial<Omit<RegisterAdminSSOProviderSAMLConfig, 'audience' | 'callbackUrl' | 'identifierFormat' | 'idpInitiatedCallbackUrl'>> & {
|
|
4249
|
+
audience?: string | null;
|
|
4250
|
+
callbackUrl?: string | null;
|
|
4251
|
+
identifierFormat?: string | null;
|
|
4252
|
+
idpInitiatedCallbackUrl?: string | null;
|
|
4253
|
+
};
|
|
4254
|
+
/** Claim→role mappings applied on every SSO login. Replaces the stored set. */
|
|
4255
|
+
roleMappings?: AdminSSOProviderRoleMapping[];
|
|
4256
|
+
/** Whether signing in through this provider may create a new user. */
|
|
4257
|
+
allowSignUp?: boolean;
|
|
4258
|
+
/** Role of users no role mapping matches. Null removes it. */
|
|
4259
|
+
defaultRole?: string | null;
|
|
4260
|
+
/** Organization to link a provider that has none. Linked providers cannot move. */
|
|
4261
|
+
organizationId?: string;
|
|
4262
|
+
};
|
|
4003
4263
|
|
|
4004
4264
|
/**
|
|
4005
4265
|
* Service for global admin operations.
|
|
@@ -4017,6 +4277,20 @@ declare class AdminService {
|
|
|
4017
4277
|
* application routes that the Better Auth client cannot address
|
|
4018
4278
|
*/
|
|
4019
4279
|
constructor(client: APIClient, apiUrl: string);
|
|
4280
|
+
/**
|
|
4281
|
+
* Requests a route served by the Better Auth handler.
|
|
4282
|
+
*
|
|
4283
|
+
* better-auth types $fetch without the client's `throw: true` option, under
|
|
4284
|
+
* which it resolves to the parsed response body rather than { data, error }.
|
|
4285
|
+
*
|
|
4286
|
+
* @param path - Path relative to the client's base URL
|
|
4287
|
+
* @param request - Method, body, and path parameters
|
|
4288
|
+
* @param request.method - HTTP method
|
|
4289
|
+
* @param request.body - Request body
|
|
4290
|
+
* @param request.params - Values for the path's `:name` segments
|
|
4291
|
+
* @returns The parsed JSON response
|
|
4292
|
+
*/
|
|
4293
|
+
private requestAuthRoute;
|
|
4020
4294
|
/**
|
|
4021
4295
|
* Requests an application management route.
|
|
4022
4296
|
*
|
|
@@ -4390,6 +4664,39 @@ declare class AdminService {
|
|
|
4390
4664
|
* @returns Per-email invite outcomes
|
|
4391
4665
|
*/
|
|
4392
4666
|
inviteOrganizationUsers(options: InviteAdminOrganizationUsersOptions): Promise<InviteAdminOrganizationUsersResult>;
|
|
4667
|
+
/**
|
|
4668
|
+
* Lists every registered SSO provider as a global admin, with the linked
|
|
4669
|
+
* organization's name resolved for display.
|
|
4670
|
+
*
|
|
4671
|
+
* @returns The SSO providers
|
|
4672
|
+
*/
|
|
4673
|
+
listSSOProviders(): Promise<AdminSSOProvider[]>;
|
|
4674
|
+
/**
|
|
4675
|
+
* Fetches a single SSO provider by provider ID as a global admin, with its
|
|
4676
|
+
* editable configuration. Secrets are stripped by the API.
|
|
4677
|
+
*
|
|
4678
|
+
* @param providerId - The provider ID the provider was registered under
|
|
4679
|
+
* @returns The SSO provider with its sanitized configuration
|
|
4680
|
+
*/
|
|
4681
|
+
getSSOProvider(providerId: string): Promise<AdminSSOProviderDetail>;
|
|
4682
|
+
/**
|
|
4683
|
+
* Registers an OIDC or SAML SSO provider as a global admin. The API
|
|
4684
|
+
* delegates to the SSO plugin's own registration endpoint, so all of its
|
|
4685
|
+
* guards apply unchanged.
|
|
4686
|
+
*
|
|
4687
|
+
* @param options - Provider identity, domain, and exactly one of oidcConfig or samlConfig
|
|
4688
|
+
* @returns The registered provider, including the redirect URI to configure at the identity provider
|
|
4689
|
+
*/
|
|
4690
|
+
registerSSOProvider(options: RegisterAdminSSOProviderOptions): Promise<RegisterAdminSSOProviderResult>;
|
|
4691
|
+
/**
|
|
4692
|
+
* Partially updates an SSO provider as a global admin. Only provided
|
|
4693
|
+
* fields change; omitted configuration fields, including the OIDC client
|
|
4694
|
+
* secret, keep their stored values.
|
|
4695
|
+
*
|
|
4696
|
+
* @param options - Provider ID and the fields to change
|
|
4697
|
+
* @returns The updated provider with its sanitized configuration
|
|
4698
|
+
*/
|
|
4699
|
+
updateSSOProvider(options: UpdateAdminSSOProviderOptions): Promise<AdminSSOProviderDetail>;
|
|
4393
4700
|
}
|
|
4394
4701
|
|
|
4395
4702
|
/**
|
|
@@ -5398,4 +5705,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5398
5705
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
5399
5706
|
|
|
5400
5707
|
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationDisabledError, 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, LOGIN_METHODS, 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, normalizeAmr, organizationAdditionalFields, parseApplicationDisabledPayload, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
5401
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationMemberOrganization, AdminApplicationMemberRecord, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationApplicationAccess, AdminOrganizationApplicationEntitlement, AdminOrganizationApplicationMember, AdminOrganizationApplicationRole, AdminOrganizationEntitledApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationDeprecation, ApplicationDisabledPayload, ApplicationRole, ApplicationScopedMember, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, DisableAdminApplicationOptions, EmailOTPSignInOptions, FullOrganization, FullOrganizationMember, GetAdminOrganizationApplicationOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationMembersOptions, ListAdminApplicationMembersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationApplicationMembersOptions, ListAdminOrganizationApplicationMembersResult, ListAdminOrganizationApplicationsOptions, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsInclude, ListCandidateOrganizationsOptions, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithMemberCountOptions, ListOrganizationsWithRoleAndMemberCountOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithMemberCount, OrganizationWithRole, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminOrganizationApplicationRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserPasswordOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
5708
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationIdentity, AdminApplicationMember, AdminApplicationMemberOrganization, AdminApplicationMemberRecord, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminApplicationSecret, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationApplicationAccess, AdminOrganizationApplicationEntitlement, AdminOrganizationApplicationMember, AdminOrganizationApplicationRole, AdminOrganizationEntitledApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminSSOProvider, AdminSSOProviderDetail, AdminSSOProviderOIDCConfig, AdminSSOProviderOIDCMapping, AdminSSOProviderRoleMapping, AdminSSOProviderSAMLConfig, AdminSSOProviderSAMLMapping, AdminSSOProviderSAMLMetadata, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationDeprecation, ApplicationDisabledPayload, ApplicationRole, ApplicationScopedMember, ApplicationTokenStorageOptions, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, ClientCredentialsGrant, ClientCredentialsTokenResponse, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminApplicationSecretOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, CreatedAdminApplicationSecret, DecodedJWTPayload, DeleteAdminOrganizationTeamOptions, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, DisableAdminApplicationOptions, EmailOTPSignInOptions, FullOrganization, FullOrganizationMember, GetAdminOrganizationApplicationOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, GetTokenOptions, Invitation, InvitationPasswordSetupResult, InvitationSignupStatus, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationMembersOptions, ListAdminApplicationMembersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationApplicationMembersOptions, ListAdminOrganizationApplicationMembersResult, ListAdminOrganizationApplicationsOptions, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsInclude, ListCandidateOrganizationsOptions, ListCandidateOrganizationsResponse, ListMembersOptions, ListOrganizationsOptions, ListOrganizationsWithMemberCountOptions, ListOrganizationsWithRoleAndMemberCountOptions, ListOrganizationsWithRoleOptions, LoginMethod, LoginMethodsResponse, Member, ExtendedOrganization as Organization, OrganizationSettings, OrganizationWithMemberCount, OrganizationWithRole, RegisterAdminSSOProviderOIDCConfig, RegisterAdminSSOProviderOptions, RegisterAdminSSOProviderResult, RegisterAdminSSOProviderSAMLConfig, RegisterAdminSSOProviderSAMLMetadata, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminOrganizationApplicationRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserPasswordOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSsoOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, TeamMembersResponse, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateAdminOrganizationTeamOptions, UpdateAdminSSOProviderOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function isTokenExpired(token, expiresInMs) {
|
|
|
21
21
|
return nowInSeconds > expirationTime;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const version = "4.
|
|
24
|
+
const version = "4.3.0";
|
|
25
25
|
|
|
26
26
|
function parsedEnumValues(schema) {
|
|
27
27
|
return Object.fromEntries(
|
|
@@ -532,6 +532,22 @@ class AdminService {
|
|
|
532
532
|
}
|
|
533
533
|
client;
|
|
534
534
|
apiUrl;
|
|
535
|
+
/**
|
|
536
|
+
* Requests a route served by the Better Auth handler.
|
|
537
|
+
*
|
|
538
|
+
* better-auth types $fetch without the client's `throw: true` option, under
|
|
539
|
+
* which it resolves to the parsed response body rather than { data, error }.
|
|
540
|
+
*
|
|
541
|
+
* @param path - Path relative to the client's base URL
|
|
542
|
+
* @param request - Method, body, and path parameters
|
|
543
|
+
* @param request.method - HTTP method
|
|
544
|
+
* @param request.body - Request body
|
|
545
|
+
* @param request.params - Values for the path's `:name` segments
|
|
546
|
+
* @returns The parsed JSON response
|
|
547
|
+
*/
|
|
548
|
+
async requestAuthRoute(path, request) {
|
|
549
|
+
return await this.client.$fetch(path, request);
|
|
550
|
+
}
|
|
535
551
|
/**
|
|
536
552
|
* Requests an application management route.
|
|
537
553
|
*
|
|
@@ -1250,6 +1266,62 @@ class AdminService {
|
|
|
1250
1266
|
});
|
|
1251
1267
|
return data;
|
|
1252
1268
|
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Lists every registered SSO provider as a global admin, with the linked
|
|
1271
|
+
* organization's name resolved for display.
|
|
1272
|
+
*
|
|
1273
|
+
* @returns The SSO providers
|
|
1274
|
+
*/
|
|
1275
|
+
async listSSOProviders() {
|
|
1276
|
+
const { providers } = await this.requestAuthRoute("/admin/sso/providers", {
|
|
1277
|
+
method: "GET"
|
|
1278
|
+
});
|
|
1279
|
+
return providers;
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Fetches a single SSO provider by provider ID as a global admin, with its
|
|
1283
|
+
* editable configuration. Secrets are stripped by the API.
|
|
1284
|
+
*
|
|
1285
|
+
* @param providerId - The provider ID the provider was registered under
|
|
1286
|
+
* @returns The SSO provider with its sanitized configuration
|
|
1287
|
+
*/
|
|
1288
|
+
async getSSOProvider(providerId) {
|
|
1289
|
+
const { data } = await this.requestAuthRoute("/admin/sso/providers/:providerId", {
|
|
1290
|
+
method: "GET",
|
|
1291
|
+
params: { providerId }
|
|
1292
|
+
});
|
|
1293
|
+
return data;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Registers an OIDC or SAML SSO provider as a global admin. The API
|
|
1297
|
+
* delegates to the SSO plugin's own registration endpoint, so all of its
|
|
1298
|
+
* guards apply unchanged.
|
|
1299
|
+
*
|
|
1300
|
+
* @param options - Provider identity, domain, and exactly one of oidcConfig or samlConfig
|
|
1301
|
+
* @returns The registered provider, including the redirect URI to configure at the identity provider
|
|
1302
|
+
*/
|
|
1303
|
+
async registerSSOProvider(options) {
|
|
1304
|
+
const { data } = await this.requestAuthRoute("/admin/sso/register", {
|
|
1305
|
+
method: "POST",
|
|
1306
|
+
body: options
|
|
1307
|
+
});
|
|
1308
|
+
return data;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Partially updates an SSO provider as a global admin. Only provided
|
|
1312
|
+
* fields change; omitted configuration fields, including the OIDC client
|
|
1313
|
+
* secret, keep their stored values.
|
|
1314
|
+
*
|
|
1315
|
+
* @param options - Provider ID and the fields to change
|
|
1316
|
+
* @returns The updated provider with its sanitized configuration
|
|
1317
|
+
*/
|
|
1318
|
+
async updateSSOProvider(options) {
|
|
1319
|
+
const { data } = await this.requestAuthRoute("/admin/sso/update-provider", {
|
|
1320
|
+
method: "POST",
|
|
1321
|
+
body: options
|
|
1322
|
+
});
|
|
1323
|
+
return data;
|
|
1324
|
+
}
|
|
1253
1325
|
}
|
|
1254
1326
|
|
|
1255
1327
|
class BaseError extends Error {
|
|
@@ -1788,8 +1860,11 @@ class ApplicationService {
|
|
|
1788
1860
|
*
|
|
1789
1861
|
* The returned token is scoped to the requested organization and cannot be
|
|
1790
1862
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1863
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1864
|
+
* call endpoints that act on the application itself, and the response's
|
|
1865
|
+
* `organization` is `null`.
|
|
1791
1866
|
*
|
|
1792
|
-
* @param credentials - Application credentials and target organization
|
|
1867
|
+
* @param credentials - Application credentials and optional target organization
|
|
1793
1868
|
* @returns A short-lived access token with service-account and organization details
|
|
1794
1869
|
*/
|
|
1795
1870
|
async exchangeClientCredentialsForToken(credentials) {
|