@astram/guard 0.13.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/auth/connections.d.ts +2 -2
- package/dist/auth/connections.d.ts.map +1 -1
- package/dist/auth/connections.js +4 -13
- 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 +72 -3
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js +129 -7
- 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 +13 -2
- 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/config/loopback-host.d.ts +9 -0
- package/dist/config/loopback-host.d.ts.map +1 -0
- package/dist/config/loopback-host.js +19 -0
- package/dist/encryption/local-kek-crypto.d.ts +6 -0
- package/dist/encryption/local-kek-crypto.d.ts.map +1 -1
- package/dist/encryption/local-kek-crypto.js +8 -0
- package/dist/identity/identity-actions.d.ts +18 -7
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +16 -17
- package/dist/identity/module-registry.bridge.d.ts.map +1 -1
- package/dist/identity/module-registry.bridge.js +5 -3
- 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 +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -22
- package/dist/module/shield-tokens.d.ts +11 -0
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/module/shield-tokens.js +12 -1
- package/dist/module/shield.module.d.ts +10 -0
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +78 -12
- package/dist/secrets/boot-secrets.d.ts +33 -0
- package/dist/secrets/boot-secrets.d.ts.map +1 -0
- package/dist/secrets/boot-secrets.js +180 -0
- 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/dist/storage/file-intake.interceptor.d.ts +54 -0
- package/dist/storage/file-intake.interceptor.d.ts.map +1 -0
- package/dist/storage/file-intake.interceptor.js +223 -0
- package/dist/storage/node-sha256-digest.d.ts +6 -0
- package/dist/storage/node-sha256-digest.d.ts.map +1 -0
- package/dist/storage/node-sha256-digest.js +15 -0
- package/dist/storage/object-store-boot-check.d.ts +16 -0
- package/dist/storage/object-store-boot-check.d.ts.map +1 -0
- package/dist/storage/object-store-boot-check.js +52 -0
- package/dist/storage/optional-peer.d.ts +10 -0
- package/dist/storage/optional-peer.d.ts.map +1 -0
- package/dist/storage/optional-peer.js +26 -0
- package/dist/storage/s3-object-store.d.ts +35 -0
- package/dist/storage/s3-object-store.d.ts.map +1 -0
- package/dist/storage/s3-object-store.js +238 -0
- package/dist/storage/storage.providers.d.ts +10 -0
- package/dist/storage/storage.providers.d.ts.map +1 -0
- package/dist/storage/storage.providers.js +104 -0
- 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 +11 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.STORAGE_EXPORTS = void 0;
|
|
37
|
+
exports.storageProviders = storageProviders;
|
|
38
|
+
/**
|
|
39
|
+
* `ShieldModule` providers for the `storage` option (FILE_STORAGE SPEC §6):
|
|
40
|
+
* - `SHIELD_OBJECT_STORE`: the given `ObjectStore`, an `S3ObjectStore` built from
|
|
41
|
+
* `OBJECT_STORAGE_*` (`'env'`; `null` when `OBJECT_STORAGE_BUCKET` is unset), or `null` when
|
|
42
|
+
* the option is absent (the `makeAuditSinkProvider` null-binding pattern; callers answer 501).
|
|
43
|
+
* - `SHIELD_FILE_INGEST`: core `createFileIngest` over `NodeSha256Digest`, with the `xlsx`
|
|
44
|
+
* profile (its cap set from `OBJECT_STORAGE_MAX_BYTES` under `'env'`). Always bound.
|
|
45
|
+
* - `ObjectStoreBootCheck`: registered only when the option is given (fail-closed ping at boot).
|
|
46
|
+
*
|
|
47
|
+
* `S3ObjectStore` (and so `@aws-sdk/client-s3`) is loaded lazily, only for `'env'` with a bucket.
|
|
48
|
+
*/
|
|
49
|
+
const node_crypto_1 = require("node:crypto");
|
|
50
|
+
const core_1 = require("@astram/core");
|
|
51
|
+
const app_config_js_1 = require("../config/app-config.js");
|
|
52
|
+
const boot_secrets_js_1 = require("../secrets/boot-secrets.js");
|
|
53
|
+
const shield_tokens_js_1 = require("../module/shield-tokens.js");
|
|
54
|
+
const node_sha256_digest_js_1 = require("./node-sha256-digest.js");
|
|
55
|
+
const object_store_boot_check_js_1 = require("./object-store-boot-check.js");
|
|
56
|
+
/** The tokens `ShieldModule` exports app-wide for the storage option. */
|
|
57
|
+
exports.STORAGE_EXPORTS = [shield_tokens_js_1.SHIELD_OBJECT_STORE, shield_tokens_js_1.SHIELD_FILE_INGEST];
|
|
58
|
+
const STORE_METHODS = ['put', 'get', 'head', 'delete', 'ping'];
|
|
59
|
+
/** Build the storage providers for one `ShieldModule` registration (see the file header). */
|
|
60
|
+
function storageProviders(storage) {
|
|
61
|
+
if (storage !== undefined && storage !== 'env') {
|
|
62
|
+
const s = storage;
|
|
63
|
+
if (STORE_METHODS.some((m) => typeof s?.[m] !== 'function')) {
|
|
64
|
+
throw new Error("ShieldModule: `storage` must be an ObjectStore (put/get/head/delete/ping) or 'env'");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const configToken = Symbol('SHIELD_OBJECT_STORAGE_CONFIG');
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
provide: configToken,
|
|
71
|
+
useFactory: () => storage === 'env'
|
|
72
|
+
? ((0, app_config_js_1.loadObjectStorageConfig)(process.env, {
|
|
73
|
+
resolvedFromSecretRef: boot_secrets_js_1.wasResolvedFromSecretRef,
|
|
74
|
+
}) ?? null)
|
|
75
|
+
: null,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
provide: shield_tokens_js_1.SHIELD_OBJECT_STORE,
|
|
79
|
+
useFactory: async (config) => {
|
|
80
|
+
if (storage === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
if (storage !== 'env')
|
|
83
|
+
return storage;
|
|
84
|
+
if (config === null)
|
|
85
|
+
return null;
|
|
86
|
+
const { S3ObjectStore } = await Promise.resolve().then(() => __importStar(require('./s3-object-store.js')));
|
|
87
|
+
return new S3ObjectStore(config);
|
|
88
|
+
},
|
|
89
|
+
inject: [configToken],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
provide: shield_tokens_js_1.SHIELD_FILE_INGEST,
|
|
93
|
+
useFactory: (config) => (0, core_1.createFileIngest)({
|
|
94
|
+
digest: new node_sha256_digest_js_1.NodeSha256Digest(),
|
|
95
|
+
newId: node_crypto_1.randomUUID,
|
|
96
|
+
profiles: {
|
|
97
|
+
xlsx: config ? { ...core_1.XLSX_PROFILE, maxBytes: config.maxBytes } : core_1.XLSX_PROFILE,
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
inject: [configToken],
|
|
101
|
+
},
|
|
102
|
+
...(storage !== undefined ? [object_store_boot_check_js_1.ObjectStoreBootCheck] : []),
|
|
103
|
+
];
|
|
104
|
+
}
|
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
* Idempotent (CREATE TABLE IF NOT EXISTS). No hard-coded UUIDs. Run by the DDL account.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
14
|
+
|
|
15
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
16
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
17
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
18
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
19
|
+
const replacesChecksums = ['48b8c9616c73a05ad030cfbfeb8b9e447d74f59804dbd7d3d26850df16d9e07e'];
|
|
20
|
+
|
|
14
21
|
const TS = 'TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP';
|
|
15
22
|
|
|
16
|
-
async function up(
|
|
23
|
+
async function up(ctx) {
|
|
24
|
+
const { query } = ctx;
|
|
25
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
17
26
|
await query(`CREATE SCHEMA IF NOT EXISTS \`${SCHEMA}\` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
18
27
|
|
|
19
28
|
// permission — the grantable key catalog (perm_key is the stable identity).
|
|
@@ -44,10 +53,12 @@ async function up({ query }) {
|
|
|
44
53
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
async function down(
|
|
56
|
+
async function down(ctx) {
|
|
57
|
+
const { query } = ctx;
|
|
58
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
48
59
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`role_permission\``);
|
|
49
60
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`authz_permission_version\``);
|
|
50
61
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`permission\``);
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
module.exports = { up, down };
|
|
64
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -20,9 +20,17 @@
|
|
|
20
20
|
* Run by the DDL account.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
26
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
27
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
28
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
29
|
+
const replacesChecksums = ['7c6733f7acb8dfc8ddc32d79aa3e19df1a424802d87e2a18c2b109a7a0b07f5d'];
|
|
30
|
+
|
|
31
|
+
async function up(ctx) {
|
|
32
|
+
const { query } = ctx;
|
|
33
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
26
34
|
// permission — add the catalog columns astram3's MariaDbCatalogStore contract expects.
|
|
27
35
|
await query(
|
|
28
36
|
`ALTER TABLE \`${SCHEMA}\`.\`permission\` ADD COLUMN IF NOT EXISTS perm_uuid VARCHAR(36) NULL`
|
|
@@ -63,4 +71,4 @@ async function down() {
|
|
|
63
71
|
// reviewed follow-up migration — not an automatic DROP COLUMN in `down()`.
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
module.exports = { up, down };
|
|
74
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -14,9 +14,17 @@
|
|
|
14
14
|
* Idempotent (CREATE TABLE IF NOT EXISTS). Structural (no tenant gate). Run by the DDL account.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
|
|
20
|
+
// @astram/migrate without it, the default names apply only while the namespace is unset.
|
|
21
|
+
// replacesChecksums: every checksum this file had in a published release (git release tags), so
|
|
22
|
+
// an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
|
|
23
|
+
const replacesChecksums = ['7537d160c1ce7890e2ddb29333fd48ca4a13c3d191af85e8bff601d41245488f'];
|
|
24
|
+
|
|
25
|
+
async function up(ctx) {
|
|
26
|
+
const { query } = ctx;
|
|
27
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
20
28
|
await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`access_bundle\` (
|
|
21
29
|
ab_uuid CHAR(36) NOT NULL,
|
|
22
30
|
ab_key VARCHAR(120) NOT NULL,
|
|
@@ -40,10 +48,12 @@ async function up({ query }) {
|
|
|
40
48
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
async function down(
|
|
51
|
+
async function down(ctx) {
|
|
52
|
+
const { query } = ctx;
|
|
53
|
+
const SCHEMA = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
44
54
|
// FK order: drop the child (access_bundle_permission) before the parent (access_bundle).
|
|
45
55
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`access_bundle_permission\``);
|
|
46
56
|
await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`access_bundle\``);
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
module.exports = { up, down };
|
|
59
|
+
module.exports = { up, down, replacesChecksums };
|
|
@@ -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",
|
|
@@ -32,21 +32,29 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@aws-sdk/client-s3": "3.1142.0",
|
|
35
36
|
"argon2": "^0.41.1",
|
|
36
37
|
"ioredis": "^5.4.1",
|
|
37
38
|
"mariadb": "^3.5.4",
|
|
38
|
-
"@astram/core": "1.
|
|
39
|
-
"@astram/engine": "0.
|
|
39
|
+
"@astram/core": "1.7.0",
|
|
40
|
+
"@astram/engine": "0.8.0"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@nestjs/common": "^11",
|
|
43
44
|
"@nestjs/core": "^11",
|
|
45
|
+
"@nestjs/platform-express": "^11",
|
|
44
46
|
"reflect-metadata": "^0.2",
|
|
45
47
|
"rxjs": "^7"
|
|
46
48
|
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@nestjs/platform-express": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
47
54
|
"devDependencies": {
|
|
48
55
|
"@nestjs/common": "^11.0.0",
|
|
49
56
|
"@nestjs/core": "^11.0.0",
|
|
57
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
50
58
|
"@nestjs/testing": "^11.0.0",
|
|
51
59
|
"@types/node": "^22.0.0",
|
|
52
60
|
"@types/supertest": "^6.0.2",
|