@meistrari/auth-core 1.19.0 → 1.20.1

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 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
- organizations: FullOrganization[];
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 = Omit<ExtendedOrganization, 'slug'> & {
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 application details and list of candidate organizations
4817
- */
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
4762
+ * @returns The list of candidate organizations
4830
4763
  */
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, applicationId }: InviteUserToOrganizationOptions): Promise<NonNullable<{
5099
+ inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
5171
5100
  id: string;
5172
5101
  organizationId: string;
5173
5102
  email: string;
@@ -5329,8 +5258,6 @@ type SignInWithEmailAndPasswordOptions = {
5329
5258
  password: string;
5330
5259
  /** URL to redirect to after successful authentication. */
5331
5260
  callbackURL: string;
5332
- /** URL to redirect to if authentication fails. */
5333
- errorCallbackURL?: string;
5334
5261
  };
5335
5262
 
5336
5263
  /**
@@ -5428,8 +5355,9 @@ declare class SessionService {
5428
5355
  * @param options - Email/password sign-in configuration
5429
5356
  * @param options.email - User's email address
5430
5357
  * @param options.password - User's password
5358
+ * @param options.callbackURL - URL to redirect to after successful authentication
5431
5359
  */
5432
- signInWithEmailAndPassword({ email, password, }: SignInWithEmailAndPasswordOptions): Promise<void>;
5360
+ signInWithEmailAndPassword({ email, password, callbackURL, }: SignInWithEmailAndPasswordOptions): Promise<void>;
5433
5361
  /**
5434
5362
  * Signs out the currently authenticated user.
5435
5363
  *
@@ -5657,4 +5585,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
5657
5585
  declare function extractTokenPayload(token: string): JWTPayload;
5658
5586
 
5659
5587
  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, 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 };
5588
+ 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
- organizations: FullOrganization[];
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 = Omit<ExtendedOrganization, 'slug'> & {
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 application details and list of candidate organizations
4817
- */
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
4762
+ * @returns The list of candidate organizations
4830
4763
  */
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, applicationId }: InviteUserToOrganizationOptions): Promise<NonNullable<{
5099
+ inviteUserToOrganization({ userEmail, role, teamId, resend }: InviteUserToOrganizationOptions): Promise<NonNullable<{
5171
5100
  id: string;
5172
5101
  organizationId: string;
5173
5102
  email: string;
@@ -5329,8 +5258,6 @@ type SignInWithEmailAndPasswordOptions = {
5329
5258
  password: string;
5330
5259
  /** URL to redirect to after successful authentication. */
5331
5260
  callbackURL: string;
5332
- /** URL to redirect to if authentication fails. */
5333
- errorCallbackURL?: string;
5334
5261
  };
5335
5262
 
5336
5263
  /**
@@ -5428,8 +5355,9 @@ declare class SessionService {
5428
5355
  * @param options - Email/password sign-in configuration
5429
5356
  * @param options.email - User's email address
5430
5357
  * @param options.password - User's password
5358
+ * @param options.callbackURL - URL to redirect to after successful authentication
5431
5359
  */
5432
- signInWithEmailAndPassword({ email, password, }: SignInWithEmailAndPasswordOptions): Promise<void>;
5360
+ signInWithEmailAndPassword({ email, password, callbackURL, }: SignInWithEmailAndPasswordOptions): Promise<void>;
5433
5361
  /**
5434
5362
  * Signs out the currently authenticated user.
5435
5363
  *
@@ -5657,4 +5585,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
5657
5585
  declare function extractTokenPayload(token: string): JWTPayload;
5658
5586
 
5659
5587
  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, 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 };
5588
+ 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.19.0";
11
+ const version = "1.20.1";
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("/applications/candidate-organizations", {
114
+ const response = await $fetch("/organization/list", {
104
115
  query: {
105
116
  applicationId
106
117
  }
107
118
  });
108
- const organizations = response.data?.organizations ?? [];
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 application details and list of candidate organizations
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, applicationId }) {
719
- const invitation = {
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
- applicationId
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.
@@ -976,14 +960,20 @@ class SessionService {
976
960
  * @param options - Email/password sign-in configuration
977
961
  * @param options.email - User's email address
978
962
  * @param options.password - User's password
963
+ * @param options.callbackURL - URL to redirect to after successful authentication
979
964
  */
980
965
  async signInWithEmailAndPassword({
981
966
  email,
982
- password
967
+ password,
968
+ callbackURL
983
969
  }) {
970
+ if (!isValidUrl(callbackURL)) {
971
+ throw new InvalidCallbackURL(`Invalid callback URL: ${callbackURL}`);
972
+ }
984
973
  await this.client.signIn.email({
985
974
  email,
986
- password
975
+ password,
976
+ callbackURL
987
977
  });
988
978
  }
989
979
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.19.0",
3
+ "version": "1.20.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {