@meistrari/auth-core 1.33.0 → 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 +119 -10
- package/dist/index.d.ts +119 -10
- package/dist/index.mjs +161 -7
- 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
|
-
} | {
|
|
4408
4405
|
data: null;
|
|
4409
4406
|
error: {
|
|
4410
4407
|
message?: string | undefined;
|
|
4411
4408
|
status: number;
|
|
4412
4409
|
statusText: string;
|
|
4413
4410
|
};
|
|
4411
|
+
} | {
|
|
4412
|
+
data: ApplicationAuthContextResponse;
|
|
4413
|
+
error: null;
|
|
4414
4414
|
}>;
|
|
4415
4415
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
4416
4416
|
data: ListCandidateOrganizationsResponse;
|
|
@@ -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.
|
|
@@ -6282,15 +6355,15 @@ declare class AdminService {
|
|
|
6282
6355
|
* @returns The paginated organization listing
|
|
6283
6356
|
*/
|
|
6284
6357
|
listOrganizations(options?: ListAdminOrganizationsOptions): Promise<{
|
|
6358
|
+
data: ListAdminOrganizationsResult;
|
|
6359
|
+
error: null;
|
|
6360
|
+
} | {
|
|
6285
6361
|
data: null;
|
|
6286
6362
|
error: {
|
|
6287
6363
|
message?: string | undefined;
|
|
6288
6364
|
status: number;
|
|
6289
6365
|
statusText: string;
|
|
6290
6366
|
};
|
|
6291
|
-
} | {
|
|
6292
|
-
data: ListAdminOrganizationsResult;
|
|
6293
|
-
error: null;
|
|
6294
6367
|
}>;
|
|
6295
6368
|
/**
|
|
6296
6369
|
* Lists users as a global admin, optionally with organization previews
|
|
@@ -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
|
*
|
|
@@ -6484,8 +6587,14 @@ declare class AdminService {
|
|
|
6484
6587
|
* Result of accepting an organization invitation.
|
|
6485
6588
|
*/
|
|
6486
6589
|
type AcceptInvitationResult = {
|
|
6590
|
+
/** The scoped application's ID, or `null` for a plain organization invitation. */
|
|
6591
|
+
applicationId: string | null;
|
|
6592
|
+
/** The scoped application's display name, or `null` for a plain organization invitation. */
|
|
6593
|
+
applicationName: string | null;
|
|
6487
6594
|
/** Application home URL for application-scoped invitations, otherwise `null`. */
|
|
6488
6595
|
homeUrl: string | null;
|
|
6596
|
+
/** Configured post-acceptance URL for plain organization invitations. */
|
|
6597
|
+
inviteAcceptedUrl: string | null;
|
|
6489
6598
|
/** The accepted organization membership. This may be an existing membership. */
|
|
6490
6599
|
member: Member;
|
|
6491
6600
|
};
|
|
@@ -6743,8 +6852,8 @@ declare class OrganizationService {
|
|
|
6743
6852
|
* Accepts an organization invitation.
|
|
6744
6853
|
*
|
|
6745
6854
|
* @param id - The invitation ID to accept
|
|
6746
|
-
* @returns The accepted member
|
|
6747
|
-
*
|
|
6855
|
+
* @returns The accepted member, application context for app-scoped invitations,
|
|
6856
|
+
* and the configured post-acceptance URL for plain organization invitations.
|
|
6748
6857
|
*/
|
|
6749
6858
|
acceptInvitation(id: string): Promise<AcceptInvitationResult>;
|
|
6750
6859
|
/**
|
|
@@ -7413,4 +7522,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7413
7522
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7414
7523
|
|
|
7415
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 };
|
|
7416
|
-
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
|
@@ -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
|
-
} | {
|
|
4408
4405
|
data: null;
|
|
4409
4406
|
error: {
|
|
4410
4407
|
message?: string | undefined;
|
|
4411
4408
|
status: number;
|
|
4412
4409
|
statusText: string;
|
|
4413
4410
|
};
|
|
4411
|
+
} | {
|
|
4412
|
+
data: ApplicationAuthContextResponse;
|
|
4413
|
+
error: null;
|
|
4414
4414
|
}>;
|
|
4415
4415
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
4416
4416
|
data: ListCandidateOrganizationsResponse;
|
|
@@ -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.
|
|
@@ -6282,15 +6355,15 @@ declare class AdminService {
|
|
|
6282
6355
|
* @returns The paginated organization listing
|
|
6283
6356
|
*/
|
|
6284
6357
|
listOrganizations(options?: ListAdminOrganizationsOptions): Promise<{
|
|
6358
|
+
data: ListAdminOrganizationsResult;
|
|
6359
|
+
error: null;
|
|
6360
|
+
} | {
|
|
6285
6361
|
data: null;
|
|
6286
6362
|
error: {
|
|
6287
6363
|
message?: string | undefined;
|
|
6288
6364
|
status: number;
|
|
6289
6365
|
statusText: string;
|
|
6290
6366
|
};
|
|
6291
|
-
} | {
|
|
6292
|
-
data: ListAdminOrganizationsResult;
|
|
6293
|
-
error: null;
|
|
6294
6367
|
}>;
|
|
6295
6368
|
/**
|
|
6296
6369
|
* Lists users as a global admin, optionally with organization previews
|
|
@@ -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
|
*
|
|
@@ -6484,8 +6587,14 @@ declare class AdminService {
|
|
|
6484
6587
|
* Result of accepting an organization invitation.
|
|
6485
6588
|
*/
|
|
6486
6589
|
type AcceptInvitationResult = {
|
|
6590
|
+
/** The scoped application's ID, or `null` for a plain organization invitation. */
|
|
6591
|
+
applicationId: string | null;
|
|
6592
|
+
/** The scoped application's display name, or `null` for a plain organization invitation. */
|
|
6593
|
+
applicationName: string | null;
|
|
6487
6594
|
/** Application home URL for application-scoped invitations, otherwise `null`. */
|
|
6488
6595
|
homeUrl: string | null;
|
|
6596
|
+
/** Configured post-acceptance URL for plain organization invitations. */
|
|
6597
|
+
inviteAcceptedUrl: string | null;
|
|
6489
6598
|
/** The accepted organization membership. This may be an existing membership. */
|
|
6490
6599
|
member: Member;
|
|
6491
6600
|
};
|
|
@@ -6743,8 +6852,8 @@ declare class OrganizationService {
|
|
|
6743
6852
|
* Accepts an organization invitation.
|
|
6744
6853
|
*
|
|
6745
6854
|
* @param id - The invitation ID to accept
|
|
6746
|
-
* @returns The accepted member
|
|
6747
|
-
*
|
|
6855
|
+
* @returns The accepted member, application context for app-scoped invitations,
|
|
6856
|
+
* and the configured post-acceptance URL for plain organization invitations.
|
|
6748
6857
|
*/
|
|
6749
6858
|
acceptInvitation(id: string): Promise<AcceptInvitationResult>;
|
|
6750
6859
|
/**
|
|
@@ -7413,4 +7522,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
7413
7522
|
declare function extractTokenPayload(token: string): DecodedJWTPayload;
|
|
7414
7523
|
|
|
7415
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 };
|
|
7416
|
-
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
|
*
|
|
@@ -1385,16 +1536,19 @@ class OrganizationService {
|
|
|
1385
1536
|
* Accepts an organization invitation.
|
|
1386
1537
|
*
|
|
1387
1538
|
* @param id - The invitation ID to accept
|
|
1388
|
-
* @returns The accepted member
|
|
1389
|
-
*
|
|
1539
|
+
* @returns The accepted member, application context for app-scoped invitations,
|
|
1540
|
+
* and the configured post-acceptance URL for plain organization invitations.
|
|
1390
1541
|
*/
|
|
1391
1542
|
async acceptInvitation(id) {
|
|
1392
1543
|
const response = await this.client.organization.acceptInvitation({
|
|
1393
1544
|
invitationId: id
|
|
1394
1545
|
});
|
|
1395
|
-
const
|
|
1546
|
+
const responseWithContext = response;
|
|
1396
1547
|
return {
|
|
1397
|
-
|
|
1548
|
+
applicationId: responseWithContext.applicationId ?? responseWithContext.invitation?.applicationId ?? null,
|
|
1549
|
+
applicationName: responseWithContext.applicationName ?? null,
|
|
1550
|
+
homeUrl: responseWithContext.homeUrl ?? null,
|
|
1551
|
+
inviteAcceptedUrl: responseWithContext.inviteAcceptedUrl ?? null,
|
|
1398
1552
|
member: response.member
|
|
1399
1553
|
};
|
|
1400
1554
|
}
|
|
@@ -1977,7 +2131,7 @@ class AuthClient {
|
|
|
1977
2131
|
this.emailOtp = new EmailOTPService(this.client);
|
|
1978
2132
|
this.sessionAssurance = new SessionAssuranceService(this.client);
|
|
1979
2133
|
this.user = new UserService(this.client);
|
|
1980
|
-
this.admin = new AdminService(this.client);
|
|
2134
|
+
this.admin = new AdminService(this.client, apiUrl);
|
|
1981
2135
|
}
|
|
1982
2136
|
}
|
|
1983
2137
|
|