@authhero/multi-tenancy 14.23.0 → 14.24.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/multi-tenancy.cjs +1 -1
- package/dist/multi-tenancy.mjs +948 -1370
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/settings-inheritance.d.ts.map +1 -1
- package/dist/types/rollout/defaults-projection.d.ts +74 -0
- package/dist/types/rollout/defaults-projection.d.ts.map +1 -0
- package/dist/types/rollout/index.d.ts +30 -0
- package/dist/types/rollout/index.d.ts.map +1 -0
- package/dist/types/routes/tenants.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/types/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import { MultiTenancyConfig, MultiTenancyHooks, MultiTenancyBindings, MultiTenan
|
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export { initMultiTenant } from "./init";
|
|
5
5
|
export type { MultiTenantConfig, MultiTenantResult, ControlPlaneConfig, } from "./init";
|
|
6
|
+
export { createDirectRolloutAdapter, projectControlPlaneDefaults, } from "./rollout";
|
|
7
|
+
export type { ControlPlaneRolloutAdapter, DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, } from "./rollout";
|
|
6
8
|
export { createSyncHooks } from "./hooks/sync";
|
|
7
9
|
export type { EntitySyncConfig, SyncHooksResult } from "./hooks/sync";
|
|
8
10
|
export { createTenantsOpenAPIRouter } from "./routes";
|
|
9
11
|
export { createMultiTenancyMiddleware, createAccessControlMiddleware, createControlPlaneTenantMiddleware, createSubdomainMiddleware, createDatabaseMiddleware, createProtectSyncedMiddleware, createRuntimeFallbackAdapter, withRuntimeFallback, withSystemResourceServerInheritance, mergeClientWithFallback, } from "./middleware";
|
|
10
|
-
export type { RuntimeFallbackConfig, ControlPlaneResolver
|
|
12
|
+
export type { RuntimeFallbackConfig, ControlPlaneResolver } from "./middleware";
|
|
11
13
|
export { createMultiTenancyPlugin } from "./plugin";
|
|
12
14
|
export type { AuthHeroPlugin } from "./plugin";
|
|
13
15
|
export { createAccessControlHooks, createDatabaseHooks, createProvisioningHooks, } from "./hooks";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAajB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAajB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAKhB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,4BAA4B,EAC5B,mBAAmB,EACnB,mCAAmC,EACnC,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAgBnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB;cAE/C,oBAAoB;eACnB,qBAAqB;0CASnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB;;;;;;;kBAnD9C,oBAAoB;mBACnB,qBAAqB;;;IAwDhC;;;;;;;OAOG;6BAES,OAAO,UAAU,EAAE,YAAY,qBACtB;QAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAE;EAOzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-inheritance.d.ts","sourceRoot":"","sources":["../../../src/middleware/settings-inheritance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,MAAM,EAKP,MAAM,UAAU,CAAC;AA8FlB;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAChC,MAAM,CAqBR;AAED;;;GAGG;AACH,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"settings-inheritance.d.ts","sourceRoot":"","sources":["../../../src/middleware/settings-inheritance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,MAAM,EAKP,MAAM,UAAU,CAAC;AA8FlB;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAChC,MAAM,CAqBR;AAED;;;GAGG;AACH,KAAK,oBAAoB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAyH3D;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE;IACN,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;CAC5C,GACA,YAAY,CAYd;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;;;OAWG;IACH,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,YAAY,CA6Jd;AA2FD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,YAAY,CAEd"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { DataAdapters } from "authhero";
|
|
2
|
+
/**
|
|
3
|
+
* Which control plane entities to project into a tenant's own database. Every
|
|
4
|
+
* entity defaults to `true`.
|
|
5
|
+
*
|
|
6
|
+
* The projected rows are the same set the runtime fallback
|
|
7
|
+
* (`withRuntimeFallback`) reads from the control plane tenant: connections,
|
|
8
|
+
* `is_system` resource servers, `inheritable` hooks and the email provider.
|
|
9
|
+
* `branding` and `promptSettings` are projected too so a WFP tenant can render
|
|
10
|
+
* the control plane's defaults; consuming them on read still depends on the
|
|
11
|
+
* tenant resolving those singletons against the control plane tenant id.
|
|
12
|
+
*/
|
|
13
|
+
export interface DefaultsProjectionEntities {
|
|
14
|
+
connections?: boolean;
|
|
15
|
+
resourceServers?: boolean;
|
|
16
|
+
hooks?: boolean;
|
|
17
|
+
emailProvider?: boolean;
|
|
18
|
+
branding?: boolean;
|
|
19
|
+
promptSettings?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface DefaultsProjectionConfig {
|
|
22
|
+
/**
|
|
23
|
+
* The control plane tenant id. Projected rows are written into the target
|
|
24
|
+
* tenant's database under THIS id, so the existing runtime fallback resolves
|
|
25
|
+
* them exactly as it does in a shared database.
|
|
26
|
+
*/
|
|
27
|
+
controlPlaneTenantId: string;
|
|
28
|
+
/**
|
|
29
|
+
* Adapters for reading the control plane tenant's rows. Secrets are returned
|
|
30
|
+
* decrypted (this should be the encrypted adapter), and are re-encrypted at
|
|
31
|
+
* rest by the target adapter on write.
|
|
32
|
+
*/
|
|
33
|
+
getControlPlaneAdapters: () => Promise<DataAdapters>;
|
|
34
|
+
/**
|
|
35
|
+
* Adapters for the target tenant's own database. For a WFP tenant this is the
|
|
36
|
+
* adapter over the tenant's D1, ideally wrapped with a key ring that tags
|
|
37
|
+
* control-plane-tenant rows with a control-plane-only key id so the tenant
|
|
38
|
+
* operator cannot read the inherited secrets.
|
|
39
|
+
*/
|
|
40
|
+
getAdapters: (tenantId: string) => Promise<DataAdapters>;
|
|
41
|
+
/** Which entities to project. All default to true. */
|
|
42
|
+
entities?: DefaultsProjectionEntities;
|
|
43
|
+
/**
|
|
44
|
+
* When false (default) the first failing entity throws, so a pilot rollout
|
|
45
|
+
* fails loudly. When true, every entity is attempted and errors are collected
|
|
46
|
+
* into the result instead.
|
|
47
|
+
*/
|
|
48
|
+
continueOnError?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface EntityProjectionOutcome {
|
|
51
|
+
/** Rows created or updated. */
|
|
52
|
+
upserted: number;
|
|
53
|
+
/** Non-fatal errors, populated only when `continueOnError` is true. */
|
|
54
|
+
errors: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface DefaultsProjectionResult {
|
|
57
|
+
tenantId: string;
|
|
58
|
+
connections: EntityProjectionOutcome;
|
|
59
|
+
resourceServers: EntityProjectionOutcome;
|
|
60
|
+
hooks: EntityProjectionOutcome;
|
|
61
|
+
emailProvider: EntityProjectionOutcome;
|
|
62
|
+
branding: EntityProjectionOutcome;
|
|
63
|
+
promptSettings: EntityProjectionOutcome;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Projects the control plane tenant's inheritable defaults into a single target
|
|
67
|
+
* tenant's database, writing the rows under the control plane tenant id so the
|
|
68
|
+
* existing runtime fallback resolves them with no read-path change.
|
|
69
|
+
*
|
|
70
|
+
* Idempotent: every row is upserted by its stable id, so re-running the
|
|
71
|
+
* projection (a re-sync, or a later rollout) converges rather than duplicating.
|
|
72
|
+
*/
|
|
73
|
+
export declare function projectControlPlaneDefaults(config: DefaultsProjectionConfig, targetTenantId: string): Promise<DefaultsProjectionResult>;
|
|
74
|
+
//# sourceMappingURL=defaults-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-projection.d.ts","sourceRoot":"","sources":["../../../src/rollout/defaults-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,uBAAuB,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IAErD;;;;;OAKG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzD,sDAAsD;IACtD,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IAEtC;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,uBAAuB,CAAC;IACrC,eAAe,EAAE,uBAAuB,CAAC;IACzC,KAAK,EAAE,uBAAuB,CAAC;IAC/B,aAAa,EAAE,uBAAuB,CAAC;IACvC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,cAAc,EAAE,uBAAuB,CAAC;CACzC;AAgCD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,wBAAwB,EAChC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,wBAAwB,CAAC,CAyJnC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DefaultsProjectionConfig, DefaultsProjectionResult } from "./defaults-projection";
|
|
2
|
+
export type { DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, } from "./defaults-projection";
|
|
3
|
+
export { projectControlPlaneDefaults } from "./defaults-projection";
|
|
4
|
+
/**
|
|
5
|
+
* A control plane rollout applies the control plane's state to one or more
|
|
6
|
+
* tenant databases. `syncDefaults` is the only operation today; schema
|
|
7
|
+
* migrations and tenant worker code deploys are the same shape (enumerate
|
|
8
|
+
* tenants, apply per-tenant, retry, resume) and will become sibling methods.
|
|
9
|
+
*
|
|
10
|
+
* The interface is the seam for execution strategy. The direct implementation
|
|
11
|
+
* runs inline — right for a single pilot tenant. A future Cloudflare Workflows
|
|
12
|
+
* implementation will satisfy the same interface with durable, retryable,
|
|
13
|
+
* resumable fan-out, with no change to callers.
|
|
14
|
+
*/
|
|
15
|
+
export interface ControlPlaneRolloutAdapter {
|
|
16
|
+
/** Project the control plane defaults into a single tenant's database. */
|
|
17
|
+
syncDefaults(targetTenantId: string): Promise<DefaultsProjectionResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Project the defaults into several tenants. The direct implementation runs
|
|
20
|
+
* them sequentially; a Workflows implementation fans out durably.
|
|
21
|
+
*/
|
|
22
|
+
syncDefaultsToTenants(targetTenantIds: string[]): Promise<DefaultsProjectionResult[]>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a rollout adapter that executes projections inline in the current
|
|
26
|
+
* process. Use this to validate the model with a single tenant before moving to
|
|
27
|
+
* a durable Cloudflare Workflows implementation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createDirectRolloutAdapter(config: DefaultsProjectionConfig): ControlPlaneRolloutAdapter;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rollout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAExE;;;OAGG;IACH,qBAAqB,CACnB,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,wBAAwB,GAC/B,0BAA0B,CAa5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenants.d.ts","sourceRoot":"","sources":["../../../src/routes/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAUhE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB;cAGZ,oBAAoB;eACnB,qBAAqB;
|
|
1
|
+
{"version":3,"file":"tenants.d.ts","sourceRoot":"","sources":["../../../src/routes/tenants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAUhE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,iBAAiB;cAGZ,oBAAoB;eACnB,qBAAqB;YAuenC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/markusahlstrand/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "14.
|
|
14
|
+
"version": "14.24.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"
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/zod-openapi": "^1.4.0",
|
|
31
31
|
"@types/better-sqlite3": "^7.6.12",
|
|
32
|
-
"@types/node": "^22.
|
|
32
|
+
"@types/node": "^22.19.19",
|
|
33
33
|
"better-sqlite3": "^11.7.0",
|
|
34
|
-
"hono": "^4.
|
|
35
|
-
"kysely": "^0.
|
|
34
|
+
"hono": "^4.12.23",
|
|
35
|
+
"kysely": "^0.29.2",
|
|
36
36
|
"typescript": "^5.6.0",
|
|
37
|
-
"vite": "^
|
|
38
|
-
"vitest": "^
|
|
39
|
-
"@authhero/kysely-adapter": "11.
|
|
40
|
-
"authhero": "
|
|
41
|
-
"
|
|
37
|
+
"vite": "^8.0.14",
|
|
38
|
+
"vitest": "^4.1.7",
|
|
39
|
+
"@authhero/kysely-adapter": "11.8.9",
|
|
40
|
+
"@authhero/adapter-interfaces": "3.1.1",
|
|
41
|
+
"authhero": "8.3.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"zod": "^4.4.3"
|