@aventara/access 0.0.0-stage → 1.0.0-rc.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.
- package/CHANGELOG.md +877 -0
- package/LICENSE +91 -0
- package/LICENSE-ADDITIONAL-PERMISSION.md +9 -0
- package/README.md +2536 -2
- package/dist/access/access-options.d.ts +74 -0
- package/dist/access/access-options.js +5 -0
- package/dist/access/access.error.d.ts +35 -0
- package/dist/access/access.error.js +11 -0
- package/dist/access/access.factory.d.ts +275 -0
- package/dist/access/access.factory.js +440 -0
- package/dist/access/better-auth.hardening.d.ts +120 -0
- package/dist/access/better-auth.hardening.js +420 -0
- package/dist/access/better-auth.loader.d.ts +67 -0
- package/dist/access/better-auth.loader.js +65 -0
- package/dist/access/better-auth.range.d.ts +9 -0
- package/dist/access/better-auth.range.js +28 -0
- package/dist/access/better-auth.require.d.ts +90 -0
- package/dist/access/better-auth.require.js +6 -0
- package/dist/access/better-auth.require.node.d.ts +7 -0
- package/dist/access/better-auth.require.node.js +52 -0
- package/dist/access/claims.mapper.d.ts +79 -0
- package/dist/access/claims.mapper.js +152 -0
- package/dist/access/key-set.cache.d.ts +10 -0
- package/dist/access/key-set.cache.js +63 -0
- package/dist/access/policies-block.checker.d.ts +64 -0
- package/dist/access/policies-block.checker.js +138 -0
- package/dist/access/principal.subject.d.ts +22 -0
- package/dist/access/principal.subject.js +89 -0
- package/dist/access/profile.policy.d.ts +74 -0
- package/dist/access/profile.policy.js +110 -0
- package/dist/access/request.state.d.ts +89 -0
- package/dist/access/request.state.js +266 -0
- package/dist/access/session.hooks.d.ts +114 -0
- package/dist/access/session.hooks.js +258 -0
- package/dist/access/token.verifier.d.ts +35 -0
- package/dist/access/token.verifier.js +69 -0
- package/dist/access-schema.d.ts +48 -0
- package/dist/access-schema.js +5 -0
- package/dist/access-warning.emitter.d.ts +4 -0
- package/dist/access-warning.emitter.js +24 -0
- package/dist/access.builder.d.ts +340 -0
- package/dist/access.builder.js +75 -0
- package/dist/access.engine.d.ts +155 -0
- package/dist/access.engine.js +477 -0
- package/dist/audit/audit-event.d.ts +135 -0
- package/dist/audit/audit-event.js +8 -0
- package/dist/audit/audit.log.d.ts +122 -0
- package/dist/audit/audit.log.js +345 -0
- package/dist/audit/audit.schema.d.ts +143 -0
- package/dist/audit/audit.schema.js +50 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.js +2 -0
- package/dist/aventara-where.translator.d.ts +19 -0
- package/dist/aventara-where.translator.js +87 -0
- package/dist/beacon/beacon.check.d.ts +59 -0
- package/dist/beacon/beacon.check.js +128 -0
- package/dist/beacon/beacon.schema.d.ts +41 -0
- package/dist/beacon/beacon.schema.js +48 -0
- package/dist/beacon/beacon.store.d.ts +29 -0
- package/dist/beacon/beacon.store.js +78 -0
- package/dist/better-auth/access.client-plugin.d.ts +75 -0
- package/dist/better-auth/access.client-plugin.js +133 -0
- package/dist/better-auth/access.plugin.d.ts +164 -0
- package/dist/better-auth/access.plugin.js +348 -0
- package/dist/better-auth/access.provider.d.ts +80 -0
- package/dist/better-auth/access.provider.js +100 -0
- package/dist/better-auth/index.d.ts +7 -0
- package/dist/better-auth/index.js +4 -0
- package/dist/better-auth/organization.bridge.d.ts +66 -0
- package/dist/better-auth/organization.bridge.js +144 -0
- package/dist/canonical-json.writer.d.ts +12 -0
- package/dist/canonical-json.writer.js +30 -0
- package/dist/cli/avaccess.bin.d.ts +2 -0
- package/dist/cli/avaccess.bin.js +26 -0
- package/dist/cli/avaccess.program.d.ts +15 -0
- package/dist/cli/avaccess.program.js +166 -0
- package/dist/cli/beacon-pins.file.d.ts +14 -0
- package/dist/cli/beacon-pins.file.js +62 -0
- package/dist/cli/beacon.loader.d.ts +20 -0
- package/dist/cli/beacon.loader.js +71 -0
- package/dist/cli/cli.context.d.ts +49 -0
- package/dist/cli/cli.context.js +66 -0
- package/dist/cli/diff.command.d.ts +2 -0
- package/dist/cli/diff.command.js +66 -0
- package/dist/cli/generate.command.d.ts +2 -0
- package/dist/cli/generate.command.js +82 -0
- package/dist/cli/keys.command.d.ts +2 -0
- package/dist/cli/keys.command.js +96 -0
- package/dist/cli/lock.file.d.ts +31 -0
- package/dist/cli/lock.file.js +181 -0
- package/dist/cli/module.loader.d.ts +13 -0
- package/dist/cli/module.loader.js +63 -0
- package/dist/cli/policies.diff.d.ts +16 -0
- package/dist/cli/policies.diff.js +101 -0
- package/dist/cli/pull.command.d.ts +2 -0
- package/dist/cli/pull.command.js +234 -0
- package/dist/cli/push.command.d.ts +2 -0
- package/dist/cli/push.command.js +59 -0
- package/dist/cli/registry.client.d.ts +63 -0
- package/dist/cli/registry.client.js +287 -0
- package/dist/cli/schema.command.d.ts +2 -0
- package/dist/cli/schema.command.js +60 -0
- package/dist/cli/serve.command.d.ts +6 -0
- package/dist/cli/serve.command.js +200 -0
- package/dist/cli/status.command.d.ts +2 -0
- package/dist/cli/status.command.js +31 -0
- package/dist/cli/translator.flag.d.ts +6 -0
- package/dist/cli/translator.flag.js +24 -0
- package/dist/cli/verify.command.d.ts +2 -0
- package/dist/cli/verify.command.js +40 -0
- package/dist/client/access-client.factory.d.ts +92 -0
- package/dist/client/access-client.factory.js +269 -0
- package/dist/client/access-verbs.schema.d.ts +66 -0
- package/dist/client/access-verbs.schema.js +159 -0
- package/dist/client/verb-rate.limiter.d.ts +116 -0
- package/dist/client/verb-rate.limiter.js +358 -0
- package/dist/foreign/foreign-facts.d.ts +30 -0
- package/dist/foreign/foreign-facts.js +75 -0
- package/dist/foreign/foreign.merger.d.ts +10 -0
- package/dist/foreign/foreign.merger.js +52 -0
- package/dist/foreign-references.check.d.ts +6 -0
- package/dist/foreign-references.check.js +131 -0
- package/dist/generator/client.emitter.d.ts +28 -0
- package/dist/generator/client.emitter.js +411 -0
- package/dist/generator/copied-modules.reader.d.ts +14 -0
- package/dist/generator/copied-modules.reader.js +80 -0
- package/dist/generator/namespace.facts.d.ts +28 -0
- package/dist/generator/namespace.facts.js +32 -0
- package/dist/generator/orm.translator.d.ts +48 -0
- package/dist/generator/orm.translator.js +29 -0
- package/dist/generator/prisma7/prisma-schema.reader.d.ts +9 -0
- package/dist/generator/prisma7/prisma-schema.reader.js +394 -0
- package/dist/generator/prisma7/prisma-where.translator.d.ts +73 -0
- package/dist/generator/prisma7/prisma-where.translator.js +138 -0
- package/dist/generator/prisma7/prisma7.translator.d.ts +2 -0
- package/dist/generator/prisma7/prisma7.translator.js +87 -0
- package/dist/generator/schema.emitter.d.ts +14 -0
- package/dist/generator/schema.emitter.js +23 -0
- package/dist/generator/tsconfig.reader.d.ts +44 -0
- package/dist/generator/tsconfig.reader.js +110 -0
- package/dist/generator/typescript-literal.writer.d.ts +5 -0
- package/dist/generator/typescript-literal.writer.js +42 -0
- package/dist/guardrails/guardrails-contract.d.ts +45 -0
- package/dist/guardrails/guardrails-contract.js +12 -0
- package/dist/guardrails/guardrails.builder.d.ts +48 -0
- package/dist/guardrails/guardrails.builder.js +32 -0
- package/dist/guardrails/guardrails.compiler.d.ts +10 -0
- package/dist/guardrails/guardrails.compiler.js +254 -0
- package/dist/guardrails/guardrails.composer.d.ts +7 -0
- package/dist/guardrails/guardrails.composer.js +95 -0
- package/dist/guardrails/guardrails.hash.d.ts +10 -0
- package/dist/guardrails/guardrails.hash.js +38 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +6 -0
- package/dist/kiosk/kiosk-verbs.schema.d.ts +19 -0
- package/dist/kiosk/kiosk-verbs.schema.js +61 -0
- package/dist/kiosk/kiosk.plugin.d.ts +217 -0
- package/dist/kiosk/kiosk.plugin.js +877 -0
- package/dist/kiosk/kiosk.schema.d.ts +176 -0
- package/dist/kiosk/kiosk.schema.js +101 -0
- package/dist/kiosk/kiosk.store.d.ts +171 -0
- package/dist/kiosk/kiosk.store.js +478 -0
- package/dist/kiosk/lan-range.policy.d.ts +31 -0
- package/dist/kiosk/lan-range.policy.js +113 -0
- package/dist/kiosk/pin.policy.d.ts +9 -0
- package/dist/kiosk/pin.policy.js +143 -0
- package/dist/kiosk/session-use.marker.d.ts +4 -0
- package/dist/kiosk/session-use.marker.js +16 -0
- package/dist/lock/lock-contract.d.ts +38 -0
- package/dist/lock/lock-contract.js +67 -0
- package/dist/lock/lock.verifier.d.ts +27 -0
- package/dist/lock/lock.verifier.js +62 -0
- package/dist/mcp/agent-scope.gate.d.ts +13 -0
- package/dist/mcp/agent-scope.gate.js +75 -0
- package/dist/mcp/agent.grant.d.ts +40 -0
- package/dist/mcp/agent.grant.js +92 -0
- package/dist/mcp/mcp-options.d.ts +60 -0
- package/dist/mcp/mcp-options.js +72 -0
- package/dist/oauth/access-token.verifier.d.ts +66 -0
- package/dist/oauth/access-token.verifier.js +201 -0
- package/dist/oauth/oauth-provider.hardening.d.ts +62 -0
- package/dist/oauth/oauth-provider.hardening.js +261 -0
- package/dist/passwords/argon2id.hasher.d.ts +97 -0
- package/dist/passwords/argon2id.hasher.js +256 -0
- package/dist/passwords/node-rs-argon2.adapter.d.ts +25 -0
- package/dist/passwords/node-rs-argon2.adapter.js +42 -0
- package/dist/passwords/passwords.options.d.ts +79 -0
- package/dist/passwords/passwords.options.js +212 -0
- package/dist/policies-contract.d.ts +219 -0
- package/dist/policies-contract.js +8 -0
- package/dist/policies.compiler.d.ts +38 -0
- package/dist/policies.compiler.js +1433 -0
- package/dist/policies.decider.d.ts +103 -0
- package/dist/policies.decider.js +390 -0
- package/dist/policies.hash.d.ts +10 -0
- package/dist/policies.hash.js +54 -0
- package/dist/predicate.evaluator.d.ts +62 -0
- package/dist/predicate.evaluator.js +378 -0
- package/dist/random-secret.generator.d.ts +2 -0
- package/dist/random-secret.generator.js +15 -0
- package/dist/read-governed-unique.check.d.ts +3 -0
- package/dist/read-governed-unique.check.js +21 -0
- package/dist/reference-reads.check.d.ts +16 -0
- package/dist/reference-reads.check.js +158 -0
- package/dist/registry/access.registry.d.ts +173 -0
- package/dist/registry/access.registry.js +865 -0
- package/dist/registry/beacon.ledger.d.ts +30 -0
- package/dist/registry/beacon.ledger.js +93 -0
- package/dist/registry/ownership.check.d.ts +54 -0
- package/dist/registry/ownership.check.js +221 -0
- package/dist/registry/registry.endpoints.d.ts +50 -0
- package/dist/registry/registry.endpoints.js +193 -0
- package/dist/registry/registry.key.d.ts +7 -0
- package/dist/registry/registry.key.js +13 -0
- package/dist/registry/registry.options.d.ts +13 -0
- package/dist/registry/registry.options.js +28 -0
- package/dist/registry/registry.refusal.d.ts +6 -0
- package/dist/registry/registry.refusal.js +11 -0
- package/dist/registry/registry.schema.d.ts +238 -0
- package/dist/registry/registry.schema.js +127 -0
- package/dist/resources/auth-tables.catalog.d.ts +96 -0
- package/dist/resources/auth-tables.catalog.js +110 -0
- package/dist/resources/auth-tables.guard.d.ts +106 -0
- package/dist/resources/auth-tables.guard.js +462 -0
- package/dist/scope.resolver.d.ts +144 -0
- package/dist/scope.resolver.js +529 -0
- package/dist/sha256.digest.d.ts +2 -0
- package/dist/sha256.digest.js +81 -0
- package/dist/standalone/access.server.d.ts +41 -0
- package/dist/standalone/access.server.js +301 -0
- package/dist/standalone/index.d.ts +1 -0
- package/dist/standalone/index.js +1 -0
- package/package.json +102 -3
- package/skill/SKILL.md +170 -0
- package/skill/reference/callers.md +99 -0
- package/skill/reference/errors.md +89 -0
- package/skill/reference/recipes.md +281 -0
- package/skill/reference/rules.md +153 -0
- package/skill/reference/setup.md +334 -0
- package/src/aventara-where.translator.ts +116 -0
- package/src/beacon/beacon.check.ts +204 -0
- package/src/canonical-json.writer.ts +51 -0
- package/src/generator/prisma7/prisma-where.translator.ts +243 -0
- package/src/policies-contract.ts +215 -0
- package/src/policies.decider.ts +662 -0
- package/src/predicate.evaluator.ts +574 -0
- package/src/scope.resolver.ts +819 -0
- package/src/sha256.digest.ts +85 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// The declarative policies file, format `aventara-access/policies@1`. The builder
|
|
2
|
+
// compiles to it and the engine runs from it alone. It is passive JSON: no closures,
|
|
3
|
+
// no claim values, no provider names. `@1` is frozen: a change to its shape is `policies@2` beside it, never an
|
|
4
|
+
// edit of `@1`. Its canonical byte form and hash are `policies.hash.ts`'s.
|
|
5
|
+
|
|
6
|
+
/** The format marker of every `@1` file. */
|
|
7
|
+
export const POLICIES_FORMAT = "aventara-access/policies@1";
|
|
8
|
+
|
|
9
|
+
/** The format marker of the unstable v0 files, refused by name (no users, no shim). */
|
|
10
|
+
export const RETIRED_POLICIES_FORMAT = "aventara-access/policies@0";
|
|
11
|
+
|
|
12
|
+
/** The four standard operations a rule names. */
|
|
13
|
+
export type AccessAction = "read" | "create" | "update" | "delete";
|
|
14
|
+
|
|
15
|
+
/** The layer a request runs under (core's `AvRequestOrigin`, copied by shape). */
|
|
16
|
+
export type AccessOrigin = "application" | "client" | "agent";
|
|
17
|
+
|
|
18
|
+
/** The two built-in subjects: `signedIn` (a non-null principal) and `anyone` (null included). */
|
|
19
|
+
export type AccessBuiltInSubject = "signedIn" | "anyone";
|
|
20
|
+
|
|
21
|
+
/** A literal a rule compares with. */
|
|
22
|
+
export type AccessLiteral = string | number | boolean | null;
|
|
23
|
+
|
|
24
|
+
/** A value read off the principal at question time (`me.id` → `{ principal: ["id"] }`). */
|
|
25
|
+
export type AccessPrincipalOperand = {
|
|
26
|
+
readonly principal: readonly [string, ...string[]];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** What a field comparison compares with. */
|
|
30
|
+
export type AccessOperand = AccessLiteral | AccessPrincipalOperand;
|
|
31
|
+
|
|
32
|
+
/** The comparisons a rule may make. Each maps one-to-one to an Aventara filter operator. */
|
|
33
|
+
export type AccessComparison = "eq" | "ne" | "in" | "notIn";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A row condition in Access's neutral form. Field names are the Resource's own;
|
|
37
|
+
* a relation step names its target so the file needs no schema to walk it.
|
|
38
|
+
*/
|
|
39
|
+
export type AccessPredicate =
|
|
40
|
+
| { readonly op: "true" }
|
|
41
|
+
| { readonly op: "false" }
|
|
42
|
+
| { readonly op: "and"; readonly args: readonly AccessPredicate[] }
|
|
43
|
+
| { readonly op: "or"; readonly args: readonly AccessPredicate[] }
|
|
44
|
+
| { readonly op: "not"; readonly arg: AccessPredicate }
|
|
45
|
+
| {
|
|
46
|
+
readonly op: "cmp";
|
|
47
|
+
readonly field: string;
|
|
48
|
+
readonly cmp: AccessComparison;
|
|
49
|
+
readonly value: AccessOperand | readonly AccessOperand[];
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
readonly op: "rel";
|
|
53
|
+
readonly relation: string;
|
|
54
|
+
readonly target: string;
|
|
55
|
+
readonly where: AccessPredicate;
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
readonly op: "some" | "every" | "none";
|
|
59
|
+
readonly relation: string;
|
|
60
|
+
readonly target: string;
|
|
61
|
+
readonly where: AccessPredicate;
|
|
62
|
+
}
|
|
63
|
+
| { readonly op: "role"; readonly role: string };
|
|
64
|
+
|
|
65
|
+
/** A condition on the principal alone: its claims and the request's origin. */
|
|
66
|
+
export type AccessPrincipalCondition =
|
|
67
|
+
| { readonly op: "and"; readonly args: readonly AccessPrincipalCondition[] }
|
|
68
|
+
| {
|
|
69
|
+
readonly op: "cmp";
|
|
70
|
+
readonly claim: readonly [string, ...string[]];
|
|
71
|
+
readonly cmp: "eq";
|
|
72
|
+
readonly value: AccessLiteral;
|
|
73
|
+
}
|
|
74
|
+
| { readonly op: "origin"; readonly value: AccessOrigin };
|
|
75
|
+
|
|
76
|
+
/** A role: global (read from claims) or held on a row of one Resource. */
|
|
77
|
+
export type AccessRoleDefinition =
|
|
78
|
+
| { readonly global: AccessPrincipalCondition }
|
|
79
|
+
| { readonly on: string; readonly where: AccessPredicate };
|
|
80
|
+
|
|
81
|
+
/** One grant. Any grant allows (default deny). */
|
|
82
|
+
export type AccessGrantRule = {
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly subjects: readonly string[];
|
|
85
|
+
readonly actions: readonly AccessAction[];
|
|
86
|
+
readonly resource: string;
|
|
87
|
+
/** The to-one relation whose target holds each subject's row role. */
|
|
88
|
+
readonly in?: string;
|
|
89
|
+
readonly where?: AccessPredicate;
|
|
90
|
+
/** Governed fields this grant opens, as `Resource.field`. */
|
|
91
|
+
readonly fields?: readonly string[];
|
|
92
|
+
/** Fields this grant does not let a create or update write. */
|
|
93
|
+
readonly write?: { readonly except: readonly string[] };
|
|
94
|
+
/** A condition the row an update leaves must still meet. */
|
|
95
|
+
readonly after?: AccessPredicate;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** One deny. Any deny wins over every grant. */
|
|
99
|
+
export type AccessDenyRule = {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly actions: "*" | readonly AccessAction[];
|
|
102
|
+
readonly resource: string;
|
|
103
|
+
readonly where?: AccessPredicate;
|
|
104
|
+
readonly if?: AccessPrincipalCondition;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** A relation as the engine needs it: where it leads, and the reference pairs when this end holds them. */
|
|
108
|
+
export type AccessSchemaRelationFact = {
|
|
109
|
+
readonly target: string;
|
|
110
|
+
readonly cardinality: "one" | "many";
|
|
111
|
+
readonly referenceFields?: readonly [string, ...string[]];
|
|
112
|
+
readonly references?: readonly [string, ...string[]];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/** The schema facts the engine reads, per Resource. */
|
|
116
|
+
export type AccessSchemaResourceFacts = {
|
|
117
|
+
readonly identifiers: readonly (readonly string[])[];
|
|
118
|
+
readonly fields: readonly string[];
|
|
119
|
+
/**
|
|
120
|
+
* The scalar fields that may hold NULL, when there are any. A scope negates a
|
|
121
|
+
* comparison on one of them null-safely (`NOT (f = v) OR f IS NULL`), so it keeps
|
|
122
|
+
* the rows `can` keeps.
|
|
123
|
+
*/
|
|
124
|
+
readonly nullable?: readonly string[];
|
|
125
|
+
/**
|
|
126
|
+
* The scalar fields `can` compares by their type rather than by their JavaScript
|
|
127
|
+
* value, when there are any: a `decimal` as its canonical decimal digits (a decimal
|
|
128
|
+
* object, a string and a number alike), a `datetime` as its instant, a `bigint`
|
|
129
|
+
* exactly. A file without `types` has none of them.
|
|
130
|
+
*/
|
|
131
|
+
readonly types?: {
|
|
132
|
+
readonly [field: string]: "bigint" | "datetime" | "decimal";
|
|
133
|
+
};
|
|
134
|
+
readonly relations: { readonly [relation: string]: AccessSchemaRelationFact };
|
|
135
|
+
/**
|
|
136
|
+
* The namespace that owns this Resource, when it is not this file's. A foreign
|
|
137
|
+
* Resource is read in conditions and never granted on.
|
|
138
|
+
*/
|
|
139
|
+
readonly foreign?: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** A claim's type, never its value. */
|
|
143
|
+
export type AccessClaimType = {
|
|
144
|
+
readonly scalar: "string" | "number" | "boolean";
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The `@1` policies file. `Governed` keeps the `govern` block's literal type through
|
|
149
|
+
* the builder: per Resource, the list form (each field governed for reading and
|
|
150
|
+
* writing) or the object form (a mode per field).
|
|
151
|
+
*/
|
|
152
|
+
export type AccessPolicies<
|
|
153
|
+
Governed extends {
|
|
154
|
+
readonly [resource: string]:
|
|
155
|
+
| readonly string[]
|
|
156
|
+
| { readonly [field: string]: "read" | "write" | "both" };
|
|
157
|
+
} = {
|
|
158
|
+
readonly [resource: string]: readonly string[];
|
|
159
|
+
},
|
|
160
|
+
> = {
|
|
161
|
+
readonly format: typeof POLICIES_FORMAT;
|
|
162
|
+
/** The namespace that owns this file's Resources. A single app needs none. */
|
|
163
|
+
readonly namespace?: string;
|
|
164
|
+
readonly claims: { readonly [claim: string]: AccessClaimType };
|
|
165
|
+
readonly schema: { readonly [resource: string]: AccessSchemaResourceFacts };
|
|
166
|
+
readonly roles: { readonly [role: string]: AccessRoleDefinition };
|
|
167
|
+
/** Every governed field, by Resource, whatever its mode. */
|
|
168
|
+
readonly govern: {
|
|
169
|
+
readonly [R in keyof Governed]: Governed[R] extends readonly string[]
|
|
170
|
+
? Governed[R]
|
|
171
|
+
: readonly (keyof Governed[R] & string)[];
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* The governed fields governed for one access only, by Resource: `"write"`, read by
|
|
175
|
+
* default and written only through a grant that names the field; `"read"`, written
|
|
176
|
+
* by default and read only through a grant that names it. A governed field with no
|
|
177
|
+
* entry is governed for both, and a file without `governModes` has no other kind.
|
|
178
|
+
*/
|
|
179
|
+
readonly governModes?: {
|
|
180
|
+
readonly [resource: string]: {
|
|
181
|
+
readonly [field: string]: "read" | "write";
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
readonly grants: readonly AccessGrantRule[];
|
|
185
|
+
readonly denies: readonly AccessDenyRule[];
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A policies file as a JSON import types it: `resolveJsonModule` widens `format` to
|
|
190
|
+
* `string` and each tuple to an array, so the file `avaccess pull` wrote, imported
|
|
191
|
+
* with `import policies from "./access/blog.policies.json" with { type: "json" }`,
|
|
192
|
+
* is not an `AccessPolicies`. `policies.rules` and `createAccessEngine` take it as it
|
|
193
|
+
* is: only its outline is typed, and the engine checks the rest when it is built.
|
|
194
|
+
*/
|
|
195
|
+
export type AccessPoliciesJson<
|
|
196
|
+
Governed extends {
|
|
197
|
+
readonly [resource: string]:
|
|
198
|
+
| readonly string[]
|
|
199
|
+
| { readonly [field: string]: "read" | "write" | "both" };
|
|
200
|
+
} = {
|
|
201
|
+
readonly [resource: string]: readonly string[];
|
|
202
|
+
},
|
|
203
|
+
> = {
|
|
204
|
+
readonly format: string;
|
|
205
|
+
readonly namespace?: string;
|
|
206
|
+
readonly claims: { readonly [claim: string]: { readonly scalar: string } };
|
|
207
|
+
readonly schema: { readonly [resource: string]: object };
|
|
208
|
+
readonly roles: { readonly [role: string]: object };
|
|
209
|
+
readonly govern: Governed;
|
|
210
|
+
readonly governModes?: {
|
|
211
|
+
readonly [resource: string]: { readonly [field: string]: string };
|
|
212
|
+
};
|
|
213
|
+
readonly grants: readonly object[];
|
|
214
|
+
readonly denies: readonly object[];
|
|
215
|
+
};
|