@astram/guard 0.14.0 → 0.15.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/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +57 -30
- package/dist/authentication/mariadb-api-key-store.d.ts +10 -1
- package/dist/authentication/mariadb-api-key-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-api-key-store.js +20 -10
- package/dist/authentication/mariadb-credential-resolver.d.ts +8 -1
- package/dist/authentication/mariadb-credential-resolver.d.ts.map +1 -1
- package/dist/authentication/mariadb-credential-resolver.js +15 -5
- package/dist/authentication/mariadb-credential-writer.d.ts +6 -1
- package/dist/authentication/mariadb-credential-writer.d.ts.map +1 -1
- package/dist/authentication/mariadb-credential-writer.js +9 -3
- package/dist/authentication/mariadb-email-address-changer.d.ts +10 -1
- package/dist/authentication/mariadb-email-address-changer.d.ts.map +1 -1
- package/dist/authentication/mariadb-email-address-changer.js +22 -9
- package/dist/authentication/mariadb-email-change-token-store.d.ts +8 -1
- package/dist/authentication/mariadb-email-change-token-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-email-change-token-store.js +18 -9
- package/dist/authentication/mariadb-mfa-device-store.d.ts +6 -1
- package/dist/authentication/mariadb-mfa-device-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-mfa-device-store.js +22 -13
- package/dist/authentication/mariadb-profile-resolver.d.ts +6 -1
- package/dist/authentication/mariadb-profile-resolver.d.ts.map +1 -1
- package/dist/authentication/mariadb-profile-resolver.js +12 -6
- package/dist/authentication/mariadb-profile-writer.d.ts +6 -1
- package/dist/authentication/mariadb-profile-writer.d.ts.map +1 -1
- package/dist/authentication/mariadb-profile-writer.js +11 -4
- package/dist/authentication/mariadb-recovery-code-store.d.ts +6 -1
- package/dist/authentication/mariadb-recovery-code-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-recovery-code-store.js +11 -5
- package/dist/authentication/mariadb-reset-token-store.d.ts +6 -1
- package/dist/authentication/mariadb-reset-token-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-reset-token-store.js +11 -5
- package/dist/authentication/mariadb-session-sweeper.d.ts +6 -1
- package/dist/authentication/mariadb-session-sweeper.d.ts.map +1 -1
- package/dist/authentication/mariadb-session-sweeper.js +11 -5
- package/dist/authz/cross-tenant-grant-writer.d.ts.map +1 -1
- package/dist/authz/cross-tenant-grant-writer.js +4 -3
- package/dist/authz/list-scope-sql.d.ts +10 -2
- package/dist/authz/list-scope-sql.d.ts.map +1 -1
- package/dist/authz/list-scope-sql.js +4 -4
- package/dist/authz/mariadb-cross-tenant-grant-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-cross-tenant-grant-adapter.js +4 -3
- package/dist/authz/mariadb-list-scope-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-list-scope-adapter.js +4 -3
- package/dist/authz/mariadb-policy-store.d.ts.map +1 -1
- package/dist/authz/mariadb-policy-store.js +4 -3
- package/dist/authz/mariadb-record-rule-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-record-rule-adapter.js +4 -3
- package/dist/authz/mariadb-record-share-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-record-share-adapter.js +4 -3
- package/dist/authz/record-share-cascade.d.ts.map +1 -1
- package/dist/authz/record-share-cascade.js +4 -3
- package/dist/authz/record-share-writer.d.ts.map +1 -1
- package/dist/authz/record-share-writer.js +4 -3
- package/dist/authz/wire-record-authorization.d.ts +8 -0
- package/dist/authz/wire-record-authorization.d.ts.map +1 -1
- package/dist/authz/wire-record-authorization.js +14 -6
- package/dist/boot/boot-sequence.d.ts +4 -0
- package/dist/boot/boot-sequence.d.ts.map +1 -1
- package/dist/boot/boot-sequence.js +13 -1
- package/dist/boot/migration-ledger-check.d.ts +94 -0
- package/dist/boot/migration-ledger-check.d.ts.map +1 -0
- package/dist/boot/migration-ledger-check.js +280 -0
- package/dist/config/app-config.d.ts +29 -3
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js +37 -6
- package/dist/config/config.module.d.ts +7 -0
- package/dist/config/config.module.d.ts.map +1 -1
- package/dist/config/config.module.js +8 -1
- package/dist/config/framework-schema-names.d.ts +29 -0
- package/dist/config/framework-schema-names.d.ts.map +1 -0
- package/dist/config/framework-schema-names.js +41 -0
- package/dist/identity/permission-facts.adapter.d.ts +7 -1
- package/dist/identity/permission-facts.adapter.d.ts.map +1 -1
- package/dist/identity/permission-facts.adapter.js +15 -6
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +43 -7
- package/dist/session/mariadb-session-record-store.d.ts +8 -1
- package/dist/session/mariadb-session-record-store.d.ts.map +1 -1
- package/dist/session/mariadb-session-record-store.js +23 -13
- package/dist/session/session-restriction-store.d.ts +8 -1
- package/dist/session/session-restriction-store.d.ts.map +1 -1
- package/dist/session/session-restriction-store.js +15 -5
- package/migrations/1710000000006-CreateAuthzSchema.cjs +15 -4
- package/migrations/1710000000007-ExtendPermissionAndRolePermission.cjs +11 -3
- package/migrations/1710000000008-CreateAccessBundleTables.cjs +14 -4
- package/migrations/1710000000009-CreateRecordPermissionRule.cjs +15 -4
- package/migrations/1710000000014-CreateRecordShare.cjs +15 -4
- package/migrations/1710000000015-CreateScopeClosure.cjs +14 -4
- package/migrations/1710000000016-AlterCompanyParentFkRestrict.cjs +20 -9
- package/migrations/1710000000017-CreateServiceAccountKey.cjs +14 -4
- package/package.json +3 -3
|
@@ -25,10 +25,19 @@
|
|
|
25
25
|
* drops the table. Run by the DDL account.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
29
|
+
|
|
30
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
31
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
32
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
33
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
34
|
+
const replacesChecksums = ['0e28b8f4682dea265dbd399d153f29c3f42c80e826dbe8bc5cbd3319fbdc4db3'];
|
|
35
|
+
|
|
29
36
|
const TS = 'TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP';
|
|
30
37
|
|
|
31
|
-
async function up(
|
|
38
|
+
async function up(ctx) {
|
|
39
|
+
const { query } = ctx;
|
|
40
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
32
41
|
await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`record_permission_rule\` (
|
|
33
42
|
rpr_uuid VARCHAR(36) NOT NULL,
|
|
34
43
|
rpr_policy_uuid VARCHAR(36) NULL, -- groups a guided policy's AND-composed condition-rows; NULL = legacy/unconditional single-row rule
|
|
@@ -49,8 +58,10 @@ async function up({ query }) {
|
|
|
49
58
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
async function down(
|
|
61
|
+
async function down(ctx) {
|
|
62
|
+
const { query } = ctx;
|
|
63
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
53
64
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`record_permission_rule\``);
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
module.exports = { up, down };
|
|
67
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -19,10 +19,19 @@
|
|
|
19
19
|
* account. No FK to `record_permission_rule` — the two tables are independent.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
23
|
+
|
|
24
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
25
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
26
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
27
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
28
|
+
const replacesChecksums = ['434236fcd1ef4c73a419674ebd757ce889a25c39744acb4db365a93c5230a844'];
|
|
29
|
+
|
|
23
30
|
const TS = 'TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP';
|
|
24
31
|
|
|
25
|
-
async function up(
|
|
32
|
+
async function up(ctx) {
|
|
33
|
+
const { query } = ctx;
|
|
34
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
26
35
|
await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`record_share\` (
|
|
27
36
|
rs_uuid VARCHAR(36) NOT NULL,
|
|
28
37
|
rs_tenant_uuid VARCHAR(36) NOT NULL, -- the tenant the shared record belongs to
|
|
@@ -42,8 +51,10 @@ async function up({ query }) {
|
|
|
42
51
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
async function down(
|
|
54
|
+
async function down(ctx) {
|
|
55
|
+
const { query } = ctx;
|
|
56
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
46
57
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`record_share\``);
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
module.exports = { up, down };
|
|
60
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -27,9 +27,17 @@
|
|
|
27
27
|
* the Application schema).
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
33
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
34
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
35
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
36
|
+
const replacesChecksums = ['91be11b8677118a50f8a786c967cc2643ab4d5db48b5847acb57560634ab4591'];
|
|
37
|
+
|
|
38
|
+
async function up(ctx) {
|
|
39
|
+
const { query } = ctx;
|
|
40
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
33
41
|
await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`scope_closure\` (
|
|
34
42
|
ancestor_uuid VARCHAR(36) NOT NULL, -- a node (company) in the hierarchy
|
|
35
43
|
descendant_uuid VARCHAR(36) NOT NULL, -- a node at or below the ancestor (self = depth 0)
|
|
@@ -39,8 +47,10 @@ async function up({ query }) {
|
|
|
39
47
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
async function down(
|
|
50
|
+
async function down(ctx) {
|
|
51
|
+
const { query } = ctx;
|
|
52
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
43
53
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`scope_closure\``);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
module.exports = { up, down };
|
|
56
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -21,14 +21,21 @@
|
|
|
21
21
|
* timestamp); `...016` sorts strictly after `...001`, so `companies` + its FK already exist.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
25
|
+
|
|
26
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
27
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
28
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
29
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
30
|
+
const replacesChecksums = ['4af1a570fa1e9d161bcac25087866baf1a3783e88df06db40f0a91be4ee590b4'];
|
|
31
|
+
|
|
25
32
|
const TABLE = 'companies';
|
|
26
33
|
const FK = 'FK_companies_parent';
|
|
27
34
|
const COL = 'c_parent_uuid';
|
|
28
35
|
const PK = 'c_uuid';
|
|
29
36
|
|
|
30
37
|
/** True if a FK constraint of this name exists on the table (idempotency guard). */
|
|
31
|
-
async function fkExists(query) {
|
|
38
|
+
async function fkExists(query, SCHEMA) {
|
|
32
39
|
const rows = await query(
|
|
33
40
|
`SELECT 1
|
|
34
41
|
FROM information_schema.TABLE_CONSTRAINTS
|
|
@@ -42,15 +49,17 @@ async function fkExists(query) {
|
|
|
42
49
|
return Array.isArray(rows) && rows.length > 0;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
async function dropFkIfPresent(query) {
|
|
46
|
-
if (await fkExists(query)) {
|
|
52
|
+
async function dropFkIfPresent(query, SCHEMA) {
|
|
53
|
+
if (await fkExists(query, SCHEMA)) {
|
|
47
54
|
await query(`ALTER TABLE \`${SCHEMA}\`.\`${TABLE}\` DROP FOREIGN KEY \`${FK}\``);
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
async function up(
|
|
58
|
+
async function up(ctx) {
|
|
59
|
+
const { query } = ctx;
|
|
60
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
|
|
52
61
|
// Drop the existing SET NULL FK (if present), re-add it as RESTRICT.
|
|
53
|
-
await dropFkIfPresent(query);
|
|
62
|
+
await dropFkIfPresent(query, SCHEMA);
|
|
54
63
|
await query(
|
|
55
64
|
`ALTER TABLE \`${SCHEMA}\`.\`${TABLE}\`
|
|
56
65
|
ADD CONSTRAINT \`${FK}\` FOREIGN KEY (\`${COL}\`)
|
|
@@ -58,9 +67,11 @@ async function up({ query }) {
|
|
|
58
67
|
);
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
async function down(
|
|
70
|
+
async function down(ctx) {
|
|
71
|
+
const { query } = ctx;
|
|
72
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
|
|
62
73
|
// Restore the original SET NULL behavior.
|
|
63
|
-
await dropFkIfPresent(query);
|
|
74
|
+
await dropFkIfPresent(query, SCHEMA);
|
|
64
75
|
await query(
|
|
65
76
|
`ALTER TABLE \`${SCHEMA}\`.\`${TABLE}\`
|
|
66
77
|
ADD CONSTRAINT \`${FK}\` FOREIGN KEY (\`${COL}\`)
|
|
@@ -68,4 +79,4 @@ async function down({ query }) {
|
|
|
68
79
|
);
|
|
69
80
|
}
|
|
70
81
|
|
|
71
|
-
module.exports = { up, down };
|
|
82
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -15,9 +15,17 @@
|
|
|
15
15
|
* `down` drops the table. Run by the DDL account.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
21
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
22
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
23
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
24
|
+
const replacesChecksums = ['8c591ca61982f183ba26fb2ce6df2f56068333713654ca1b1e27a70d5e6101e2'];
|
|
25
|
+
|
|
26
|
+
async function up(ctx) {
|
|
27
|
+
const { query } = ctx;
|
|
28
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
21
29
|
await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`service_account_key\` (
|
|
22
30
|
sak_account_id VARCHAR(36) NOT NULL, -- the <accountId> inside the ask_ key (= service_account.sa_id)
|
|
23
31
|
sak_version INT NOT NULL, -- monotonic per account; rotation bumps it
|
|
@@ -34,8 +42,10 @@ async function up({ query }) {
|
|
|
34
42
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
async function down(
|
|
45
|
+
async function down(ctx) {
|
|
46
|
+
const { query } = ctx;
|
|
47
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
38
48
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`service_account_key\``);
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
module.exports = { up, down };
|
|
51
|
+
module.exports = { up, down, replacesChecksums };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — the enforcement guard + real-world adapters (the 'hands'). One global deny-by-default gate every request passes through (ADR-0002), classification decorators, boot-pool assertion (ADR-0018), the forRoot() registration seam, and the DB/Redis/crypto adapters that connect the sealed core to a real backend. Depends on @astram/core (ADR-0003, ADR-0023).",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"argon2": "^0.41.1",
|
|
37
37
|
"ioredis": "^5.4.1",
|
|
38
38
|
"mariadb": "^3.5.4",
|
|
39
|
-
"@astram/core": "1.
|
|
40
|
-
"@astram/engine": "0.
|
|
39
|
+
"@astram/core": "1.7.0",
|
|
40
|
+
"@astram/engine": "0.8.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nestjs/common": "^11",
|