@lunora/server 1.0.0-alpha.3 → 1.0.0-alpha.31
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/LICENSE.md +6 -0
- package/README.md +50 -0
- package/dist/data-model.d.mts +231 -156
- package/dist/data-model.d.ts +231 -156
- package/dist/index.d.mts +1191 -811
- package/dist/index.d.ts +1191 -811
- package/dist/index.mjs +20 -15
- package/dist/packem_shared/{LunoraEnvError-DjFkpkSP.mjs → LunoraEnvError-BGmd1Qs0.mjs} +4 -4
- package/dist/packem_shared/LunoraError-WbxmrpxR.mjs +9 -0
- package/dist/packem_shared/{PRESENCE_DEFAULT_TTL_MS-UQuUI5sV.mjs → PRESENCE_DEFAULT_TTL_MS-Cr0i4mTv.mjs} +5 -5
- package/dist/packem_shared/{bindOrm-Ce57S3N9.mjs → bindOrm-CaY7Wq9Z.mjs} +42 -23
- package/dist/packem_shared/buildRlsReadRegistry-2uk_GfiH.mjs +107 -0
- package/dist/packem_shared/{composePluginMiddleware-Ck5_TUO8.mjs → composePluginMiddleware-z62dttBo.mjs} +11 -8
- package/dist/packem_shared/{createPolicyDsl-De67zPDS.mjs → createPolicyDsl-By3QB4he.mjs} +4 -1
- package/dist/packem_shared/createSecrets-DwaR2rNG.mjs +58 -0
- package/dist/packem_shared/{defineAggregateIndex-B20MIOmj.mjs → defineAggregateIndex-cdo0g-un.mjs} +108 -8
- package/dist/packem_shared/defineIdentity-DiX4zM9x.mjs +35 -0
- package/dist/packem_shared/{defineMigration-CAJLr6fx.mjs → defineMigration-Hx01yIht.mjs} +3 -1
- package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +11 -0
- package/dist/packem_shared/defineShape-C5scNOrf.mjs +18 -0
- package/dist/packem_shared/{defineStorageRule-qu0mpilX.mjs → defineStorageRule-B5nL4Z1P.mjs} +4 -1
- package/dist/packem_shared/functions-Di9FUNkf.mjs +5 -0
- package/dist/packem_shared/{httpAction-B7FYUEgr.mjs → httpAction-DCXoYPIk.mjs} +42 -27
- package/dist/packem_shared/{initLunora-CATvPsVt.mjs → initLunora-D0Wuki7S.mjs} +36 -7
- package/dist/packem_shared/{mask-eCUYOwhd.mjs → mask-BepaW7YN.mjs} +132 -9
- package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +13 -0
- package/dist/packem_shared/{protectPublic-BjFkQ_Or.mjs → protectPublic-BlcGpiRc.mjs} +1 -1
- package/dist/packem_shared/{rls-Bi9HiyDC.mjs → rls-BaDQf7MG.mjs} +34 -6
- package/dist/packem_shared/{run-middleware-CYQOuoV6.mjs → run-middleware-I6EiQfxL.mjs} +3 -1
- package/dist/packem_shared/{storageRules-4a30FSpI.mjs → storageRules-6QxzDOcx.mjs} +1 -1
- package/dist/packem_shared/types.d-C4CMJK8x.d.mts +141 -0
- package/dist/packem_shared/types.d-DdYF8E18.d.ts +141 -0
- package/dist/rls/testing.d.mts +31 -31
- package/dist/rls/testing.d.ts +31 -31
- package/dist/rls/testing.mjs +1 -1
- package/dist/types.d.mts +957 -433
- package/dist/types.d.ts +957 -433
- package/package.json +6 -5
- package/dist/packem_shared/LunoraError-DhggBJZF.mjs +0 -51
- package/dist/packem_shared/types.d-BDY0FYHK.d.ts +0 -135
- package/dist/packem_shared/types.d-DmvyEMD6.d.mts +0 -135
package/dist/rls/testing.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-
|
|
1
|
+
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-C4CMJK8x.mjs";
|
|
2
2
|
import "../data-model.mjs";
|
|
3
3
|
/**
|
|
4
|
-
* The slice of a request identity a policy reads. Mirrors the
|
|
5
|
-
* `PolicyContext.auth` shape the middleware builds at request time — every
|
|
6
|
-
* field is optional and defaults the same way the middleware defaults it
|
|
7
|
-
* (`userId`/`identity` → `null`, `roles` → `[]`).
|
|
8
|
-
*/
|
|
4
|
+
* The slice of a request identity a policy reads. Mirrors the
|
|
5
|
+
* `PolicyContext.auth` shape the middleware builds at request time — every
|
|
6
|
+
* field is optional and defaults the same way the middleware defaults it
|
|
7
|
+
* (`userId`/`identity` → `null`, `roles` → `[]`).
|
|
8
|
+
*/
|
|
9
9
|
interface TestIdentity {
|
|
10
10
|
/** Raw identity claims a policy may branch on (`auth.identity.email`, …). */
|
|
11
11
|
identity?: Record<string, unknown> | null;
|
|
@@ -17,32 +17,32 @@ interface TestIdentity {
|
|
|
17
17
|
/** Options for {@link expectPolicy}. */
|
|
18
18
|
interface ExpectPolicyOptions<Context = unknown> {
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* The procedure context a policy reads via `ctx` (e.g. `ctx.orgId`). Held
|
|
21
|
+
* for the whole harness; pass a fresh `expectPolicy(..., { ctx })` for a
|
|
22
|
+
* different context. Defaults to an empty object.
|
|
23
|
+
*/
|
|
24
24
|
ctx?: Context;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* Role→permission grants backing `auth.can(...)` — the same registry passed
|
|
27
|
+
* to `rls(policies, { roles })`. A role not listed here grants nothing, so
|
|
28
|
+
* `can(...)` fails closed exactly as it does in production.
|
|
29
|
+
*/
|
|
30
30
|
roles?: ReadonlyArray<Role>;
|
|
31
31
|
}
|
|
32
32
|
/** A harness bound to one identity; answers can/cannot for an `(op, table, row)`. */
|
|
33
33
|
interface BoundPolicyAssertion {
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
* Would this identity be **allowed** the operation on `row`?
|
|
36
|
+
*
|
|
37
|
+
* - `read` — is `row` visible? `true` when the table has no read policy (unrestricted), or when the effective read `baseWhere` matches `row`.
|
|
38
|
+
* - `insert` — is the candidate `row` allowed by the insert policies?
|
|
39
|
+
* - `update` / `delete` — is the pre-write `row` allowed? For `update` pass `nextRow` to also assert the post-image (WITH CHECK) — a policy can't be satisfied by the old row while the patch reassigns it to another tenant.
|
|
40
|
+
*
|
|
41
|
+
* A table with **no** policy in the list is unguarded → always `true`
|
|
42
|
+
* (mirrors the middleware passing such tables through unwrapped). A table
|
|
43
|
+
* that participates but declares no policy for the write `op` denies
|
|
44
|
+
* (default-DENY), exactly as the middleware does.
|
|
45
|
+
*/
|
|
46
46
|
can: (op: PolicyOperation, table: string, row?: Record<string, unknown>, nextRow?: Record<string, unknown>) => boolean;
|
|
47
47
|
/** Negation of {@link BoundPolicyAssertion.can} — reads more naturally in a denial test. */
|
|
48
48
|
cannot: (op: PolicyOperation, table: string, row?: Record<string, unknown>, nextRow?: Record<string, unknown>) => boolean;
|
|
@@ -53,11 +53,11 @@ interface PolicyAssertion {
|
|
|
53
53
|
as: (identity?: TestIdentity | null) => BoundPolicyAssertion;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* Build an in-process assertion harness over a policy set. Reuses the `rls()`
|
|
57
|
-
* middleware's own evaluation primitives, so an assertion is faithful to
|
|
58
|
-
* request-time behaviour by construction.
|
|
59
|
-
* @param policies the policy list, typically from `definePolicies([...])`.
|
|
60
|
-
* @param options role registry + procedure `ctx` (see {@link ExpectPolicyOptions}).
|
|
61
|
-
*/
|
|
56
|
+
* Build an in-process assertion harness over a policy set. Reuses the `rls()`
|
|
57
|
+
* middleware's own evaluation primitives, so an assertion is faithful to
|
|
58
|
+
* request-time behaviour by construction.
|
|
59
|
+
* @param policies the policy list, typically from `definePolicies([...])`.
|
|
60
|
+
* @param options role registry + procedure `ctx` (see {@link ExpectPolicyOptions}).
|
|
61
|
+
*/
|
|
62
62
|
declare const expectPolicy: <Context = unknown>(policies: ReadonlyArray<Policy<Context>>, options?: ExpectPolicyOptions<Context>) => PolicyAssertion;
|
|
63
63
|
export { BoundPolicyAssertion, ExpectPolicyOptions, PolicyAssertion, TestIdentity, expectPolicy };
|
package/dist/rls/testing.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-
|
|
1
|
+
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-DdYF8E18.js";
|
|
2
2
|
import "../data-model.js";
|
|
3
3
|
/**
|
|
4
|
-
* The slice of a request identity a policy reads. Mirrors the
|
|
5
|
-
* `PolicyContext.auth` shape the middleware builds at request time — every
|
|
6
|
-
* field is optional and defaults the same way the middleware defaults it
|
|
7
|
-
* (`userId`/`identity` → `null`, `roles` → `[]`).
|
|
8
|
-
*/
|
|
4
|
+
* The slice of a request identity a policy reads. Mirrors the
|
|
5
|
+
* `PolicyContext.auth` shape the middleware builds at request time — every
|
|
6
|
+
* field is optional and defaults the same way the middleware defaults it
|
|
7
|
+
* (`userId`/`identity` → `null`, `roles` → `[]`).
|
|
8
|
+
*/
|
|
9
9
|
interface TestIdentity {
|
|
10
10
|
/** Raw identity claims a policy may branch on (`auth.identity.email`, …). */
|
|
11
11
|
identity?: Record<string, unknown> | null;
|
|
@@ -17,32 +17,32 @@ interface TestIdentity {
|
|
|
17
17
|
/** Options for {@link expectPolicy}. */
|
|
18
18
|
interface ExpectPolicyOptions<Context = unknown> {
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* The procedure context a policy reads via `ctx` (e.g. `ctx.orgId`). Held
|
|
21
|
+
* for the whole harness; pass a fresh `expectPolicy(..., { ctx })` for a
|
|
22
|
+
* different context. Defaults to an empty object.
|
|
23
|
+
*/
|
|
24
24
|
ctx?: Context;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* Role→permission grants backing `auth.can(...)` — the same registry passed
|
|
27
|
+
* to `rls(policies, { roles })`. A role not listed here grants nothing, so
|
|
28
|
+
* `can(...)` fails closed exactly as it does in production.
|
|
29
|
+
*/
|
|
30
30
|
roles?: ReadonlyArray<Role>;
|
|
31
31
|
}
|
|
32
32
|
/** A harness bound to one identity; answers can/cannot for an `(op, table, row)`. */
|
|
33
33
|
interface BoundPolicyAssertion {
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
* Would this identity be **allowed** the operation on `row`?
|
|
36
|
+
*
|
|
37
|
+
* - `read` — is `row` visible? `true` when the table has no read policy (unrestricted), or when the effective read `baseWhere` matches `row`.
|
|
38
|
+
* - `insert` — is the candidate `row` allowed by the insert policies?
|
|
39
|
+
* - `update` / `delete` — is the pre-write `row` allowed? For `update` pass `nextRow` to also assert the post-image (WITH CHECK) — a policy can't be satisfied by the old row while the patch reassigns it to another tenant.
|
|
40
|
+
*
|
|
41
|
+
* A table with **no** policy in the list is unguarded → always `true`
|
|
42
|
+
* (mirrors the middleware passing such tables through unwrapped). A table
|
|
43
|
+
* that participates but declares no policy for the write `op` denies
|
|
44
|
+
* (default-DENY), exactly as the middleware does.
|
|
45
|
+
*/
|
|
46
46
|
can: (op: PolicyOperation, table: string, row?: Record<string, unknown>, nextRow?: Record<string, unknown>) => boolean;
|
|
47
47
|
/** Negation of {@link BoundPolicyAssertion.can} — reads more naturally in a denial test. */
|
|
48
48
|
cannot: (op: PolicyOperation, table: string, row?: Record<string, unknown>, nextRow?: Record<string, unknown>) => boolean;
|
|
@@ -53,11 +53,11 @@ interface PolicyAssertion {
|
|
|
53
53
|
as: (identity?: TestIdentity | null) => BoundPolicyAssertion;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* Build an in-process assertion harness over a policy set. Reuses the `rls()`
|
|
57
|
-
* middleware's own evaluation primitives, so an assertion is faithful to
|
|
58
|
-
* request-time behaviour by construction.
|
|
59
|
-
* @param policies the policy list, typically from `definePolicies([...])`.
|
|
60
|
-
* @param options role registry + procedure `ctx` (see {@link ExpectPolicyOptions}).
|
|
61
|
-
*/
|
|
56
|
+
* Build an in-process assertion harness over a policy set. Reuses the `rls()`
|
|
57
|
+
* middleware's own evaluation primitives, so an assertion is faithful to
|
|
58
|
+
* request-time behaviour by construction.
|
|
59
|
+
* @param policies the policy list, typically from `definePolicies([...])`.
|
|
60
|
+
* @param options role registry + procedure `ctx` (see {@link ExpectPolicyOptions}).
|
|
61
|
+
*/
|
|
62
62
|
declare const expectPolicy: <Context = unknown>(policies: ReadonlyArray<Policy<Context>>, options?: ExpectPolicyOptions<Context>) => PolicyAssertion;
|
|
63
63
|
export { BoundPolicyAssertion, ExpectPolicyOptions, PolicyAssertion, TestIdentity, expectPolicy };
|
package/dist/rls/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { indexRolePermissions, computeReadBaseWhere, matchesWhere, evaluateWrite, permissionName } from '../packem_shared/rls-
|
|
1
|
+
import { indexRolePermissions, computeReadBaseWhere, matchesWhere, evaluateWrite, permissionName } from '../packem_shared/rls-BaDQf7MG.mjs';
|
|
2
2
|
|
|
3
3
|
const expectPolicy = (policies, options = {}) => {
|
|
4
4
|
const rolePermissions = indexRolePermissions(options.roles);
|