@meistrari/auth-core 1.33.1 → 1.35.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 +132 -8
- package/dist/index.d.ts +132 -8
- package/dist/index.mjs +181 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4402,15 +4402,15 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4402
4402
|
} & {
|
|
4403
4403
|
applications: {
|
|
4404
4404
|
getApplicationAuthContext: (applicationId: string) => Promise<{
|
|
4405
|
+
data: ApplicationAuthContextResponse;
|
|
4406
|
+
error: null;
|
|
4407
|
+
} | {
|
|
4405
4408
|
data: null;
|
|
4406
4409
|
error: {
|
|
4407
4410
|
message?: string | undefined;
|
|
4408
4411
|
status: number;
|
|
4409
4412
|
statusText: string;
|
|
4410
4413
|
};
|
|
4411
|
-
} | {
|
|
4412
|
-
data: ApplicationAuthContextResponse;
|
|
4413
|
-
error: null;
|
|
4414
4414
|
}>;
|
|
4415
4415
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
4416
4416
|
data: ListCandidateOrganizationsResponse;
|
|
@@ -6079,6 +6079,8 @@ type AdminUserAccessApplication = {
|
|
|
6079
6079
|
imageUrl: string | null;
|
|
6080
6080
|
/** Effective role from entitlement rule evaluation. Null when the first matching rule denies access or no rule matches. */
|
|
6081
6081
|
role: string | null;
|
|
6082
|
+
/** User-facing name from the application role catalog. Null when no role matches. */
|
|
6083
|
+
roleDisplayName: string | null;
|
|
6082
6084
|
};
|
|
6083
6085
|
/**
|
|
6084
6086
|
* Team row in an admin user access report.
|
|
@@ -6135,6 +6137,42 @@ type AdminApplicationEntitlement = {
|
|
|
6135
6137
|
* Entitlement record returned by entitlement mutation endpoints.
|
|
6136
6138
|
*/
|
|
6137
6139
|
type AdminApplicationEntitlementRecord = Omit<AdminApplicationEntitlement, 'organization'>;
|
|
6140
|
+
/** Application-scoped role definition used by entitlement rules. */
|
|
6141
|
+
type AdminApplicationRole = {
|
|
6142
|
+
applicationId: string;
|
|
6143
|
+
name: string;
|
|
6144
|
+
displayName: string;
|
|
6145
|
+
description: string;
|
|
6146
|
+
};
|
|
6147
|
+
/** Options accepted when creating an application role. */
|
|
6148
|
+
type CreateAdminApplicationRoleOptions = Omit<AdminApplicationRole, 'applicationId'>;
|
|
6149
|
+
/** Options accepted when updating an application role. */
|
|
6150
|
+
type UpdateAdminApplicationRoleOptions = CreateAdminApplicationRoleOptions;
|
|
6151
|
+
/** Kind of matcher an entitlement rule applies. */
|
|
6152
|
+
type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
|
|
6153
|
+
/**
|
|
6154
|
+
* A single access rule on an entitlement. Rules are evaluated in `position`
|
|
6155
|
+
* order, first match wins. A non-null `role` grants access with that role; a
|
|
6156
|
+
* null `role` denies access.
|
|
6157
|
+
*/
|
|
6158
|
+
type AdminEntitlementRule = {
|
|
6159
|
+
type: AdminEntitlementRuleType;
|
|
6160
|
+
value: string;
|
|
6161
|
+
role: string | null;
|
|
6162
|
+
position: number;
|
|
6163
|
+
};
|
|
6164
|
+
/** An entitlement together with its ordered access rules. */
|
|
6165
|
+
type AdminEntitlementWithRules = AdminApplicationEntitlementRecord & {
|
|
6166
|
+
rules: AdminEntitlementRule[];
|
|
6167
|
+
};
|
|
6168
|
+
/** Options accepted when enabling or disabling an entitlement. */
|
|
6169
|
+
type UpdateAdminEntitlementOptions = {
|
|
6170
|
+
enabled: boolean;
|
|
6171
|
+
};
|
|
6172
|
+
/** Options accepted when replacing all rules on an entitlement. */
|
|
6173
|
+
type SetAdminEntitlementRulesOptions = {
|
|
6174
|
+
rules: AdminEntitlementRule[];
|
|
6175
|
+
};
|
|
6138
6176
|
/**
|
|
6139
6177
|
* Member preview returned alongside each admin application row.
|
|
6140
6178
|
*/
|
|
@@ -6268,12 +6306,68 @@ type InviteAdminOrganizationUsersResult = {
|
|
|
6268
6306
|
*/
|
|
6269
6307
|
declare class AdminService {
|
|
6270
6308
|
private client;
|
|
6309
|
+
private apiUrl;
|
|
6271
6310
|
/**
|
|
6272
6311
|
* Creates a new AdminService instance.
|
|
6273
6312
|
*
|
|
6274
6313
|
* @param client - The API client for making admin requests
|
|
6314
|
+
* @param apiUrl - The base URL of the authentication API, used to reach the
|
|
6315
|
+
* application routes that the Better Auth client cannot address
|
|
6275
6316
|
*/
|
|
6276
|
-
constructor(client: APIClient);
|
|
6317
|
+
constructor(client: APIClient, apiUrl: string);
|
|
6318
|
+
/**
|
|
6319
|
+
* Requests an application management route.
|
|
6320
|
+
*
|
|
6321
|
+
* These routes are served by the API itself rather than by the Better Auth
|
|
6322
|
+
* handler, so they sit outside the `/api/auth` base path that the Better
|
|
6323
|
+
* Auth client prepends and cannot go through {@link APIClient.$fetch}. They
|
|
6324
|
+
* authenticate with the session cookie alone; a bearer token must never be
|
|
6325
|
+
* attached, since the API reads one only as an internal API key and would
|
|
6326
|
+
* reject the request.
|
|
6327
|
+
*
|
|
6328
|
+
* @param path - Path relative to the API root, without a leading slash
|
|
6329
|
+
* @param request - Method, body, and query parameters
|
|
6330
|
+
* @returns The parsed JSON response
|
|
6331
|
+
*/
|
|
6332
|
+
private requestApplicationRoute;
|
|
6333
|
+
/**
|
|
6334
|
+
* Lists applications, optionally filtered by organization.
|
|
6335
|
+
*
|
|
6336
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
6337
|
+
* @returns The application listing with entitlement details
|
|
6338
|
+
*/
|
|
6339
|
+
listApplications(options?: ListAdminApplicationsOptions): Promise<ListAdminApplicationsResult>;
|
|
6340
|
+
/**
|
|
6341
|
+
* Creates an application.
|
|
6342
|
+
*
|
|
6343
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6344
|
+
* @returns The created application
|
|
6345
|
+
*/
|
|
6346
|
+
createApplication(options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6347
|
+
/**
|
|
6348
|
+
* Updates an application.
|
|
6349
|
+
*
|
|
6350
|
+
* @param applicationId - ID of the application to update
|
|
6351
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6352
|
+
* @returns The updated application
|
|
6353
|
+
*/
|
|
6354
|
+
updateApplication(applicationId: string, options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6355
|
+
/** Lists the role catalog for an application. */
|
|
6356
|
+
listApplicationRoles(applicationId: string): Promise<AdminApplicationRole[]>;
|
|
6357
|
+
/** Creates an application-scoped role definition. */
|
|
6358
|
+
createApplicationRole(applicationId: string, options: CreateAdminApplicationRoleOptions): Promise<AdminApplicationRole>;
|
|
6359
|
+
/** Updates an application-scoped role definition. */
|
|
6360
|
+
updateApplicationRole(applicationId: string, currentName: string, options: UpdateAdminApplicationRoleOptions): Promise<AdminApplicationRole>;
|
|
6361
|
+
/** Deletes an application-scoped role definition. */
|
|
6362
|
+
deleteApplicationRole(applicationId: string, name: string): Promise<AdminApplicationRole>;
|
|
6363
|
+
/**
|
|
6364
|
+
* Enables an organization for an application.
|
|
6365
|
+
*
|
|
6366
|
+
* @param applicationId - ID of the application to update
|
|
6367
|
+
* @param options - Organization entitlement payload
|
|
6368
|
+
* @returns The created entitlement
|
|
6369
|
+
*/
|
|
6370
|
+
createApplicationEntitlement(applicationId: string, options: CreateAdminApplicationEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6277
6371
|
/**
|
|
6278
6372
|
* Lists all organizations, optionally with member and application previews
|
|
6279
6373
|
* and totals when a preview size is requested.
|
|
@@ -6282,15 +6376,15 @@ declare class AdminService {
|
|
|
6282
6376
|
* @returns The paginated organization listing
|
|
6283
6377
|
*/
|
|
6284
6378
|
listOrganizations(options?: ListAdminOrganizationsOptions): Promise<{
|
|
6285
|
-
data: ListAdminOrganizationsResult;
|
|
6286
|
-
error: null;
|
|
6287
|
-
} | {
|
|
6288
6379
|
data: null;
|
|
6289
6380
|
error: {
|
|
6290
6381
|
message?: string | undefined;
|
|
6291
6382
|
status: number;
|
|
6292
6383
|
statusText: string;
|
|
6293
6384
|
};
|
|
6385
|
+
} | {
|
|
6386
|
+
data: ListAdminOrganizationsResult;
|
|
6387
|
+
error: null;
|
|
6294
6388
|
}>;
|
|
6295
6389
|
/**
|
|
6296
6390
|
* Lists users as a global admin, optionally with organization previews
|
|
@@ -6393,6 +6487,36 @@ declare class AdminService {
|
|
|
6393
6487
|
createOrganizationTeam(options: CreateAdminOrganizationTeamOptions): Promise<{
|
|
6394
6488
|
data: AdminOrganizationTeamRecord;
|
|
6395
6489
|
} | null>;
|
|
6490
|
+
/**
|
|
6491
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
6492
|
+
*
|
|
6493
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
6494
|
+
* @returns The entitlement and its rules
|
|
6495
|
+
*/
|
|
6496
|
+
getEntitlement(entitlementId: string): Promise<AdminEntitlementWithRules>;
|
|
6497
|
+
/**
|
|
6498
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
6499
|
+
*
|
|
6500
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
6501
|
+
* @param options - The full set of rules to persist
|
|
6502
|
+
* @returns The entitlement with the saved rules
|
|
6503
|
+
*/
|
|
6504
|
+
setEntitlementRules(entitlementId: string, options: SetAdminEntitlementRulesOptions): Promise<AdminEntitlementWithRules>;
|
|
6505
|
+
/**
|
|
6506
|
+
* Enables or disables an entitlement.
|
|
6507
|
+
*
|
|
6508
|
+
* @param entitlementId - ID of the entitlement to update
|
|
6509
|
+
* @param options - The desired enabled state
|
|
6510
|
+
* @returns The updated entitlement
|
|
6511
|
+
*/
|
|
6512
|
+
updateEntitlement(entitlementId: string, options: UpdateAdminEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6513
|
+
/**
|
|
6514
|
+
* Deletes an entitlement and all of its access rules.
|
|
6515
|
+
*
|
|
6516
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
6517
|
+
* @returns The deleted entitlement
|
|
6518
|
+
*/
|
|
6519
|
+
deleteEntitlement(entitlementId: string): Promise<AdminApplicationEntitlementRecord>;
|
|
6396
6520
|
/**
|
|
6397
6521
|
* Creates an organization without adding the creator as a member.
|
|
6398
6522
|
*
|
|
@@ -7419,4 +7543,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7419
7543
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7420
7544
|
|
|
7421
7545
|
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
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 };
|
|
7546
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, Invitation, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -4402,15 +4402,15 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
4402
4402
|
} & {
|
|
4403
4403
|
applications: {
|
|
4404
4404
|
getApplicationAuthContext: (applicationId: string) => Promise<{
|
|
4405
|
+
data: ApplicationAuthContextResponse;
|
|
4406
|
+
error: null;
|
|
4407
|
+
} | {
|
|
4405
4408
|
data: null;
|
|
4406
4409
|
error: {
|
|
4407
4410
|
message?: string | undefined;
|
|
4408
4411
|
status: number;
|
|
4409
4412
|
statusText: string;
|
|
4410
4413
|
};
|
|
4411
|
-
} | {
|
|
4412
|
-
data: ApplicationAuthContextResponse;
|
|
4413
|
-
error: null;
|
|
4414
4414
|
}>;
|
|
4415
4415
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
4416
4416
|
data: ListCandidateOrganizationsResponse;
|
|
@@ -6079,6 +6079,8 @@ type AdminUserAccessApplication = {
|
|
|
6079
6079
|
imageUrl: string | null;
|
|
6080
6080
|
/** Effective role from entitlement rule evaluation. Null when the first matching rule denies access or no rule matches. */
|
|
6081
6081
|
role: string | null;
|
|
6082
|
+
/** User-facing name from the application role catalog. Null when no role matches. */
|
|
6083
|
+
roleDisplayName: string | null;
|
|
6082
6084
|
};
|
|
6083
6085
|
/**
|
|
6084
6086
|
* Team row in an admin user access report.
|
|
@@ -6135,6 +6137,42 @@ type AdminApplicationEntitlement = {
|
|
|
6135
6137
|
* Entitlement record returned by entitlement mutation endpoints.
|
|
6136
6138
|
*/
|
|
6137
6139
|
type AdminApplicationEntitlementRecord = Omit<AdminApplicationEntitlement, 'organization'>;
|
|
6140
|
+
/** Application-scoped role definition used by entitlement rules. */
|
|
6141
|
+
type AdminApplicationRole = {
|
|
6142
|
+
applicationId: string;
|
|
6143
|
+
name: string;
|
|
6144
|
+
displayName: string;
|
|
6145
|
+
description: string;
|
|
6146
|
+
};
|
|
6147
|
+
/** Options accepted when creating an application role. */
|
|
6148
|
+
type CreateAdminApplicationRoleOptions = Omit<AdminApplicationRole, 'applicationId'>;
|
|
6149
|
+
/** Options accepted when updating an application role. */
|
|
6150
|
+
type UpdateAdminApplicationRoleOptions = CreateAdminApplicationRoleOptions;
|
|
6151
|
+
/** Kind of matcher an entitlement rule applies. */
|
|
6152
|
+
type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
|
|
6153
|
+
/**
|
|
6154
|
+
* A single access rule on an entitlement. Rules are evaluated in `position`
|
|
6155
|
+
* order, first match wins. A non-null `role` grants access with that role; a
|
|
6156
|
+
* null `role` denies access.
|
|
6157
|
+
*/
|
|
6158
|
+
type AdminEntitlementRule = {
|
|
6159
|
+
type: AdminEntitlementRuleType;
|
|
6160
|
+
value: string;
|
|
6161
|
+
role: string | null;
|
|
6162
|
+
position: number;
|
|
6163
|
+
};
|
|
6164
|
+
/** An entitlement together with its ordered access rules. */
|
|
6165
|
+
type AdminEntitlementWithRules = AdminApplicationEntitlementRecord & {
|
|
6166
|
+
rules: AdminEntitlementRule[];
|
|
6167
|
+
};
|
|
6168
|
+
/** Options accepted when enabling or disabling an entitlement. */
|
|
6169
|
+
type UpdateAdminEntitlementOptions = {
|
|
6170
|
+
enabled: boolean;
|
|
6171
|
+
};
|
|
6172
|
+
/** Options accepted when replacing all rules on an entitlement. */
|
|
6173
|
+
type SetAdminEntitlementRulesOptions = {
|
|
6174
|
+
rules: AdminEntitlementRule[];
|
|
6175
|
+
};
|
|
6138
6176
|
/**
|
|
6139
6177
|
* Member preview returned alongside each admin application row.
|
|
6140
6178
|
*/
|
|
@@ -6268,12 +6306,68 @@ type InviteAdminOrganizationUsersResult = {
|
|
|
6268
6306
|
*/
|
|
6269
6307
|
declare class AdminService {
|
|
6270
6308
|
private client;
|
|
6309
|
+
private apiUrl;
|
|
6271
6310
|
/**
|
|
6272
6311
|
* Creates a new AdminService instance.
|
|
6273
6312
|
*
|
|
6274
6313
|
* @param client - The API client for making admin requests
|
|
6314
|
+
* @param apiUrl - The base URL of the authentication API, used to reach the
|
|
6315
|
+
* application routes that the Better Auth client cannot address
|
|
6275
6316
|
*/
|
|
6276
|
-
constructor(client: APIClient);
|
|
6317
|
+
constructor(client: APIClient, apiUrl: string);
|
|
6318
|
+
/**
|
|
6319
|
+
* Requests an application management route.
|
|
6320
|
+
*
|
|
6321
|
+
* These routes are served by the API itself rather than by the Better Auth
|
|
6322
|
+
* handler, so they sit outside the `/api/auth` base path that the Better
|
|
6323
|
+
* Auth client prepends and cannot go through {@link APIClient.$fetch}. They
|
|
6324
|
+
* authenticate with the session cookie alone; a bearer token must never be
|
|
6325
|
+
* attached, since the API reads one only as an internal API key and would
|
|
6326
|
+
* reject the request.
|
|
6327
|
+
*
|
|
6328
|
+
* @param path - Path relative to the API root, without a leading slash
|
|
6329
|
+
* @param request - Method, body, and query parameters
|
|
6330
|
+
* @returns The parsed JSON response
|
|
6331
|
+
*/
|
|
6332
|
+
private requestApplicationRoute;
|
|
6333
|
+
/**
|
|
6334
|
+
* Lists applications, optionally filtered by organization.
|
|
6335
|
+
*
|
|
6336
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
6337
|
+
* @returns The application listing with entitlement details
|
|
6338
|
+
*/
|
|
6339
|
+
listApplications(options?: ListAdminApplicationsOptions): Promise<ListAdminApplicationsResult>;
|
|
6340
|
+
/**
|
|
6341
|
+
* Creates an application.
|
|
6342
|
+
*
|
|
6343
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6344
|
+
* @returns The created application
|
|
6345
|
+
*/
|
|
6346
|
+
createApplication(options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6347
|
+
/**
|
|
6348
|
+
* Updates an application.
|
|
6349
|
+
*
|
|
6350
|
+
* @param applicationId - ID of the application to update
|
|
6351
|
+
* @param options - Application name, URLs, logo, and authentication settings
|
|
6352
|
+
* @returns The updated application
|
|
6353
|
+
*/
|
|
6354
|
+
updateApplication(applicationId: string, options: CreateAdminApplicationOptions): Promise<AdminApplicationRecord>;
|
|
6355
|
+
/** Lists the role catalog for an application. */
|
|
6356
|
+
listApplicationRoles(applicationId: string): Promise<AdminApplicationRole[]>;
|
|
6357
|
+
/** Creates an application-scoped role definition. */
|
|
6358
|
+
createApplicationRole(applicationId: string, options: CreateAdminApplicationRoleOptions): Promise<AdminApplicationRole>;
|
|
6359
|
+
/** Updates an application-scoped role definition. */
|
|
6360
|
+
updateApplicationRole(applicationId: string, currentName: string, options: UpdateAdminApplicationRoleOptions): Promise<AdminApplicationRole>;
|
|
6361
|
+
/** Deletes an application-scoped role definition. */
|
|
6362
|
+
deleteApplicationRole(applicationId: string, name: string): Promise<AdminApplicationRole>;
|
|
6363
|
+
/**
|
|
6364
|
+
* Enables an organization for an application.
|
|
6365
|
+
*
|
|
6366
|
+
* @param applicationId - ID of the application to update
|
|
6367
|
+
* @param options - Organization entitlement payload
|
|
6368
|
+
* @returns The created entitlement
|
|
6369
|
+
*/
|
|
6370
|
+
createApplicationEntitlement(applicationId: string, options: CreateAdminApplicationEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6277
6371
|
/**
|
|
6278
6372
|
* Lists all organizations, optionally with member and application previews
|
|
6279
6373
|
* and totals when a preview size is requested.
|
|
@@ -6282,15 +6376,15 @@ declare class AdminService {
|
|
|
6282
6376
|
* @returns The paginated organization listing
|
|
6283
6377
|
*/
|
|
6284
6378
|
listOrganizations(options?: ListAdminOrganizationsOptions): Promise<{
|
|
6285
|
-
data: ListAdminOrganizationsResult;
|
|
6286
|
-
error: null;
|
|
6287
|
-
} | {
|
|
6288
6379
|
data: null;
|
|
6289
6380
|
error: {
|
|
6290
6381
|
message?: string | undefined;
|
|
6291
6382
|
status: number;
|
|
6292
6383
|
statusText: string;
|
|
6293
6384
|
};
|
|
6385
|
+
} | {
|
|
6386
|
+
data: ListAdminOrganizationsResult;
|
|
6387
|
+
error: null;
|
|
6294
6388
|
}>;
|
|
6295
6389
|
/**
|
|
6296
6390
|
* Lists users as a global admin, optionally with organization previews
|
|
@@ -6393,6 +6487,36 @@ declare class AdminService {
|
|
|
6393
6487
|
createOrganizationTeam(options: CreateAdminOrganizationTeamOptions): Promise<{
|
|
6394
6488
|
data: AdminOrganizationTeamRecord;
|
|
6395
6489
|
} | null>;
|
|
6490
|
+
/**
|
|
6491
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
6492
|
+
*
|
|
6493
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
6494
|
+
* @returns The entitlement and its rules
|
|
6495
|
+
*/
|
|
6496
|
+
getEntitlement(entitlementId: string): Promise<AdminEntitlementWithRules>;
|
|
6497
|
+
/**
|
|
6498
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
6499
|
+
*
|
|
6500
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
6501
|
+
* @param options - The full set of rules to persist
|
|
6502
|
+
* @returns The entitlement with the saved rules
|
|
6503
|
+
*/
|
|
6504
|
+
setEntitlementRules(entitlementId: string, options: SetAdminEntitlementRulesOptions): Promise<AdminEntitlementWithRules>;
|
|
6505
|
+
/**
|
|
6506
|
+
* Enables or disables an entitlement.
|
|
6507
|
+
*
|
|
6508
|
+
* @param entitlementId - ID of the entitlement to update
|
|
6509
|
+
* @param options - The desired enabled state
|
|
6510
|
+
* @returns The updated entitlement
|
|
6511
|
+
*/
|
|
6512
|
+
updateEntitlement(entitlementId: string, options: UpdateAdminEntitlementOptions): Promise<AdminApplicationEntitlementRecord>;
|
|
6513
|
+
/**
|
|
6514
|
+
* Deletes an entitlement and all of its access rules.
|
|
6515
|
+
*
|
|
6516
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
6517
|
+
* @returns The deleted entitlement
|
|
6518
|
+
*/
|
|
6519
|
+
deleteEntitlement(entitlementId: string): Promise<AdminApplicationEntitlementRecord>;
|
|
6396
6520
|
/**
|
|
6397
6521
|
* Creates an organization without adding the creator as a member.
|
|
6398
6522
|
*
|
|
@@ -7419,4 +7543,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7419
7543
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7420
7544
|
|
|
7421
7545
|
export { AAL, AALBrand, AALs, ACR, ACRBrand, ACRs, AMR, AMRBrand, AMRs, ApiKeyMetadata, ApplicationConfig, ApplicationError, ApplicationSessionAssuranceConfig, ApplicationSessionAssuranceError, AuthClient, AuthMethod, AuthMethodBrand, AuthMethods, AuthorizationFlowError, DEFAULT_APPLICATION_CONFIG, DEFAULT_JWT_ASSURANCE, DEFAULT_SESSION_ASSURANCE_CONFIG, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailOTPService, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadAssurance, JWTPayloadUser, JWTPayloadWorkspace, OAuthBeginStepUpResponse, OAuthCompleteStepUpResponse, OAuthStepUpProvider, RefreshTokenExpiredError, Roles, SENSITIVE_ACTION_ASSURANCE_POLICY, STEP_UP_MAX_AGE_SECONDS, SendOtpResponse, SessionAssurancePolicy, SessionAssuranceRequiredError, SessionAssuranceRequiredPayload, SessionAssuranceResponse, SessionAssuranceService, StepUpOption, UserNotLoggedInError, ac, assuranceFields, canStepUpWithAmr, createAPIClient, extractTokenPayload, getAalRank, invitationAdditionalFields, isAssuranceSufficientForPolicy, isSessionAssuranceSufficient, isTokenExpired, memberAdditionalFields, mergeStepUpAssurance, organizationAdditionalFields, parseSessionAssuranceRequiredPayload, rolesAccessControl, sessionAssurancePluginClient, userAdditionalFields, validateToken };
|
|
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 };
|
|
7546
|
+
export type { APIClient, AcceptInvitationResult, AdminApplication, AdminApplicationEntitlement, AdminApplicationEntitlementRecord, AdminApplicationMember, AdminApplicationOrganization, AdminApplicationRecord, AdminApplicationRole, AdminEntitlementRule, AdminEntitlementRuleType, AdminEntitlementWithRules, AdminMember, AdminOrganization, AdminOrganizationApplication, AdminOrganizationMember, AdminOrganizationMemberApplication, AdminOrganizationMemberRecord, AdminOrganizationMemberTeam, AdminOrganizationSummary, AdminOrganizationTeam, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, AdminUserAccessApplication, AdminUserAccessOrganization, AdminUserAccessTeam, AdminUserInvitation, AdminUserOrganization, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, AssuranceFields, BaseOrganization, BeginOAuthStepUpParams, BillingMode, CompleteAuthorizationFlowResponse, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, CreateApiKeyPayload, CreateTeamPayload, DecodedJWTPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, EmailOTPSignInOptions, FullOrganization, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, Invitation, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, InviteUserToOrganizationOptions, JWTPayloadData, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveAdminMemberOptions, RemoveUserFromOrganizationOptions, ResendAdminInviteOptions, Role, SendVerificationOTPOptions, Session, SessionAssuranceActions, SessionData, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateAdminApplicationRoleOptions, UpdateAdminEntitlementOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, UserProfile, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
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.35.0";
|
|
12
12
|
|
|
13
13
|
function parsedEnumValues(schema) {
|
|
14
14
|
return Object.fromEntries(
|
|
@@ -408,14 +408,143 @@ 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
|
+
/** Lists the role catalog for an application. */
|
|
510
|
+
async listApplicationRoles(applicationId) {
|
|
511
|
+
return await this.requestApplicationRoute(
|
|
512
|
+
`applications/${encodeURIComponent(applicationId)}/roles`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
/** Creates an application-scoped role definition. */
|
|
516
|
+
async createApplicationRole(applicationId, options) {
|
|
517
|
+
return await this.requestApplicationRoute(
|
|
518
|
+
`applications/${encodeURIComponent(applicationId)}/roles`,
|
|
519
|
+
{ method: "POST", body: options }
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
/** Updates an application-scoped role definition. */
|
|
523
|
+
async updateApplicationRole(applicationId, currentName, options) {
|
|
524
|
+
return await this.requestApplicationRoute(
|
|
525
|
+
`applications/${encodeURIComponent(applicationId)}/roles/${encodeURIComponent(currentName)}`,
|
|
526
|
+
{ method: "PUT", body: options }
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
/** Deletes an application-scoped role definition. */
|
|
530
|
+
async deleteApplicationRole(applicationId, name) {
|
|
531
|
+
return await this.requestApplicationRoute(
|
|
532
|
+
`applications/${encodeURIComponent(applicationId)}/roles/${encodeURIComponent(name)}`,
|
|
533
|
+
{ method: "DELETE" }
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Enables an organization for an application.
|
|
538
|
+
*
|
|
539
|
+
* @param applicationId - ID of the application to update
|
|
540
|
+
* @param options - Organization entitlement payload
|
|
541
|
+
* @returns The created entitlement
|
|
542
|
+
*/
|
|
543
|
+
async createApplicationEntitlement(applicationId, options) {
|
|
544
|
+
return await this.requestApplicationRoute(`applications/${encodeURIComponent(applicationId)}/entitlements`, {
|
|
545
|
+
method: "POST",
|
|
546
|
+
body: options
|
|
547
|
+
});
|
|
419
548
|
}
|
|
420
549
|
/**
|
|
421
550
|
* Lists all organizations, optionally with member and application previews
|
|
@@ -586,6 +715,55 @@ class AdminService {
|
|
|
586
715
|
});
|
|
587
716
|
return data;
|
|
588
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
720
|
+
*
|
|
721
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
722
|
+
* @returns The entitlement and its rules
|
|
723
|
+
*/
|
|
724
|
+
async getEntitlement(entitlementId) {
|
|
725
|
+
return await this.requestApplicationRoute(
|
|
726
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
731
|
+
*
|
|
732
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
733
|
+
* @param options - The full set of rules to persist
|
|
734
|
+
* @returns The entitlement with the saved rules
|
|
735
|
+
*/
|
|
736
|
+
async setEntitlementRules(entitlementId, options) {
|
|
737
|
+
return await this.requestApplicationRoute(
|
|
738
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}/rules`,
|
|
739
|
+
{ method: "PUT", body: options }
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Enables or disables an entitlement.
|
|
744
|
+
*
|
|
745
|
+
* @param entitlementId - ID of the entitlement to update
|
|
746
|
+
* @param options - The desired enabled state
|
|
747
|
+
* @returns The updated entitlement
|
|
748
|
+
*/
|
|
749
|
+
async updateEntitlement(entitlementId, options) {
|
|
750
|
+
return await this.requestApplicationRoute(
|
|
751
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`,
|
|
752
|
+
{ method: "PUT", body: options }
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Deletes an entitlement and all of its access rules.
|
|
757
|
+
*
|
|
758
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
759
|
+
* @returns The deleted entitlement
|
|
760
|
+
*/
|
|
761
|
+
async deleteEntitlement(entitlementId) {
|
|
762
|
+
return await this.requestApplicationRoute(
|
|
763
|
+
`applications/entitlements/${encodeURIComponent(entitlementId)}`,
|
|
764
|
+
{ method: "DELETE" }
|
|
765
|
+
);
|
|
766
|
+
}
|
|
589
767
|
/**
|
|
590
768
|
* Creates an organization without adding the creator as a member.
|
|
591
769
|
*
|
|
@@ -1980,7 +2158,7 @@ class AuthClient {
|
|
|
1980
2158
|
this.emailOtp = new EmailOTPService(this.client);
|
|
1981
2159
|
this.sessionAssurance = new SessionAssuranceService(this.client);
|
|
1982
2160
|
this.user = new UserService(this.client);
|
|
1983
|
-
this.admin = new AdminService(this.client);
|
|
2161
|
+
this.admin = new AdminService(this.client, apiUrl);
|
|
1984
2162
|
}
|
|
1985
2163
|
}
|
|
1986
2164
|
|