@aooth/arbac-moost 0.2.1 → 0.2.2
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/atscript/index.d.mts +9 -17
- package/dist/atscript/index.mjs +14 -17
- package/dist/{decorateMetadata-CU_mqYGT.mjs → decorateMetadata-BqEexuhv.mjs} +3 -6
- package/dist/index.d.mts +42 -66
- package/dist/index.mjs +31 -48
- package/dist/plugin.d.mts +1 -4
- package/dist/plugin.mjs +1 -2
- package/dist/{user.provider-SisapkME.d.mts → user.provider-BbYgv9RC.d.mts} +0 -14
- package/package.json +17 -17
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { r as AoothArbacClaims, t as ArbacUserProvider } from "../user.provider-
|
|
1
|
+
import { r as AoothArbacClaims, t as ArbacUserProvider } from "../user.provider-BbYgv9RC.mjs";
|
|
2
2
|
import { TAtscriptAnnotatedType, TAtscriptTypeObject, TMetadataMap, TValidatorOptions, Validator } from "@atscript/typescript/utils";
|
|
3
3
|
import { AoothUserCredentials } from "@aooth/user/atscript-db/model.as";
|
|
4
|
-
//#region src/atscript/auto-provider.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Minimal atscript-db readable surface used to fetch the user record.
|
|
7
6
|
* Structurally compatible with `AtscriptDbTable<T>.findOne` so the runtime
|
|
@@ -74,7 +73,7 @@ interface ArbacUserRecordCacheOptions {
|
|
|
74
73
|
*
|
|
75
74
|
* @since 0.1.78
|
|
76
75
|
*/
|
|
77
|
-
declare class ArbacUserRecordCache {
|
|
76
|
+
export declare class ArbacUserRecordCache {
|
|
78
77
|
private readonly ttlMs;
|
|
79
78
|
private readonly max;
|
|
80
79
|
private readonly now;
|
|
@@ -103,7 +102,7 @@ declare class ArbacUserRecordCache {
|
|
|
103
102
|
* `extraSelect` (third constructor argument) to have the fetch include the
|
|
104
103
|
* extra fields they read.
|
|
105
104
|
*/
|
|
106
|
-
declare abstract class AtscriptArbacUserProvider<T extends object = object> extends ArbacUserProvider {
|
|
105
|
+
export declare abstract class AtscriptArbacUserProvider<T extends object = object> extends ArbacUserProvider {
|
|
107
106
|
protected readonly userType: TAtscriptAnnotatedType;
|
|
108
107
|
protected readonly table: ArbacUserTable<T>;
|
|
109
108
|
private readonly spec;
|
|
@@ -142,8 +141,6 @@ declare abstract class AtscriptArbacUserProvider<T extends object = object> exte
|
|
|
142
141
|
*/
|
|
143
142
|
private fetchRecord;
|
|
144
143
|
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/atscript/attenuation-extract.d.ts
|
|
147
144
|
/**
|
|
148
145
|
* Spec computed once per credential `TAtscriptAnnotatedType` — which typed root
|
|
149
146
|
* fields carry the restrict-only ARBAC attenuation:
|
|
@@ -165,7 +162,7 @@ interface ArbacAttenuationSpec {
|
|
|
165
162
|
* {@link ArbacAttenuationSpec}. Mirrors the user-side `getArbacExtractSpec`:
|
|
166
163
|
* structural, computed once, fail-loud on an ambiguous (multiple) role field.
|
|
167
164
|
*/
|
|
168
|
-
declare function getArbacAttenuationSpec(credType: TAtscriptAnnotatedType): ArbacAttenuationSpec;
|
|
165
|
+
export declare function getArbacAttenuationSpec(credType: TAtscriptAnnotatedType): ArbacAttenuationSpec;
|
|
169
166
|
/**
|
|
170
167
|
* Boot-time cross-model check: every `@arbac.attenuate.attr "userAttr"` target
|
|
171
168
|
* must name a real key in the user model's `@arbac.attribute` keyspace
|
|
@@ -174,7 +171,7 @@ declare function getArbacAttenuationSpec(credType: TAtscriptAnnotatedType): Arba
|
|
|
174
171
|
* cached). Soundness does NOT depend on this — the scope conjunction clips
|
|
175
172
|
* regardless — but it turns a silent misconfig into a loud boot failure.
|
|
176
173
|
*/
|
|
177
|
-
declare function validateAttenuationTargets(credType: TAtscriptAnnotatedType, validUserAttrs: Iterable<string>): void;
|
|
174
|
+
export declare function validateAttenuationTargets(credType: TAtscriptAnnotatedType, validUserAttrs: Iterable<string>): void;
|
|
178
175
|
/**
|
|
179
176
|
* Build the restrict-only {@link AoothArbacClaims} for a credential `record`
|
|
180
177
|
* (its typed root fields — e.g. the auth context, which carries the credential
|
|
@@ -194,9 +191,7 @@ declare function validateAttenuationTargets(credType: TAtscriptAnnotatedType, va
|
|
|
194
191
|
* are omitted (attrs-only narrowing), which is the distinct "no role narrowing"
|
|
195
192
|
* case, not a malformed one.
|
|
196
193
|
*/
|
|
197
|
-
declare function extractAttenuation(credType: TAtscriptAnnotatedType, record: object | null | undefined): AoothArbacClaims | undefined;
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/atscript/handle-spec.d.ts
|
|
194
|
+
export declare function extractAttenuation(credType: TAtscriptAnnotatedType, record: object | null | undefined): AoothArbacClaims | undefined;
|
|
200
195
|
/**
|
|
201
196
|
* Resolved login/recovery HANDLE fields for a user credential model, discovered
|
|
202
197
|
* from the `@aooth.user.*` annotations (registered by `arbacPlugin`). Computed
|
|
@@ -233,14 +228,12 @@ interface AoothUserHandleSpec {
|
|
|
233
228
|
* `@aooth.user.*` field resolves to all-`undefined` handles (email/phone login
|
|
234
229
|
* is simply unavailable — graceful degradation, not an error).
|
|
235
230
|
*/
|
|
236
|
-
declare function getAoothUserHandleSpec(userType: TAtscriptAnnotatedType): AoothUserHandleSpec;
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region src/atscript/models/user.as.d.ts
|
|
231
|
+
export declare function getAoothUserHandleSpec(userType: TAtscriptAnnotatedType): AoothUserHandleSpec;
|
|
239
232
|
/**
|
|
240
233
|
* Atscript interface **AoothArbacUserCredentials**
|
|
241
234
|
* @see {@link ./user.as:7:18}
|
|
242
235
|
*/
|
|
243
|
-
declare class AoothArbacUserCredentials extends AoothUserCredentials {
|
|
236
|
+
export declare class AoothArbacUserCredentials extends AoothUserCredentials {
|
|
244
237
|
roles: string[];
|
|
245
238
|
static __is_atscript_annotated_type: true;
|
|
246
239
|
static type: TAtscriptTypeObject<keyof AoothArbacUserCredentials, AoothArbacUserCredentials>;
|
|
@@ -252,5 +245,4 @@ declare class AoothArbacUserCredentials extends AoothUserCredentials {
|
|
|
252
245
|
static toExampleData?: () => any;
|
|
253
246
|
}
|
|
254
247
|
// prettier-ignore-end
|
|
255
|
-
|
|
256
|
-
export { AoothArbacUserCredentials, type AoothUserHandleSpec, type ArbacAttenuationSpec, ArbacUserRecordCache, type ArbacUserRecordCacheOptions, type ArbacUserTable, AtscriptArbacUserProvider, type AtscriptArbacUserProviderOptions, extractAttenuation, getAoothUserHandleSpec, getArbacAttenuationSpec, validateAttenuationTargets };
|
|
248
|
+
export type { AoothUserHandleSpec, ArbacAttenuationSpec, ArbacUserRecordCacheOptions, ArbacUserTable, AtscriptArbacUserProviderOptions };
|
package/dist/atscript/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as __decorate, n as ArbacUserProvider, t as __decorateMetadata } from "../decorateMetadata-
|
|
1
|
+
import { i as __decorate, n as ArbacUserProvider, t as __decorateMetadata } from "../decorateMetadata-BqEexuhv.mjs";
|
|
2
2
|
import { defineWook, key } from "@wooksjs/event-core";
|
|
3
3
|
import { Injectable } from "moost";
|
|
4
4
|
import { $ak, $f, $nr, defineAnnotatedType, throwFeatureDisabled } from "@atscript/typescript/utils";
|
|
5
5
|
import { AoothUserCredentials } from "@aooth/user/atscript-db/model.as";
|
|
6
|
-
|
|
6
|
+
// src/atscript/role-list.ts
|
|
7
7
|
/**
|
|
8
8
|
* Collect unique, non-empty strings from an iterable of unknown values,
|
|
9
9
|
* preserving first-seen order and dropping anything that is not a non-empty
|
|
@@ -21,8 +21,7 @@ function uniqueStrings(values) {
|
|
|
21
21
|
}
|
|
22
22
|
return out;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
//#region src/atscript/auto-provider.ts
|
|
24
|
+
// src/atscript/auto-provider.ts
|
|
26
25
|
const specCache$2 = /* @__PURE__ */ new WeakMap();
|
|
27
26
|
/**
|
|
28
27
|
* Resolve the identifier field on an object type using the three-step chain
|
|
@@ -52,12 +51,14 @@ function resolveIdentifierField(type) {
|
|
|
52
51
|
}
|
|
53
52
|
if (explicit) return explicit;
|
|
54
53
|
const preferred = type.metadata.get("db.table.preferredId.uniqueIndex");
|
|
55
|
-
if (preferred !== void 0)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
if (preferred !== void 0) {
|
|
55
|
+
if (typeof preferred === "string") {
|
|
56
|
+
const fields = uniqueIndexFields.get(preferred);
|
|
57
|
+
if (fields && fields.length === 1) return fields[0];
|
|
58
|
+
} else {
|
|
59
|
+
for (const fields of uniqueIndexFields.values()) if (fields.length === 1) return fields[0];
|
|
60
|
+
if (anyUniqueField.length > 0) return anyUniqueField[0];
|
|
61
|
+
}
|
|
61
62
|
}
|
|
62
63
|
return metaId;
|
|
63
64
|
}
|
|
@@ -308,8 +309,7 @@ AtscriptArbacUserProvider = __decorate([Injectable(), __decorateMetadata("design
|
|
|
308
309
|
Object,
|
|
309
310
|
Object
|
|
310
311
|
])], AtscriptArbacUserProvider);
|
|
311
|
-
|
|
312
|
-
//#region src/atscript/attenuation-extract.ts
|
|
312
|
+
// src/atscript/attenuation-extract.ts
|
|
313
313
|
const specCache$1 = /* @__PURE__ */ new WeakMap();
|
|
314
314
|
/**
|
|
315
315
|
* Walk a credential model's `@arbac.attenuate.*` annotations into a cached
|
|
@@ -403,8 +403,7 @@ function extractAttenuation(credType, record) {
|
|
|
403
403
|
if (attrs !== void 0) out.attrs = attrs;
|
|
404
404
|
return out;
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
//#region src/atscript/handle-spec.ts
|
|
406
|
+
// src/atscript/handle-spec.ts
|
|
408
407
|
const specCache = /* @__PURE__ */ new WeakMap();
|
|
409
408
|
/** A `@db.index.unique` annotation is a non-empty `(string | true)[]`. */
|
|
410
409
|
function hasUniqueIndex(md) {
|
|
@@ -466,8 +465,7 @@ function getAoothUserHandleSpec(userType) {
|
|
|
466
465
|
specCache.set(userType, spec);
|
|
467
466
|
return spec;
|
|
468
467
|
}
|
|
469
|
-
|
|
470
|
-
//#region src/atscript/models/user.as
|
|
468
|
+
// src/atscript/models/user.as
|
|
471
469
|
var AoothArbacUserCredentials = class {
|
|
472
470
|
static __is_atscript_annotated_type = true;
|
|
473
471
|
static type = {};
|
|
@@ -480,5 +478,4 @@ var AoothArbacUserCredentials = class {
|
|
|
480
478
|
$ak("db.index.fulltext", "db.index.plain", "db.index.unique", "db.view.joins", "expect.pattern");
|
|
481
479
|
$nr("aooth.auth.metadata", "aooth.user.email", "aooth.user.phone", "arbac.attenuate.attr", "arbac.attenuate.role", "arbac.attribute", "arbac.role", "arbac.userId", "db.agg.avg", "db.agg.count", "db.agg.countDistinct", "db.agg.max", "db.agg.min", "db.agg.sum", "db.alias", "db.amount.currency.ref", "db.column", "db.column.collate", "db.column.derived", "db.column.dimension", "db.column.filterable", "db.column.measure", "db.column.precision", "db.column.renamed", "db.column.searchable", "db.column.sortable", "db.column.version", "db.column.version.exempt", "db.compute", "db.default", "db.default.increment", "db.default.now", "db.default.uuid", "db.depth.limit", "db.encrypted", "db.http.path", "db.ignore", "db.index.fulltext", "db.index.geo", "db.index.plain", "db.index.unique", "db.json", "db.onUpdate.inc", "db.onUpdate.now", "db.patch.strategy", "db.rel.FK", "db.rel.filter", "db.rel.filterable", "db.rel.from", "db.rel.onDelete", "db.rel.onUpdate", "db.rel.to", "db.rel.via", "db.schema", "db.search.filter", "db.search.vector", "db.search.vector.threshold", "db.sort.nulls", "db.space", "db.sync.method", "db.table", "db.table.filterable", "db.table.preferredId.uniqueIndex", "db.table.renamed", "db.table.sortable", "db.unit.ref", "db.view", "db.view.filter", "db.view.for", "db.view.having", "db.view.joins", "db.view.materialized", "db.view.renamed", "db.writeOnly", "meta.default", "meta.id", "meta.readonly", "meta.required");
|
|
482
480
|
defineAnnotatedType("object", AoothArbacUserCredentials).prop("id", $f(AoothUserCredentials, "id")).prop("username", $f(AoothUserCredentials, "username")).prop("version", $f(AoothUserCredentials, "version")).prop("password", $f(AoothUserCredentials, "password")).prop("account", $f(AoothUserCredentials, "account")).prop("mfa", $f(AoothUserCredentials, "mfa")).prop("trustedDevices", $f(AoothUserCredentials, "trustedDevices")).prop("seenDevices", $f(AoothUserCredentials, "seenDevices")).prop("roles", defineAnnotatedType("array").of(defineAnnotatedType().designType("string").tags("string").$type).annotate("arbac.role", true).$type);
|
|
483
|
-
//#endregion
|
|
484
481
|
export { AoothArbacUserCredentials, ArbacUserRecordCache, AtscriptArbacUserProvider, extractAttenuation, getAoothUserHandleSpec, getArbacAttenuationSpec, validateAttenuationTargets };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
// \0@oxc-project+runtime@0.155.0/helpers/esm/decorate.js
|
|
2
2
|
function __decorate(decorators, target, key, desc) {
|
|
3
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
//#region src/user.provider.ts
|
|
8
|
+
// src/user.provider.ts
|
|
10
9
|
/**
|
|
11
10
|
* Abstract base class for providing user data required for ARBAC evaluations.
|
|
12
11
|
*
|
|
@@ -27,10 +26,8 @@ var ArbacUserProvider = class {};
|
|
|
27
26
|
* etc. Runtime resolves to the concrete subclass registered via DI.
|
|
28
27
|
*/
|
|
29
28
|
const ArbacUserProviderToken = ArbacUserProvider;
|
|
30
|
-
|
|
31
|
-
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateMetadata.js
|
|
29
|
+
// \0@oxc-project+runtime@0.155.0/helpers/esm/decorateMetadata.js
|
|
32
30
|
function __decorateMetadata(k, v) {
|
|
33
31
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
34
32
|
}
|
|
35
|
-
//#endregion
|
|
36
33
|
export { __decorate as i, ArbacUserProvider as n, ArbacUserProviderToken as r, __decorateMetadata as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ProjectionOf, a as conjoinArbacDbScopes, b as TArbacMeta, c as ArbacDbScope, d as extractUsedControlValues, f as applyAllowedFieldsAndSet, g as OwnFieldKey, h as NavTarget, i as ConjoinArbacDbScopesOptions, l as AsArbacDbController, m as NavRelationKey, n as ArbacUserProviderToken, o as RefForeignKey, p as ControlsOf, r as AoothArbacClaims, s as RefTableSource, t as ArbacUserProvider, u as enforceControlsPolicy, v as ARBAC_DELEGATED_AUTH, x as getArbacMate, y as ArbacDelegatedAuth } from "./user.provider-
|
|
1
|
+
import { _ as ProjectionOf, a as conjoinArbacDbScopes, b as TArbacMeta, c as ArbacDbScope, d as extractUsedControlValues, f as applyAllowedFieldsAndSet, g as OwnFieldKey, h as NavTarget, i as ConjoinArbacDbScopesOptions, l as AsArbacDbController, m as NavRelationKey, n as ArbacUserProviderToken, o as RefForeignKey, p as ControlsOf, r as AoothArbacClaims, s as RefTableSource, t as ArbacUserProvider, u as enforceControlsPolicy, v as ARBAC_DELEGATED_AUTH, x as getArbacMate, y as ArbacDelegatedAuth } from "./user.provider-BbYgv9RC.mjs";
|
|
2
2
|
import { Arbac, Arbac as Arbac$1, TArbacCompiledRule, TArbacEvalResult, TArbacEvalResult as TArbacEvalResult$1, TArbacRole, TArbacRoleForResource, TArbacRule, arbacPatternToRegex } from "@aooth/arbac-core";
|
|
3
3
|
import { ControlGate, ControlGate as ControlGate$1, TProjection, TScopeFieldRules, TScopeFilter, conjoinScopeFilters } from "@aooth/arbac";
|
|
4
4
|
import { TAuthGuardDef } from "@moostjs/event-http";
|
|
@@ -6,7 +6,6 @@ import { EventContext } from "@wooksjs/event-core";
|
|
|
6
6
|
import { FilterExpr, TDbRemoveGuardContext, TDbWriteCheckContext, TDbWriteGuardContext, TDeleteOptions, TMetaResponse, TRowResolveOptions, TWriteOptions, UniqueryControls } from "@atscript/db";
|
|
7
7
|
import { AsDbReadableController, AsJsonValueHelpController, AsValueHelpController, TDbActionScopeContext, TDbControlsType, TDbIndexFieldPaths, TDbRequestContext, ValueHelpSelect } from "@atscript/moost-db";
|
|
8
8
|
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
9
|
-
//#region src/db/visibility.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* The slice of an atscript-db readable (table / view) the visibility walk
|
|
12
11
|
* reads — a moost-db controller's `this.readable` satisfies it: identifiers
|
|
@@ -136,20 +135,20 @@ interface MetaVisibility {
|
|
|
136
135
|
* scopes at all, or any scope without a `projection` (a universal grant makes
|
|
137
136
|
* `unionProjections` collapse to the universe `{}`).
|
|
138
137
|
*/
|
|
139
|
-
declare function unionScopeProjection(scopes: ArbacDbScope[]): TProjection | undefined;
|
|
138
|
+
export declare function unionScopeProjection(scopes: ArbacDbScope[]): TProjection | undefined;
|
|
140
139
|
/**
|
|
141
140
|
* Relation names any scope explicitly declares via `with.<name>` — those
|
|
142
141
|
* relations are governed by the declared sub-scopes alone (parent authority),
|
|
143
142
|
* and the declaration implies the relation EXISTS for this principal even
|
|
144
143
|
* when the projection union does not name it (see {@link ArbacDbScope.with}).
|
|
145
144
|
*/
|
|
146
|
-
declare function collectWithGrantNames(scopes: ArbacDbScope[]): ReadonlySet<string>;
|
|
145
|
+
export declare function collectWithGrantNames(scopes: ArbacDbScope[]): ReadonlySet<string>;
|
|
147
146
|
/**
|
|
148
147
|
* Union of write-scope `allowedFields`; `"all"` for field-unrestricted write
|
|
149
148
|
* access. The whitelist exists only when at least one scope carries an
|
|
150
149
|
* `allowedFields` array — scoped-but-unlisted writes are field-unrestricted.
|
|
151
150
|
*/
|
|
152
|
-
declare function collectWritableFields(scopes: ArbacDbScope[], unrestricted: boolean): ReadonlySet<string> | "all" | undefined;
|
|
151
|
+
export declare function collectWritableFields(scopes: ArbacDbScope[], unrestricted: boolean): ReadonlySet<string> | "all" | undefined;
|
|
153
152
|
/**
|
|
154
153
|
* Whether a flattened dot-path field exists for this principal.
|
|
155
154
|
*
|
|
@@ -164,13 +163,13 @@ declare function collectWritableFields(scopes: ArbacDbScope[], unrestricted: boo
|
|
|
164
163
|
* So a field a joined table hides is as unknown in a `$with` sub-query as a
|
|
165
164
|
* top-level hidden column is in the main query (no filter/sort value oracle).
|
|
166
165
|
*/
|
|
167
|
-
declare function isMetaFieldVisible(path: string, vis: MetaVisibility): boolean;
|
|
166
|
+
export declare function isMetaFieldVisible(path: string, vis: MetaVisibility): boolean;
|
|
168
167
|
/**
|
|
169
168
|
* PK + `preferredId` for a controller's table/readable — the
|
|
170
169
|
* {@link MetaVisibility.alwaysVisible} set. Kept for compatibility: the
|
|
171
170
|
* controllers now pass `this.readable` and it is derived there.
|
|
172
171
|
*/
|
|
173
|
-
declare function metaAlwaysVisibleFields(_controller: object, source: {
|
|
172
|
+
export declare function metaAlwaysVisibleFields(_controller: object, source: {
|
|
174
173
|
primaryKeys: readonly string[];
|
|
175
174
|
preferredId: readonly string[];
|
|
176
175
|
}): ReadonlySet<string>;
|
|
@@ -199,9 +198,7 @@ interface ScopeVisibilityOptions {
|
|
|
199
198
|
* @param opts - {@link ScopeVisibilityOptions}; a bare identifier set is the
|
|
200
199
|
* 0.1.71 `alwaysVisible` argument
|
|
201
200
|
*/
|
|
202
|
-
declare function buildScopeVisibility(scopes: ArbacDbScope[], table: VisibilityTableSource | undefined, opts?: ScopeVisibilityOptions | ReadonlySet<string>): MetaVisibility;
|
|
203
|
-
//#endregion
|
|
204
|
-
//#region src/arbac.composables.d.ts
|
|
201
|
+
export declare function buildScopeVisibility(scopes: ArbacDbScope[], table: VisibilityTableSource | undefined, opts?: ScopeVisibilityOptions | ReadonlySet<string>): MetaVisibility;
|
|
205
202
|
/**
|
|
206
203
|
* The scopes cached for the current event (`undefined` before the authorize
|
|
207
204
|
* interceptor / `setScopes` ran). A direct slot read — no controller
|
|
@@ -210,9 +207,9 @@ declare function buildScopeVisibility(scopes: ArbacDbScope[], table: VisibilityT
|
|
|
210
207
|
*
|
|
211
208
|
* `TScope` is a caller-side type witness (see `evaluate` below).
|
|
212
209
|
*/
|
|
213
|
-
declare function getArbacScopes<TScope extends object>(ctx?: EventContext): TScope[] | undefined;
|
|
210
|
+
export declare function getArbacScopes<TScope extends object>(ctx?: EventContext): TScope[] | undefined;
|
|
214
211
|
/** Options of `useArbac().evaluate()` / `evaluateOrThrow()`. */
|
|
215
|
-
interface ArbacEvaluateOptions {
|
|
212
|
+
export interface ArbacEvaluateOptions {
|
|
216
213
|
/** Resource to evaluate; defaults to the current handler's. */
|
|
217
214
|
resource?: string;
|
|
218
215
|
/** Action to evaluate; defaults to the current handler's. */
|
|
@@ -268,9 +265,7 @@ interface ArbacBindings {
|
|
|
268
265
|
* step handlers. Scope read/write goes through `arbacScopesKey` directly
|
|
269
266
|
* so it still lives on the per-event slot.
|
|
270
267
|
*/
|
|
271
|
-
declare const useArbac: (_ctx?: EventContext) => ArbacBindings;
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/arbac.decorator.d.ts
|
|
268
|
+
export declare const useArbac: (_ctx?: EventContext) => ArbacBindings;
|
|
274
269
|
/**
|
|
275
270
|
* ARBAC checks authorization, not authentication, so the transport
|
|
276
271
|
* declaration is empty — pair with an upstream auth guard (e.g. JWT
|
|
@@ -281,21 +276,19 @@ declare const useArbac: (_ctx?: EventContext) => ArbacBindings;
|
|
|
281
276
|
* apply it to controllers/handlers that should remain reachable without an
|
|
282
277
|
* evaluated rule (e.g. login/recovery workflows, health probes).
|
|
283
278
|
*/
|
|
284
|
-
declare const arbacAuthorizeInterceptor: TAuthGuardDef;
|
|
279
|
+
export declare const arbacAuthorizeInterceptor: TAuthGuardDef;
|
|
285
280
|
/** Wrapped via `Authenticate` so `@moostjs/swagger` picks up the auth-guard metadata. */
|
|
286
|
-
declare const ArbacAuthorize: () => ClassDecorator & MethodDecorator;
|
|
281
|
+
export declare const ArbacAuthorize: () => ClassDecorator & MethodDecorator;
|
|
287
282
|
/**
|
|
288
283
|
* Decorator to specify a resource id for ARBAC evaluation. Apply to a
|
|
289
284
|
* controller class or a handler method.
|
|
290
285
|
*/
|
|
291
|
-
declare const ArbacResource: (name: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
286
|
+
export declare const ArbacResource: (name: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
292
287
|
/**
|
|
293
288
|
* Decorator to specify an action id for ARBAC evaluation. Typically applied
|
|
294
289
|
* at the method level.
|
|
295
290
|
*/
|
|
296
|
-
declare const ArbacAction: (name: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
297
|
-
//#endregion
|
|
298
|
-
//#region src/db/as-arbac-db-readable-controller.d.ts
|
|
291
|
+
export declare const ArbacAction: (name: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
299
292
|
type TSelect = UniqueryControls["$select"];
|
|
300
293
|
/**
|
|
301
294
|
* Read-only mirror of {@link AsArbacDbController} for view-style controllers
|
|
@@ -303,7 +296,7 @@ type TSelect = UniqueryControls["$select"];
|
|
|
303
296
|
* Applies the same fail-closed `prepareRequest` and filter / projection /
|
|
304
297
|
* controls overlays — no write-side hooks because the parent exposes none.
|
|
305
298
|
*/
|
|
306
|
-
declare class AsArbacDbReadableController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType> extends AsDbReadableController<T> {
|
|
299
|
+
export declare class AsArbacDbReadableController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType> extends AsDbReadableController<T> {
|
|
307
300
|
/** Makes this controller the `$with` policy source for its table's ARBAC resource. */
|
|
308
301
|
protected readonly _arbacRelationTarget: true;
|
|
309
302
|
/** Same contract as {@link AsArbacDbController.prepareRequest}. */
|
|
@@ -335,8 +328,6 @@ declare class AsArbacDbReadableController<T extends TAtscriptAnnotatedType = TAt
|
|
|
335
328
|
/** Same contract as {@link AsArbacDbController.hasField}. */
|
|
336
329
|
protected hasField(path: string): boolean;
|
|
337
330
|
}
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/db/as-arbac-value-help-controller.d.ts
|
|
340
331
|
/**
|
|
341
332
|
* ARBAC-scoped mirror of `@atscript/moost-db`'s {@link AsValueHelpController}
|
|
342
333
|
* (bring your own backing source): the same scope contract as
|
|
@@ -370,7 +361,7 @@ declare class AsArbacDbReadableController<T extends TAtscriptAnnotatedType = TAt
|
|
|
370
361
|
*
|
|
371
362
|
* @since 0.1.72
|
|
372
363
|
*/
|
|
373
|
-
declare abstract class AsArbacValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsValueHelpController<T, DataType> {
|
|
364
|
+
export declare abstract class AsArbacValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsValueHelpController<T, DataType> {
|
|
374
365
|
private _arbacHost?;
|
|
375
366
|
/** Makes this controller the binding / `ref` policy source for its bound type's ARBAC resource. */
|
|
376
367
|
protected readonly _arbacValueHelpTarget: true;
|
|
@@ -405,7 +396,7 @@ declare abstract class AsArbacValueHelpController<T extends TAtscriptAnnotatedTy
|
|
|
405
396
|
*
|
|
406
397
|
* @since 0.1.72
|
|
407
398
|
*/
|
|
408
|
-
declare class AsArbacJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsJsonValueHelpController<T, DataType> {
|
|
399
|
+
export declare class AsArbacJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsJsonValueHelpController<T, DataType> {
|
|
409
400
|
private _arbacHost?;
|
|
410
401
|
/** Makes this controller the binding / `ref` policy source for its bound type's ARBAC resource. */
|
|
411
402
|
protected readonly _arbacValueHelpTarget: true;
|
|
@@ -422,8 +413,6 @@ declare class AsArbacJsonValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
422
413
|
runGetOne(id: string): ReturnType<AsJsonValueHelpController<T, DataType>["runGetOne"]>;
|
|
423
414
|
runGetOneComposite(query: Record<string, string>): ReturnType<AsJsonValueHelpController<T, DataType>["runGetOneComposite"]>;
|
|
424
415
|
}
|
|
425
|
-
//#endregion
|
|
426
|
-
//#region src/db/relation-policy.d.ts
|
|
427
416
|
/**
|
|
428
417
|
* Register an ARBAC DB controller as an owner of its readable's ARBAC
|
|
429
418
|
* resource, so a `$with` from another controller can evaluate the caller's
|
|
@@ -435,7 +424,7 @@ declare class AsArbacJsonValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
435
424
|
* @returns `true` (so it can initialize a field)
|
|
436
425
|
* @since 0.1.72
|
|
437
426
|
*/
|
|
438
|
-
declare function registerArbacDbTarget(controller: object): true;
|
|
427
|
+
export declare function registerArbacDbTarget(controller: object): true;
|
|
439
428
|
/**
|
|
440
429
|
* The ARBAC resource + action a controller's handler is authorized as — the
|
|
441
430
|
* precedence `useArbac()` applies while that handler serves a request.
|
|
@@ -445,12 +434,10 @@ declare function registerArbacDbTarget(controller: object): true;
|
|
|
445
434
|
*
|
|
446
435
|
* @since 0.1.72
|
|
447
436
|
*/
|
|
448
|
-
declare function resolveHandlerArbacIds(instance: object, methodName: string): {
|
|
437
|
+
export declare function resolveHandlerArbacIds(instance: object, methodName: string): {
|
|
449
438
|
resource: string;
|
|
450
439
|
action: string;
|
|
451
440
|
};
|
|
452
|
-
//#endregion
|
|
453
|
-
//#region src/db/meta-projection.d.ts
|
|
454
441
|
/**
|
|
455
442
|
* Foreign `ref` targets for `/meta` pruning: annotated type → the caller's
|
|
456
443
|
* visibility on it, or `null` when the caller cannot read it.
|
|
@@ -475,7 +462,7 @@ type MetaRefTargets = ReadonlyMap<object, MetaVisibility | null>;
|
|
|
475
462
|
* NEVER mutates the input — the base controller caches the static envelope
|
|
476
463
|
* (`applyMetaOverlay` contract); every pruned branch is a fresh object.
|
|
477
464
|
*/
|
|
478
|
-
declare function pruneMetaByVisibility(meta: TMetaResponse, vis: MetaVisibility, refTargets?: MetaRefTargets): TMetaResponse;
|
|
465
|
+
export declare function pruneMetaByVisibility(meta: TMetaResponse, vis: MetaVisibility, refTargets?: MetaRefTargets): TMetaResponse;
|
|
479
466
|
/**
|
|
480
467
|
* The full ARBAC `/meta` overlay, shared by the ARBAC DB and value-help
|
|
481
468
|
* controllers.
|
|
@@ -511,7 +498,7 @@ declare function pruneMetaByVisibility(meta: TMetaResponse, vis: MetaVisibility,
|
|
|
511
498
|
* signature) still works, without them
|
|
512
499
|
* @param _indexes - @deprecated ignored since 0.1.74 (moost-db prunes the search surface)
|
|
513
500
|
*/
|
|
514
|
-
declare function applyArbacMetaOverlay(meta: TMetaResponse, source: VisibilityTableSource | ReadonlySet<string>, _indexes?: readonly TDbIndexFieldPaths[]): Promise<TMetaResponse>;
|
|
501
|
+
export declare function applyArbacMetaOverlay(meta: TMetaResponse, source: VisibilityTableSource | ReadonlySet<string>, _indexes?: readonly TDbIndexFieldPaths[]): Promise<TMetaResponse>;
|
|
515
502
|
/**
|
|
516
503
|
* Test-friendly internal helper — exported for unit tests and helper
|
|
517
504
|
* composition; regular consumers should not call this directly.
|
|
@@ -524,16 +511,14 @@ declare function applyArbacMetaOverlay(meta: TMetaResponse, source: VisibilityTa
|
|
|
524
511
|
* properties are skipped entirely (a getter-valued property is not a method
|
|
525
512
|
* and can never carry `@DbAction` metadata).
|
|
526
513
|
*/
|
|
527
|
-
declare function collectMethodNames(instance: object): string[];
|
|
528
|
-
//#endregion
|
|
529
|
-
//#region src/db/request-scopes.d.ts
|
|
514
|
+
export declare function collectMethodNames(instance: object): string[];
|
|
530
515
|
/**
|
|
531
516
|
* The scopes resolved for the current event, or `undefined` before
|
|
532
517
|
* {@link resolveRequestScopes} ran.
|
|
533
518
|
*
|
|
534
519
|
* @since 0.1.72
|
|
535
520
|
*/
|
|
536
|
-
declare function cachedRequestScopes(): ArbacDbScope[] | undefined;
|
|
521
|
+
export declare function cachedRequestScopes(): ArbacDbScope[] | undefined;
|
|
537
522
|
/**
|
|
538
523
|
* Resolve the current event's scopes once: the ones the authorize
|
|
539
524
|
* interceptor cached, else an ARBAC evaluation of the handler's
|
|
@@ -544,7 +529,7 @@ declare function cachedRequestScopes(): ArbacDbScope[] | undefined;
|
|
|
544
529
|
*
|
|
545
530
|
* @since 0.1.72
|
|
546
531
|
*/
|
|
547
|
-
declare function resolveRequestScopes(): Promise<ArbacDbScope[]>;
|
|
532
|
+
export declare function resolveRequestScopes(): Promise<ArbacDbScope[]>;
|
|
548
533
|
/**
|
|
549
534
|
* The resolved scopes, synchronously — for the hooks that run after the
|
|
550
535
|
* entry point (`validateControls`, `transformFilter`, the write guards …).
|
|
@@ -552,7 +537,7 @@ declare function resolveRequestScopes(): Promise<ArbacDbScope[]>;
|
|
|
552
537
|
*
|
|
553
538
|
* @since 0.1.72
|
|
554
539
|
*/
|
|
555
|
-
declare function requireRequestScopes(): ArbacDbScope[];
|
|
540
|
+
export declare function requireRequestScopes(): ArbacDbScope[];
|
|
556
541
|
/**
|
|
557
542
|
* Shared body of the ARBAC controllers' `hasField` overrides: a field
|
|
558
543
|
* outside the read-scope visibility — hidden by the projection union, a
|
|
@@ -563,7 +548,7 @@ declare function requireRequestScopes(): ArbacDbScope[];
|
|
|
563
548
|
*
|
|
564
549
|
* @since 0.1.72
|
|
565
550
|
*/
|
|
566
|
-
declare function requestFieldVisible(path: string, source: VisibilityTableSource | ReadonlySet<string>): boolean;
|
|
551
|
+
export declare function requestFieldVisible(path: string, source: VisibilityTableSource | ReadonlySet<string>): boolean;
|
|
567
552
|
/**
|
|
568
553
|
* Whether `path` is visible to `scopes` over `source` (see
|
|
569
554
|
* {@link requestFieldVisible}, which reads the request's scopes).
|
|
@@ -571,7 +556,7 @@ declare function requestFieldVisible(path: string, source: VisibilityTableSource
|
|
|
571
556
|
* @param source - the controller's `this.readable`; an identifier set (the
|
|
572
557
|
* 0.1.67 signature) still works, without relation / schema rules
|
|
573
558
|
*/
|
|
574
|
-
declare function isScopedFieldVisible(scopes: ArbacDbScope[], path: string, source: VisibilityTableSource | ReadonlySet<string>): boolean;
|
|
559
|
+
export declare function isScopedFieldVisible(scopes: ArbacDbScope[], path: string, source: VisibilityTableSource | ReadonlySet<string>): boolean;
|
|
575
560
|
/**
|
|
576
561
|
* Body of the ARBAC DB / value-help controllers' `prepareRequest` — every
|
|
577
562
|
* endpoint, `@DbAction` handlers included (`endpoint: "action"`, before any
|
|
@@ -593,7 +578,7 @@ declare function isScopedFieldVisible(scopes: ArbacDbScope[], path: string, sour
|
|
|
593
578
|
*
|
|
594
579
|
* @since 0.1.72
|
|
595
580
|
*/
|
|
596
|
-
declare function prepareArbacRequest(ctx: TDbRequestContext, readable?: VisibilityTableSource): Promise<void>;
|
|
581
|
+
export declare function prepareArbacRequest(ctx: TDbRequestContext, readable?: VisibilityTableSource): Promise<void>;
|
|
597
582
|
/**
|
|
598
583
|
* `authorizeForm` for the ARBAC DB controllers: a form is served iff the
|
|
599
584
|
* caller may run at least one of the actions that take it as input — each
|
|
@@ -601,7 +586,7 @@ declare function prepareArbacRequest(ctx: TDbRequestContext, readable?: Visibili
|
|
|
601
586
|
*
|
|
602
587
|
* @since 0.1.72
|
|
603
588
|
*/
|
|
604
|
-
declare function authorizeArbacForm(actionNames: readonly string[]): Promise<boolean>;
|
|
589
|
+
export declare function authorizeArbacForm(actionNames: readonly string[]): Promise<boolean>;
|
|
605
590
|
/**
|
|
606
591
|
* Body of the ARBAC DB controllers' `allowedActions`: the action `names` the
|
|
607
592
|
* caller holds a grant on — each evaluated as {@link actionArbacIds} names
|
|
@@ -610,7 +595,7 @@ declare function authorizeArbacForm(actionNames: readonly string[]): Promise<boo
|
|
|
610
595
|
*
|
|
611
596
|
* @since 0.1.72
|
|
612
597
|
*/
|
|
613
|
-
declare function arbacAllowedActions(names: readonly string[]): Promise<string[]>;
|
|
598
|
+
export declare function arbacAllowedActions(names: readonly string[]): Promise<string[]>;
|
|
614
599
|
/**
|
|
615
600
|
* Body of the ARBAC DB controllers' `actionRowScope`: the rows the
|
|
616
601
|
* `@DbAction` `name` may run on — the filter of the caller's grant on the
|
|
@@ -629,7 +614,7 @@ declare function arbacAllowedActions(names: readonly string[]): Promise<string[]
|
|
|
629
614
|
*
|
|
630
615
|
* @since 0.1.72
|
|
631
616
|
*/
|
|
632
|
-
declare function arbacActionRowScope(name: string): Promise<Record<string, unknown> | undefined>;
|
|
617
|
+
export declare function arbacActionRowScope(name: string): Promise<Record<string, unknown> | undefined>;
|
|
633
618
|
/**
|
|
634
619
|
* Body of the ARBAC controllers' `transformFilter` (and so of the row
|
|
635
620
|
* overlay `/one`, `DELETE` and `@DbAction` ids use): the user filter
|
|
@@ -637,7 +622,7 @@ declare function arbacActionRowScope(name: string): Promise<Record<string, unkno
|
|
|
637
622
|
*
|
|
638
623
|
* @since 0.1.72
|
|
639
624
|
*/
|
|
640
|
-
declare function arbacRowFilter(filter: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
625
|
+
export declare function arbacRowFilter(filter: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
641
626
|
/**
|
|
642
627
|
* Body of the ARBAC DB controllers' `transformRelationFilter` (since 0.1.74):
|
|
643
628
|
* the operand of a CLIENT relational predicate at `path` (`ticket`,
|
|
@@ -651,9 +636,7 @@ declare function arbacRowFilter(filter: Record<string, unknown> | undefined): Re
|
|
|
651
636
|
*
|
|
652
637
|
* @since 0.1.74
|
|
653
638
|
*/
|
|
654
|
-
declare function arbacRelationFilter(path: string, filter: FilterExpr, readable: VisibilityTableSource): FilterExpr;
|
|
655
|
-
//#endregion
|
|
656
|
-
//#region src/db/shared-read-helpers.d.ts
|
|
639
|
+
export declare function arbacRelationFilter(path: string, filter: FilterExpr, readable: VisibilityTableSource): FilterExpr;
|
|
657
640
|
/**
|
|
658
641
|
* Restrict the user-supplied `$select` to the scopes' projection union.
|
|
659
642
|
* Returns the original projection untouched when no scope declares a
|
|
@@ -677,14 +660,14 @@ declare function arbacRelationFilter(path: string, filter: FilterExpr, readable:
|
|
|
677
660
|
*
|
|
678
661
|
* @since 0.1.72
|
|
679
662
|
*/
|
|
680
|
-
declare function applyArbacProjection(projection: unknown, scopes: ArbacDbScope[], readable?: VisibilityTableSource): TProjection | undefined;
|
|
663
|
+
export declare function applyArbacProjection(projection: unknown, scopes: ArbacDbScope[], readable?: VisibilityTableSource): TProjection | undefined;
|
|
681
664
|
/**
|
|
682
665
|
* Enforce the union of per-scope `controls` gates against the parsed
|
|
683
666
|
* Uniquery controls. Throws `HttpError(403)` on the first violation.
|
|
684
667
|
*
|
|
685
668
|
* @since 0.1.72
|
|
686
669
|
*/
|
|
687
|
-
declare function applyArbacControls(controls: Record<string, unknown>, scopes: ArbacDbScope[]): void;
|
|
670
|
+
export declare function applyArbacControls(controls: Record<string, unknown>, scopes: ArbacDbScope[]): void;
|
|
688
671
|
/**
|
|
689
672
|
* Walk the user-supplied `$with` items in `controls` and overlay each joined
|
|
690
673
|
* relation with the policy of its rows (the `$with` inherit-target policy):
|
|
@@ -701,9 +684,7 @@ declare function applyArbacControls(controls: Record<string, unknown>, scopes: A
|
|
|
701
684
|
*
|
|
702
685
|
* @since 0.1.72
|
|
703
686
|
*/
|
|
704
|
-
declare function applyArbacRelationScopes(controls: Record<string, unknown>, scopes: ArbacDbScope[], readable?: VisibilityTableSource): void;
|
|
705
|
-
//#endregion
|
|
706
|
-
//#region src/db/write-policy.d.ts
|
|
687
|
+
export declare function applyArbacRelationScopes(controls: Record<string, unknown>, scopes: ArbacDbScope[], readable?: VisibilityTableSource): void;
|
|
707
688
|
/** The table surface the write guards need (`AtscriptDbTable` satisfies it). */
|
|
708
689
|
interface ArbacWriteTable {
|
|
709
690
|
count(query: {
|
|
@@ -732,17 +713,15 @@ interface ArbacWriteTable {
|
|
|
732
713
|
* 0.1.75) — and, with `ignoreConflicts` (`?$onConflict=ignore`), refused
|
|
733
714
|
* whenever it cannot, since the post-write check never sees skipped rows.
|
|
734
715
|
*/
|
|
735
|
-
declare function guardArbacWrite(ctx: TDbWriteGuardContext, scopes: readonly ArbacDbScope[], table: ArbacWriteTable, refs: RefTableSource, ignoreConflicts?: boolean): Promise<void>;
|
|
716
|
+
export declare function guardArbacWrite(ctx: TDbWriteGuardContext, scopes: readonly ArbacDbScope[], table: ArbacWriteTable, refs: RefTableSource, ignoreConflicts?: boolean): Promise<void>;
|
|
736
717
|
/**
|
|
737
718
|
* WITH CHECK after the write, inside its transaction: every written row must
|
|
738
719
|
* match the scopes' `check` (default `filter`) — else 403 and the write rolls
|
|
739
720
|
* back. Non-transactional adapters were checked in {@link guardArbacWrite}.
|
|
740
721
|
*/
|
|
741
|
-
declare function checkArbacWrite(ctx: TDbWriteCheckContext, scopes: readonly ArbacDbScope[]): Promise<void>;
|
|
722
|
+
export declare function checkArbacWrite(ctx: TDbWriteCheckContext, scopes: readonly ArbacDbScope[]): Promise<void>;
|
|
742
723
|
/** USING for deletes: the exact row the delete targets must match the scope filter (else 404). */
|
|
743
|
-
declare function guardArbacRemove(ctx: TDbRemoveGuardContext, scopes: readonly ArbacDbScope[], table: Pick<ArbacWriteTable, "count">): Promise<void>;
|
|
744
|
-
//#endregion
|
|
745
|
-
//#region src/db/use-arbac-db-scope.d.ts
|
|
724
|
+
export declare function guardArbacRemove(ctx: TDbRemoveGuardContext, scopes: readonly ArbacDbScope[], table: Pick<ArbacWriteTable, "count">): Promise<void>;
|
|
746
725
|
/**
|
|
747
726
|
* The slice of an atscript-db table {@link ArbacDbScopeHelpers.assertRowsInScope}
|
|
748
727
|
* needs — satisfied by `AtscriptDbTable` / a controller's `this.table`.
|
|
@@ -835,9 +814,7 @@ interface ArbacDbScopeHelpers<T = unknown> {
|
|
|
835
814
|
* await this.table.insertOne({ ...row, ...scope.set() }, scope.writeOptions(this.table));
|
|
836
815
|
* ```
|
|
837
816
|
*/
|
|
838
|
-
declare function useArbacDbScope<T = unknown>(): Promise<ArbacDbScopeHelpers<T>>;
|
|
839
|
-
//#endregion
|
|
840
|
-
//#region src/moost-arbac.d.ts
|
|
817
|
+
export declare function useArbacDbScope<T = unknown>(): Promise<ArbacDbScopeHelpers<T>>;
|
|
841
818
|
/**
|
|
842
819
|
* A DI-enabled extension of the `Arbac` class for use within Moost.
|
|
843
820
|
*
|
|
@@ -849,7 +826,7 @@ declare function useArbacDbScope<T = unknown>(): Promise<ArbacDbScopeHelpers<T>>
|
|
|
849
826
|
* @template TUserAttrs - The type representing user attributes relevant to access control.
|
|
850
827
|
* @template TScope - The type representing access control scopes.
|
|
851
828
|
*/
|
|
852
|
-
declare class MoostArbac<TUserAttrs extends object, TScope extends object> extends Arbac$1<TUserAttrs, TScope> {
|
|
829
|
+
export declare class MoostArbac<TUserAttrs extends object, TScope extends object> extends Arbac$1<TUserAttrs, TScope> {
|
|
853
830
|
private scopeFieldRules;
|
|
854
831
|
/**
|
|
855
832
|
* Register the conjunction rule of custom (declaration-merged) scope
|
|
@@ -916,5 +893,4 @@ declare class MoostArbac<TUserAttrs extends object, TScope extends object> exten
|
|
|
916
893
|
/** The registered custom scope field rules. @since 0.1.72 */
|
|
917
894
|
getScopeFields(): TScopeFieldRules<TScope>;
|
|
918
895
|
}
|
|
919
|
-
|
|
920
|
-
export { ARBAC_DELEGATED_AUTH, type AoothArbacClaims, Arbac, ArbacAction, ArbacAuthorize, ArbacDbScope, type ArbacDbScopeHelpers, ArbacDelegatedAuth, ArbacEvaluateOptions, type ArbacGuardedTable, type ArbacRelationResolution, ArbacResource, type ArbacScopedTable, ArbacUserProvider, ArbacUserProviderToken, type ArbacWriteTable, AsArbacDbController, AsArbacDbReadableController, AsArbacJsonValueHelpController, AsArbacValueHelpController, type ConjoinArbacDbScopesOptions, type ControlGate, type ControlsOf, type MetaVisibility, MoostArbac, type NavRelationKey, type NavTarget, type OwnFieldKey, type ProjectionOf, type RefForeignKey, type RefTableSource, type ScopeVisibilityOptions, type TArbacCompiledRule, type TArbacEvalResult, TArbacMeta, type TArbacRole, type TArbacRoleForResource, type TArbacRule, type VisibilityTableSource, applyAllowedFieldsAndSet, applyArbacControls, applyArbacMetaOverlay, applyArbacProjection, applyArbacRelationScopes, arbacActionRowScope, arbacAllowedActions, arbacAuthorizeInterceptor, arbacPatternToRegex, arbacRelationFilter, arbacRowFilter, authorizeArbacForm, buildScopeVisibility, cachedRequestScopes, checkArbacWrite, collectMethodNames, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, conjoinScopeFilters, enforceControlsPolicy, extractUsedControlValues, getArbacMate, getArbacScopes, guardArbacRemove, guardArbacWrite, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, prepareArbacRequest, pruneMetaByVisibility, registerArbacDbTarget, requestFieldVisible, requireRequestScopes, resolveHandlerArbacIds, resolveRequestScopes, unionScopeProjection, useArbac, useArbacDbScope };
|
|
896
|
+
export { ARBAC_DELEGATED_AUTH, type AoothArbacClaims, Arbac, ArbacDbScope, type ArbacDbScopeHelpers, ArbacDelegatedAuth, type ArbacGuardedTable, type ArbacRelationResolution, type ArbacScopedTable, ArbacUserProvider, ArbacUserProviderToken, type ArbacWriteTable, AsArbacDbController, type ConjoinArbacDbScopesOptions, type ControlGate, type ControlsOf, type MetaVisibility, type NavRelationKey, type NavTarget, type OwnFieldKey, type ProjectionOf, type RefForeignKey, type RefTableSource, type ScopeVisibilityOptions, type TArbacCompiledRule, type TArbacEvalResult, TArbacMeta, type TArbacRole, type TArbacRoleForResource, type TArbacRule, type VisibilityTableSource, applyAllowedFieldsAndSet, arbacPatternToRegex, conjoinArbacDbScopes, conjoinScopeFilters, enforceControlsPolicy, extractUsedControlValues, getArbacMate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as __decorate, n as ArbacUserProvider, r as ArbacUserProviderToken, t as __decorateMetadata } from "./decorateMetadata-
|
|
1
|
+
import { i as __decorate, n as ArbacUserProvider, r as ArbacUserProviderToken, t as __decorateMetadata } from "./decorateMetadata-BqEexuhv.mjs";
|
|
2
2
|
import { Arbac, Arbac as Arbac$1, arbacPatternToRegex } from "@aooth/arbac-core";
|
|
3
3
|
import { DB_SCOPE_KEYS, DENY_FILTER, ScopeFieldConfigError, applyScopeFieldFilters, conjoinScopeFilters, conjoinScopeFilters as conjoinScopeFilters$1, conjoinScopes, effectiveScope, expandExcludeToLeaves, getProjectionMode, intersectEnabled, isFieldAllowed, needsInheritedConjunction, normalizeScopes, restrictProjection, stableKey, unionOutcomes } from "@aooth/arbac";
|
|
4
4
|
import { Authenticate, HttpError } from "@moostjs/event-http";
|
|
@@ -7,7 +7,7 @@ import { Inherit, Injectable, TInterceptorPriority, defineBeforeInterceptor, get
|
|
|
7
7
|
import { computeInsights, containsRelationFilter, findAncestorInSet, getPath, hasRelationOp, isPlainObject, isRelationOp, translateQueryTree } from "@atscript/db";
|
|
8
8
|
import { AsDbController, AsDbReadableController, AsJsonValueHelpController, AsValueHelpController, DB_CRUD_HANDLERS, VALUE_HELP_CRUD_HANDLERS, badRequest, discoverRowLevelActions, getControllerFormType, getDbEndpoint, hasActionDelegations, resolveTerminalRef, stableMeta } from "@atscript/moost-db";
|
|
9
9
|
import { groupByFields, walkFilter } from "@uniqu/core";
|
|
10
|
-
|
|
10
|
+
// src/db/helpers.ts
|
|
11
11
|
/** `map.get(key)`, created with `create()` and stored on a miss. */
|
|
12
12
|
function getOrCreate(map, key, create) {
|
|
13
13
|
let value = map.get(key);
|
|
@@ -44,8 +44,7 @@ const navFieldsCache = /* @__PURE__ */ new WeakMap();
|
|
|
44
44
|
function navFieldsOf(table) {
|
|
45
45
|
return table.navFields ?? getOrCreate(navFieldsCache, table, () => new Set(table.relations?.keys()));
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
//#region src/db/visibility.ts
|
|
47
|
+
// src/db/visibility.ts
|
|
49
48
|
/**
|
|
50
49
|
* Union the per-scope `projection` whitelists into the single access-control
|
|
51
50
|
* projection used for FIELD-EXISTENCE decisions (`hasField` parity + `/meta`
|
|
@@ -289,8 +288,7 @@ function isIdentifierSet(source) {
|
|
|
289
288
|
function scopeVisibility(scopes, source = NO_TABLE) {
|
|
290
289
|
return getOrCreate(getOrCreate(scopeVisibilityCache, scopes, () => /* @__PURE__ */ new WeakMap()), source, () => isIdentifierSet(source) ? buildScopeVisibility(scopes, void 0, source) : buildScopeVisibility(scopes, source === NO_TABLE ? void 0 : source));
|
|
291
290
|
}
|
|
292
|
-
|
|
293
|
-
//#region src/db/relation-policy.ts
|
|
291
|
+
// src/db/relation-policy.ts
|
|
294
292
|
/** Registry bucket for controllers without an `app`. */
|
|
295
293
|
const NO_APP = {};
|
|
296
294
|
const registry = /* @__PURE__ */ new WeakMap();
|
|
@@ -504,8 +502,7 @@ function requestRelations(readable) {
|
|
|
504
502
|
const stored = ctx.has(requestRelationsKey) ? ctx.get(requestRelationsKey) : void 0;
|
|
505
503
|
return stored && stored.readable === readable ? stored.relations : void 0;
|
|
506
504
|
}
|
|
507
|
-
|
|
508
|
-
//#region src/db/write-refs.ts
|
|
505
|
+
// src/db/write-refs.ts
|
|
509
506
|
/**
|
|
510
507
|
* The FK a `checkRefs` entry designates: one of its local fields, or the TO
|
|
511
508
|
* relation it backs (`readable.foreignKeyOf`). A name that is neither is a
|
|
@@ -664,8 +661,7 @@ function prefetchRefTargets(scopes, table) {
|
|
|
664
661
|
}
|
|
665
662
|
for (const type of types) evaluateTypeRead(type).catch(() => {});
|
|
666
663
|
}
|
|
667
|
-
|
|
668
|
-
//#region src/attenuation.ts
|
|
664
|
+
// src/attenuation.ts
|
|
669
665
|
/**
|
|
670
666
|
* Conjoin the full-authority scopes (`userScopes`, the ceiling) and the
|
|
671
667
|
* credential's narrowed scopes (`credScopes`) into ONE composite
|
|
@@ -708,8 +704,7 @@ function conjoinArbacDbScopes(userScopes, credScopes, opts) {
|
|
|
708
704
|
fields
|
|
709
705
|
})];
|
|
710
706
|
}
|
|
711
|
-
|
|
712
|
-
//#region src/db/field-children.ts
|
|
707
|
+
// src/db/field-children.ts
|
|
713
708
|
const fieldChildrenCache = /* @__PURE__ */ new WeakMap();
|
|
714
709
|
const NONE = /* @__PURE__ */ new Set();
|
|
715
710
|
/**
|
|
@@ -735,8 +730,7 @@ function fieldChildrenOf(table) {
|
|
|
735
730
|
return (path) => byParent.get(path) ?? [];
|
|
736
731
|
});
|
|
737
732
|
}
|
|
738
|
-
|
|
739
|
-
//#region src/moost-arbac.ts
|
|
733
|
+
// src/moost-arbac.ts
|
|
740
734
|
/** Default number of memoized `/meta` projections per envelope. */
|
|
741
735
|
const DEFAULT_META_MEMO_MAX = 64;
|
|
742
736
|
let MoostArbac = class MoostArbac extends Arbac$1 {
|
|
@@ -830,8 +824,7 @@ let MoostArbac = class MoostArbac extends Arbac$1 {
|
|
|
830
824
|
}
|
|
831
825
|
};
|
|
832
826
|
MoostArbac = __decorate([Injectable()], MoostArbac);
|
|
833
|
-
|
|
834
|
-
//#region src/arbac.evaluate.ts
|
|
827
|
+
// src/arbac.evaluate.ts
|
|
835
828
|
/**
|
|
836
829
|
* The ARBAC resource + action a handler is authorized as. Resource: method
|
|
837
830
|
* `@ArbacResource` → class `@ArbacResource` → controller id → class name.
|
|
@@ -980,8 +973,7 @@ function evaluateArbacCached(resource, action, table) {
|
|
|
980
973
|
table: normalized
|
|
981
974
|
}, true);
|
|
982
975
|
}
|
|
983
|
-
|
|
984
|
-
//#region src/arbac.composables.ts
|
|
976
|
+
// src/arbac.composables.ts
|
|
985
977
|
/**
|
|
986
978
|
* Writable slot holding the evaluated scopes for the current event.
|
|
987
979
|
*
|
|
@@ -1042,7 +1034,11 @@ const useArbac = (_ctx) => {
|
|
|
1042
1034
|
};
|
|
1043
1035
|
const evaluateOrThrow = async (opts) => {
|
|
1044
1036
|
const result = await evaluate(opts);
|
|
1045
|
-
if (!result.allowed)
|
|
1037
|
+
if (!result.allowed) {
|
|
1038
|
+
const r = opts?.resource || resource;
|
|
1039
|
+
const a = opts?.action || action;
|
|
1040
|
+
throw new HttpError(403, `Forbidden: ${r}/${a}`);
|
|
1041
|
+
}
|
|
1046
1042
|
return {
|
|
1047
1043
|
...result,
|
|
1048
1044
|
allowed: true
|
|
@@ -1058,8 +1054,7 @@ const useArbac = (_ctx) => {
|
|
|
1058
1054
|
isPublic
|
|
1059
1055
|
};
|
|
1060
1056
|
};
|
|
1061
|
-
|
|
1062
|
-
//#region src/arbac.mate.ts
|
|
1057
|
+
// src/arbac.mate.ts
|
|
1063
1058
|
/**
|
|
1064
1059
|
* Returns the shared `Mate` instance typed with ARBAC metadata fields.
|
|
1065
1060
|
*
|
|
@@ -1081,8 +1076,7 @@ function getArbacMate() {
|
|
|
1081
1076
|
* @since 0.1.72
|
|
1082
1077
|
*/
|
|
1083
1078
|
const ARBAC_DELEGATED_AUTH = Symbol.for("aooth.arbac.delegatedAuth");
|
|
1084
|
-
|
|
1085
|
-
//#region src/arbac.decorator.ts
|
|
1079
|
+
// src/arbac.decorator.ts
|
|
1086
1080
|
/**
|
|
1087
1081
|
* ARBAC checks authorization, not authentication, so the transport
|
|
1088
1082
|
* declaration is empty — pair with an upstream auth guard (e.g. JWT
|
|
@@ -1129,8 +1123,7 @@ const ArbacResource = (name) => getArbacMate().decorate("arbacResourceId", name)
|
|
|
1129
1123
|
* at the method level.
|
|
1130
1124
|
*/
|
|
1131
1125
|
const ArbacAction = (name) => getArbacMate().decorate("arbacActionId", name);
|
|
1132
|
-
|
|
1133
|
-
//#region src/db/meta-memo.ts
|
|
1126
|
+
// src/db/meta-memo.ts
|
|
1134
1127
|
/** Deepest relation nesting the decision record follows; deeper → not memoized. */
|
|
1135
1128
|
const MAX_RECORD_DEPTH = 16;
|
|
1136
1129
|
var Unkeyable = class extends Error {};
|
|
@@ -1307,8 +1300,7 @@ function memoMetaProjection(envelope, key, max, compute) {
|
|
|
1307
1300
|
function shareMeta(obj) {
|
|
1308
1301
|
return stableMeta(obj);
|
|
1309
1302
|
}
|
|
1310
|
-
|
|
1311
|
-
//#region src/db/meta-projection.ts
|
|
1303
|
+
// src/db/meta-projection.ts
|
|
1312
1304
|
/**
|
|
1313
1305
|
* Exact-or-ancestor membership in the write whitelist: `credit.credentials.user`
|
|
1314
1306
|
* matches a `credit.credentials` grant. A path through a nav relation is
|
|
@@ -2037,7 +2029,7 @@ function formChildren(runtime, node) {
|
|
|
2037
2029
|
/** Nested-relation walk bound — serialized nav bodies are finite, this only guards pathological input. */
|
|
2038
2030
|
const MAX_NAV_DEPTH = 8;
|
|
2039
2031
|
/** The form walk bound; past it every `ref` / binding is stripped (fail closed). */
|
|
2040
|
-
const MAX_FORM_DEPTH =
|
|
2032
|
+
const MAX_FORM_DEPTH = 16;
|
|
2041
2033
|
function serializedChildren(node) {
|
|
2042
2034
|
const def = node.type;
|
|
2043
2035
|
return [
|
|
@@ -2421,8 +2413,7 @@ function collectMethodNames(instance) {
|
|
|
2421
2413
|
}
|
|
2422
2414
|
return [...names];
|
|
2423
2415
|
}
|
|
2424
|
-
|
|
2425
|
-
//#region src/db/shared-read-helpers.ts
|
|
2416
|
+
// src/db/shared-read-helpers.ts
|
|
2426
2417
|
/**
|
|
2427
2418
|
* Restrict the user-supplied `$select` to the scopes' projection union.
|
|
2428
2419
|
* Returns the original projection untouched when no scope declares a
|
|
@@ -2453,7 +2444,8 @@ function applyArbacProjection(projection, scopes, readable) {
|
|
|
2453
2444
|
function restrictSelect(projection, vis) {
|
|
2454
2445
|
if (Object.keys(vis.allowed).length === 0) return projection;
|
|
2455
2446
|
const childrenOf = fieldChildrenOf(vis.table);
|
|
2456
|
-
|
|
2447
|
+
const result = restrictProjection(normalizeSelect(projection) ?? {}, vis.allowed, childrenOf);
|
|
2448
|
+
return expandExcludeToLeaves(result, childrenOf);
|
|
2457
2449
|
}
|
|
2458
2450
|
/**
|
|
2459
2451
|
* Enforce the union of per-scope `controls` gates against the parsed
|
|
@@ -2539,8 +2531,7 @@ function normalizeSelect(value) {
|
|
|
2539
2531
|
}
|
|
2540
2532
|
if (typeof value === "object") return value;
|
|
2541
2533
|
}
|
|
2542
|
-
|
|
2543
|
-
//#region src/db/request-scopes.ts
|
|
2534
|
+
// src/db/request-scopes.ts
|
|
2544
2535
|
/** Endpoints whose `prepareRequest` carries parsed Uniquery controls. */
|
|
2545
2536
|
const READ_ENDPOINTS = /* @__PURE__ */ new Set([
|
|
2546
2537
|
"query",
|
|
@@ -2829,8 +2820,7 @@ function arbacRelationFilter(path, filter, readable) {
|
|
|
2829
2820
|
if (!level?.scopes) throw badRequest(path, `Unknown field "${path}"`);
|
|
2830
2821
|
return conjoinScopeFilters$1(effectiveScope(level.scopes).filter, filter) ?? filter;
|
|
2831
2822
|
}
|
|
2832
|
-
|
|
2833
|
-
//#region src/db/write-fields.ts
|
|
2823
|
+
// src/db/write-fields.ts
|
|
2834
2824
|
/**
|
|
2835
2825
|
* Test-friendly internal helper — exported for unit tests and helper
|
|
2836
2826
|
* composition; regular consumers should not call this directly.
|
|
@@ -2947,8 +2937,7 @@ function applyPreparedOverlay(data, prepared) {
|
|
|
2947
2937
|
if (prepared.setOverrides) for (const [path, value] of prepared.setOverrides) setPath$1(merged, path, value, prepared.isMergePatch);
|
|
2948
2938
|
return merged;
|
|
2949
2939
|
}
|
|
2950
|
-
|
|
2951
|
-
//#region src/db/write-check.ts
|
|
2940
|
+
// src/db/write-check.ts
|
|
2952
2941
|
/** Thrown by {@link compileScopeCheck} for an operator the evaluator does not model. */
|
|
2953
2942
|
var UnsupportedCheckError = class extends Error {};
|
|
2954
2943
|
/**
|
|
@@ -3071,8 +3060,7 @@ function setPath(target, path, value) {
|
|
|
3071
3060
|
}
|
|
3072
3061
|
node[segs.at(-1)] = value;
|
|
3073
3062
|
}
|
|
3074
|
-
|
|
3075
|
-
//#region src/db/write-policy.ts
|
|
3063
|
+
// src/db/write-policy.ts
|
|
3076
3064
|
const OUT_OF_SCOPE = "Row outside your write scope";
|
|
3077
3065
|
/**
|
|
3078
3066
|
* Nested writes through nav props are denied unless a write scope opts the
|
|
@@ -3185,8 +3173,7 @@ async function guardArbacRemove(ctx, scopes, table) {
|
|
|
3185
3173
|
controls: {}
|
|
3186
3174
|
}) === 0) throw new HttpError(404, "Not found");
|
|
3187
3175
|
}
|
|
3188
|
-
|
|
3189
|
-
//#region src/db/as-arbac-db-controller.ts
|
|
3176
|
+
// src/db/as-arbac-db-controller.ts
|
|
3190
3177
|
let AsArbacDbController = class AsArbacDbController extends AsDbController {
|
|
3191
3178
|
/** Makes this controller the `$with` policy source for its table's ARBAC resource. */
|
|
3192
3179
|
_arbacRelationTarget = registerArbacDbTarget(this);
|
|
@@ -3488,8 +3475,7 @@ function remapUniquUrlSyntaxError(err) {
|
|
|
3488
3475
|
if (!/at (?:pos )?\d+/.test(msg)) return err;
|
|
3489
3476
|
return new HttpError(400, `Invalid query string: ${msg}`);
|
|
3490
3477
|
}
|
|
3491
|
-
|
|
3492
|
-
//#region src/db/as-arbac-db-readable-controller.ts
|
|
3478
|
+
// src/db/as-arbac-db-readable-controller.ts
|
|
3493
3479
|
let AsArbacDbReadableController = class AsArbacDbReadableController extends AsDbReadableController {
|
|
3494
3480
|
/** Makes this controller the `$with` policy source for its table's ARBAC resource. */
|
|
3495
3481
|
_arbacRelationTarget = registerArbacDbTarget(this);
|
|
@@ -3551,8 +3537,7 @@ let AsArbacDbReadableController = class AsArbacDbReadableController extends AsDb
|
|
|
3551
3537
|
}
|
|
3552
3538
|
};
|
|
3553
3539
|
AsArbacDbReadableController = __decorate([Inherit()], AsArbacDbReadableController);
|
|
3554
|
-
|
|
3555
|
-
//#region src/db/as-arbac-value-help-controller.ts
|
|
3540
|
+
// src/db/as-arbac-value-help-controller.ts
|
|
3556
3541
|
function valueHelpHost(boundType, primaryKey, searchableFields) {
|
|
3557
3542
|
const ids = primaryKey ? [primaryKey] : [];
|
|
3558
3543
|
return {
|
|
@@ -3749,8 +3734,7 @@ __decorate([
|
|
|
3749
3734
|
__decorateMetadata("design:returntype", typeof ReturnType === "undefined" ? Object : ReturnType)
|
|
3750
3735
|
], AsArbacJsonValueHelpController.prototype, "runGetOneComposite", null);
|
|
3751
3736
|
AsArbacJsonValueHelpController = __decorate([Inherit()], AsArbacJsonValueHelpController);
|
|
3752
|
-
|
|
3753
|
-
//#region src/db/use-arbac-db-scope.ts
|
|
3737
|
+
// src/db/use-arbac-db-scope.ts
|
|
3754
3738
|
/**
|
|
3755
3739
|
* The current event's merged ARBAC DB scope, for custom routes and
|
|
3756
3740
|
* `@DbAction` handlers that query the table directly. Resolves the event's
|
|
@@ -3812,5 +3796,4 @@ async function useArbacDbScope() {
|
|
|
3812
3796
|
})
|
|
3813
3797
|
};
|
|
3814
3798
|
}
|
|
3815
|
-
//#endregion
|
|
3816
3799
|
export { ARBAC_DELEGATED_AUTH, Arbac, ArbacAction, ArbacAuthorize, ArbacResource, ArbacUserProvider, ArbacUserProviderToken, AsArbacDbController, AsArbacDbReadableController, AsArbacJsonValueHelpController, AsArbacValueHelpController, MoostArbac, applyAllowedFieldsAndSet, applyArbacControls, applyArbacMetaOverlay, applyArbacProjection, applyArbacRelationScopes, arbacActionRowScope, arbacAllowedActions, arbacAuthorizeInterceptor, arbacPatternToRegex, arbacRelationFilter, arbacRowFilter, authorizeArbacForm, buildScopeVisibility, cachedRequestScopes, checkArbacWrite, collectMethodNames, collectWithGrantNames, collectWritableFields, conjoinArbacDbScopes, conjoinScopeFilters, enforceControlsPolicy, extractUsedControlValues, getArbacMate, getArbacScopes, guardArbacRemove, guardArbacWrite, isMetaFieldVisible, isScopedFieldVisible, metaAlwaysVisibleFields, prepareArbacRequest, pruneMetaByVisibility, registerArbacDbTarget, requestFieldVisible, requireRequestScopes, resolveHandlerArbacIds, resolveRequestScopes, unionScopeProjection, useArbac, useArbacDbScope };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TAtscriptPlugin } from "@atscript/core";
|
|
2
|
-
//#region src/plugin.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Registers the `@arbac.*` annotation namespace for `@aooth/arbac-moost`:
|
|
5
4
|
*
|
|
@@ -45,6 +44,4 @@ import { TAtscriptPlugin } from "@atscript/core";
|
|
|
45
44
|
* export default { plugins: [arbacPlugin()] }
|
|
46
45
|
* ```
|
|
47
46
|
*/
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
export { arbacPlugin as default };
|
|
47
|
+
export default function arbacPlugin(): TAtscriptPlugin;
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnnotationSpec } from "@atscript/core";
|
|
2
|
-
|
|
2
|
+
// src/plugin.ts
|
|
3
3
|
/**
|
|
4
4
|
* Registers the `@arbac.*` annotation namespace for `@aooth/arbac-moost`:
|
|
5
5
|
*
|
|
@@ -115,5 +115,4 @@ function arbacPlugin() {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
//#endregion
|
|
119
118
|
export { arbacPlugin as default };
|
|
@@ -3,7 +3,6 @@ import { Mate, TClassConstructor, TMateParamMeta, TMoostMetadata } from "moost";
|
|
|
3
3
|
import { FilterExpr, TDbRemoveGuardContext, TDbWriteAction, TDbWriteCheckContext, TDbWriteGuardContext, TMetaResponse, UniqueryControls } from "@atscript/db";
|
|
4
4
|
import { AsDbController, TDbActionScopeContext, TDbControlsType, TDbRequestContext } from "@atscript/moost-db";
|
|
5
5
|
import { NavPropsOf, OwnPropsOf, TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
6
|
-
//#region src/arbac.mate.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* ARBAC metadata fields attached to classes and methods by ARBAC decorators.
|
|
9
8
|
*
|
|
@@ -47,8 +46,6 @@ declare const ARBAC_DELEGATED_AUTH: unique symbol;
|
|
|
47
46
|
interface ArbacDelegatedAuth {
|
|
48
47
|
[ARBAC_DELEGATED_AUTH](method: string): boolean;
|
|
49
48
|
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/db/scope-types.d.ts
|
|
52
49
|
/**
|
|
53
50
|
* Unwrap a `NavPropsOf<T>[K]` value to its target model type:
|
|
54
51
|
* `Comment[]` → `Comment`, `Task` → `Task`. Used to recurse `with.<K>` into
|
|
@@ -99,8 +96,6 @@ type ControlsOf<T> = IsUnknown<T> extends true ? Record<string, ControlGate> : {
|
|
|
99
96
|
$with?: ReadonlyArray<NavRelationKey<T>> | boolean;
|
|
100
97
|
$groupBy?: ReadonlyArray<OwnFieldKey<T>> | boolean;
|
|
101
98
|
} & Partial<Record<BooleanControl, boolean>>;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/db/write-fields.d.ts
|
|
104
99
|
/**
|
|
105
100
|
* Test-friendly internal helper — exported for unit tests and helper
|
|
106
101
|
* composition; regular consumers should not call this directly.
|
|
@@ -123,8 +118,6 @@ type ControlsOf<T> = IsUnknown<T> extends true ? Record<string, ControlGate> : {
|
|
|
123
118
|
* does not carry is skipped (adding the block would clear its other leaves).
|
|
124
119
|
*/
|
|
125
120
|
declare function applyAllowedFieldsAndSet(data: unknown, scopes: ArbacDbScope[], preserveFields?: readonly string[], isMergePatch?: (objectPath: string) => boolean): unknown;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/db/as-arbac-db-controller.d.ts
|
|
128
121
|
type TSelect = UniqueryControls["$select"];
|
|
129
122
|
/**
|
|
130
123
|
* Contract returned by an ARBAC role's scope predicate on a DB-backed resource.
|
|
@@ -442,8 +435,6 @@ declare function enforceControlsPolicy(policy: Record<string, ControlGate>, cont
|
|
|
442
435
|
* gate, which throws if a non-whitelistable control receives a string[]).
|
|
443
436
|
*/
|
|
444
437
|
declare function extractUsedControlValues(key: string, value: unknown, controls?: Record<string, unknown>): string[];
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/db/write-refs.d.ts
|
|
447
438
|
/** A `@db.rel.FK` entry as atscript-db's readable exposes it. */
|
|
448
439
|
interface RefForeignKey {
|
|
449
440
|
readonly fields: readonly string[];
|
|
@@ -458,8 +449,6 @@ interface RefTableSource {
|
|
|
458
449
|
/** The FK a TO relation is backed by (atscript-db's `readable.foreignKeyOf`). @since 0.1.72 */
|
|
459
450
|
foreignKeyOf?(relationName: string): RefForeignKey | undefined;
|
|
460
451
|
}
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region src/attenuation.d.ts
|
|
463
452
|
/**
|
|
464
453
|
* The restrict-only ARBAC attenuation carried by a credential — its assumed
|
|
465
454
|
* role SUBSET and narrowing attribute overrides. Sourced into evaluation via
|
|
@@ -535,8 +524,6 @@ interface ConjoinArbacDbScopesOptions {
|
|
|
535
524
|
*/
|
|
536
525
|
fields?: TScopeFieldRules<ArbacDbScope>;
|
|
537
526
|
}
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/user.provider.d.ts
|
|
540
527
|
/**
|
|
541
528
|
* Abstract base class for providing user data required for ARBAC evaluations.
|
|
542
529
|
*
|
|
@@ -591,5 +578,4 @@ declare abstract class ArbacUserProvider<TUserAttrs extends object = object> {
|
|
|
591
578
|
* etc. Runtime resolves to the concrete subclass registered via DI.
|
|
592
579
|
*/
|
|
593
580
|
declare const ArbacUserProviderToken: TClassConstructor<ArbacUserProvider>;
|
|
594
|
-
//#endregion
|
|
595
581
|
export { ProjectionOf as _, conjoinArbacDbScopes as a, TArbacMeta as b, ArbacDbScope as c, extractUsedControlValues as d, applyAllowedFieldsAndSet as f, OwnFieldKey as g, NavTarget as h, ConjoinArbacDbScopesOptions as i, AsArbacDbController as l, NavRelationKey as m, ArbacUserProviderToken as n, RefForeignKey as o, ControlsOf as p, AoothArbacClaims as r, RefTableSource as s, ArbacUserProvider as t, enforceControlsPolicy as u, ARBAC_DELEGATED_AUTH as v, getArbacMate as x, ArbacDelegatedAuth as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aooth/arbac-moost",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Moost RBAC integration for aoothjs (migrated from @moostjs/arbac)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"abac",
|
|
@@ -61,29 +61,29 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@uniqu/core": "^0.1.15",
|
|
64
|
-
"@aooth/arbac": "0.2.
|
|
65
|
-
"@aooth/
|
|
66
|
-
"@aooth/
|
|
64
|
+
"@aooth/arbac": "0.2.2",
|
|
65
|
+
"@aooth/user": "0.2.2",
|
|
66
|
+
"@aooth/arbac-core": "0.2.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@atscript/core": "^0.2.
|
|
70
|
-
"@atscript/db": "^0.1.
|
|
71
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
72
|
-
"@atscript/db-sqlite": "^0.1.
|
|
73
|
-
"@atscript/moost-db": "^0.1.
|
|
74
|
-
"@atscript/typescript": "^0.2.
|
|
75
|
-
"@moostjs/event-http": "^0.7.
|
|
69
|
+
"@atscript/core": "^0.2.3",
|
|
70
|
+
"@atscript/db": "^0.1.167",
|
|
71
|
+
"@atscript/db-sql-tools": "^0.1.167",
|
|
72
|
+
"@atscript/db-sqlite": "^0.1.167",
|
|
73
|
+
"@atscript/moost-db": "^0.1.167",
|
|
74
|
+
"@atscript/typescript": "^0.2.3",
|
|
75
|
+
"@moostjs/event-http": "^0.7.1",
|
|
76
76
|
"@types/better-sqlite3": "^7.6.13",
|
|
77
77
|
"better-sqlite3": "^12.6.2",
|
|
78
|
-
"unplugin-atscript": "^0.2.
|
|
78
|
+
"unplugin-atscript": "^0.2.3"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@atscript/db": "^0.1.
|
|
82
|
-
"@atscript/moost-db": "^0.1.
|
|
83
|
-
"@atscript/typescript": "^0.2.
|
|
84
|
-
"@moostjs/event-http": "^0.7.
|
|
81
|
+
"@atscript/db": "^0.1.167",
|
|
82
|
+
"@atscript/moost-db": "^0.1.167",
|
|
83
|
+
"@atscript/typescript": "^0.2.3",
|
|
84
|
+
"@moostjs/event-http": "^0.7.1",
|
|
85
85
|
"@wooksjs/event-core": "^0.8.0",
|
|
86
|
-
"moost": "^0.7.
|
|
86
|
+
"moost": "^0.7.1"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@atscript/db": {
|