@voltro/plugin-multitenancy 0.32.0 → 0.34.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/CHANGELOG.md +2006 -0
- package/dist/guard.d.ts +16 -0
- package/dist/index.d.ts +16 -0
- package/package.json +6 -5
package/dist/guard.d.ts
CHANGED
|
@@ -5,6 +5,22 @@ import { Subject } from '@voltro/protocol';
|
|
|
5
5
|
* Guard a tenant-scoped mutation against cross-tenant spoofing. Throws
|
|
6
6
|
* `TenantMismatch` if `input.tenantId` doesn't equal `subject.tenantId`.
|
|
7
7
|
*
|
|
8
|
+
* **What this does NOT cover, and what covers it instead.** This checks a
|
|
9
|
+
* CLAIMED `input.tenantId` — it can only fire on a mutation that carries one and
|
|
10
|
+
* whose author remembered to call it. It is a convention, not a boundary. The
|
|
11
|
+
* boundary is in the store middleware: every write is tenant-enforced by
|
|
12
|
+
* construction — inserts auto-stamp `tenantId` and refuse a null tenant, reads /
|
|
13
|
+
* `updateMany` / `deleteMany` AND-merge `eq('tenantId', …)`, and a KEYED-BY-PK
|
|
14
|
+
* write (`ctx.store.update(table, id, …)`, `delete`, `hardDelete`, `patchJson`)
|
|
15
|
+
* resolves its target row inside the caller's tenant and fails with
|
|
16
|
+
* `TenantRowNotFound` otherwise. A mutation that takes a row id from user input
|
|
17
|
+
* is therefore safe whether or not it calls this.
|
|
18
|
+
*
|
|
19
|
+
* Reach for it when the input carries an explicit `tenantId` you are about to
|
|
20
|
+
* USE (an admin form, a webhook payload) and you want a typed, early
|
|
21
|
+
* `TenantMismatch` at the top of the handler rather than a store-level refusal
|
|
22
|
+
* partway through.
|
|
23
|
+
*
|
|
8
24
|
* The subject's tenantId may be null (anonymous subjects without a
|
|
9
25
|
* tenant scope); those callers can't write to ANY tenant so the guard
|
|
10
26
|
* always throws — anonymous + tenant-scoped writes need a different
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,22 @@ import { Subject } from '@voltro/protocol';
|
|
|
9
9
|
* Guard a tenant-scoped mutation against cross-tenant spoofing. Throws
|
|
10
10
|
* `TenantMismatch` if `input.tenantId` doesn't equal `subject.tenantId`.
|
|
11
11
|
*
|
|
12
|
+
* **What this does NOT cover, and what covers it instead.** This checks a
|
|
13
|
+
* CLAIMED `input.tenantId` — it can only fire on a mutation that carries one and
|
|
14
|
+
* whose author remembered to call it. It is a convention, not a boundary. The
|
|
15
|
+
* boundary is in the store middleware: every write is tenant-enforced by
|
|
16
|
+
* construction — inserts auto-stamp `tenantId` and refuse a null tenant, reads /
|
|
17
|
+
* `updateMany` / `deleteMany` AND-merge `eq('tenantId', …)`, and a KEYED-BY-PK
|
|
18
|
+
* write (`ctx.store.update(table, id, …)`, `delete`, `hardDelete`, `patchJson`)
|
|
19
|
+
* resolves its target row inside the caller's tenant and fails with
|
|
20
|
+
* `TenantRowNotFound` otherwise. A mutation that takes a row id from user input
|
|
21
|
+
* is therefore safe whether or not it calls this.
|
|
22
|
+
*
|
|
23
|
+
* Reach for it when the input carries an explicit `tenantId` you are about to
|
|
24
|
+
* USE (an admin form, a webhook payload) and you want a typed, early
|
|
25
|
+
* `TenantMismatch` at the top of the handler rather than a store-level refusal
|
|
26
|
+
* partway through.
|
|
27
|
+
*
|
|
12
28
|
* The subject's tenantId may be null (anonymous subjects without a
|
|
13
29
|
* tenant scope); those callers can't write to ANY tenant so the guard
|
|
14
30
|
* always throws — anonymous + tenant-scoped writes need a different
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-multitenancy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Multi-tenancy plugin — ships the `tenant()` schema mixin (auto-scopes reads, fills tenantId on inserts) plus the `assertOwnTenant` write-guard and `TenantMismatch` typed error.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"types": "./dist/guard.d.ts",
|
|
33
33
|
"import": "./dist/guard.js",
|
|
34
34
|
"default": "./dist/guard.js"
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json"
|
|
36
37
|
},
|
|
37
38
|
"main": "./dist/index.js",
|
|
38
39
|
"module": "./dist/index.js",
|
|
@@ -42,9 +43,9 @@
|
|
|
42
43
|
"node": ">=24.0.0"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@voltro/database": "0.
|
|
46
|
-
"@voltro/plugin-audit": "0.
|
|
47
|
-
"@voltro/protocol": "0.
|
|
46
|
+
"@voltro/database": "0.34.0",
|
|
47
|
+
"@voltro/plugin-audit": "0.34.0",
|
|
48
|
+
"@voltro/protocol": "0.34.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"effect": "^3.22.0"
|