@meistrari/auth-core 1.16.0 → 1.17.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 +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.mjs +40 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -209,6 +209,18 @@ declare const memberAdditionalFields: {
|
|
|
209
209
|
defaultValue: null;
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Additional database fields added to the `invitation` table.
|
|
214
|
+
*
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
declare const invitationAdditionalFields: {
|
|
218
|
+
applicationId: {
|
|
219
|
+
type: "string";
|
|
220
|
+
input: true;
|
|
221
|
+
required: false;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
212
224
|
/**
|
|
213
225
|
* Zod schema and type for the `user` claim within a JWT payload.
|
|
214
226
|
*/
|
|
@@ -3383,6 +3395,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3383
3395
|
statusText: string;
|
|
3384
3396
|
};
|
|
3385
3397
|
}>;
|
|
3398
|
+
inviteUserToApplication: (options: InviteUserToApplicationOptions) => Promise<{
|
|
3399
|
+
data: null;
|
|
3400
|
+
error: {
|
|
3401
|
+
message?: string | undefined;
|
|
3402
|
+
status: number;
|
|
3403
|
+
statusText: string;
|
|
3404
|
+
};
|
|
3405
|
+
} | {
|
|
3406
|
+
data: CreateApplicationInvitationResponse;
|
|
3407
|
+
error: null;
|
|
3408
|
+
}>;
|
|
3386
3409
|
startAuthorizationFlow: (applicationId: string, redirectUri: string, codeChallenge: string, organizationId: string) => Promise<{
|
|
3387
3410
|
data: null;
|
|
3388
3411
|
error: {
|
|
@@ -4571,6 +4594,30 @@ type WhoAmIOptions = {
|
|
|
4571
4594
|
*/
|
|
4572
4595
|
include?: WhoAmIInclude[];
|
|
4573
4596
|
};
|
|
4597
|
+
type InviteUserToApplicationOptions = {
|
|
4598
|
+
organizationId: string;
|
|
4599
|
+
applicationId: string;
|
|
4600
|
+
email: string;
|
|
4601
|
+
role: Role;
|
|
4602
|
+
teamId?: string;
|
|
4603
|
+
resend?: boolean;
|
|
4604
|
+
sendEmail?: boolean;
|
|
4605
|
+
};
|
|
4606
|
+
type ApplicationInvitationResponse = {
|
|
4607
|
+
id: string;
|
|
4608
|
+
organizationId: string;
|
|
4609
|
+
email: string;
|
|
4610
|
+
role: string | null;
|
|
4611
|
+
teamId: string | null;
|
|
4612
|
+
applicationId: string | null;
|
|
4613
|
+
status: string;
|
|
4614
|
+
expiresAt: Date | string;
|
|
4615
|
+
inviterId: string;
|
|
4616
|
+
createdAt: Date | string;
|
|
4617
|
+
};
|
|
4618
|
+
type CreateApplicationInvitationResponse = {
|
|
4619
|
+
data?: ApplicationInvitationResponse;
|
|
4620
|
+
};
|
|
4574
4621
|
/**
|
|
4575
4622
|
* Response returned when starting a device authorization flow (RFC 8628).
|
|
4576
4623
|
*/
|
|
@@ -4747,6 +4794,13 @@ declare class ApplicationService {
|
|
|
4747
4794
|
organizations: FullOrganization[];
|
|
4748
4795
|
application?: Application | undefined;
|
|
4749
4796
|
}>;
|
|
4797
|
+
/**
|
|
4798
|
+
* Invites a user to an application through an organization entitlement.
|
|
4799
|
+
*
|
|
4800
|
+
* @param options - Invitation details including organization, application, email, and role
|
|
4801
|
+
* @returns The created invitation
|
|
4802
|
+
*/
|
|
4803
|
+
inviteUserToApplication(options: InviteUserToApplicationOptions): Promise<CreateApplicationInvitationResponse>;
|
|
4750
4804
|
/**
|
|
4751
4805
|
* Starts an authorization flow for a specific application.
|
|
4752
4806
|
*
|
|
@@ -4883,6 +4937,16 @@ type InviteUserToOrganizationOptions = {
|
|
|
4883
4937
|
teamId?: string;
|
|
4884
4938
|
/** Whether to resend the invitation if one already exists for this email. */
|
|
4885
4939
|
resend?: boolean;
|
|
4940
|
+
/**
|
|
4941
|
+
* Application scope for legacy callers that still pass this option through
|
|
4942
|
+
* the organization invitation path.
|
|
4943
|
+
*
|
|
4944
|
+
* New app-scoped invitations should use
|
|
4945
|
+
* `applications.inviteUserToApplication`, which calls
|
|
4946
|
+
* `POST /api/auth/applications/invitations`. The server rejects legacy
|
|
4947
|
+
* organization invitation creation when this field is present.
|
|
4948
|
+
*/
|
|
4949
|
+
applicationId?: string;
|
|
4886
4950
|
};
|
|
4887
4951
|
/**
|
|
4888
4952
|
* Options for removing a user from the active organization.
|
|
@@ -5071,10 +5135,11 @@ declare class OrganizationService {
|
|
|
5071
5135
|
* @param options.userEmail - Email address of the user to invite
|
|
5072
5136
|
* @param options.role - Role to assign to the invited user
|
|
5073
5137
|
* @param options.teamId - Team ID to add the user to
|
|
5138
|
+
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
5074
5139
|
* @param options.resend - Whether to resend if invitation already exists
|
|
5075
5140
|
* @returns The created invitation
|
|
5076
5141
|
*/
|
|
5077
|
-
inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5142
|
+
inviteUserToOrganization({ userEmail, role, teamId, resend, applicationId }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5078
5143
|
id: string;
|
|
5079
5144
|
organizationId: string;
|
|
5080
5145
|
email: string;
|
|
@@ -5105,8 +5170,12 @@ declare class OrganizationService {
|
|
|
5105
5170
|
* Accepts an organization invitation.
|
|
5106
5171
|
*
|
|
5107
5172
|
* @param id - The invitation ID to accept
|
|
5173
|
+
* @returns Object containing the application's `homeUrl` when the invitation is
|
|
5174
|
+
* scoped to an application that defines one; otherwise `null`.
|
|
5108
5175
|
*/
|
|
5109
|
-
acceptInvitation(id: string): Promise<
|
|
5176
|
+
acceptInvitation(id: string): Promise<{
|
|
5177
|
+
homeUrl: string | null;
|
|
5178
|
+
}>;
|
|
5110
5179
|
/**
|
|
5111
5180
|
* Removes a user from the active organization.
|
|
5112
5181
|
*
|
|
@@ -5559,5 +5628,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5559
5628
|
*/
|
|
5560
5629
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5561
5630
|
|
|
5562
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5563
|
-
export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
5631
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5632
|
+
export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, ApplicationInvitationResponse, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateApplicationInvitationResponse, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToApplicationOptions, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,18 @@ declare const memberAdditionalFields: {
|
|
|
209
209
|
defaultValue: null;
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Additional database fields added to the `invitation` table.
|
|
214
|
+
*
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
declare const invitationAdditionalFields: {
|
|
218
|
+
applicationId: {
|
|
219
|
+
type: "string";
|
|
220
|
+
input: true;
|
|
221
|
+
required: false;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
212
224
|
/**
|
|
213
225
|
* Zod schema and type for the `user` claim within a JWT payload.
|
|
214
226
|
*/
|
|
@@ -3383,6 +3395,17 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3383
3395
|
statusText: string;
|
|
3384
3396
|
};
|
|
3385
3397
|
}>;
|
|
3398
|
+
inviteUserToApplication: (options: InviteUserToApplicationOptions) => Promise<{
|
|
3399
|
+
data: null;
|
|
3400
|
+
error: {
|
|
3401
|
+
message?: string | undefined;
|
|
3402
|
+
status: number;
|
|
3403
|
+
statusText: string;
|
|
3404
|
+
};
|
|
3405
|
+
} | {
|
|
3406
|
+
data: CreateApplicationInvitationResponse;
|
|
3407
|
+
error: null;
|
|
3408
|
+
}>;
|
|
3386
3409
|
startAuthorizationFlow: (applicationId: string, redirectUri: string, codeChallenge: string, organizationId: string) => Promise<{
|
|
3387
3410
|
data: null;
|
|
3388
3411
|
error: {
|
|
@@ -4571,6 +4594,30 @@ type WhoAmIOptions = {
|
|
|
4571
4594
|
*/
|
|
4572
4595
|
include?: WhoAmIInclude[];
|
|
4573
4596
|
};
|
|
4597
|
+
type InviteUserToApplicationOptions = {
|
|
4598
|
+
organizationId: string;
|
|
4599
|
+
applicationId: string;
|
|
4600
|
+
email: string;
|
|
4601
|
+
role: Role;
|
|
4602
|
+
teamId?: string;
|
|
4603
|
+
resend?: boolean;
|
|
4604
|
+
sendEmail?: boolean;
|
|
4605
|
+
};
|
|
4606
|
+
type ApplicationInvitationResponse = {
|
|
4607
|
+
id: string;
|
|
4608
|
+
organizationId: string;
|
|
4609
|
+
email: string;
|
|
4610
|
+
role: string | null;
|
|
4611
|
+
teamId: string | null;
|
|
4612
|
+
applicationId: string | null;
|
|
4613
|
+
status: string;
|
|
4614
|
+
expiresAt: Date | string;
|
|
4615
|
+
inviterId: string;
|
|
4616
|
+
createdAt: Date | string;
|
|
4617
|
+
};
|
|
4618
|
+
type CreateApplicationInvitationResponse = {
|
|
4619
|
+
data?: ApplicationInvitationResponse;
|
|
4620
|
+
};
|
|
4574
4621
|
/**
|
|
4575
4622
|
* Response returned when starting a device authorization flow (RFC 8628).
|
|
4576
4623
|
*/
|
|
@@ -4747,6 +4794,13 @@ declare class ApplicationService {
|
|
|
4747
4794
|
organizations: FullOrganization[];
|
|
4748
4795
|
application?: Application | undefined;
|
|
4749
4796
|
}>;
|
|
4797
|
+
/**
|
|
4798
|
+
* Invites a user to an application through an organization entitlement.
|
|
4799
|
+
*
|
|
4800
|
+
* @param options - Invitation details including organization, application, email, and role
|
|
4801
|
+
* @returns The created invitation
|
|
4802
|
+
*/
|
|
4803
|
+
inviteUserToApplication(options: InviteUserToApplicationOptions): Promise<CreateApplicationInvitationResponse>;
|
|
4750
4804
|
/**
|
|
4751
4805
|
* Starts an authorization flow for a specific application.
|
|
4752
4806
|
*
|
|
@@ -4883,6 +4937,16 @@ type InviteUserToOrganizationOptions = {
|
|
|
4883
4937
|
teamId?: string;
|
|
4884
4938
|
/** Whether to resend the invitation if one already exists for this email. */
|
|
4885
4939
|
resend?: boolean;
|
|
4940
|
+
/**
|
|
4941
|
+
* Application scope for legacy callers that still pass this option through
|
|
4942
|
+
* the organization invitation path.
|
|
4943
|
+
*
|
|
4944
|
+
* New app-scoped invitations should use
|
|
4945
|
+
* `applications.inviteUserToApplication`, which calls
|
|
4946
|
+
* `POST /api/auth/applications/invitations`. The server rejects legacy
|
|
4947
|
+
* organization invitation creation when this field is present.
|
|
4948
|
+
*/
|
|
4949
|
+
applicationId?: string;
|
|
4886
4950
|
};
|
|
4887
4951
|
/**
|
|
4888
4952
|
* Options for removing a user from the active organization.
|
|
@@ -5071,10 +5135,11 @@ declare class OrganizationService {
|
|
|
5071
5135
|
* @param options.userEmail - Email address of the user to invite
|
|
5072
5136
|
* @param options.role - Role to assign to the invited user
|
|
5073
5137
|
* @param options.teamId - Team ID to add the user to
|
|
5138
|
+
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
5074
5139
|
* @param options.resend - Whether to resend if invitation already exists
|
|
5075
5140
|
* @returns The created invitation
|
|
5076
5141
|
*/
|
|
5077
|
-
inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5142
|
+
inviteUserToOrganization({ userEmail, role, teamId, resend, applicationId }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5078
5143
|
id: string;
|
|
5079
5144
|
organizationId: string;
|
|
5080
5145
|
email: string;
|
|
@@ -5105,8 +5170,12 @@ declare class OrganizationService {
|
|
|
5105
5170
|
* Accepts an organization invitation.
|
|
5106
5171
|
*
|
|
5107
5172
|
* @param id - The invitation ID to accept
|
|
5173
|
+
* @returns Object containing the application's `homeUrl` when the invitation is
|
|
5174
|
+
* scoped to an application that defines one; otherwise `null`.
|
|
5108
5175
|
*/
|
|
5109
|
-
acceptInvitation(id: string): Promise<
|
|
5176
|
+
acceptInvitation(id: string): Promise<{
|
|
5177
|
+
homeUrl: string | null;
|
|
5178
|
+
}>;
|
|
5110
5179
|
/**
|
|
5111
5180
|
* Removes a user from the active organization.
|
|
5112
5181
|
*
|
|
@@ -5559,5 +5628,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5559
5628
|
*/
|
|
5560
5629
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5561
5630
|
|
|
5562
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5563
|
-
export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
|
5631
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5632
|
+
export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, ApplicationInvitationResponse, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateApplicationInvitationResponse, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToApplicationOptions, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, 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 } from 'zod';
|
|
9
9
|
export { APIError } from 'better-auth';
|
|
10
10
|
|
|
11
|
-
const version = "1.
|
|
11
|
+
const version = "1.17.0";
|
|
12
12
|
|
|
13
13
|
const statements = {
|
|
14
14
|
...defaultStatements,
|
|
@@ -61,6 +61,13 @@ const memberAdditionalFields = {
|
|
|
61
61
|
defaultValue: null
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
const invitationAdditionalFields = {
|
|
65
|
+
applicationId: {
|
|
66
|
+
type: "string",
|
|
67
|
+
input: true,
|
|
68
|
+
required: false
|
|
69
|
+
}
|
|
70
|
+
};
|
|
64
71
|
const JWTPayloadUser = z.object({
|
|
65
72
|
id: z.string(),
|
|
66
73
|
name: z.string(),
|
|
@@ -100,6 +107,12 @@ function applicationsPluginClient() {
|
|
|
100
107
|
}
|
|
101
108
|
};
|
|
102
109
|
},
|
|
110
|
+
inviteUserToApplication: async (options) => {
|
|
111
|
+
return await $fetch("/applications/invitations", {
|
|
112
|
+
method: "POST",
|
|
113
|
+
body: options
|
|
114
|
+
});
|
|
115
|
+
},
|
|
103
116
|
startAuthorizationFlow: async (applicationId, redirectUri, codeChallenge, organizationId) => {
|
|
104
117
|
return await $fetch("/applications/authorize", {
|
|
105
118
|
method: "POST",
|
|
@@ -385,6 +398,20 @@ class ApplicationService {
|
|
|
385
398
|
}
|
|
386
399
|
return response.data;
|
|
387
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Invites a user to an application through an organization entitlement.
|
|
403
|
+
*
|
|
404
|
+
* @param options - Invitation details including organization, application, email, and role
|
|
405
|
+
* @returns The created invitation
|
|
406
|
+
*/
|
|
407
|
+
async inviteUserToApplication(options) {
|
|
408
|
+
const response = await this.client.applications.inviteUserToApplication(options);
|
|
409
|
+
const invitation = response.data;
|
|
410
|
+
if (!invitation) {
|
|
411
|
+
throw new Error("No invitation returned from application invitation endpoint");
|
|
412
|
+
}
|
|
413
|
+
return invitation;
|
|
414
|
+
}
|
|
388
415
|
/**
|
|
389
416
|
* Starts an authorization flow for a specific application.
|
|
390
417
|
*
|
|
@@ -664,16 +691,19 @@ class OrganizationService {
|
|
|
664
691
|
* @param options.userEmail - Email address of the user to invite
|
|
665
692
|
* @param options.role - Role to assign to the invited user
|
|
666
693
|
* @param options.teamId - Team ID to add the user to
|
|
694
|
+
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
667
695
|
* @param options.resend - Whether to resend if invitation already exists
|
|
668
696
|
* @returns The created invitation
|
|
669
697
|
*/
|
|
670
|
-
async inviteUserToOrganization({ userEmail, role, teamId, resend }) {
|
|
671
|
-
|
|
698
|
+
async inviteUserToOrganization({ userEmail, role, teamId, resend, applicationId }) {
|
|
699
|
+
const invitation = {
|
|
672
700
|
email: userEmail,
|
|
673
701
|
role,
|
|
674
702
|
teamId,
|
|
675
|
-
resend: resend ?? false
|
|
676
|
-
|
|
703
|
+
resend: resend ?? false,
|
|
704
|
+
applicationId
|
|
705
|
+
};
|
|
706
|
+
return await this.client.organization.inviteMember(invitation);
|
|
677
707
|
}
|
|
678
708
|
/**
|
|
679
709
|
* Cancels a pending organization invitation.
|
|
@@ -689,11 +719,14 @@ class OrganizationService {
|
|
|
689
719
|
* Accepts an organization invitation.
|
|
690
720
|
*
|
|
691
721
|
* @param id - The invitation ID to accept
|
|
722
|
+
* @returns Object containing the application's `homeUrl` when the invitation is
|
|
723
|
+
* scoped to an application that defines one; otherwise `null`.
|
|
692
724
|
*/
|
|
693
725
|
async acceptInvitation(id) {
|
|
694
|
-
await this.client.organization.acceptInvitation({
|
|
726
|
+
const response = await this.client.organization.acceptInvitation({
|
|
695
727
|
invitationId: id
|
|
696
728
|
});
|
|
729
|
+
return { homeUrl: response?.homeUrl ?? null };
|
|
697
730
|
}
|
|
698
731
|
/**
|
|
699
732
|
* Removes a user from the active organization.
|
|
@@ -1126,4 +1159,4 @@ function extractTokenPayload(token) {
|
|
|
1126
1159
|
return payload;
|
|
1127
1160
|
}
|
|
1128
1161
|
|
|
1129
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
1162
|
+
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|