@authhero/multi-tenancy 13.13.0 → 13.13.2
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/multi-tenancy.d.ts +27 -56
- package/package.json +3 -3
package/dist/multi-tenancy.d.ts
CHANGED
|
@@ -14702,73 +14702,25 @@ export interface SamlSigner {
|
|
|
14702
14702
|
*/
|
|
14703
14703
|
signSAML(xmlContent: string, privateKey: string, publicCert: string): Promise<string>;
|
|
14704
14704
|
}
|
|
14705
|
-
/**
|
|
14706
|
-
* Context passed to all entity hooks
|
|
14707
|
-
*/
|
|
14705
|
+
/** Context passed to entity hooks */
|
|
14708
14706
|
export interface EntityHookContext {
|
|
14709
|
-
/** The tenant where the operation occurred */
|
|
14710
14707
|
tenantId: string;
|
|
14711
|
-
/** Data adapters for the current tenant */
|
|
14712
14708
|
adapters: DataAdapters;
|
|
14713
14709
|
}
|
|
14714
|
-
/**
|
|
14715
|
-
* CRUD hooks for any entity type.
|
|
14716
|
-
*
|
|
14717
|
-
* Use these hooks to implement cross-tenant synchronization,
|
|
14718
|
-
* audit logging, webhooks, or any other side effects.
|
|
14719
|
-
*
|
|
14720
|
-
* @example
|
|
14721
|
-
* ```typescript
|
|
14722
|
-
* const roleHooks: EntityHooks<Role, RoleInsert> = {
|
|
14723
|
-
* afterCreate: async (ctx, role) => {
|
|
14724
|
-
* // Propagate to other tenants
|
|
14725
|
-
* await syncToChildTenants(ctx, role);
|
|
14726
|
-
* },
|
|
14727
|
-
* afterUpdate: async (ctx, id, role) => {
|
|
14728
|
-
* // Log the update
|
|
14729
|
-
* await auditLog('role_updated', { id, tenantId: ctx.tenantId });
|
|
14730
|
-
* },
|
|
14731
|
-
* };
|
|
14732
|
-
* ```
|
|
14733
|
-
*/
|
|
14710
|
+
/** CRUD hooks for entity operations */
|
|
14734
14711
|
export interface EntityHooks<TEntity, TInsert, TUpdate = Partial<TInsert>> {
|
|
14735
|
-
/** Called before an entity is created */
|
|
14736
14712
|
beforeCreate?: (ctx: EntityHookContext, data: TInsert) => Promise<TInsert>;
|
|
14737
|
-
/** Called after an entity is created */
|
|
14738
14713
|
afterCreate?: (ctx: EntityHookContext, entity: TEntity) => Promise<void>;
|
|
14739
|
-
/** Called before an entity is updated */
|
|
14740
14714
|
beforeUpdate?: (ctx: EntityHookContext, id: string, data: TUpdate) => Promise<TUpdate>;
|
|
14741
|
-
/** Called after an entity is updated */
|
|
14742
14715
|
afterUpdate?: (ctx: EntityHookContext, id: string, entity: TEntity) => Promise<void>;
|
|
14743
|
-
/** Called before an entity is deleted */
|
|
14744
14716
|
beforeDelete?: (ctx: EntityHookContext, id: string) => Promise<void>;
|
|
14745
|
-
/** Called after an entity is deleted */
|
|
14746
14717
|
afterDelete?: (ctx: EntityHookContext, id: string) => Promise<void>;
|
|
14747
14718
|
}
|
|
14748
|
-
/**
|
|
14749
|
-
* Hooks for role permission assignment operations.
|
|
14750
|
-
*
|
|
14751
|
-
* Role permissions use assign/remove operations rather than typical CRUD,
|
|
14752
|
-
* so they have a specialized hook interface.
|
|
14753
|
-
*
|
|
14754
|
-
* @example
|
|
14755
|
-
* ```typescript
|
|
14756
|
-
* const rolePermissionHooks: RolePermissionHooks = {
|
|
14757
|
-
* afterAssign: async (ctx, roleId, permissions) => {
|
|
14758
|
-
* // Sync permissions to child tenants
|
|
14759
|
-
* await syncPermissionsToChildTenants(ctx, roleId, permissions);
|
|
14760
|
-
* },
|
|
14761
|
-
* };
|
|
14762
|
-
* ```
|
|
14763
|
-
*/
|
|
14719
|
+
/** Hooks for role permission assign/remove operations */
|
|
14764
14720
|
export interface RolePermissionHooks {
|
|
14765
|
-
/** Called before permissions are assigned to a role */
|
|
14766
14721
|
beforeAssign?: (ctx: EntityHookContext, roleId: string, permissions: RolePermissionInsert[]) => Promise<RolePermissionInsert[]>;
|
|
14767
|
-
/** Called after permissions are assigned to a role */
|
|
14768
14722
|
afterAssign?: (ctx: EntityHookContext, roleId: string, permissions: RolePermissionInsert[]) => Promise<void>;
|
|
14769
|
-
/** Called before permissions are removed from a role */
|
|
14770
14723
|
beforeRemove?: (ctx: EntityHookContext, roleId: string, permissions: Pick<RolePermissionInsert, "resource_server_identifier" | "permission_name">[]) => Promise<Pick<RolePermissionInsert, "resource_server_identifier" | "permission_name">[]>;
|
|
14771
|
-
/** Called after permissions are removed from a role */
|
|
14772
14724
|
afterRemove?: (ctx: EntityHookContext, roleId: string, permissions: Pick<RolePermissionInsert, "resource_server_identifier" | "permission_name">[]) => Promise<void>;
|
|
14773
14725
|
}
|
|
14774
14726
|
export type Transaction = {
|
|
@@ -14785,7 +14737,7 @@ export type Transaction = {
|
|
|
14785
14737
|
};
|
|
14786
14738
|
export type HookRequest = {
|
|
14787
14739
|
asn?: string;
|
|
14788
|
-
body?: Record<string,
|
|
14740
|
+
body?: Record<string, unknown>;
|
|
14789
14741
|
geoip?: {
|
|
14790
14742
|
cityName?: string;
|
|
14791
14743
|
continentCode?: string;
|
|
@@ -14828,13 +14780,13 @@ export type HookEvent = {
|
|
|
14828
14780
|
id: string;
|
|
14829
14781
|
name: string;
|
|
14830
14782
|
strategy: string;
|
|
14831
|
-
metadata?: Record<string,
|
|
14783
|
+
metadata?: Record<string, unknown>;
|
|
14832
14784
|
};
|
|
14833
14785
|
organization?: {
|
|
14834
14786
|
id: string;
|
|
14835
14787
|
name: string;
|
|
14836
14788
|
display_name: string;
|
|
14837
|
-
metadata?: Record<string,
|
|
14789
|
+
metadata?: Record<string, unknown>;
|
|
14838
14790
|
};
|
|
14839
14791
|
resource_server?: {
|
|
14840
14792
|
identifier: string;
|
|
@@ -14950,7 +14902,20 @@ export type OnExecuteValidateRegistrationUsername = (event: Omit<HookEvent, "use
|
|
|
14950
14902
|
connection: string;
|
|
14951
14903
|
};
|
|
14952
14904
|
}, api: OnExecuteValidateRegistrationUsernameAPI) => Promise<void>;
|
|
14953
|
-
export type
|
|
14905
|
+
export type UserInfoEvent = {
|
|
14906
|
+
ctx: Context<{
|
|
14907
|
+
Bindings: Bindings;
|
|
14908
|
+
Variables: Variables;
|
|
14909
|
+
}>;
|
|
14910
|
+
user: User;
|
|
14911
|
+
tenant_id: string;
|
|
14912
|
+
scopes: string[];
|
|
14913
|
+
};
|
|
14914
|
+
export type OnFetchUserInfoAPI = {
|
|
14915
|
+
setCustomClaim: (claim: string, value: unknown) => void;
|
|
14916
|
+
};
|
|
14917
|
+
/** Called when /userinfo endpoint is accessed */
|
|
14918
|
+
export type OnFetchUserInfo = (event: UserInfoEvent, api: OnFetchUserInfoAPI) => Promise<void>;
|
|
14954
14919
|
/**
|
|
14955
14920
|
* Entity hooks configuration for CRUD operations.
|
|
14956
14921
|
*
|
|
@@ -14993,6 +14958,11 @@ export interface AuthHeroConfig {
|
|
|
14993
14958
|
onExecutePostUserRegistration?: OnExecutePostUserRegistration;
|
|
14994
14959
|
onExecutePreUserUpdate?: OnExecutePreUserUpdate;
|
|
14995
14960
|
onExecutePostLogin?: OnExecutePostLogin;
|
|
14961
|
+
/**
|
|
14962
|
+
* Called when the /userinfo endpoint is accessed.
|
|
14963
|
+
* Use this to add custom claims to the userinfo response.
|
|
14964
|
+
*/
|
|
14965
|
+
onFetchUserInfo?: OnFetchUserInfo;
|
|
14996
14966
|
};
|
|
14997
14967
|
/**
|
|
14998
14968
|
* Entity CRUD hooks for when resources are created/updated/deleted.
|
|
@@ -15094,8 +15064,9 @@ export type Bindings = {
|
|
|
15094
15064
|
onExecutePostLogin?: OnExecutePostLogin;
|
|
15095
15065
|
onExecutePreUserDeletion?: OnExecutePreUserDeletion;
|
|
15096
15066
|
onExecutePostUserDeletion?: OnExecutePostUserDeletion;
|
|
15097
|
-
onExecuteValidateSignupEmail?: OnExecuteValidateSignupEmail;
|
|
15098
15067
|
onExecuteValidateRegistrationUsername?: OnExecuteValidateRegistrationUsername;
|
|
15068
|
+
/** Called when /userinfo endpoint is accessed to add custom claims */
|
|
15069
|
+
onFetchUserInfo?: OnFetchUserInfo;
|
|
15099
15070
|
};
|
|
15100
15071
|
/**
|
|
15101
15072
|
* Entity CRUD hooks for when resources are created/updated/deleted.
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/markusahlstrand/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "13.13.
|
|
14
|
+
"version": "13.13.2",
|
|
15
15
|
"description": "Multi-tenancy support for AuthHero with organization-based access control and per-tenant database isolation",
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"zod": "^3.24.0",
|
|
44
|
-
"
|
|
45
|
-
"authhero": "
|
|
44
|
+
"authhero": "2.0.0",
|
|
45
|
+
"@authhero/adapter-interfaces": "0.115.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@hono/zod-openapi": "^0.19.10",
|