@authhero/multi-tenancy 13.1.2 → 13.2.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.
Files changed (2) hide show
  1. package/README.md +35 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -10,6 +10,7 @@ Multi-tenancy support for AuthHero with organization-based access control, per-t
10
10
  - 🌐 **Subdomain Routing** - Automatic subdomain-to-tenant resolution
11
11
  - 🔄 **Tenant Lifecycle** - Automated provisioning and deprovisioning
12
12
  - 🪝 **Hooks Integration** - Seamless integration with AuthHero hooks system
13
+ - 📡 **Resource Server Sync** - Automatically sync resource servers from main tenant to all child tenants
13
14
 
14
15
  ## Installation
15
16
 
@@ -82,6 +83,40 @@ const token = await getAccessTokenSilently({
82
83
  });
83
84
  ```
84
85
 
86
+ ## Resource Server Synchronization
87
+
88
+ Automatically sync resource servers (APIs) from the main tenant to all child tenants. When you create, update, or delete a resource server on the main tenant, it's automatically propagated to all other tenants.
89
+
90
+ ```typescript
91
+ import { createResourceServerSyncHooks } from "@authhero/multi-tenancy";
92
+
93
+ const resourceServerHooks = createResourceServerSyncHooks({
94
+ mainTenantId: "main",
95
+ getChildTenantIds: async () => {
96
+ // Return all tenant IDs except the main tenant
97
+ const { tenants } = await adapters.tenants.list();
98
+ return tenants.filter((t) => t.id !== "main").map((t) => t.id);
99
+ },
100
+ getAdapters: async (tenantId) => {
101
+ // Return adapters for the target tenant
102
+ return createAdaptersForTenant(tenantId);
103
+ },
104
+ // Optional: filter which resource servers to sync
105
+ shouldSync: (resourceServer) => {
106
+ // Only sync resource servers that start with "api:"
107
+ return resourceServer.identifier.startsWith("api:");
108
+ },
109
+ });
110
+
111
+ // Use with AuthHero config
112
+ const config: AuthHeroConfig = {
113
+ dataAdapter,
114
+ entityHooks: {
115
+ resourceServers: resourceServerHooks,
116
+ },
117
+ };
118
+ ```
119
+
85
120
  ## License
86
121
 
87
122
  MIT
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.1.2",
14
+ "version": "13.2.0",
15
15
  "description": "Multi-tenancy support for AuthHero with organization-based access control and per-tenant database isolation",
16
16
  "files": [
17
17
  "dist"
@@ -37,11 +37,11 @@
37
37
  "typescript": "^5.6.0",
38
38
  "vite": "^6.0.0",
39
39
  "vitest": "^2.1.0",
40
- "@authhero/kysely-adapter": "10.68.0"
40
+ "@authhero/kysely-adapter": "10.69.0"
41
41
  },
42
42
  "dependencies": {
43
43
  "zod": "^3.24.0",
44
- "@authhero/adapter-interfaces": "0.110.0"
44
+ "@authhero/adapter-interfaces": "0.111.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@hono/zod-openapi": "^0.19.10",