@authhero/multi-tenancy 14.24.1 → 14.25.1

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.
@@ -3,8 +3,8 @@ 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
+ export { createDirectRolloutAdapter, projectControlPlaneDefaults, buildControlPlaneDefaultsPayload, applyControlPlaneDefaultsPayload, } from "./rollout";
7
+ export type { ControlPlaneRolloutAdapter, DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, ProjectableDefaults, ControlPlaneDefaultsPayload, ControlPlaneDefaultsApplyResult, ControlPlaneTenantSeed, DefaultsPayloadEntities, } from "./rollout";
8
8
  export { createSyncHooks } from "./hooks/sync";
9
9
  export type { EntitySyncConfig, SyncHooksResult } from "./hooks/sync";
10
10
  export { createTenantsOpenAPIRouter } from "./routes";
@@ -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;AAKhB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GA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AAE,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,4 +1,4 @@
1
- import { DataAdapters } from "authhero";
1
+ import { DataAdapters, Connection, ResourceServer, Hook, EmailProvider, Branding, PromptSetting } from "authhero";
2
2
  /**
3
3
  * Which control plane entities to project into a tenant's own database. Every
4
4
  * entity defaults to `true`.
@@ -18,6 +18,30 @@ export interface DefaultsProjectionEntities {
18
18
  branding?: boolean;
19
19
  promptSettings?: boolean;
20
20
  }
21
+ /** Entity flags resolved to concrete booleans (all defaulted to `true`). */
22
+ export interface ResolvedDefaultsEntities {
23
+ connections: boolean;
24
+ resourceServers: boolean;
25
+ hooks: boolean;
26
+ emailProvider: boolean;
27
+ branding: boolean;
28
+ promptSettings: boolean;
29
+ }
30
+ export declare function resolveDefaultsEntities(entities?: DefaultsProjectionEntities): ResolvedDefaultsEntities;
31
+ /**
32
+ * The control plane defaults as plain data — the result of reading them off a
33
+ * control plane adapter. This is also the non-key half of the wire payload
34
+ * (`ControlPlaneDefaultsPayload`), so the same `writeControlPlaneDefaults` path
35
+ * serves both the in-process projection and the apply-a-payload path.
36
+ */
37
+ export interface ProjectableDefaults {
38
+ connections: Connection[];
39
+ resourceServers: ResourceServer[];
40
+ hooks: Hook[];
41
+ emailProvider: EmailProvider | null;
42
+ branding: Branding | null;
43
+ promptSettings: PromptSetting | null;
44
+ }
21
45
  export interface DefaultsProjectionConfig {
22
46
  /**
23
47
  * The control plane tenant id. Projected rows are written into the target
@@ -62,6 +86,28 @@ export interface DefaultsProjectionResult {
62
86
  branding: EntityProjectionOutcome;
63
87
  promptSettings: EntityProjectionOutcome;
64
88
  }
89
+ export declare function emptyOutcome(): EntityProjectionOutcome;
90
+ export declare function emptyResult(tenantId: string): DefaultsProjectionResult;
91
+ export declare function isInheritableHook(hook: Hook): boolean;
92
+ /**
93
+ * Runs `op`, routing any failure either to a thrown error (loud, default) or to
94
+ * the outcome's `errors` array (when `continueOnError`).
95
+ */
96
+ export declare function attempt(outcome: EntityProjectionOutcome, label: string, continueOnError: boolean, op: () => Promise<void>): Promise<void>;
97
+ /**
98
+ * Reads the control plane's defaults off `cp` into plain data. Returns the full
99
+ * (unfiltered) set; the `is_system` / `inheritable` filters are applied on the
100
+ * write side so reads stay uniform. Entities whose flag is false are skipped
101
+ * (empty array / null) so callers don't pay for rows they won't write.
102
+ */
103
+ export declare function readControlPlaneDefaults(cp: DataAdapters, cpId: string, project: ResolvedDefaultsEntities): Promise<ProjectableDefaults>;
104
+ /**
105
+ * Writes `data` into `target` under `cpId`, upserting each row by its stable id
106
+ * so re-runs converge. Resource servers are filtered to `is_system` and hooks
107
+ * to `inheritable` — the same set the runtime fallback reads — so passing the
108
+ * full (unfiltered) read result here is safe. `result` is mutated in place.
109
+ */
110
+ export declare function writeControlPlaneDefaults(data: ProjectableDefaults, target: DataAdapters, cpId: string, project: ResolvedDefaultsEntities, continueOnError: boolean, result: DefaultsProjectionResult): Promise<void>;
65
111
  /**
66
112
  * Projects the control plane tenant's inheritable defaults into a single target
67
113
  * tenant's database, writing the rows under the control plane tenant id so the
@@ -1 +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"}
1
+ {"version":3,"file":"defaults-projection.d.ts","sourceRoot":"","sources":["../../../src/rollout/defaults-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,aAAa,EAKd,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,4EAA4E;AAC5E,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,0BAA+B,GACxC,wBAAwB,CAS1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAA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AAC,CAyC9B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,wBAAwB,EACjC,eAAe,EAAE,OAAO,EACxB,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqGf;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,wBAAwB,EAChC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,wBAAwB,CAAC,CA0BnC"}
@@ -1,6 +1,8 @@
1
1
  import { DefaultsProjectionConfig, DefaultsProjectionResult } from "./defaults-projection";
2
- export type { DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, } from "./defaults-projection";
2
+ export type { DefaultsProjectionConfig, DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, ProjectableDefaults, } from "./defaults-projection";
3
3
  export { projectControlPlaneDefaults } from "./defaults-projection";
4
+ export type { ControlPlaneDefaultsPayload, ControlPlaneDefaultsApplyResult, ControlPlaneTenantSeed, DefaultsPayloadEntities, } from "./payload";
5
+ export { buildControlPlaneDefaultsPayload, applyControlPlaneDefaultsPayload, } from "./payload";
4
6
  /**
5
7
  * A control plane rollout applies the control plane's state to one or more
6
8
  * tenant databases. `syncDefaults` is the only operation today; schema
@@ -1 +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
+ {"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,EACvB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,YAAY,EACV,2BAA2B,EAC3B,+BAA+B,EAC/B,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;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"}
@@ -0,0 +1,91 @@
1
+ import { DataAdapters, SigningKey } from "authhero";
2
+ import { DefaultsProjectionEntities, DefaultsProjectionResult, EntityProjectionOutcome, ProjectableDefaults } from "./defaults-projection";
3
+ /**
4
+ * Entity flags for the wire payload — the six default entities plus signing
5
+ * keys and tenant rows, which only flow through the payload (build + apply),
6
+ * never through the in-process `projectControlPlaneDefaults`.
7
+ */
8
+ export type DefaultsPayloadEntities = DefaultsProjectionEntities & {
9
+ signingKeys?: boolean;
10
+ /**
11
+ * Seed the FK-target `tenants` rows into the tenant DB before writing the
12
+ * keyed defaults. Defaults to `true`. See {@link ControlPlaneTenantSeed}.
13
+ */
14
+ tenants?: boolean;
15
+ };
16
+ /**
17
+ * A minimal `tenants` row the payload carries so the tenant DB has the foreign
18
+ * key targets every other write depends on. D1 enforces the
19
+ * `tenant_id -> tenants(id)` FK, so a freshly provisioned tenant DB (which only
20
+ * has the empty `tenants` table the migrations create) rejects every
21
+ * tenant-scoped insert until these rows exist:
22
+ *
23
+ * 1. the **control-plane tenant id** — the projected defaults
24
+ * (connections / resource servers / hooks / …) are keyed under it; and
25
+ * 2. the **target tenant's own id** — the tenant's own users / connections /
26
+ * sessions reference it.
27
+ *
28
+ * Deliberately minimal (`id` + `friendly_name`): the FK only needs the row to
29
+ * exist, `friendly_name` is the only required create field, and keeping it
30
+ * minimal avoids shipping control-plane tenant settings/secrets into a tenant
31
+ * DB. Rows are create-if-missing on apply, so a re-sync never clobbers a row a
32
+ * tenant has since edited.
33
+ */
34
+ export interface ControlPlaneTenantSeed {
35
+ id: string;
36
+ friendly_name: string;
37
+ }
38
+ /**
39
+ * Wire shape pushed from a control plane to a tenant database. Transport-
40
+ * agnostic: a Cloudflare dispatch push, an HTTP POST, or an in-process call all
41
+ * carry this same object. Built on the control plane with
42
+ * {@link buildControlPlaneDefaultsPayload} and applied on the tenant with
43
+ * {@link applyControlPlaneDefaultsPayload}.
44
+ */
45
+ export interface ControlPlaneDefaultsPayload extends ProjectableDefaults {
46
+ /**
47
+ * Control-plane shared `jwt_signing` keys, PUBLIC material only. Invariant:
48
+ * `pkcs7` (the private key) is stripped on build AND re-stripped on apply, so
49
+ * a private key can never cross the wire or land in a tenant DB. Used to
50
+ * verify tokens the control plane signed (e.g. forwarded admin tokens).
51
+ */
52
+ signingKeys: SigningKey[];
53
+ /**
54
+ * FK-target `tenants` rows upserted into the tenant DB *before* any keyed
55
+ * default, so the `tenant_id -> tenants(id)` FK resolves. See
56
+ * {@link ControlPlaneTenantSeed}.
57
+ */
58
+ tenants: ControlPlaneTenantSeed[];
59
+ }
60
+ /** Result of applying a payload — the projection result plus the key/tenant outcomes. */
61
+ export interface ControlPlaneDefaultsApplyResult extends DefaultsProjectionResult {
62
+ signingKeys: EntityProjectionOutcome;
63
+ tenants: EntityProjectionOutcome;
64
+ }
65
+ /**
66
+ * Reads the control plane's defaults + public signing keys off a control-plane
67
+ * adapter and filters them down to the inheritable, shareable set — the wire
68
+ * payload. Mirrors what `projectControlPlaneDefaults` writes, minus the write.
69
+ *
70
+ * The signing-key selection reuses authhero's `listControlPlaneKeys`
71
+ * (`-_exists_:tenant_id`) so the public-key query has a single source of truth;
72
+ * this layer only strips `pkcs7`.
73
+ */
74
+ export declare function buildControlPlaneDefaultsPayload(controlPlaneAdapters: DataAdapters, controlPlaneTenantId: string, entities?: DefaultsPayloadEntities, targetTenantId?: string): Promise<ControlPlaneDefaultsPayload>;
75
+ /**
76
+ * Applies a control-plane defaults payload to a tenant's own adapter, writing
77
+ * the rows under `controlPlaneTenantId` so the runtime fallback resolves them
78
+ * locally. Reuses the same upsert/filter path as `projectControlPlaneDefaults`
79
+ * (via `writeControlPlaneDefaults`) and adds the dedicated signing-key path.
80
+ *
81
+ * The payload is a trust boundary: every singleton is re-parsed with its schema
82
+ * and signing keys are re-stripped of `pkcs7` before anything is written.
83
+ *
84
+ * `result.tenantId` is the control-plane tenant id the rows are keyed under
85
+ * (the target adapter already _is_ the tenant's database).
86
+ */
87
+ export declare function applyControlPlaneDefaultsPayload(payload: ControlPlaneDefaultsPayload, targetAdapters: DataAdapters, controlPlaneTenantId: string, options?: {
88
+ continueOnError?: boolean;
89
+ entities?: DefaultsPayloadEntities;
90
+ }): Promise<ControlPlaneDefaultsApplyResult>;
91
+ //# sourceMappingURL=payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/rollout/payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EAKX,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EAQpB,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,0BAA0B,GAAG;IACjE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;;;;OAKG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;;;OAIG;IACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;CACnC;AAED,yFAAyF;AACzF,MAAM,WAAW,+BAAgC,SAAQ,wBAAwB;IAC/E,WAAW,EAAE,uBAAuB,CAAC;IACrC,OAAO,EAAE,uBAAuB,CAAC;CAClC;AAkBD;;;;;;;;GAQG;AACH,wBAAsB,gCAAgC,CACpD,oBAAoB,EAAE,YAAY,EAClC,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,GAAE,uBAA4B,EACtC,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,2BAA2B,CAAC,CAqCtC;AA0FD;;;;;;;;;;;GAWG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,2BAA2B,EACpC,cAAc,EAAE,YAAY,EAC5B,oBAAoB,EAAE,MAAM,EAC5B,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CAC/B,GACL,OAAO,CAAC,+BAA+B,CAAC,CAoD1C"}
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.24.1",
14
+ "version": "14.25.1",
15
15
  "description": "Multi-tenancy support for AuthHero with organization-based access control and per-tenant database isolation",
16
16
  "files": [
17
17
  "dist"
@@ -38,7 +38,7 @@
38
38
  "vitest": "^4.1.7",
39
39
  "@authhero/adapter-interfaces": "3.1.1",
40
40
  "@authhero/kysely-adapter": "11.8.9",
41
- "authhero": "8.4.1"
41
+ "authhero": "8.7.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "zod": "^4.4.3"