@meistrari/auth-core 1.19.0 → 1.20.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 +15 -86
- package/dist/index.d.ts +15 -86
- package/dist/index.mjs +22 -38
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3393,32 +3393,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3393
3393
|
};
|
|
3394
3394
|
}>;
|
|
3395
3395
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
3396
|
-
data:
|
|
3397
|
-
|
|
3398
|
-
application?: Application | undefined;
|
|
3399
|
-
};
|
|
3400
|
-
error: {
|
|
3401
|
-
message?: string | undefined;
|
|
3402
|
-
status: number;
|
|
3403
|
-
statusText: string;
|
|
3404
|
-
};
|
|
3405
|
-
} | {
|
|
3406
|
-
data: {
|
|
3407
|
-
organizations: FullOrganization[];
|
|
3408
|
-
application?: Application | undefined;
|
|
3409
|
-
};
|
|
3410
|
-
error: null;
|
|
3411
|
-
}>;
|
|
3412
|
-
inviteUserToApplication: (options: InviteUserToApplicationOptions) => Promise<{
|
|
3413
|
-
data: null;
|
|
3414
|
-
error: {
|
|
3415
|
-
message?: string | undefined;
|
|
3416
|
-
status: number;
|
|
3417
|
-
statusText: string;
|
|
3418
|
-
};
|
|
3419
|
-
} | {
|
|
3420
|
-
data: CreateApplicationInvitationResponse;
|
|
3421
|
-
error: null;
|
|
3396
|
+
data: ListCandidateOrganizationsResponse;
|
|
3397
|
+
error?: unknown;
|
|
3422
3398
|
}>;
|
|
3423
3399
|
startAuthorizationFlow: (applicationId: string, redirectUri: string, codeChallenge: string, organizationId: string) => Promise<{
|
|
3424
3400
|
data: null;
|
|
@@ -4508,8 +4484,7 @@ type ExtendedOrganization = BaseOrganization & {
|
|
|
4508
4484
|
/**
|
|
4509
4485
|
* A complete organization object including its members, invitations, and teams.
|
|
4510
4486
|
*/
|
|
4511
|
-
type FullOrganization =
|
|
4512
|
-
slug: string | null;
|
|
4487
|
+
type FullOrganization = ExtendedOrganization & {
|
|
4513
4488
|
members: Member[];
|
|
4514
4489
|
invitations: Invitation[];
|
|
4515
4490
|
teams: Team[];
|
|
@@ -4559,12 +4534,7 @@ type Application = {
|
|
|
4559
4534
|
/**
|
|
4560
4535
|
* Response returned when listing candidate organizations for an application.
|
|
4561
4536
|
*/
|
|
4562
|
-
type ListCandidateOrganizationsResponse =
|
|
4563
|
-
/** The application being queried. */
|
|
4564
|
-
application: Application;
|
|
4565
|
-
/** Organizations where the user is a member and the application is entitled. */
|
|
4566
|
-
organizations: FullOrganization[];
|
|
4567
|
-
};
|
|
4537
|
+
type ListCandidateOrganizationsResponse = FullOrganization[];
|
|
4568
4538
|
/**
|
|
4569
4539
|
* Public application context used to preserve continuity during auth redirects.
|
|
4570
4540
|
*/
|
|
@@ -4615,30 +4585,6 @@ type WhoAmIOptions = {
|
|
|
4615
4585
|
*/
|
|
4616
4586
|
include?: WhoAmIInclude[];
|
|
4617
4587
|
};
|
|
4618
|
-
type InviteUserToApplicationOptions = {
|
|
4619
|
-
organizationId: string;
|
|
4620
|
-
applicationId: string;
|
|
4621
|
-
email: string;
|
|
4622
|
-
role: Role;
|
|
4623
|
-
teamId?: string;
|
|
4624
|
-
resend?: boolean;
|
|
4625
|
-
sendEmail?: boolean;
|
|
4626
|
-
};
|
|
4627
|
-
type ApplicationInvitationResponse = {
|
|
4628
|
-
id: string;
|
|
4629
|
-
organizationId: string;
|
|
4630
|
-
email: string;
|
|
4631
|
-
role: string | null;
|
|
4632
|
-
teamId: string | null;
|
|
4633
|
-
applicationId: string | null;
|
|
4634
|
-
status: string;
|
|
4635
|
-
expiresAt: Date | string;
|
|
4636
|
-
inviterId: string;
|
|
4637
|
-
createdAt: Date | string;
|
|
4638
|
-
};
|
|
4639
|
-
type CreateApplicationInvitationResponse = {
|
|
4640
|
-
data?: ApplicationInvitationResponse;
|
|
4641
|
-
};
|
|
4642
4588
|
/**
|
|
4643
4589
|
* Response returned when starting a device authorization flow (RFC 8628).
|
|
4644
4590
|
*/
|
|
@@ -4813,22 +4759,9 @@ declare class ApplicationService {
|
|
|
4813
4759
|
* the application has been enabled with appropriate entitlement rules.
|
|
4814
4760
|
*
|
|
4815
4761
|
* @param applicationId - The application ID to get candidate organizations for
|
|
4816
|
-
* @returns The
|
|
4762
|
+
* @returns The list of candidate organizations
|
|
4817
4763
|
*/
|
|
4818
|
-
listCandidateOrganizations(applicationId: string): Promise<
|
|
4819
|
-
organizations: FullOrganization[];
|
|
4820
|
-
application?: Application | undefined;
|
|
4821
|
-
} | {
|
|
4822
|
-
organizations: FullOrganization[];
|
|
4823
|
-
application?: Application | undefined;
|
|
4824
|
-
}>;
|
|
4825
|
-
/**
|
|
4826
|
-
* Invites a user to an application through an organization entitlement.
|
|
4827
|
-
*
|
|
4828
|
-
* @param options - Invitation details including organization, application, email, and role
|
|
4829
|
-
* @returns The created invitation
|
|
4830
|
-
*/
|
|
4831
|
-
inviteUserToApplication(options: InviteUserToApplicationOptions): Promise<CreateApplicationInvitationResponse>;
|
|
4764
|
+
listCandidateOrganizations(applicationId: string): Promise<ListCandidateOrganizationsResponse>;
|
|
4832
4765
|
/**
|
|
4833
4766
|
* Starts an authorization flow for a specific application.
|
|
4834
4767
|
*
|
|
@@ -4955,6 +4888,10 @@ type ListMembersOptions = {
|
|
|
4955
4888
|
};
|
|
4956
4889
|
/**
|
|
4957
4890
|
* Options for inviting a user to the active organization.
|
|
4891
|
+
*
|
|
4892
|
+
* When the SDK is authenticated with an application-scoped session, the invitation
|
|
4893
|
+
* is automatically scoped to that application. First-party callers receive a
|
|
4894
|
+
* plain organization invitation.
|
|
4958
4895
|
*/
|
|
4959
4896
|
type InviteUserToOrganizationOptions = {
|
|
4960
4897
|
/** Email address of the user to invite. */
|
|
@@ -4965,16 +4902,6 @@ type InviteUserToOrganizationOptions = {
|
|
|
4965
4902
|
teamId?: string;
|
|
4966
4903
|
/** Whether to resend the invitation if one already exists for this email. */
|
|
4967
4904
|
resend?: boolean;
|
|
4968
|
-
/**
|
|
4969
|
-
* Application scope for legacy callers that still pass this option through
|
|
4970
|
-
* the organization invitation path.
|
|
4971
|
-
*
|
|
4972
|
-
* New app-scoped invitations should use
|
|
4973
|
-
* `applications.inviteUserToApplication`, which calls
|
|
4974
|
-
* `POST /api/auth/applications/invitations`. The server rejects legacy
|
|
4975
|
-
* organization invitation creation when this field is present.
|
|
4976
|
-
*/
|
|
4977
|
-
applicationId?: string;
|
|
4978
4905
|
};
|
|
4979
4906
|
/**
|
|
4980
4907
|
* Options for removing a user from the active organization.
|
|
@@ -5159,15 +5086,17 @@ declare class OrganizationService {
|
|
|
5159
5086
|
/**
|
|
5160
5087
|
* Invites a user to join the active organization.
|
|
5161
5088
|
*
|
|
5089
|
+
* When the SDK runs with an application-scoped session, the server
|
|
5090
|
+
* automatically scopes the resulting invitation to that application.
|
|
5091
|
+
*
|
|
5162
5092
|
* @param options - Invitation configuration
|
|
5163
5093
|
* @param options.userEmail - Email address of the user to invite
|
|
5164
5094
|
* @param options.role - Role to assign to the invited user
|
|
5165
5095
|
* @param options.teamId - Team ID to add the user to
|
|
5166
|
-
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
5167
5096
|
* @param options.resend - Whether to resend if invitation already exists
|
|
5168
5097
|
* @returns The created invitation
|
|
5169
5098
|
*/
|
|
5170
|
-
inviteUserToOrganization({ userEmail, role, teamId, resend
|
|
5099
|
+
inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5171
5100
|
id: string;
|
|
5172
5101
|
organizationId: string;
|
|
5173
5102
|
email: string;
|
|
@@ -5657,4 +5586,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5657
5586
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5658
5587
|
|
|
5659
5588
|
export { ApiKeyMetadata, 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 };
|
|
5660
|
-
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse,
|
|
5589
|
+
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -3393,32 +3393,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
3393
3393
|
};
|
|
3394
3394
|
}>;
|
|
3395
3395
|
listCandidateOrganizations: (applicationId: string) => Promise<{
|
|
3396
|
-
data:
|
|
3397
|
-
|
|
3398
|
-
application?: Application | undefined;
|
|
3399
|
-
};
|
|
3400
|
-
error: {
|
|
3401
|
-
message?: string | undefined;
|
|
3402
|
-
status: number;
|
|
3403
|
-
statusText: string;
|
|
3404
|
-
};
|
|
3405
|
-
} | {
|
|
3406
|
-
data: {
|
|
3407
|
-
organizations: FullOrganization[];
|
|
3408
|
-
application?: Application | undefined;
|
|
3409
|
-
};
|
|
3410
|
-
error: null;
|
|
3411
|
-
}>;
|
|
3412
|
-
inviteUserToApplication: (options: InviteUserToApplicationOptions) => Promise<{
|
|
3413
|
-
data: null;
|
|
3414
|
-
error: {
|
|
3415
|
-
message?: string | undefined;
|
|
3416
|
-
status: number;
|
|
3417
|
-
statusText: string;
|
|
3418
|
-
};
|
|
3419
|
-
} | {
|
|
3420
|
-
data: CreateApplicationInvitationResponse;
|
|
3421
|
-
error: null;
|
|
3396
|
+
data: ListCandidateOrganizationsResponse;
|
|
3397
|
+
error?: unknown;
|
|
3422
3398
|
}>;
|
|
3423
3399
|
startAuthorizationFlow: (applicationId: string, redirectUri: string, codeChallenge: string, organizationId: string) => Promise<{
|
|
3424
3400
|
data: null;
|
|
@@ -4508,8 +4484,7 @@ type ExtendedOrganization = BaseOrganization & {
|
|
|
4508
4484
|
/**
|
|
4509
4485
|
* A complete organization object including its members, invitations, and teams.
|
|
4510
4486
|
*/
|
|
4511
|
-
type FullOrganization =
|
|
4512
|
-
slug: string | null;
|
|
4487
|
+
type FullOrganization = ExtendedOrganization & {
|
|
4513
4488
|
members: Member[];
|
|
4514
4489
|
invitations: Invitation[];
|
|
4515
4490
|
teams: Team[];
|
|
@@ -4559,12 +4534,7 @@ type Application = {
|
|
|
4559
4534
|
/**
|
|
4560
4535
|
* Response returned when listing candidate organizations for an application.
|
|
4561
4536
|
*/
|
|
4562
|
-
type ListCandidateOrganizationsResponse =
|
|
4563
|
-
/** The application being queried. */
|
|
4564
|
-
application: Application;
|
|
4565
|
-
/** Organizations where the user is a member and the application is entitled. */
|
|
4566
|
-
organizations: FullOrganization[];
|
|
4567
|
-
};
|
|
4537
|
+
type ListCandidateOrganizationsResponse = FullOrganization[];
|
|
4568
4538
|
/**
|
|
4569
4539
|
* Public application context used to preserve continuity during auth redirects.
|
|
4570
4540
|
*/
|
|
@@ -4615,30 +4585,6 @@ type WhoAmIOptions = {
|
|
|
4615
4585
|
*/
|
|
4616
4586
|
include?: WhoAmIInclude[];
|
|
4617
4587
|
};
|
|
4618
|
-
type InviteUserToApplicationOptions = {
|
|
4619
|
-
organizationId: string;
|
|
4620
|
-
applicationId: string;
|
|
4621
|
-
email: string;
|
|
4622
|
-
role: Role;
|
|
4623
|
-
teamId?: string;
|
|
4624
|
-
resend?: boolean;
|
|
4625
|
-
sendEmail?: boolean;
|
|
4626
|
-
};
|
|
4627
|
-
type ApplicationInvitationResponse = {
|
|
4628
|
-
id: string;
|
|
4629
|
-
organizationId: string;
|
|
4630
|
-
email: string;
|
|
4631
|
-
role: string | null;
|
|
4632
|
-
teamId: string | null;
|
|
4633
|
-
applicationId: string | null;
|
|
4634
|
-
status: string;
|
|
4635
|
-
expiresAt: Date | string;
|
|
4636
|
-
inviterId: string;
|
|
4637
|
-
createdAt: Date | string;
|
|
4638
|
-
};
|
|
4639
|
-
type CreateApplicationInvitationResponse = {
|
|
4640
|
-
data?: ApplicationInvitationResponse;
|
|
4641
|
-
};
|
|
4642
4588
|
/**
|
|
4643
4589
|
* Response returned when starting a device authorization flow (RFC 8628).
|
|
4644
4590
|
*/
|
|
@@ -4813,22 +4759,9 @@ declare class ApplicationService {
|
|
|
4813
4759
|
* the application has been enabled with appropriate entitlement rules.
|
|
4814
4760
|
*
|
|
4815
4761
|
* @param applicationId - The application ID to get candidate organizations for
|
|
4816
|
-
* @returns The
|
|
4762
|
+
* @returns The list of candidate organizations
|
|
4817
4763
|
*/
|
|
4818
|
-
listCandidateOrganizations(applicationId: string): Promise<
|
|
4819
|
-
organizations: FullOrganization[];
|
|
4820
|
-
application?: Application | undefined;
|
|
4821
|
-
} | {
|
|
4822
|
-
organizations: FullOrganization[];
|
|
4823
|
-
application?: Application | undefined;
|
|
4824
|
-
}>;
|
|
4825
|
-
/**
|
|
4826
|
-
* Invites a user to an application through an organization entitlement.
|
|
4827
|
-
*
|
|
4828
|
-
* @param options - Invitation details including organization, application, email, and role
|
|
4829
|
-
* @returns The created invitation
|
|
4830
|
-
*/
|
|
4831
|
-
inviteUserToApplication(options: InviteUserToApplicationOptions): Promise<CreateApplicationInvitationResponse>;
|
|
4764
|
+
listCandidateOrganizations(applicationId: string): Promise<ListCandidateOrganizationsResponse>;
|
|
4832
4765
|
/**
|
|
4833
4766
|
* Starts an authorization flow for a specific application.
|
|
4834
4767
|
*
|
|
@@ -4955,6 +4888,10 @@ type ListMembersOptions = {
|
|
|
4955
4888
|
};
|
|
4956
4889
|
/**
|
|
4957
4890
|
* Options for inviting a user to the active organization.
|
|
4891
|
+
*
|
|
4892
|
+
* When the SDK is authenticated with an application-scoped session, the invitation
|
|
4893
|
+
* is automatically scoped to that application. First-party callers receive a
|
|
4894
|
+
* plain organization invitation.
|
|
4958
4895
|
*/
|
|
4959
4896
|
type InviteUserToOrganizationOptions = {
|
|
4960
4897
|
/** Email address of the user to invite. */
|
|
@@ -4965,16 +4902,6 @@ type InviteUserToOrganizationOptions = {
|
|
|
4965
4902
|
teamId?: string;
|
|
4966
4903
|
/** Whether to resend the invitation if one already exists for this email. */
|
|
4967
4904
|
resend?: boolean;
|
|
4968
|
-
/**
|
|
4969
|
-
* Application scope for legacy callers that still pass this option through
|
|
4970
|
-
* the organization invitation path.
|
|
4971
|
-
*
|
|
4972
|
-
* New app-scoped invitations should use
|
|
4973
|
-
* `applications.inviteUserToApplication`, which calls
|
|
4974
|
-
* `POST /api/auth/applications/invitations`. The server rejects legacy
|
|
4975
|
-
* organization invitation creation when this field is present.
|
|
4976
|
-
*/
|
|
4977
|
-
applicationId?: string;
|
|
4978
4905
|
};
|
|
4979
4906
|
/**
|
|
4980
4907
|
* Options for removing a user from the active organization.
|
|
@@ -5159,15 +5086,17 @@ declare class OrganizationService {
|
|
|
5159
5086
|
/**
|
|
5160
5087
|
* Invites a user to join the active organization.
|
|
5161
5088
|
*
|
|
5089
|
+
* When the SDK runs with an application-scoped session, the server
|
|
5090
|
+
* automatically scopes the resulting invitation to that application.
|
|
5091
|
+
*
|
|
5162
5092
|
* @param options - Invitation configuration
|
|
5163
5093
|
* @param options.userEmail - Email address of the user to invite
|
|
5164
5094
|
* @param options.role - Role to assign to the invited user
|
|
5165
5095
|
* @param options.teamId - Team ID to add the user to
|
|
5166
|
-
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
5167
5096
|
* @param options.resend - Whether to resend if invitation already exists
|
|
5168
5097
|
* @returns The created invitation
|
|
5169
5098
|
*/
|
|
5170
|
-
inviteUserToOrganization({ userEmail, role, teamId, resend
|
|
5099
|
+
inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
|
|
5171
5100
|
id: string;
|
|
5172
5101
|
organizationId: string;
|
|
5173
5102
|
email: string;
|
|
@@ -5657,4 +5586,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5657
5586
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5658
5587
|
|
|
5659
5588
|
export { ApiKeyMetadata, 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 };
|
|
5660
|
-
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse,
|
|
5589
|
+
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
|
8
8
|
import z$1, { z } from 'zod';
|
|
9
9
|
export { APIError } from 'better-auth';
|
|
10
10
|
|
|
11
|
-
const version = "1.
|
|
11
|
+
const version = "1.20.0";
|
|
12
12
|
|
|
13
13
|
const statements = {
|
|
14
14
|
...defaultStatements,
|
|
@@ -86,6 +86,17 @@ const JWTPayload = z.object({
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
const DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
89
|
+
function normalizeOrganizationsResponse(response) {
|
|
90
|
+
if (Array.isArray(response)) {
|
|
91
|
+
return {
|
|
92
|
+
data: response
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
...response,
|
|
97
|
+
data: Array.isArray(response.data) ? response.data : []
|
|
98
|
+
};
|
|
99
|
+
}
|
|
89
100
|
function applicationsPluginClient() {
|
|
90
101
|
return {
|
|
91
102
|
id: "applications",
|
|
@@ -100,25 +111,12 @@ function applicationsPluginClient() {
|
|
|
100
111
|
});
|
|
101
112
|
},
|
|
102
113
|
listCandidateOrganizations: async (applicationId) => {
|
|
103
|
-
const response = await $fetch("/
|
|
114
|
+
const response = await $fetch("/organization/list", {
|
|
104
115
|
query: {
|
|
105
116
|
applicationId
|
|
106
117
|
}
|
|
107
118
|
});
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
...response,
|
|
111
|
-
data: {
|
|
112
|
-
...response.data,
|
|
113
|
-
organizations
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
inviteUserToApplication: async (options) => {
|
|
118
|
-
return await $fetch("/applications/invitations", {
|
|
119
|
-
method: "POST",
|
|
120
|
-
body: options
|
|
121
|
-
});
|
|
119
|
+
return normalizeOrganizationsResponse(response);
|
|
122
120
|
},
|
|
123
121
|
startAuthorizationFlow: async (applicationId, redirectUri, codeChallenge, organizationId) => {
|
|
124
122
|
return await $fetch("/applications/authorize", {
|
|
@@ -409,7 +407,7 @@ class ApplicationService {
|
|
|
409
407
|
* the application has been enabled with appropriate entitlement rules.
|
|
410
408
|
*
|
|
411
409
|
* @param applicationId - The application ID to get candidate organizations for
|
|
412
|
-
* @returns The
|
|
410
|
+
* @returns The list of candidate organizations
|
|
413
411
|
*/
|
|
414
412
|
async listCandidateOrganizations(applicationId) {
|
|
415
413
|
const response = await this.client.applications.listCandidateOrganizations(applicationId);
|
|
@@ -418,20 +416,6 @@ class ApplicationService {
|
|
|
418
416
|
}
|
|
419
417
|
return response.data;
|
|
420
418
|
}
|
|
421
|
-
/**
|
|
422
|
-
* Invites a user to an application through an organization entitlement.
|
|
423
|
-
*
|
|
424
|
-
* @param options - Invitation details including organization, application, email, and role
|
|
425
|
-
* @returns The created invitation
|
|
426
|
-
*/
|
|
427
|
-
async inviteUserToApplication(options) {
|
|
428
|
-
const response = await this.client.applications.inviteUserToApplication(options);
|
|
429
|
-
const invitation = response.data;
|
|
430
|
-
if (!invitation) {
|
|
431
|
-
throw new Error("No invitation returned from application invitation endpoint");
|
|
432
|
-
}
|
|
433
|
-
return invitation;
|
|
434
|
-
}
|
|
435
419
|
/**
|
|
436
420
|
* Starts an authorization flow for a specific application.
|
|
437
421
|
*
|
|
@@ -707,23 +691,23 @@ class OrganizationService {
|
|
|
707
691
|
/**
|
|
708
692
|
* Invites a user to join the active organization.
|
|
709
693
|
*
|
|
694
|
+
* When the SDK runs with an application-scoped session, the server
|
|
695
|
+
* automatically scopes the resulting invitation to that application.
|
|
696
|
+
*
|
|
710
697
|
* @param options - Invitation configuration
|
|
711
698
|
* @param options.userEmail - Email address of the user to invite
|
|
712
699
|
* @param options.role - Role to assign to the invited user
|
|
713
700
|
* @param options.teamId - Team ID to add the user to
|
|
714
|
-
* @param options.applicationId - Legacy application scope; prefer applications.inviteUserToApplication for new app-scoped invites
|
|
715
701
|
* @param options.resend - Whether to resend if invitation already exists
|
|
716
702
|
* @returns The created invitation
|
|
717
703
|
*/
|
|
718
|
-
async inviteUserToOrganization({ userEmail, role, teamId, resend
|
|
719
|
-
|
|
704
|
+
async inviteUserToOrganization({ userEmail, role, teamId, resend }) {
|
|
705
|
+
return await this.client.organization.inviteMember({
|
|
720
706
|
email: userEmail,
|
|
721
707
|
role,
|
|
722
708
|
teamId,
|
|
723
|
-
resend: resend ?? false
|
|
724
|
-
|
|
725
|
-
};
|
|
726
|
-
return await this.client.organization.inviteMember(invitation);
|
|
709
|
+
resend: resend ?? false
|
|
710
|
+
});
|
|
727
711
|
}
|
|
728
712
|
/**
|
|
729
713
|
* Cancels a pending organization invitation.
|