@meistrari/auth-core 2.2.0 → 2.4.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 CHANGED
@@ -884,7 +884,9 @@ declare class ApplicationService {
884
884
  * Lists candidate organizations for a specific application.
885
885
  *
886
886
  * Returns organizations where the authenticated user is a member and
887
- * the application has been enabled with appropriate entitlement rules.
887
+ * the effective entitlement grants access through its rules. An enabled global
888
+ * entitlement is selected first; organization entitlements are considered only
889
+ * when no global entitlement is enabled.
888
890
  *
889
891
  * @param applicationId - The application ID to get candidate organizations for
890
892
  * @returns The list of candidate organizations
@@ -993,8 +995,10 @@ declare class ApplicationService {
993
995
  * Switches the active organization for the authenticated user.
994
996
  *
995
997
  * Issues new access and refresh tokens scoped to the specified organization.
996
- * The target organization must be entitled to the application and the entitlement's
997
- * access rules must allow the current user.
998
+ * Requires active membership in the target organization and an enabled entitlement
999
+ * whose rules allow the user. The global entitlement is selected first, and its
1000
+ * denial never falls back to an organization entitlement. Organization entitlements
1001
+ * are considered only when no global entitlement is enabled.
998
1002
  *
999
1003
  * @param organizationId - The ID of the organization to switch to
1000
1004
  * @param accessToken - Access token for authentication, sent as the `x-tela-access-token` header
@@ -4434,15 +4438,15 @@ type CreateAdminApplicationOptions = {
4434
4438
  homeUrl?: string | null;
4435
4439
  /** Custom application authentication settings. */
4436
4440
  config?: ApplicationConfig | null;
4437
- /** Organizations to enable for this application during creation. */
4441
+ /** Organization or global entitlements to create for this application. */
4438
4442
  entitlements?: CreateAdminApplicationEntitlementOptions[];
4439
4443
  };
4440
4444
  /**
4441
- * Options accepted when enabling an organization for an application.
4445
+ * Options accepted when creating an organization or global entitlement for an application.
4442
4446
  */
4443
4447
  type CreateAdminApplicationEntitlementOptions = {
4444
- /** Organization that should be entitled to the application. */
4445
- organizationId: string;
4448
+ /** Organization ID for type `organization`; passing null creates an entitlement with type `global`. */
4449
+ organizationId: string | null;
4446
4450
  };
4447
4451
  /**
4448
4452
  * Options accepted when creating a client secret for an application.
@@ -4856,8 +4860,11 @@ type AdminApplicationOrganization = {
4856
4860
  */
4857
4861
  type AdminApplicationEntitlement = {
4858
4862
  id: string;
4863
+ /** Access scope. Defaults to `organization` when omitted; the API returns the resolved type. Type `global` applies across organizations. */
4864
+ entitlementType?: 'organization' | 'global';
4859
4865
  applicationId: string;
4860
- organizationId: string;
4866
+ /** Required for type `organization` and constrained to null for type `global`. */
4867
+ organizationId: string | null;
4861
4868
  enabled: boolean;
4862
4869
  createdAt: string;
4863
4870
  updatedAt: string;
@@ -4881,10 +4888,10 @@ type CreateAdminApplicationRoleOptions = Omit<AdminApplicationRole, 'application
4881
4888
  /** Options accepted when updating an application role. */
4882
4889
  type UpdateAdminApplicationRoleOptions = CreateAdminApplicationRoleOptions;
4883
4890
  /** Kind of matcher an entitlement rule applies. */
4884
- type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
4891
+ type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals' | 'global';
4885
4892
  /**
4886
4893
  * A single access rule on an entitlement. Rules are evaluated in `position`
4887
- * order, first match wins. A non-null `role` grants access with that role; a
4894
+ * order with the global catch-all always last, first match wins. A non-null `role` grants access with that role; a
4888
4895
  * null `role` denies access.
4889
4896
  */
4890
4897
  type AdminEntitlementRule = {
@@ -5264,6 +5271,25 @@ declare class AdminService {
5264
5271
  getUserAccess(userId: string): Promise<{
5265
5272
  data: AdminUserAccess;
5266
5273
  } | null>;
5274
+ /**
5275
+ * Lists applications with their entitlements as a global admin. Unlike
5276
+ * {@link listApplications}, which goes through the session-only application
5277
+ * routes, this uses the admin endpoint and so also works with a bearer token.
5278
+ *
5279
+ * @param options - Pagination, ordering, organization filter, search, and member preview options
5280
+ * @returns The application listing with entitlement details
5281
+ */
5282
+ listAdminApplications(options?: ListAdminApplicationsOptions): Promise<{
5283
+ data: null;
5284
+ error: {
5285
+ message?: string | undefined;
5286
+ status: number;
5287
+ statusText: string;
5288
+ };
5289
+ } | {
5290
+ data: ListAdminApplicationsResult;
5291
+ error: null;
5292
+ }>;
5267
5293
  /**
5268
5294
  * Lists the users with access to an application as a global admin, one row
5269
5295
  * per user with every organization that grants them access and the role it
package/dist/index.d.ts CHANGED
@@ -884,7 +884,9 @@ declare class ApplicationService {
884
884
  * Lists candidate organizations for a specific application.
885
885
  *
886
886
  * Returns organizations where the authenticated user is a member and
887
- * the application has been enabled with appropriate entitlement rules.
887
+ * the effective entitlement grants access through its rules. An enabled global
888
+ * entitlement is selected first; organization entitlements are considered only
889
+ * when no global entitlement is enabled.
888
890
  *
889
891
  * @param applicationId - The application ID to get candidate organizations for
890
892
  * @returns The list of candidate organizations
@@ -993,8 +995,10 @@ declare class ApplicationService {
993
995
  * Switches the active organization for the authenticated user.
994
996
  *
995
997
  * Issues new access and refresh tokens scoped to the specified organization.
996
- * The target organization must be entitled to the application and the entitlement's
997
- * access rules must allow the current user.
998
+ * Requires active membership in the target organization and an enabled entitlement
999
+ * whose rules allow the user. The global entitlement is selected first, and its
1000
+ * denial never falls back to an organization entitlement. Organization entitlements
1001
+ * are considered only when no global entitlement is enabled.
998
1002
  *
999
1003
  * @param organizationId - The ID of the organization to switch to
1000
1004
  * @param accessToken - Access token for authentication, sent as the `x-tela-access-token` header
@@ -4434,15 +4438,15 @@ type CreateAdminApplicationOptions = {
4434
4438
  homeUrl?: string | null;
4435
4439
  /** Custom application authentication settings. */
4436
4440
  config?: ApplicationConfig | null;
4437
- /** Organizations to enable for this application during creation. */
4441
+ /** Organization or global entitlements to create for this application. */
4438
4442
  entitlements?: CreateAdminApplicationEntitlementOptions[];
4439
4443
  };
4440
4444
  /**
4441
- * Options accepted when enabling an organization for an application.
4445
+ * Options accepted when creating an organization or global entitlement for an application.
4442
4446
  */
4443
4447
  type CreateAdminApplicationEntitlementOptions = {
4444
- /** Organization that should be entitled to the application. */
4445
- organizationId: string;
4448
+ /** Organization ID for type `organization`; passing null creates an entitlement with type `global`. */
4449
+ organizationId: string | null;
4446
4450
  };
4447
4451
  /**
4448
4452
  * Options accepted when creating a client secret for an application.
@@ -4856,8 +4860,11 @@ type AdminApplicationOrganization = {
4856
4860
  */
4857
4861
  type AdminApplicationEntitlement = {
4858
4862
  id: string;
4863
+ /** Access scope. Defaults to `organization` when omitted; the API returns the resolved type. Type `global` applies across organizations. */
4864
+ entitlementType?: 'organization' | 'global';
4859
4865
  applicationId: string;
4860
- organizationId: string;
4866
+ /** Required for type `organization` and constrained to null for type `global`. */
4867
+ organizationId: string | null;
4861
4868
  enabled: boolean;
4862
4869
  createdAt: string;
4863
4870
  updatedAt: string;
@@ -4881,10 +4888,10 @@ type CreateAdminApplicationRoleOptions = Omit<AdminApplicationRole, 'application
4881
4888
  /** Options accepted when updating an application role. */
4882
4889
  type UpdateAdminApplicationRoleOptions = CreateAdminApplicationRoleOptions;
4883
4890
  /** Kind of matcher an entitlement rule applies. */
4884
- type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals';
4891
+ type AdminEntitlementRuleType = 'email_equals' | 'email_domain_equals' | 'organization_member' | 'user_id_equals' | 'global';
4885
4892
  /**
4886
4893
  * A single access rule on an entitlement. Rules are evaluated in `position`
4887
- * order, first match wins. A non-null `role` grants access with that role; a
4894
+ * order with the global catch-all always last, first match wins. A non-null `role` grants access with that role; a
4888
4895
  * null `role` denies access.
4889
4896
  */
4890
4897
  type AdminEntitlementRule = {
@@ -5264,6 +5271,25 @@ declare class AdminService {
5264
5271
  getUserAccess(userId: string): Promise<{
5265
5272
  data: AdminUserAccess;
5266
5273
  } | null>;
5274
+ /**
5275
+ * Lists applications with their entitlements as a global admin. Unlike
5276
+ * {@link listApplications}, which goes through the session-only application
5277
+ * routes, this uses the admin endpoint and so also works with a bearer token.
5278
+ *
5279
+ * @param options - Pagination, ordering, organization filter, search, and member preview options
5280
+ * @returns The application listing with entitlement details
5281
+ */
5282
+ listAdminApplications(options?: ListAdminApplicationsOptions): Promise<{
5283
+ data: null;
5284
+ error: {
5285
+ message?: string | undefined;
5286
+ status: number;
5287
+ statusText: string;
5288
+ };
5289
+ } | {
5290
+ data: ListAdminApplicationsResult;
5291
+ error: null;
5292
+ }>;
5267
5293
  /**
5268
5294
  * Lists the users with access to an application as a global admin, one row
5269
5295
  * per user with every organization that grants them access and the role it
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ function isTokenExpired(token, expiresInMs) {
21
21
  return nowInSeconds > expirationTime;
22
22
  }
23
23
 
24
- const version = "2.2.0";
24
+ const version = "2.4.0";
25
25
 
26
26
  function parsedEnumValues(schema) {
27
27
  return Object.fromEntries(
@@ -822,6 +822,28 @@ class AdminService {
822
822
  });
823
823
  return data;
824
824
  }
825
+ /**
826
+ * Lists applications with their entitlements as a global admin. Unlike
827
+ * {@link listApplications}, which goes through the session-only application
828
+ * routes, this uses the admin endpoint and so also works with a bearer token.
829
+ *
830
+ * @param options - Pagination, ordering, organization filter, search, and member preview options
831
+ * @returns The application listing with entitlement details
832
+ */
833
+ async listAdminApplications(options = {}) {
834
+ return await this.client.$fetch("/admin/applications", {
835
+ method: "GET",
836
+ query: {
837
+ ...options.limit !== void 0 ? { limit: options.limit } : {},
838
+ ...options.offset !== void 0 ? { offset: options.offset } : {},
839
+ ...options.search ? { search: options.search } : {},
840
+ ...options.organizationId ? { organization_id: options.organizationId } : {},
841
+ ...options.membersPreview !== void 0 ? { members_preview: options.membersPreview } : {},
842
+ ...options.orderBy ? { sortBy: options.orderBy } : {},
843
+ ...options.orderDirection ? { sortDirection: options.orderDirection } : {}
844
+ }
845
+ });
846
+ }
825
847
  /**
826
848
  * Lists the users with access to an application as a global admin, one row
827
849
  * per user with every organization that grants them access and the role it
@@ -1449,7 +1471,9 @@ class ApplicationService {
1449
1471
  * Lists candidate organizations for a specific application.
1450
1472
  *
1451
1473
  * Returns organizations where the authenticated user is a member and
1452
- * the application has been enabled with appropriate entitlement rules.
1474
+ * the effective entitlement grants access through its rules. An enabled global
1475
+ * entitlement is selected first; organization entitlements are considered only
1476
+ * when no global entitlement is enabled.
1453
1477
  *
1454
1478
  * @param applicationId - The application ID to get candidate organizations for
1455
1479
  * @returns The list of candidate organizations
@@ -1659,8 +1683,10 @@ class ApplicationService {
1659
1683
  * Switches the active organization for the authenticated user.
1660
1684
  *
1661
1685
  * Issues new access and refresh tokens scoped to the specified organization.
1662
- * The target organization must be entitled to the application and the entitlement's
1663
- * access rules must allow the current user.
1686
+ * Requires active membership in the target organization and an enabled entitlement
1687
+ * whose rules allow the user. The global entitlement is selected first, and its
1688
+ * denial never falls back to an organization entitlement. Organization entitlements
1689
+ * are considered only when no global entitlement is enabled.
1664
1690
  *
1665
1691
  * @param organizationId - The ID of the organization to switch to
1666
1692
  * @param accessToken - Access token for authentication, sent as the `x-tela-access-token` header
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {