@meistrari/auth-core 1.33.1 → 1.34.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 +115 -12
- package/dist/index.d.ts +115 -12
- package/dist/index.mjs +154 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -14,11 +14,11 @@ declare const AALBrand: unique symbol;
|
|
|
14
14
|
declare const ACRBrand: unique symbol;
|
|
15
15
|
declare const AuthMethodBrand: unique symbol;
|
|
16
16
|
declare const AMRs: {
|
|
17
|
-
readonly Pwd: ("
|
|
18
|
-
readonly Otp: ("
|
|
19
|
-
readonly Oauth: ("
|
|
20
|
-
readonly Sso: ("
|
|
21
|
-
readonly Saml: ("
|
|
17
|
+
readonly Pwd: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
18
|
+
readonly Otp: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
19
|
+
readonly Oauth: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
20
|
+
readonly Sso: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
21
|
+
readonly Saml: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
22
22
|
};
|
|
23
23
|
declare const AALs: {
|
|
24
24
|
readonly Aal1: ("aal1" & z.core.$brand<typeof AALBrand>) | ("aal2" & z.core.$brand<typeof AALBrand>) | ("aal3" & z.core.$brand<typeof AALBrand>);
|
|
@@ -29,11 +29,11 @@ declare const ACRs: {
|
|
|
29
29
|
readonly Unspecified: "urn:tela:auth:unspecified" & z.core.$brand<typeof ACRBrand>;
|
|
30
30
|
};
|
|
31
31
|
declare const AuthMethods: {
|
|
32
|
-
readonly Password: ("
|
|
33
|
-
readonly EmailOTP: ("
|
|
34
|
-
readonly OAuth: ("
|
|
35
|
-
readonly SAML: ("
|
|
36
|
-
readonly Unknown: ("
|
|
32
|
+
readonly Password: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
33
|
+
readonly EmailOTP: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
34
|
+
readonly OAuth: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
35
|
+
readonly SAML: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
+
readonly Unknown: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
37
37
|
};
|
|
38
38
|
declare const AMR: z.core.$ZodBranded<z.ZodEnum<{
|
|
39
39
|
readonly Pwd: "pwd";
|
|
@@ -6135,6 +6135,31 @@ type AdminApplicationEntitlement = {
|
|
|
6135
6135
|
* Entitlement record returned by entitlement mutation endpoints.
|
|
6136
6136
|
*/
|
|
6137
6137
|
type AdminApplicationEntitlementRecord = Omit<AdminApplicationEntitlement, 'organization'>;
|
|
6138
|
+
/** Kind of matcher an entitlement rule applies. */
|
|
6139
|
+
type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
|
|
6140
|
+
/**
|
|
6141
|
+
* A single access rule on an entitlement. Rules are evaluated in `position`
|
|
6142
|
+
* order, first match wins. A non-null `role` grants access with that role; a
|
|
6143
|
+
* null `role` denies access.
|
|
6144
|
+
*/
|
|
6145
|
+
type AdminEntitlementRule = {
|
|
6146
|
+
type: AdminEntitlementRuleType;
|
|
6147
|
+
value: string;
|
|
6148
|
+
role?: string | null;
|
|
6149
|
+
position: number;
|
|
6150
|
+
};
|
|
6151
|
+
/** An entitlement together with its ordered access rules. */
|
|
6152
|
+
type AdminEntitlementWithRules = AdminApplicationEntitlementRecord & {
|
|
6153
|
+
rules: AdminEntitlementRule[];
|
|
6154
|
+
};
|
|
6155
|
+
/** Options accepted when enabling or disabling an entitlement. */
|
|
6156
|
+
type UpdateAdminEntitlementOptions = {
|
|
6157
|
+
enabled: boolean;
|
|
6158
|
+
};
|
|
6159
|
+
/** Options accepted when replacing all rules on an entitlement. */
|
|
6160
|
+
type SetAdminEntitlementRulesOptions = {
|
|
6161
|
+
rules: AdminEntitlementRule[];
|
|
6162
|
+
};
|
|
6138
6163
|
/**
|
|
6139
6164
|
* Member preview returned alongside each admin application row.
|
|
6140
6165
|
*/
|
|
@@ -6268,12 +6293,60 @@ type InviteAdminOrganizationUsersResult = {
|
|
|
6268
6293
|
*/
|
|
6269
6294
|
declare class AdminService {
|
|
6270
6295
|
private client;
|
|
6296
|
+
private apiUrl;
|
|
6271
6297
|
/**
|
|
6272
6298
|
* Creates a new AdminService instance.
|
|
6273
6299
|
*
|
|
6274
6300
|
* @param client - The API client for making admin requests
|
|
6301
|
+
* @param apiUrl - The base URL of the authentication API, used to reach the
|
|
6302
|
+
* application routes that the Better Auth client cannot address
|
|
6275
6303
|
*/
|
|
6276
|
-
constructor(client: APIClient);
|
|
6304
|
+
constructor(client: APIClient, apiUrl: string);
|
|
6305
|
+
/**
|
|
6306
|
+
* Requests an application management route.
|
|
6307
|
+
*
|
|
6308
|
+
* These routes are served by the API itself rather than by the Better Auth
|
|
6309
|
+
* handler, so they sit outside the `/api/auth` base path that the Better
|
|
6310
|
+
* Auth client prepends and cannot go through {@link APIClient.$fetch}. They
|
|
6311
|
+
* authenticate with the session cookie alone; a bearer token must never be
|
|
6312
|
+
* attached, since the API reads one only as an internal API key and would
|
|
6313
|
+
* reject the request.
|
|
6314
|
+
*
|
|
6315
|
+
* @param path - Path relative to the API root, without a leading slash
|
|
6316
|
+
* @param request - Method, body, and query parameters
|
|
6317
|
+
* @returns The parsed JSON response
|
|
6318
|
+
*/
|
|
6319
|
+
private requestApplicationRoute;
|
|
6320
|
+
/**
|
|
6321
|
+
* Lists applications, optionally filtered by organization.
|
|
6322
|
+
*
|
|
6323
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
6324
|
+
* @returns The application listing with entitlement details
|
|
6325
|
+
*/
|
|
6326
|
+
listApplications(options?: ListAdminApplicationsOptions): Promise<ListAdminApplicationsResult>;
|
|
6327
|
+
/**
|
|
6328
|
+
* Creates an application.
|
|
6329
|
+
*
|
|
6330
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6331
|
+
* @returns The created application
|
|
6332
|
+
*/
|
|
6333
|
+
createApplication(options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6334
|
+
/**
|
|
6335
|
+
* Updates an application.
|
|
6336
|
+
*
|
|
6337
|
+
* @param applicationId - ID of the application to update
|
|
6338
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6339
|
+
* @returns The updated application
|
|
6340
|
+
*/
|
|
6341
|
+
updateApplication(applicationId: string, options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6342
|
+
/**
|
|
6343
|
+
* Enables an organization for an application.
|
|
6344
|
+
*
|
|
6345
|
+
* @param applicationId - ID of the application to update
|
|
6346
|
+
* @param options - Organization entitlement payload
|
|
6347
|
+
* @returns The created entitlement
|
|
6348
|
+
*/
|
|
6349
|
+
createApplicationEntitlement(applicationId: string, options: CreateAdminApplicationEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6277
6350
|
/**
|
|
6278
6351
|
* Lists all organizations, optionally with member and application previews
|
|
6279
6352
|
* and totals when a preview size is requested.
|
|
@@ -6393,6 +6466,36 @@ declare class AdminService {
|
|
|
6393
6466
|
createOrganizationTeam(options: CreateAdminOrganizationTeamOptions): Promise<{
|
|
6394
6467
|
data: AdminOrganizationTeamRecord;
|
|
6395
6468
|
} | null>;
|
|
6469
|
+
/**
|
|
6470
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
6471
|
+
*
|
|
6472
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
6473
|
+
* @returns The entitlement and its rules
|
|
6474
|
+
*/
|
|
6475
|
+
getEntitlement(entitlementId: string): Promise<AdminEntitlementWithRules>;
|
|
6476
|
+
/**
|
|
6477
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
6478
|
+
*
|
|
6479
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
6480
|
+
* @param options - The full set of rules to persist
|
|
6481
|
+
* @returns The entitlement with the saved rules
|
|
6482
|
+
*/
|
|
6483
|
+
setEntitlementRules(entitlementId: string, options: SetAdminEntitlementRulesOptions): Promise<AdminEntitlementWithRules>;
|
|
6484
|
+
/**
|
|
6485
|
+
* Enables or disables an entitlement.
|
|
6486
|
+
*
|
|
6487
|
+
* @param entitlementId - ID of the entitlement to update
|
|
6488
|
+
* @param options - The desired enabled state
|
|
6489
|
+
* @returns The updated entitlement
|
|
6490
|
+
*/
|
|
6491
|
+
updateEntitlement(entitlementId: string, options: UpdateAdminEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6492
|
+
/**
|
|
6493
|
+
* Deletes an entitlement and all of its access rules.
|
|
6494
|
+
*
|
|
6495
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
6496
|
+
* @returns The deleted entitlement
|
|
6497
|
+
*/
|
|
6498
|
+
deleteEntitlement(entitlementId: string): Promise<AdminApplicationEntitlementRecord>;
|
|
6396
6499
|
/**
|
|
6397
6500
|
* Creates an organization without adding the creator as a member.
|
|
6398
6501
|
*
|
|
@@ -7419,4 +7522,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7419
7522
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7420
7523
|
|
|
7421
7524
|
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 };
|
|
7422
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, 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, 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, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
7525
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, 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, 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, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ declare const AALBrand: unique symbol;
|
|
|
14
14
|
declare const ACRBrand: unique symbol;
|
|
15
15
|
declare const AuthMethodBrand: unique symbol;
|
|
16
16
|
declare const AMRs: {
|
|
17
|
-
readonly Pwd: ("
|
|
18
|
-
readonly Otp: ("
|
|
19
|
-
readonly Oauth: ("
|
|
20
|
-
readonly Sso: ("
|
|
21
|
-
readonly Saml: ("
|
|
17
|
+
readonly Pwd: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
18
|
+
readonly Otp: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
19
|
+
readonly Oauth: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
20
|
+
readonly Sso: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
21
|
+
readonly Saml: ("pwd" & z.core.$brand<typeof AMRBrand>) | ("otp" & z.core.$brand<typeof AMRBrand>) | ("oauth" & z.core.$brand<typeof AMRBrand>) | ("sso" & z.core.$brand<typeof AMRBrand>) | ("saml" & z.core.$brand<typeof AMRBrand>);
|
|
22
22
|
};
|
|
23
23
|
declare const AALs: {
|
|
24
24
|
readonly Aal1: ("aal1" & z.core.$brand<typeof AALBrand>) | ("aal2" & z.core.$brand<typeof AALBrand>) | ("aal3" & z.core.$brand<typeof AALBrand>);
|
|
@@ -29,11 +29,11 @@ declare const ACRs: {
|
|
|
29
29
|
readonly Unspecified: "urn:tela:auth:unspecified" & z.core.$brand<typeof ACRBrand>;
|
|
30
30
|
};
|
|
31
31
|
declare const AuthMethods: {
|
|
32
|
-
readonly Password: ("
|
|
33
|
-
readonly EmailOTP: ("
|
|
34
|
-
readonly OAuth: ("
|
|
35
|
-
readonly SAML: ("
|
|
36
|
-
readonly Unknown: ("
|
|
32
|
+
readonly Password: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
33
|
+
readonly EmailOTP: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
34
|
+
readonly OAuth: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
35
|
+
readonly SAML: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
36
|
+
readonly Unknown: ("oauth" & z.core.$brand<typeof AuthMethodBrand>) | ("saml" & z.core.$brand<typeof AuthMethodBrand>) | ("password" & z.core.$brand<typeof AuthMethodBrand>) | ("email_otp" & z.core.$brand<typeof AuthMethodBrand>) | ("unknown" & z.core.$brand<typeof AuthMethodBrand>);
|
|
37
37
|
};
|
|
38
38
|
declare const AMR: z.core.$ZodBranded<z.ZodEnum<{
|
|
39
39
|
readonly Pwd: "pwd";
|
|
@@ -6135,6 +6135,31 @@ type AdminApplicationEntitlement = {
|
|
|
6135
6135
|
* Entitlement record returned by entitlement mutation endpoints.
|
|
6136
6136
|
*/
|
|
6137
6137
|
type AdminApplicationEntitlementRecord = Omit<AdminApplicationEntitlement, 'organization'>;
|
|
6138
|
+
/** Kind of matcher an entitlement rule applies. */
|
|
6139
|
+
type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
|
|
6140
|
+
/**
|
|
6141
|
+
* A single access rule on an entitlement. Rules are evaluated in `position`
|
|
6142
|
+
* order, first match wins. A non-null `role` grants access with that role; a
|
|
6143
|
+
* null `role` denies access.
|
|
6144
|
+
*/
|
|
6145
|
+
type AdminEntitlementRule = {
|
|
6146
|
+
type: AdminEntitlementRuleType;
|
|
6147
|
+
value: string;
|
|
6148
|
+
role?: string | null;
|
|
6149
|
+
position: number;
|
|
6150
|
+
};
|
|
6151
|
+
/** An entitlement together with its ordered access rules. */
|
|
6152
|
+
type AdminEntitlementWithRules = AdminApplicationEntitlementRecord & {
|
|
6153
|
+
rules: AdminEntitlementRule[];
|
|
6154
|
+
};
|
|
6155
|
+
/** Options accepted when enabling or disabling an entitlement. */
|
|
6156
|
+
type UpdateAdminEntitlementOptions = {
|
|
6157
|
+
enabled: boolean;
|
|
6158
|
+
};
|
|
6159
|
+
/** Options accepted when replacing all rules on an entitlement. */
|
|
6160
|
+
type SetAdminEntitlementRulesOptions = {
|
|
6161
|
+
rules: AdminEntitlementRule[];
|
|
6162
|
+
};
|
|
6138
6163
|
/**
|
|
6139
6164
|
* Member preview returned alongside each admin application row.
|
|
6140
6165
|
*/
|
|
@@ -6268,12 +6293,60 @@ type InviteAdminOrganizationUsersResult = {
|
|
|
6268
6293
|
*/
|
|
6269
6294
|
declare class AdminService {
|
|
6270
6295
|
private client;
|
|
6296
|
+
private apiUrl;
|
|
6271
6297
|
/**
|
|
6272
6298
|
* Creates a new AdminService instance.
|
|
6273
6299
|
*
|
|
6274
6300
|
* @param client - The API client for making admin requests
|
|
6301
|
+
* @param apiUrl - The base URL of the authentication API, used to reach the
|
|
6302
|
+
* application routes that the Better Auth client cannot address
|
|
6275
6303
|
*/
|
|
6276
|
-
constructor(client: APIClient);
|
|
6304
|
+
constructor(client: APIClient, apiUrl: string);
|
|
6305
|
+
/**
|
|
6306
|
+
* Requests an application management route.
|
|
6307
|
+
*
|
|
6308
|
+
* These routes are served by the API itself rather than by the Better Auth
|
|
6309
|
+
* handler, so they sit outside the `/api/auth` base path that the Better
|
|
6310
|
+
* Auth client prepends and cannot go through {@link APIClient.$fetch}. They
|
|
6311
|
+
* authenticate with the session cookie alone; a bearer token must never be
|
|
6312
|
+
* attached, since the API reads one only as an internal API key and would
|
|
6313
|
+
* reject the request.
|
|
6314
|
+
*
|
|
6315
|
+
* @param path - Path relative to the API root, without a leading slash
|
|
6316
|
+
* @param request - Method, body, and query parameters
|
|
6317
|
+
* @returns The parsed JSON response
|
|
6318
|
+
*/
|
|
6319
|
+
private requestApplicationRoute;
|
|
6320
|
+
/**
|
|
6321
|
+
* Lists applications, optionally filtered by organization.
|
|
6322
|
+
*
|
|
6323
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
6324
|
+
* @returns The application listing with entitlement details
|
|
6325
|
+
*/
|
|
6326
|
+
listApplications(options?: ListAdminApplicationsOptions): Promise<ListAdminApplicationsResult>;
|
|
6327
|
+
/**
|
|
6328
|
+
* Creates an application.
|
|
6329
|
+
*
|
|
6330
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6331
|
+
* @returns The created application
|
|
6332
|
+
*/
|
|
6333
|
+
createApplication(options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6334
|
+
/**
|
|
6335
|
+
* Updates an application.
|
|
6336
|
+
*
|
|
6337
|
+
* @param applicationId - ID of the application to update
|
|
6338
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6339
|
+
* @returns The updated application
|
|
6340
|
+
*/
|
|
6341
|
+
updateApplication(applicationId: string, options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6342
|
+
/**
|
|
6343
|
+
* Enables an organization for an application.
|
|
6344
|
+
*
|
|
6345
|
+
* @param applicationId - ID of the application to update
|
|
6346
|
+
* @param options - Organization entitlement payload
|
|
6347
|
+
* @returns The created entitlement
|
|
6348
|
+
*/
|
|
6349
|
+
createApplicationEntitlement(applicationId: string, options: CreateAdminApplicationEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6277
6350
|
/**
|
|
6278
6351
|
* Lists all organizations, optionally with member and application previews
|
|
6279
6352
|
* and totals when a preview size is requested.
|
|
@@ -6393,6 +6466,36 @@ declare class AdminService {
|
|
|
6393
6466
|
createOrganizationTeam(options: CreateAdminOrganizationTeamOptions): Promise<{
|
|
6394
6467
|
data: AdminOrganizationTeamRecord;
|
|
6395
6468
|
} | null>;
|
|
6469
|
+
/**
|
|
6470
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
6471
|
+
*
|
|
6472
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
6473
|
+
* @returns The entitlement and its rules
|
|
6474
|
+
*/
|
|
6475
|
+
getEntitlement(entitlementId: string): Promise<AdminEntitlementWithRules>;
|
|
6476
|
+
/**
|
|
6477
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
6478
|
+
*
|
|
6479
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
6480
|
+
* @param options - The full set of rules to persist
|
|
6481
|
+
* @returns The entitlement with the saved rules
|
|
6482
|
+
*/
|
|
6483
|
+
setEntitlementRules(entitlementId: string, options: SetAdminEntitlementRulesOptions): Promise<AdminEntitlementWithRules>;
|
|
6484
|
+
/**
|
|
6485
|
+
* Enables or disables an entitlement.
|
|
6486
|
+
*
|
|
6487
|
+
* @param entitlementId - ID of the entitlement to update
|
|
6488
|
+
* @param options - The desired enabled state
|
|
6489
|
+
* @returns The updated entitlement
|
|
6490
|
+
*/
|
|
6491
|
+
updateEntitlement(entitlementId: string, options: UpdateAdminEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6492
|
+
/**
|
|
6493
|
+
* Deletes an entitlement and all of its access rules.
|
|
6494
|
+
*
|
|
6495
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
6496
|
+
* @returns The deleted entitlement
|
|
6497
|
+
*/
|
|
6498
|
+
deleteEntitlement(entitlementId: string): Promise<AdminApplicationEntitlementRecord>;
|
|
6396
6499
|
/**
|
|
6397
6500
|
* Creates an organization without adding the creator as a member.
|
|
6398
6501
|
*
|
|
@@ -7419,4 +7522,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7419
7522
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7420
7523
|
|
|
7421
7524
|
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 };
|
|
7422
|
-
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, 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, 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, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
7525
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, 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, 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, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
|
8
8
|
import z, { z as z$1 } from 'zod';
|
|
9
9
|
export { APIError } from 'better-auth';
|
|
10
10
|
|
|
11
|
-
const version = "1.
|
|
11
|
+
const version = "1.34.0";
|
|
12
12
|
|
|
13
13
|
function parsedEnumValues(schema) {
|
|
14
14
|
return Object.fromEntries(
|
|
@@ -408,14 +408,116 @@ function createAPIClient(apiUrl, fetchOptions = {}) {
|
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
+
async function readErrorMessage(response) {
|
|
412
|
+
try {
|
|
413
|
+
const body = await response.json();
|
|
414
|
+
return body.error ?? body.message ?? response.statusText;
|
|
415
|
+
} catch {
|
|
416
|
+
return response.statusText;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
411
419
|
class AdminService {
|
|
412
420
|
/**
|
|
413
421
|
* Creates a new AdminService instance.
|
|
414
422
|
*
|
|
415
423
|
* @param client - The API client for making admin requests
|
|
424
|
+
* @param apiUrl - The base URL of the authentication API, used to reach the
|
|
425
|
+
* application routes that the Better Auth client cannot address
|
|
416
426
|
*/
|
|
417
|
-
constructor(client) {
|
|
427
|
+
constructor(client, apiUrl) {
|
|
418
428
|
this.client = client;
|
|
429
|
+
this.apiUrl = apiUrl;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Requests an application management route.
|
|
433
|
+
*
|
|
434
|
+
* These routes are served by the API itself rather than by the Better Auth
|
|
435
|
+
* handler, so they sit outside the `/api/auth` base path that the Better
|
|
436
|
+
* Auth client prepends and cannot go through {@link APIClient.$fetch}. They
|
|
437
|
+
* authenticate with the session cookie alone; a bearer token must never be
|
|
438
|
+
* attached, since the API reads one only as an internal API key and would
|
|
439
|
+
* reject the request.
|
|
440
|
+
*
|
|
441
|
+
* @param path - Path relative to the API root, without a leading slash
|
|
442
|
+
* @param request - Method, body, and query parameters
|
|
443
|
+
* @returns The parsed JSON response
|
|
444
|
+
*/
|
|
445
|
+
async requestApplicationRoute(path, request = {}) {
|
|
446
|
+
const base = this.apiUrl.endsWith("/") ? this.apiUrl : `${this.apiUrl}/`;
|
|
447
|
+
const url = new URL(path, base);
|
|
448
|
+
for (const [key, value] of Object.entries(request.query ?? {})) {
|
|
449
|
+
if (value !== void 0)
|
|
450
|
+
url.searchParams.set(key, String(value));
|
|
451
|
+
}
|
|
452
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
453
|
+
if (request.body !== void 0)
|
|
454
|
+
headers.set("Content-Type", "application/json");
|
|
455
|
+
const response = await fetch(url, {
|
|
456
|
+
method: request.method ?? "GET",
|
|
457
|
+
credentials: "include",
|
|
458
|
+
headers,
|
|
459
|
+
...request.body !== void 0 ? { body: JSON.stringify(request.body) } : {}
|
|
460
|
+
});
|
|
461
|
+
if (!response.ok)
|
|
462
|
+
throw new Error(await readErrorMessage(response));
|
|
463
|
+
return await response.json();
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Lists applications, optionally filtered by organization.
|
|
467
|
+
*
|
|
468
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
469
|
+
* @returns The application listing with entitlement details
|
|
470
|
+
*/
|
|
471
|
+
async listApplications(options = {}) {
|
|
472
|
+
return await this.requestApplicationRoute("applications", {
|
|
473
|
+
query: {
|
|
474
|
+
limit: options.limit,
|
|
475
|
+
membersPreview: options.membersPreview,
|
|
476
|
+
offset: options.offset,
|
|
477
|
+
orderBy: options.orderBy,
|
|
478
|
+
orderDirection: options.orderDirection,
|
|
479
|
+
organizationId: options.organizationId,
|
|
480
|
+
search: options.search
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Creates an application.
|
|
486
|
+
*
|
|
487
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
488
|
+
* @returns The created application
|
|
489
|
+
*/
|
|
490
|
+
async createApplication(options) {
|
|
491
|
+
return await this.requestApplicationRoute("applications", {
|
|
492
|
+
method: "POST",
|
|
493
|
+
body: options
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Updates an application.
|
|
498
|
+
*
|
|
499
|
+
* @param applicationId - ID of the application to update
|
|
500
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
501
|
+
* @returns The updated application
|
|
502
|
+
*/
|
|
503
|
+
async updateApplication(applicationId, options) {
|
|
504
|
+
return await this.requestApplicationRoute(`applications/${encodeURIComponent(applicationId)}`, {
|
|
505
|
+
method: "PUT",
|
|
506
|
+
body: options
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Enables an organization for an application.
|
|
511
|
+
*
|
|
512
|
+
* @param applicationId - ID of the application to update
|
|
513
|
+
* @param options - Organization entitlement payload
|
|
514
|
+
* @returns The created entitlement
|
|
515
|
+
*/
|
|
516
|
+
async createApplicationEntitlement(applicationId, options) {
|
|
517
|
+
return await this.requestApplicationRoute(`applications/${encodeURIComponent(applicationId)}/entitlements`, {
|
|
518
|
+
method: "POST",
|
|
519
|
+
body: options
|
|
520
|
+
});
|
|
419
521
|
}
|
|
420
522
|
/**
|
|
421
523
|
* Lists all organizations, optionally with member and application previews
|
|
@@ -586,6 +688,55 @@ class AdminService {
|
|
|
586
688
|
});
|
|
587
689
|
return data;
|
|
588
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
693
|
+
*
|
|
694
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
695
|
+
* @returns The entitlement and its rules
|
|
696
|
+
*/
|
|
697
|
+
async getEntitlement(entitlementId) {
|
|
698
|
+
return await this.requestApplicationRoute(
|
|
699
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
704
|
+
*
|
|
705
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
706
|
+
* @param options - The full set of rules to persist
|
|
707
|
+
* @returns The entitlement with the saved rules
|
|
708
|
+
*/
|
|
709
|
+
async setEntitlementRules(entitlementId, options) {
|
|
710
|
+
return await this.requestApplicationRoute(
|
|
711
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}/rules`,
|
|
712
|
+
{ method: "PUT", body: options }
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Enables or disables an entitlement.
|
|
717
|
+
*
|
|
718
|
+
* @param entitlementId - ID of the entitlement to update
|
|
719
|
+
* @param options - The desired enabled state
|
|
720
|
+
* @returns The updated entitlement
|
|
721
|
+
*/
|
|
722
|
+
async updateEntitlement(entitlementId, options) {
|
|
723
|
+
return await this.requestApplicationRoute(
|
|
724
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`,
|
|
725
|
+
{ method: "PUT", body: options }
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Deletes an entitlement and all of its access rules.
|
|
730
|
+
*
|
|
731
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
732
|
+
* @returns The deleted entitlement
|
|
733
|
+
*/
|
|
734
|
+
async deleteEntitlement(entitlementId) {
|
|
735
|
+
return await this.requestApplicationRoute(
|
|
736
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`,
|
|
737
|
+
{ method: "DELETE" }
|
|
738
|
+
);
|
|
739
|
+
}
|
|
589
740
|
/**
|
|
590
741
|
* Creates an organization without adding the creator as a member.
|
|
591
742
|
*
|
|
@@ -1980,7 +2131,7 @@ class AuthClient {
|
|
|
1980
2131
|
this.emailOtp = new EmailOTPService(this.client);
|
|
1981
2132
|
this.sessionAssurance = new SessionAssuranceService(this.client);
|
|
1982
2133
|
this.user = new UserService(this.client);
|
|
1983
|
-
this.admin = new AdminService(this.client);
|
|
2134
|
+
this.admin = new AdminService(this.client, apiUrl);
|
|
1984
2135
|
}
|
|
1985
2136
|
}
|
|
1986
2137
|
|