@astram/core 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authentication/captcha.d.ts +58 -0
- package/dist/authentication/captcha.d.ts.map +1 -0
- package/dist/authentication/captcha.js +37 -0
- package/dist/authentication/captcha.js.map +1 -0
- package/dist/authentication/index.d.ts +3 -0
- package/dist/authentication/index.d.ts.map +1 -1
- package/dist/authentication/index.js +6 -0
- package/dist/authentication/index.js.map +1 -1
- package/dist/authentication/login-name.d.ts +22 -0
- package/dist/authentication/login-name.d.ts.map +1 -0
- package/dist/authentication/login-name.js +35 -0
- package/dist/authentication/login-name.js.map +1 -0
- package/dist/authentication/mfa-requirement.d.ts +156 -0
- package/dist/authentication/mfa-requirement.d.ts.map +1 -0
- package/dist/authentication/mfa-requirement.js +122 -0
- package/dist/authentication/mfa-requirement.js.map +1 -0
- package/dist/authorization/delegation/operation-identity.d.ts.map +1 -1
- package/dist/authorization/delegation/operation-identity.js +19 -1
- package/dist/authorization/delegation/operation-identity.js.map +1 -1
- package/dist/authorization/index.d.ts +1 -0
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +2 -0
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/record/permit-tier.d.ts +4 -0
- package/dist/authorization/record/permit-tier.d.ts.map +1 -1
- package/dist/authorization/record/permit-tier.js +13 -0
- package/dist/authorization/record/permit-tier.js.map +1 -1
- package/dist/authorization/record/separation-of-duties.d.ts +45 -0
- package/dist/authorization/record/separation-of-duties.d.ts.map +1 -0
- package/dist/authorization/record/separation-of-duties.js +72 -0
- package/dist/authorization/record/separation-of-duties.js.map +1 -0
- package/dist/database/framework-tables.d.ts.map +1 -1
- package/dist/database/framework-tables.js +2 -0
- package/dist/database/framework-tables.js.map +1 -1
- package/dist/metadata/index.d.ts +11 -0
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js.map +1 -1
- package/dist-cjs/authentication/captcha.js +40 -0
- package/dist-cjs/authentication/index.js +6 -0
- package/dist-cjs/authentication/login-name.js +39 -0
- package/dist-cjs/authentication/mfa-requirement.js +127 -0
- package/dist-cjs/authorization/delegation/operation-identity.js +18 -0
- package/dist-cjs/authorization/index.js +2 -0
- package/dist-cjs/authorization/record/permit-tier.js +13 -0
- package/dist-cjs/authorization/record/separation-of-duties.js +76 -0
- package/dist-cjs/database/framework-tables.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
|
|
4
|
+
* (R4, R5, R7, D-4, D-7).
|
|
5
|
+
*
|
|
6
|
+
* A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
|
|
7
|
+
* (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
|
|
8
|
+
* BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
|
|
9
|
+
* a declared action whose attribute is missing or malformed is unverifiable and fails closed.
|
|
10
|
+
*
|
|
11
|
+
* PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
|
|
12
|
+
* `ctx.context.attributes`. Never throws on odd attribute shapes.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = exports.SEPARATION_OF_DUTIES_DENY_DETAIL = exports.SEPARATION_OF_DUTIES_ATTRIBUTE = void 0;
|
|
16
|
+
exports.isSeparationOfDutiesDeny = isSeparationOfDutiesDeny;
|
|
17
|
+
exports.evaluateSeparationOfDuties = evaluateSeparationOfDuties;
|
|
18
|
+
/** Decision-attribute key under which the engine supplies the SoD facts. */
|
|
19
|
+
exports.SEPARATION_OF_DUTIES_ATTRIBUTE = 'shield.separationOfDuties';
|
|
20
|
+
/** Deny detail when the principal is named in the record's facts. */
|
|
21
|
+
exports.SEPARATION_OF_DUTIES_DENY_DETAIL = 'separation_of_duties';
|
|
22
|
+
/** Deny detail when a bound action arrives without valid facts (fail closed). */
|
|
23
|
+
exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = 'separation_of_duties_unverified';
|
|
24
|
+
/**
|
|
25
|
+
* Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
|
|
26
|
+
* one: a delegated operation is bound by the rule like any other principal (ADR-0048).
|
|
27
|
+
*/
|
|
28
|
+
function isSeparationOfDutiesDeny(decision) {
|
|
29
|
+
return (decision.effect === 'deny' &&
|
|
30
|
+
decision.reason === 'explicit_deny_policy' &&
|
|
31
|
+
(decision.detail === exports.SEPARATION_OF_DUTIES_DENY_DETAIL ||
|
|
32
|
+
decision.detail === exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* - `unbound`: the type does not declare SoD for this action (nothing to enforce).
|
|
36
|
+
* - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
|
|
37
|
+
* - `bound_principal`: the principal appears in `actorIds` (deny).
|
|
38
|
+
* - `clear`: declared, verified, principal not named.
|
|
39
|
+
*
|
|
40
|
+
* A registry throw propagates, as in the other gate-6 evaluators.
|
|
41
|
+
*/
|
|
42
|
+
function evaluateSeparationOfDuties(ctx) {
|
|
43
|
+
const descriptor = ctx.deps.registry.resolveObjectType(ctx.resource.typeKey);
|
|
44
|
+
const declarations = descriptor?.separationOfDuties;
|
|
45
|
+
if (!Array.isArray(declarations))
|
|
46
|
+
return 'unbound';
|
|
47
|
+
const declared = declarations.some((d) => d !== null &&
|
|
48
|
+
typeof d === 'object' &&
|
|
49
|
+
Array.isArray(d.actions) &&
|
|
50
|
+
d.actions.includes(ctx.action.key));
|
|
51
|
+
if (!declared)
|
|
52
|
+
return 'unbound';
|
|
53
|
+
const attributes = ctx.context.attributes;
|
|
54
|
+
if (attributes === undefined || attributes === null)
|
|
55
|
+
return 'unverified';
|
|
56
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, exports.SEPARATION_OF_DUTIES_ATTRIBUTE)) {
|
|
57
|
+
return 'unverified';
|
|
58
|
+
}
|
|
59
|
+
const value = attributes[exports.SEPARATION_OF_DUTIES_ATTRIBUTE];
|
|
60
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
61
|
+
return 'unverified';
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(value, 'actorIds'))
|
|
63
|
+
return 'unverified';
|
|
64
|
+
const actorIds = value.actorIds;
|
|
65
|
+
if (!Array.isArray(actorIds))
|
|
66
|
+
return 'unverified';
|
|
67
|
+
for (const id of actorIds) {
|
|
68
|
+
if (typeof id !== 'string')
|
|
69
|
+
return 'unverified';
|
|
70
|
+
}
|
|
71
|
+
const principalId = ctx.principal.id;
|
|
72
|
+
if (typeof principalId === 'string' && principalId.length > 0 && actorIds.includes(principalId)) {
|
|
73
|
+
return 'bound_principal';
|
|
74
|
+
}
|
|
75
|
+
return 'clear';
|
|
76
|
+
}
|
|
@@ -25,6 +25,7 @@ exports.FRAMEWORK_TABLES = Object.freeze({
|
|
|
25
25
|
'shared_resource',
|
|
26
26
|
'service_account',
|
|
27
27
|
'stored_file',
|
|
28
|
+
'security_policy',
|
|
28
29
|
]),
|
|
29
30
|
identity: Object.freeze([
|
|
30
31
|
'identity_credential',
|
|
@@ -34,6 +35,7 @@ exports.FRAMEWORK_TABLES = Object.freeze({
|
|
|
34
35
|
'password_reset_token',
|
|
35
36
|
'mfa_recovery_code',
|
|
36
37
|
'email_change_token',
|
|
38
|
+
'mfa_requirement_state',
|
|
37
39
|
]),
|
|
38
40
|
authz: Object.freeze([
|
|
39
41
|
'permission',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — sealed security core (Identity, Authentication, Session, Risk, Authorization, Audit). ZERO framework deps — the portable decision brain (ADR-0003). The frozen public contract consumers build against; installed, not edited (ADR-0023).",
|
|
6
6
|
"type": "module",
|