authhero 4.2.0 → 4.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.
@@ -37552,6 +37552,7 @@ export type Variables = {
37552
37552
  tenant_id: string;
37553
37553
  org_name?: string;
37554
37554
  org_id?: string;
37555
+ scope?: string;
37555
37556
  };
37556
37557
  organization_id?: string;
37557
37558
  org_name?: string;
@@ -37797,6 +37798,22 @@ export type OnFetchUserInfoAPI = {
37797
37798
  };
37798
37799
  /** Called when /userinfo endpoint is accessed */
37799
37800
  export type OnFetchUserInfo = (event: UserInfoEvent, api: OnFetchUserInfoAPI) => Promise<void>;
37801
+ /**
37802
+ * All available auth flow hooks.
37803
+ * This type is shared between AuthHeroConfig and Bindings to ensure consistency.
37804
+ */
37805
+ export type Hooks = {
37806
+ onExecuteCredentialsExchange?: OnExecuteCredentialsExchange;
37807
+ onExecutePreUserRegistration?: OnExecutePreUserRegistration;
37808
+ onExecutePostUserRegistration?: OnExecutePostUserRegistration;
37809
+ onExecutePreUserUpdate?: OnExecutePreUserUpdate;
37810
+ onExecutePostLogin?: OnExecutePostLogin;
37811
+ onExecutePreUserDeletion?: OnExecutePreUserDeletion;
37812
+ onExecutePostUserDeletion?: OnExecutePostUserDeletion;
37813
+ onExecuteValidateRegistrationUsername?: OnExecuteValidateRegistrationUsername;
37814
+ /** Called when /userinfo endpoint is accessed to add custom claims */
37815
+ onFetchUserInfo?: OnFetchUserInfo;
37816
+ };
37800
37817
  /**
37801
37818
  * Entity hooks configuration for CRUD operations.
37802
37819
  *
@@ -37837,18 +37854,7 @@ export interface AuthHeroConfig {
37837
37854
  /**
37838
37855
  * Auth0-style action hooks for auth flow events.
37839
37856
  */
37840
- hooks?: {
37841
- onExecuteCredentialsExchange?: OnExecuteCredentialsExchange;
37842
- onExecutePreUserRegistration?: OnExecutePreUserRegistration;
37843
- onExecutePostUserRegistration?: OnExecutePostUserRegistration;
37844
- onExecutePreUserUpdate?: OnExecutePreUserUpdate;
37845
- onExecutePostLogin?: OnExecutePostLogin;
37846
- /**
37847
- * Called when the /userinfo endpoint is accessed.
37848
- * Use this to add custom claims to the userinfo response.
37849
- */
37850
- onFetchUserInfo?: OnFetchUserInfo;
37851
- };
37857
+ hooks?: Hooks;
37852
37858
  /**
37853
37859
  * Entity CRUD hooks for when resources are created/updated/deleted.
37854
37860
  * Use these to implement cross-tenant sync, audit logging, webhooks, etc.
@@ -37979,18 +37985,7 @@ export type Bindings = {
37979
37985
  UNIVERSAL_LOGIN_URL?: string;
37980
37986
  OAUTH_API_URL?: string;
37981
37987
  data: DataAdapters;
37982
- hooks?: {
37983
- onExecuteCredentialsExchange?: OnExecuteCredentialsExchange;
37984
- onExecutePreUserRegistration?: OnExecutePreUserRegistration;
37985
- onExecutePostUserRegistration?: OnExecutePostUserRegistration;
37986
- onExecutePreUserUpdate?: OnExecutePreUserUpdate;
37987
- onExecutePostLogin?: OnExecutePostLogin;
37988
- onExecutePreUserDeletion?: OnExecutePreUserDeletion;
37989
- onExecutePostUserDeletion?: OnExecutePostUserDeletion;
37990
- onExecuteValidateRegistrationUsername?: OnExecuteValidateRegistrationUsername;
37991
- /** Called when /userinfo endpoint is accessed to add custom claims */
37992
- onFetchUserInfo?: OnFetchUserInfo;
37993
- };
37988
+ hooks?: Hooks;
37994
37989
  /**
37995
37990
  * Entity CRUD hooks for when resources are created/updated/deleted.
37996
37991
  * Use these to implement cross-tenant sync, audit logging, webhooks, etc.
package/dist/authhero.mjs CHANGED
@@ -25814,17 +25814,17 @@ const kk = new ae().openapi(
25814
25814
  sub: n.user_id
25815
25815
  }), i = e.env.hooks?.onFetchUserInfo;
25816
25816
  if (i) {
25817
- const o = {};
25817
+ const o = {}, c = e.var.user?.scope?.split(" ") || [];
25818
25818
  return await i(
25819
25819
  {
25820
25820
  ctx: e,
25821
25821
  user: n,
25822
25822
  tenant_id: t,
25823
- scopes: e.var.scope?.split(" ") || []
25823
+ scopes: c
25824
25824
  },
25825
25825
  {
25826
- setCustomClaim: (a, c) => {
25827
- o[a] = c;
25826
+ setCustomClaim: (u, l) => {
25827
+ o[u] = l;
25828
25828
  }
25829
25829
  }
25830
25830
  ), e.json({ ...r, ...o });