@astram/guard 0.32.0 → 0.34.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/README.md +25 -0
- package/dist/authz/record-share-writer.d.ts +49 -11
- package/dist/authz/record-share-writer.d.ts.map +1 -1
- package/dist/authz/record-share-writer.js +68 -20
- package/dist/enforcement/engine-error.filter.d.ts +14 -3
- package/dist/enforcement/engine-error.filter.d.ts.map +1 -1
- package/dist/enforcement/engine-error.filter.js +18 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/module/shield-tokens.d.ts +61 -0
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/module/shield-tokens.js +45 -1
- package/migrations/1710000000126-AddRecordShareSource.cjs +187 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -96,6 +96,31 @@ Framework code that runs inside a request but has no `req` in hand (for example
|
|
|
96
96
|
supply a server-held tenant). Keep connector code in Nest handlers or boot-started jobs.
|
|
97
97
|
- In memory only: no database or Redis read is added to the request path (Shield #12).
|
|
98
98
|
|
|
99
|
+
## File-share port token (`SHIELD_FILE_SHARE`, GAPS #57)
|
|
100
|
+
|
|
101
|
+
`src/module/shield-tokens.ts` declares the port so guard never imports identity (ADR-0003);
|
|
102
|
+
`@astram/identity` binds it per request. Spec `docs/features/file-share-port/SPEC.md` v1, ADR-0040
|
|
103
|
+
addendum (2026-11-03).
|
|
104
|
+
|
|
105
|
+
- Exports: `SHIELD_FILE_SHARE` (a `Symbol`, unbound without identity), `FileSharePort`
|
|
106
|
+
(`shareWithRole`, `unshare`, `revokeForParent`, `listForParent`, `reconcileFile`; no actor,
|
|
107
|
+
tenant, owner or company argument), `FileShareParent` (`{ typeKey, id }`), `FileShareResult`
|
|
108
|
+
(`{ created, effective, missing }`), `FileShareError`, `FILE_SHARE_ERROR_CODES`,
|
|
109
|
+
`FileShareErrorCode`.
|
|
110
|
+
- `FileShareError(code)` takes only the code, so its message never carries an id, file name or
|
|
111
|
+
table: `file_share_invalid` 400 `Invalid file share request.`, `file_share_not_found` 404
|
|
112
|
+
`Not found.`, `file_share_denied` 403 `Not permitted.`, `file_share_unavailable` 503
|
|
113
|
+
`File sharing is unavailable.`; an unknown code becomes `file_share_unavailable`.
|
|
114
|
+
- Migration `1710000000126-AddRecordShareSource.cjs` adds the source columns
|
|
115
|
+
(`rs_source_type_key`, `rs_source_record_uuid`, `rs_source_operation`, `''` for owner shares),
|
|
116
|
+
`ck_rs_source_complete`, `uq_rs_grant_source` (replaces `uq_rs_grant`) and `idx_rs_source`;
|
|
117
|
+
`down` refuses while a port row exists.
|
|
118
|
+
- `RecordShareWriter`: owner `unshare` deletes owner-made rows only and refuses a tuple that
|
|
119
|
+
matches only port rows with `ShareNotPermittedError(SHARE_MANAGED_BY_LINKED_RECORD)` (`This
|
|
120
|
+
share is managed by a linked record.`); list rows (`RecordShareRow`) carry the source fields;
|
|
121
|
+
`listSharesForAuthorizedRecord` lists a record's shares without the owner bound, for a caller that
|
|
122
|
+
has already proven authority with `decide()` (identity's stored-file admin listing).
|
|
123
|
+
|
|
99
124
|
## Peer dependencies (ADR-0023 §2)
|
|
100
125
|
|
|
101
126
|
`@astram/guard` **peer-depends** on the host runtime so the consumer owns exactly
|
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
* the request principal, NOT from a user-controlled body field. The writer never
|
|
28
28
|
* trusts an owner id in `input`; it fetches the owner and compares against `sharerId`.
|
|
29
29
|
*
|
|
30
|
-
* ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index on
|
|
31
|
-
* (tenant, type, record, grantee_kind, grantee_uuid, action
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index `uq_rs_grant_source` on
|
|
31
|
+
* (tenant, type, record, grantee_kind, grantee_uuid, action, source type, source record),
|
|
32
|
+
* migration 126; an owner share leaves the source columns at their `''` default, so a repeat
|
|
33
|
+
* share of the same tuple stays a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare`
|
|
34
|
+
* DELETEs the matching OWNER-MADE row(s) only; rows made through the file-share port are
|
|
35
|
+
* read-only here (file-share-port SPEC §5 E). Every share/unshare emits an audit event via the injected
|
|
34
36
|
* {@link ShareAuditSink} (best-effort; a sink error never fails the operation). NO raw
|
|
35
37
|
* uuid appears in a human-readable audit MESSAGE — ids ride in structured fields only.
|
|
36
38
|
*
|
|
@@ -117,6 +119,27 @@ export interface ShareInput {
|
|
|
117
119
|
*/
|
|
118
120
|
readonly sharerId: string;
|
|
119
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* The one fixed text of an owner `unshare` whose tuple matches only rows made through the
|
|
124
|
+
* file-share port (file-share-port SPEC §5 E, §10; supervisor 2026-11-03). It never names or hints
|
|
125
|
+
* at the parent record (type, id or label): the same text for every such tuple.
|
|
126
|
+
*/
|
|
127
|
+
export declare const SHARE_MANAGED_BY_LINKED_RECORD = "This share is managed by a linked record.";
|
|
128
|
+
/**
|
|
129
|
+
* One share row as the owner listing returns it. The three source fields are `''` for an
|
|
130
|
+
* owner-made share; a port-made row (file-share-port SPEC §4 A) carries the parent type key, the
|
|
131
|
+
* parent record id and the operation (`shield:file-share`). Identity labels port rows from them and
|
|
132
|
+
* never shows the parent id (SPEC §5 E).
|
|
133
|
+
*/
|
|
134
|
+
export interface RecordShareRow {
|
|
135
|
+
readonly granteeKind: ShareGranteeKind;
|
|
136
|
+
readonly granteeUuid: string;
|
|
137
|
+
readonly action: string;
|
|
138
|
+
readonly grantedBy: string;
|
|
139
|
+
readonly sourceTypeKey: string;
|
|
140
|
+
readonly sourceRecordId: string;
|
|
141
|
+
readonly sourceOperation: string;
|
|
142
|
+
}
|
|
120
143
|
/** Thrown when the who-may-share bound rejects a share/unshare (fail-closed). */
|
|
121
144
|
export declare class ShareNotPermittedError extends Error {
|
|
122
145
|
constructor(message: string);
|
|
@@ -153,7 +176,13 @@ export declare class RecordShareWriter {
|
|
|
153
176
|
/**
|
|
154
177
|
* Remove a share. The SAME owner bound applies — only the owner of the record may revoke
|
|
155
178
|
* a share on it (a grantee cannot unshare a record they don't own). DELETEs the matching
|
|
156
|
-
* row(s); a no-match delete is a benign no-op. Emits `share.removed` on success.
|
|
179
|
+
* owner-made row(s) only; a no-match delete is a benign no-op. Emits `share.removed` on success.
|
|
180
|
+
*
|
|
181
|
+
* file-share-port SPEC §5 E, §6: rows made through the file-share port (non-empty source) are
|
|
182
|
+
* read-only here. A tuple that matches only port rows is refused with
|
|
183
|
+
* {@link SHARE_MANAGED_BY_LINKED_RECORD} (403 at the route), nothing deleted and nothing
|
|
184
|
+
* audited; when owner and port rows both match, only the owner row is removed. Port rows are
|
|
185
|
+
* removed only through the port.
|
|
157
186
|
*/
|
|
158
187
|
unshare(input: ShareInput): Promise<void>;
|
|
159
188
|
/**
|
|
@@ -172,12 +201,21 @@ export declare class RecordShareWriter {
|
|
|
172
201
|
typeKey: string;
|
|
173
202
|
recordId: string;
|
|
174
203
|
sharerId: string;
|
|
175
|
-
}): Promise<ReadonlyArray<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
204
|
+
}): Promise<ReadonlyArray<RecordShareRow>>;
|
|
205
|
+
/**
|
|
206
|
+
* List the shares on a record WITHOUT the owner bound, for a caller that has already proven its
|
|
207
|
+
* authority over the record with `decide()` (file-share-port SPEC §5 E: identity calls it for a
|
|
208
|
+
* `stored_file` only after `records.authorize('stored_file', id, 'update')` allows — an admin of
|
|
209
|
+
* that file). Tenant + type + record scoped exactly like {@link listSharesForRecord}; never a
|
|
210
|
+
* write. The caller supplies `tenantId` from the request principal, never from input.
|
|
211
|
+
*/
|
|
212
|
+
listSharesForAuthorizedRecord(input: {
|
|
213
|
+
tenantId: string;
|
|
214
|
+
typeKey: string;
|
|
215
|
+
recordId: string;
|
|
216
|
+
}): Promise<ReadonlyArray<RecordShareRow>>;
|
|
217
|
+
/** The share rows of one record in one tenant, oldest first, source columns included. */
|
|
218
|
+
private selectShares;
|
|
181
219
|
/**
|
|
182
220
|
* Enforce the §6.2 who-may-share bound (steps 1–3) and return the resolved type info.
|
|
183
221
|
* Fetches the record owner tenant-scoped and proves `sharerId` owns it. Throws
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-share-writer.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-writer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"record-share-writer.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,eAAuC,CAAC;AAE/E,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;CACrD;AAED,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,+BAA+B;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MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAgB1C;;;;;;OAMG;IACG,6BAA6B,CAAC,KAAK,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAI1C,yFAAyF;YAC3E,YAAY;IA0C1B;;;;OAIG;YACW,cAAc;IAoC5B;;;;OAIG;YACW,sBAAsB;IA6BpC,OAAO,CAAC,cAAc;IAItB,sFAAsF;YACxE,IAAI;CAsBnB"}
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
* the request principal, NOT from a user-controlled body field. The writer never
|
|
29
29
|
* trusts an owner id in `input`; it fetches the owner and compares against `sharerId`.
|
|
30
30
|
*
|
|
31
|
-
* ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index on
|
|
32
|
-
* (tenant, type, record, grantee_kind, grantee_uuid, action
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index `uq_rs_grant_source` on
|
|
32
|
+
* (tenant, type, record, grantee_kind, grantee_uuid, action, source type, source record),
|
|
33
|
+
* migration 126; an owner share leaves the source columns at their `''` default, so a repeat
|
|
34
|
+
* share of the same tuple stays a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare`
|
|
35
|
+
* DELETEs the matching OWNER-MADE row(s) only; rows made through the file-share port are
|
|
36
|
+
* read-only here (file-share-port SPEC §5 E). Every share/unshare emits an audit event via the injected
|
|
35
37
|
* {@link ShareAuditSink} (best-effort; a sink error never fails the operation). NO raw
|
|
36
38
|
* uuid appears in a human-readable audit MESSAGE — ids ride in structured fields only.
|
|
37
39
|
*
|
|
@@ -40,11 +42,17 @@
|
|
|
40
42
|
* record outside the sharer's tenant is "not found" ⇒ rejected at step 2.
|
|
41
43
|
*/
|
|
42
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.RecordShareWriter = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHIELD_RECORD_SHARE_WRITER = void 0;
|
|
45
|
+
exports.RecordShareWriter = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHARE_MANAGED_BY_LINKED_RECORD = exports.SHIELD_RECORD_SHARE_WRITER = void 0;
|
|
44
46
|
const node_crypto_1 = require("node:crypto");
|
|
45
47
|
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
46
48
|
/** The DI token the writer is bound under. */
|
|
47
49
|
exports.SHIELD_RECORD_SHARE_WRITER = Symbol('SHIELD_RECORD_SHARE_WRITER');
|
|
50
|
+
/**
|
|
51
|
+
* The one fixed text of an owner `unshare` whose tuple matches only rows made through the
|
|
52
|
+
* file-share port (file-share-port SPEC §5 E, §10; supervisor 2026-11-03). It never names or hints
|
|
53
|
+
* at the parent record (type, id or label): the same text for every such tuple.
|
|
54
|
+
*/
|
|
55
|
+
exports.SHARE_MANAGED_BY_LINKED_RECORD = 'This share is managed by a linked record.';
|
|
48
56
|
/** Thrown when the who-may-share bound rejects a share/unshare (fail-closed). */
|
|
49
57
|
class ShareNotPermittedError extends Error {
|
|
50
58
|
constructor(message) {
|
|
@@ -113,25 +121,46 @@ class RecordShareWriter {
|
|
|
113
121
|
/**
|
|
114
122
|
* Remove a share. The SAME owner bound applies — only the owner of the record may revoke
|
|
115
123
|
* a share on it (a grantee cannot unshare a record they don't own). DELETEs the matching
|
|
116
|
-
* row(s); a no-match delete is a benign no-op. Emits `share.removed` on success.
|
|
124
|
+
* owner-made row(s) only; a no-match delete is a benign no-op. Emits `share.removed` on success.
|
|
125
|
+
*
|
|
126
|
+
* file-share-port SPEC §5 E, §6: rows made through the file-share port (non-empty source) are
|
|
127
|
+
* read-only here. A tuple that matches only port rows is refused with
|
|
128
|
+
* {@link SHARE_MANAGED_BY_LINKED_RECORD} (403 at the route), nothing deleted and nothing
|
|
129
|
+
* audited; when owner and port rows both match, only the owner row is removed. Port rows are
|
|
130
|
+
* removed only through the port.
|
|
117
131
|
*/
|
|
118
132
|
async unshare(input) {
|
|
119
133
|
await this.assertMayShare(input);
|
|
134
|
+
const tuple = [
|
|
135
|
+
input.tenantId,
|
|
136
|
+
input.typeKey,
|
|
137
|
+
input.recordId,
|
|
138
|
+
input.granteeKind,
|
|
139
|
+
input.granteeUuid,
|
|
140
|
+
input.action,
|
|
141
|
+
];
|
|
142
|
+
const tupleWhere = ` WHERE rs_tenant_uuid = ?` +
|
|
143
|
+
` AND rs_type_key = ?` +
|
|
144
|
+
` AND rs_record_uuid = ?` +
|
|
145
|
+
` AND rs_grantee_kind = ?` +
|
|
146
|
+
` AND rs_grantee_uuid = ?` +
|
|
147
|
+
` AND rs_action = ?`;
|
|
148
|
+
let sources;
|
|
149
|
+
try {
|
|
150
|
+
sources = (await this.db.query(`SELECT rs_source_type_key FROM \`${this.schema}\`.\`record_share\`` + tupleWhere, tuple));
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
throw new ShareStoreUnavailableError(`record_share read failed for ${input.typeKey}: ${err.message}`);
|
|
154
|
+
}
|
|
155
|
+
const rows = Array.isArray(sources) ? sources : [];
|
|
156
|
+
const isPortRow = (r) => typeof r.rs_source_type_key === 'string' && r.rs_source_type_key !== '';
|
|
157
|
+
if (rows.length > 0 && rows.every(isPortRow)) {
|
|
158
|
+
throw new ShareNotPermittedError(exports.SHARE_MANAGED_BY_LINKED_RECORD);
|
|
159
|
+
}
|
|
120
160
|
try {
|
|
121
161
|
await this.db.query(`DELETE FROM \`${this.schema}\`.\`record_share\`` +
|
|
122
|
-
|
|
123
|
-
` AND
|
|
124
|
-
` AND rs_record_uuid = ?` +
|
|
125
|
-
` AND rs_grantee_kind = ?` +
|
|
126
|
-
` AND rs_grantee_uuid = ?` +
|
|
127
|
-
` AND rs_action = ?`, [
|
|
128
|
-
input.tenantId,
|
|
129
|
-
input.typeKey,
|
|
130
|
-
input.recordId,
|
|
131
|
-
input.granteeKind,
|
|
132
|
-
input.granteeUuid,
|
|
133
|
-
input.action,
|
|
134
|
-
]);
|
|
162
|
+
tupleWhere +
|
|
163
|
+
` AND rs_source_type_key = ''`, tuple);
|
|
135
164
|
}
|
|
136
165
|
catch (err) {
|
|
137
166
|
throw new ShareStoreUnavailableError(`record_share delete failed for ${input.typeKey}: ${err.message}`);
|
|
@@ -162,9 +191,24 @@ class RecordShareWriter {
|
|
|
162
191
|
granteeUuid: '',
|
|
163
192
|
action: '',
|
|
164
193
|
});
|
|
194
|
+
return this.selectShares(input);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* List the shares on a record WITHOUT the owner bound, for a caller that has already proven its
|
|
198
|
+
* authority over the record with `decide()` (file-share-port SPEC §5 E: identity calls it for a
|
|
199
|
+
* `stored_file` only after `records.authorize('stored_file', id, 'update')` allows — an admin of
|
|
200
|
+
* that file). Tenant + type + record scoped exactly like {@link listSharesForRecord}; never a
|
|
201
|
+
* write. The caller supplies `tenantId` from the request principal, never from input.
|
|
202
|
+
*/
|
|
203
|
+
async listSharesForAuthorizedRecord(input) {
|
|
204
|
+
return this.selectShares(input);
|
|
205
|
+
}
|
|
206
|
+
/** The share rows of one record in one tenant, oldest first, source columns included. */
|
|
207
|
+
async selectShares(input) {
|
|
165
208
|
let rows;
|
|
166
209
|
try {
|
|
167
|
-
rows = (await this.db.query(`SELECT rs_grantee_kind, rs_grantee_uuid, rs_action, rs_granted_by
|
|
210
|
+
rows = (await this.db.query(`SELECT rs_grantee_kind, rs_grantee_uuid, rs_action, rs_granted_by,` +
|
|
211
|
+
` rs_source_type_key, rs_source_record_uuid, rs_source_operation` +
|
|
168
212
|
` FROM \`${this.schema}\`.\`record_share\`` +
|
|
169
213
|
` WHERE rs_tenant_uuid = ? AND rs_type_key = ? AND rs_record_uuid = ?` +
|
|
170
214
|
` ORDER BY rs_created_at`, [input.tenantId, input.typeKey, input.recordId]));
|
|
@@ -172,11 +216,15 @@ class RecordShareWriter {
|
|
|
172
216
|
catch (err) {
|
|
173
217
|
throw new ShareStoreUnavailableError(`record_share list failed for ${input.typeKey}: ${err.message}`);
|
|
174
218
|
}
|
|
219
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
175
220
|
return rows.map((r) => ({
|
|
176
221
|
granteeKind: r.rs_grantee_kind === 'role' ? 'role' : 'user',
|
|
177
222
|
granteeUuid: r.rs_grantee_uuid,
|
|
178
223
|
action: r.rs_action,
|
|
179
224
|
grantedBy: r.rs_granted_by,
|
|
225
|
+
sourceTypeKey: text(r.rs_source_type_key),
|
|
226
|
+
sourceRecordId: text(r.rs_source_record_uuid),
|
|
227
|
+
sourceOperation: text(r.rs_source_operation),
|
|
180
228
|
}));
|
|
181
229
|
}
|
|
182
230
|
// --- the bound -------------------------------------------------------------
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* AuthorizationDeniedError (incl. ADR-0034 `create_outside_write_scope`) → 403
|
|
10
10
|
* ValidationError → 400
|
|
11
11
|
* EngineUnavailableError → 503
|
|
12
|
+
* UniqueConflictError (GAPS #58) → 409 `unique_conflict`
|
|
12
13
|
*
|
|
13
14
|
* with FIXED, id-free messages (ADR-0012): the engine's own message carries reason codes, record
|
|
14
15
|
* ids and detail meant for logs, never for clients. There is deliberately no 404 mapping: the
|
|
@@ -28,13 +29,23 @@
|
|
|
28
29
|
* structural match also keeps working when a consumer's tree holds two copies of
|
|
29
30
|
* `@astram/engine` (version skew), where `instanceof` silently fails and the 500 returns. An
|
|
30
31
|
* error matches only when ALL hold: it is an `Error`, its prototype chain contains a class named
|
|
31
|
-
* `EngineError` (the engine's base), its `name` is one of the
|
|
32
|
-
* sets `name = new.target.name`), and it carries that class's field (`reason` / `field`
|
|
32
|
+
* `EngineError` (the engine's base), its `name` is one of the four classes above (the engine
|
|
33
|
+
* sets `name = new.target.name`), and it carries that class's field (`reason` / `field` /
|
|
34
|
+
* `typeKey`). A
|
|
33
35
|
* third-party error that merely shares a name is not mapped.
|
|
34
36
|
*/
|
|
35
37
|
import { type ArgumentsHost } from '@nestjs/common';
|
|
36
38
|
import { BaseExceptionFilter } from '@nestjs/core';
|
|
37
|
-
type EngineErrorKind = 'denied' | 'invalid' | 'unavailable';
|
|
39
|
+
type EngineErrorKind = 'denied' | 'invalid' | 'unavailable' | 'conflict';
|
|
40
|
+
/**
|
|
41
|
+
* GAPS #58 (SPEC `docs/features/unique-conflict-error/SPEC.md` §5 D, decision Q1): the fixed 409
|
|
42
|
+
* body for `UniqueConflictError`. No index name, type key or value: those stay server-side.
|
|
43
|
+
*/
|
|
44
|
+
export declare const UNIQUE_CONFLICT_BODY: {
|
|
45
|
+
readonly statusCode: 409;
|
|
46
|
+
readonly code: "unique_conflict";
|
|
47
|
+
readonly message: "This record conflicts with an existing one.";
|
|
48
|
+
};
|
|
38
49
|
/** Classify an engine error this filter maps, or `null` for anything else. */
|
|
39
50
|
export declare function classifyEngineError(err: unknown): EngineErrorKind | null;
|
|
40
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-error.filter.d.ts","sourceRoot":"","sources":["../../src/enforcement/engine-error.filter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"engine-error.filter.d.ts","sourceRoot":"","sources":["../../src/enforcement/engine-error.filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,KAAK,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAaX,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAexE;AAED;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAGrD;AAKD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAwBvD;AAED,+FAA+F;AAC/F,qBACa,iBAAkB,SAAQ,mBAAmB;IAC/C,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;CAG9D"}
|
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.EngineErrorFilter = exports.EngineHttpMappableError = void 0;
|
|
9
|
+
exports.EngineErrorFilter = exports.EngineHttpMappableError = exports.UNIQUE_CONFLICT_BODY = void 0;
|
|
10
10
|
exports.classifyEngineError = classifyEngineError;
|
|
11
11
|
exports.toEngineHttpError = toEngineHttpError;
|
|
12
12
|
/**
|
|
@@ -20,6 +20,7 @@ exports.toEngineHttpError = toEngineHttpError;
|
|
|
20
20
|
* AuthorizationDeniedError (incl. ADR-0034 `create_outside_write_scope`) → 403
|
|
21
21
|
* ValidationError → 400
|
|
22
22
|
* EngineUnavailableError → 503
|
|
23
|
+
* UniqueConflictError (GAPS #58) → 409 `unique_conflict`
|
|
23
24
|
*
|
|
24
25
|
* with FIXED, id-free messages (ADR-0012): the engine's own message carries reason codes, record
|
|
25
26
|
* ids and detail meant for logs, never for clients. There is deliberately no 404 mapping: the
|
|
@@ -39,12 +40,22 @@ exports.toEngineHttpError = toEngineHttpError;
|
|
|
39
40
|
* structural match also keeps working when a consumer's tree holds two copies of
|
|
40
41
|
* `@astram/engine` (version skew), where `instanceof` silently fails and the 500 returns. An
|
|
41
42
|
* error matches only when ALL hold: it is an `Error`, its prototype chain contains a class named
|
|
42
|
-
* `EngineError` (the engine's base), its `name` is one of the
|
|
43
|
-
* sets `name = new.target.name`), and it carries that class's field (`reason` / `field`
|
|
43
|
+
* `EngineError` (the engine's base), its `name` is one of the four classes above (the engine
|
|
44
|
+
* sets `name = new.target.name`), and it carries that class's field (`reason` / `field` /
|
|
45
|
+
* `typeKey`). A
|
|
44
46
|
* third-party error that merely shares a name is not mapped.
|
|
45
47
|
*/
|
|
46
48
|
const common_1 = require("@nestjs/common");
|
|
47
49
|
const core_1 = require("@nestjs/core");
|
|
50
|
+
/**
|
|
51
|
+
* GAPS #58 (SPEC `docs/features/unique-conflict-error/SPEC.md` §5 D, decision Q1): the fixed 409
|
|
52
|
+
* body for `UniqueConflictError`. No index name, type key or value: those stay server-side.
|
|
53
|
+
*/
|
|
54
|
+
exports.UNIQUE_CONFLICT_BODY = {
|
|
55
|
+
statusCode: 409,
|
|
56
|
+
code: 'unique_conflict',
|
|
57
|
+
message: 'This record conflicts with an existing one.',
|
|
58
|
+
};
|
|
48
59
|
/** True when `err`'s prototype chain contains the engine's `EngineError` base class. */
|
|
49
60
|
function isEngineFamily(err) {
|
|
50
61
|
let proto = Object.getPrototypeOf(err);
|
|
@@ -64,6 +75,8 @@ function classifyEngineError(err) {
|
|
|
64
75
|
switch (err.name) {
|
|
65
76
|
case 'AuthorizationDeniedError':
|
|
66
77
|
return typeof fields.reason === 'string' ? 'denied' : null;
|
|
78
|
+
case 'UniqueConflictError':
|
|
79
|
+
return typeof fields.typeKey === 'string' ? 'conflict' : null;
|
|
67
80
|
case 'ValidationError':
|
|
68
81
|
return typeof fields.field === 'string' ? 'invalid' : null;
|
|
69
82
|
case 'EngineUnavailableError':
|
|
@@ -102,6 +115,8 @@ function toEngineHttpError(err) {
|
|
|
102
115
|
}
|
|
103
116
|
case 'unavailable':
|
|
104
117
|
return new common_1.ServiceUnavailableException('This operation is temporarily unavailable. Try again.');
|
|
118
|
+
case 'conflict':
|
|
119
|
+
return new common_1.ConflictException({ ...exports.UNIQUE_CONFLICT_BODY });
|
|
105
120
|
default:
|
|
106
121
|
return err;
|
|
107
122
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export { ObjectStoreBootCheck } from './storage/object-store-boot-check.js';
|
|
|
53
53
|
export { FileIntake, FILE_INTAKE_REQUEST_KEY, FILE_INTAKE_DEFAULT_MAX_BYTES, type FileIntakeOptions, type FileIntakeResult, } from './storage/file-intake.interceptor.js';
|
|
54
54
|
export type { ShieldStorageOption, AppFileProfile } from './storage/storage.providers.js';
|
|
55
55
|
export { APP_CONTENT_TYPE_DENY_LIST, MAX_APP_FILE_PROFILES, isDeniedAppContentType, } from './storage/storage.providers.js';
|
|
56
|
-
export { SHIELD_OBJECT_STORE, SHIELD_FILE_INGEST, SHIELD_AGENT_FILE_READER, type AgentFileReader, type OpenedFileLike, SHIELD_PROPOSAL_PORT, SHIELD_PROPOSAL_READER, SHIELD_AGENT_TASK_CALLS, type ProposalPort, type ProposalReader, type ProposalReaderQuery, type ProposalReaderState, type ProposalDraftLike, type ProposalProvenanceLike, type SubmittedProposalLike, type ProposalSummaryLike, type ProposalSummaryPage, type AgentTaskCalls, } from './module/shield-tokens.js';
|
|
56
|
+
export { SHIELD_OBJECT_STORE, SHIELD_FILE_INGEST, SHIELD_AGENT_FILE_READER, type AgentFileReader, type OpenedFileLike, SHIELD_PROPOSAL_PORT, SHIELD_PROPOSAL_READER, SHIELD_AGENT_TASK_CALLS, type ProposalPort, type ProposalReader, type ProposalReaderQuery, type ProposalReaderState, type ProposalDraftLike, type ProposalProvenanceLike, type SubmittedProposalLike, type ProposalSummaryLike, type ProposalSummaryPage, type AgentTaskCalls, SHIELD_FILE_SHARE, FILE_SHARE_ERROR_CODES, FileShareError, type FileShareErrorCode, type FileShareParent, type FileSharePort, type FileShareResult, } from './module/shield-tokens.js';
|
|
57
57
|
export { loadObjectStorageConfig, DEFAULT_OBJECT_STORAGE_MAX_BYTES, type ObjectStorageConfig, type LoadObjectStorageConfigOptions, } from './config/app-config.js';
|
|
58
58
|
export { MariaDbSessionRecordStore, SHIELD_SESSION_RECORD_STORE, RedisHotSessionStore, SHIELD_HOT_SESSION_STORE, RedisRecentRotationStore, type RedisRecentRotationStoreOptions, CryptoTokenGenerator, Sha256RefreshTokenHasher, SystemClock, cryptoTokenGeneratorProvider, refreshHasherProvider, systemClockProvider, SHIELD_TOKEN_GENERATOR, SHIELD_REFRESH_HASHER, SHIELD_CLOCK, HotRevokingSessionRecordStore, type SessionHotRevoker, type LineageSessionLookup, SHIELD_SESSION_LIFETIMES, ROTATE_GRACE_MS, accessBindingTtlMs, } from './session/index.js';
|
|
59
59
|
export { MariaDbRecordPermissionRuleAdapter, SHIELD_RECORD_RULE_PORT, type RuleQueryable, } from './authz/mariadb-record-rule-adapter.js';
|
|
@@ -61,7 +61,7 @@ export { MariaDbPolicyStore, SHIELD_POLICY_STORE, type RuleQueryable as PolicySt
|
|
|
61
61
|
export { MariaDbListScopeAdapter, SHIELD_LIST_SCOPE_PORT, type ListScopeQueryable, } from './authz/mariadb-list-scope-adapter.js';
|
|
62
62
|
export { translateListScope, UnknownScopeFieldError, type TranslatedListScope, type ListScopePrincipal, } from './authz/list-scope-sql.js';
|
|
63
63
|
export { MariaDbRecordShareAdapter, SHIELD_RECORD_SHARE_PORT, type ShareQueryable, } from './authz/mariadb-record-share-adapter.js';
|
|
64
|
-
export { RecordShareWriter, SHIELD_RECORD_SHARE_WRITER, ShareNotPermittedError, ShareStoreUnavailableError, type ShareInput, type ShareGranteeKind, type ShareTypeInfo, type ShareTypeResolver, type ShareAuditEvent, type ShareAuditSink, } from './authz/record-share-writer.js';
|
|
64
|
+
export { RecordShareWriter, SHIELD_RECORD_SHARE_WRITER, SHARE_MANAGED_BY_LINKED_RECORD, ShareNotPermittedError, ShareStoreUnavailableError, type RecordShareRow, type ShareInput, type ShareGranteeKind, type ShareTypeInfo, type ShareTypeResolver, type ShareAuditEvent, type ShareAuditSink, } from './authz/record-share-writer.js';
|
|
65
65
|
export { makeShareDeleteCascade, type RecordDeletedHook, type ShareQueryFn, } from './authz/record-share-cascade.js';
|
|
66
66
|
export { MariaDbCrossTenantGrantAdapter, SHIELD_CROSS_TENANT_GRANT_PORT, type GrantQueryable, } from './authz/mariadb-cross-tenant-grant-adapter.js';
|
|
67
67
|
export { CrossTenantGrantWriter, SHIELD_CROSS_TENANT_GRANT_WRITER, GrantNotPermittedError, InvalidGrantError, GrantStoreUnavailableError, type GrantAuthorizeFn, type GrantAuditEvent, type GrantAuditSink, type GrantGranteeKind, type GrantScope, type OfferGrantInput, type AcceptGrantInput, type RevokeGrantInput, } from './authz/cross-tenant-grant-writer.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,YAAY,EACZ,yBAAyB,EAGzB,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAI7B,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,MAA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E,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAMlE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAOjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAQ5E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.EncryptedFileSecretsProvider = exports.LocalKekCrypto = exports.resolveAuthLinkBaseUrls = exports.CredentialExistsError = exports.isLockedHash = exports.lockedPasswordHash = exports.SHIELD_PASSWORD_HASHER = exports.argon2idHasherProvider = exports.Argon2idPasswordHasher = exports.stubDecisionAuthority = exports.GlobalEnforcementGuard = exports.currentRequestPrincipal = exports.NO_SESSION_FACTS = exports.SHIELD_SESSION_FACTS_ALS = exports.MariaDbApiKeyStore = exports.isApiKey = exports.extractBearerToken = exports.principalFromClaims = exports.resolveRequestAuth = exports.resolveRequestPrincipal = exports.SessionTokenBinder = exports.SHIELD_SERVICE_AUTHENTICATOR = exports.SHIELD_SESSION_TOKEN_BINDER = exports.CatalogGatabilityError = exports.CatalogReconciler = exports.OperationInventoryScanner = exports.uuidArrayField = exports.optionalUuidField = exports.uuidField = exports.UuidPipe = exports.normalizeClassification = exports.DEFAULT_CLASSIFIED_ACTION = exports.CLASSIFICATION_METADATA = exports.Classified = exports.Public = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = exports.ShieldModule = exports.actionsOf = exports.actionsFor = exports.AGENT_TENANT_MODES = exports.AGENT_ACTIONS = exports.SERVICE_ACCOUNT_ACTIONS = exports.RECORD_SHARE_ACTIONS = exports.CROSS_TENANT_GRANT_ACTIONS = exports.IDENTITY_ACTIONS = exports.MODULE_KEY = exports.permissionTextByKey = exports.buildIdentityModuleRegistry = exports.guardMigrationsDir = void 0;
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = exports.maskEmail = exports.isEmailShaped = exports.canonicalEmail = exports.hmacSha1 = exports.resolveTotpVerifier = exports.makeDefaultTotpVerifier = exports.AuthModule = exports.SHIELD_CAPTCHA_GATE = exports.RECAPTCHA_SITEVERIFY_URL = exports.RecaptchaVerifier = exports.TURNSTILE_SITEVERIFY_URL = exports.TurnstileVerifier = exports.MAX_CAPTCHA_TIMEOUT_MS = void 0;
|
|
20
|
+
exports.SHIELD_CLOCK = exports.SHIELD_REFRESH_HASHER = exports.SHIELD_TOKEN_GENERATOR = exports.systemClockProvider = exports.refreshHasherProvider = exports.cryptoTokenGeneratorProvider = exports.SystemClock = exports.Sha256RefreshTokenHasher = exports.CryptoTokenGenerator = exports.RedisRecentRotationStore = exports.SHIELD_HOT_SESSION_STORE = exports.RedisHotSessionStore = exports.SHIELD_SESSION_RECORD_STORE = exports.MariaDbSessionRecordStore = exports.DEFAULT_OBJECT_STORAGE_MAX_BYTES = exports.loadObjectStorageConfig = exports.FileShareError = exports.FILE_SHARE_ERROR_CODES = exports.SHIELD_FILE_SHARE = exports.SHIELD_AGENT_TASK_CALLS = exports.SHIELD_PROPOSAL_READER = exports.SHIELD_PROPOSAL_PORT = exports.SHIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.isDeniedAppContentType = exports.MAX_APP_FILE_PROFILES = exports.APP_CONTENT_TYPE_DENY_LIST = exports.FILE_INTAKE_DEFAULT_MAX_BYTES = exports.FILE_INTAKE_REQUEST_KEY = exports.FileIntake = exports.ObjectStoreBootCheck = exports.SHIELD_NOTIFICATIONS = exports.loadNotificationConfig = exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_BULK_ACTIONS = exports.NOTIFICATION_STATUSES = exports.NOTIFICATION_SEVERITIES = exports.NOTIFICATION_CATEGORIES = exports.NotificationService = exports.loadAuditSealConfig = exports.NodeSha256Hash = exports.NodeSha256Digest = exports.S3ObjectStore = exports.wasResolvedFromSecretRef = exports.assertNoUnresolvedSecretRefs = exports.createSecretsProviderFromEnv = exports.resolveBootSecrets = void 0;
|
|
21
|
+
exports.FRAMEWORK_SCHEMAS = exports.APP_CONFIG = exports.resolveMigrationLedgerCheck = exports.resolveMigrationLedger = exports.frameworkMigrationIds = exports.assertFrameworkMigrationsApplied = exports.SHIELD_MIGRATION_LEDGER_REGISTRY = exports.MigrationLedgerRegistry = exports.FrameworkMigrationLedgerCheck = exports.frameworkDatabasesLogLine = exports.assertPoolBudget = exports.BootSequence = exports.buildListScopeFn = exports.MariaDbSessionRestrictionStore = exports.SHIELD_SESSION_RESTRICTIONS = exports.SHIELD_PERMISSION_VERSION_CACHE = exports.DEFAULT_PERMISSION_VERSION_TTL_MS = exports.PERMISSION_VERSION_KEY_PREFIX = exports.RedisPermissionVersionCache = exports.withRedisPermissionVersion = exports.buildRecordAuthorization = exports.SHIELD_OPERATION_AUTHORITY_PORT = exports.ManifestOperationAuthorityAdapter = exports.GrantStoreUnavailableError = exports.InvalidGrantError = exports.GrantNotPermittedError = exports.SHIELD_CROSS_TENANT_GRANT_WRITER = exports.CrossTenantGrantWriter = exports.SHIELD_CROSS_TENANT_GRANT_PORT = exports.MariaDbCrossTenantGrantAdapter = exports.makeShareDeleteCascade = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHARE_MANAGED_BY_LINKED_RECORD = exports.SHIELD_RECORD_SHARE_WRITER = exports.RecordShareWriter = exports.SHIELD_RECORD_SHARE_PORT = exports.MariaDbRecordShareAdapter = exports.UnknownScopeFieldError = exports.translateListScope = exports.SHIELD_LIST_SCOPE_PORT = exports.MariaDbListScopeAdapter = exports.SHIELD_POLICY_STORE = exports.MariaDbPolicyStore = exports.SHIELD_RECORD_RULE_PORT = exports.MariaDbRecordPermissionRuleAdapter = exports.accessBindingTtlMs = exports.ROTATE_GRACE_MS = exports.SHIELD_SESSION_LIFETIMES = exports.HotRevokingSessionRecordStore = void 0;
|
|
22
|
+
exports.CAPTCHA_MODES = exports.CAPTCHA_ENDPOINTS = exports.loadCaptchaConfig = exports.SHIELD_SIGN_IN_WITH = exports.DEFAULT_SIGN_IN_WITH = exports.resolveSignInWith = exports.MariaDbCredentialResolver = exports.SHIELD_TOTP_VERIFIER_OVERRIDE = exports.SHIELD_MFA_DEVICE_STORE = exports.SHIELD_AUDIT_SINK = exports.SHIELD_SESSION_SWEEPER = exports.SHIELD_PROFILE_WRITER = exports.SHIELD_RECOVERY_CODE_STORE = exports.SHIELD_MESSAGE_DISPATCHER = exports.SHIELD_EMAIL_SENDER = exports.SHIELD_EMAIL_CHANGE_TOKEN_STORE = exports.SHIELD_RESET_TOKEN_STORE = exports.SHIELD_CREDENTIAL_WRITER = exports.SHIELD_SESSION_AUTHORITY = exports.SHIELD_AUTHENTICATOR = exports.SHIELD_PROFILE_RESOLVER = exports.SHIELD_CREDENTIAL_RESOLVER = exports.SHIELD_REDIS = exports.withoutStatementTimeout = exports.mariadbPoolTuningOptions = exports.mariadbSslOption = exports.reservedOperationPrincipal = exports.RESERVED_OPERATION_PRINCIPALS = exports.assertNoReservedRootId = exports.ORG_BOOTSTRAP_PRINCIPAL_ID = exports.rootIdsFromEnv = exports.loadPoolTuning = exports.loadDbTlsConfig = exports.isDevOrTestNodeEnv = exports.DEFAULT_LOGIN_IP_LIMIT = exports.loadRefreshReplayWindowMs = exports.loadLoginIpLimit = exports.DEFAULT_REDIS_URL = exports.DEFAULT_DB_CONFIG = exports.assertRefreshHmacKey = exports.loadRefreshHmacKey = exports.loadSessionLifetimes = exports.loadRedisConfig = exports.loadDbConfig = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = exports.evaluatePoolBudget = exports.loadPoolBudget = exports.loadAppConfig = exports.frameworkSchemasOf = void 0;
|
|
23
|
+
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = exports.maskEmail = exports.isEmailShaped = exports.canonicalEmail = exports.hmacSha1 = exports.resolveTotpVerifier = exports.makeDefaultTotpVerifier = exports.AuthModule = exports.SHIELD_CAPTCHA_GATE = exports.RECAPTCHA_SITEVERIFY_URL = exports.RecaptchaVerifier = exports.TURNSTILE_SITEVERIFY_URL = exports.TurnstileVerifier = exports.MAX_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_MIN_SCORE = exports.DEFAULT_CAPTCHA_THRESHOLD = exports.CAPTCHA_FAIL_MODES = void 0;
|
|
24
24
|
// Framework authz migrations (shield_authz DDL — permission / role_permission /
|
|
25
25
|
// authz_permission_version). Absolute path a consumer's `@astram/migrate` setup merges in.
|
|
26
26
|
var migrations_dir_js_1 = require("./migrations-dir.js");
|
|
@@ -205,6 +205,10 @@ Object.defineProperty(exports, "SHIELD_AGENT_FILE_READER", { enumerable: true, g
|
|
|
205
205
|
Object.defineProperty(exports, "SHIELD_PROPOSAL_PORT", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_PROPOSAL_PORT; } });
|
|
206
206
|
Object.defineProperty(exports, "SHIELD_PROPOSAL_READER", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_PROPOSAL_READER; } });
|
|
207
207
|
Object.defineProperty(exports, "SHIELD_AGENT_TASK_CALLS", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_AGENT_TASK_CALLS; } });
|
|
208
|
+
// file-share-port SPEC v1 §5 A, §10 (GAPS #57): bound by @astram/identity.
|
|
209
|
+
Object.defineProperty(exports, "SHIELD_FILE_SHARE", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_FILE_SHARE; } });
|
|
210
|
+
Object.defineProperty(exports, "FILE_SHARE_ERROR_CODES", { enumerable: true, get: function () { return shield_tokens_js_1.FILE_SHARE_ERROR_CODES; } });
|
|
211
|
+
Object.defineProperty(exports, "FileShareError", { enumerable: true, get: function () { return shield_tokens_js_1.FileShareError; } });
|
|
208
212
|
var app_config_js_1 = require("./config/app-config.js");
|
|
209
213
|
Object.defineProperty(exports, "loadObjectStorageConfig", { enumerable: true, get: function () { return app_config_js_1.loadObjectStorageConfig; } });
|
|
210
214
|
Object.defineProperty(exports, "DEFAULT_OBJECT_STORAGE_MAX_BYTES", { enumerable: true, get: function () { return app_config_js_1.DEFAULT_OBJECT_STORAGE_MAX_BYTES; } });
|
|
@@ -284,6 +288,7 @@ Object.defineProperty(exports, "SHIELD_RECORD_SHARE_PORT", { enumerable: true, g
|
|
|
284
288
|
var record_share_writer_js_1 = require("./authz/record-share-writer.js");
|
|
285
289
|
Object.defineProperty(exports, "RecordShareWriter", { enumerable: true, get: function () { return record_share_writer_js_1.RecordShareWriter; } });
|
|
286
290
|
Object.defineProperty(exports, "SHIELD_RECORD_SHARE_WRITER", { enumerable: true, get: function () { return record_share_writer_js_1.SHIELD_RECORD_SHARE_WRITER; } });
|
|
291
|
+
Object.defineProperty(exports, "SHARE_MANAGED_BY_LINKED_RECORD", { enumerable: true, get: function () { return record_share_writer_js_1.SHARE_MANAGED_BY_LINKED_RECORD; } });
|
|
287
292
|
Object.defineProperty(exports, "ShareNotPermittedError", { enumerable: true, get: function () { return record_share_writer_js_1.ShareNotPermittedError; } });
|
|
288
293
|
Object.defineProperty(exports, "ShareStoreUnavailableError", { enumerable: true, get: function () { return record_share_writer_js_1.ShareStoreUnavailableError; } });
|
|
289
294
|
// The delete-cascade (design §6.2 orphan-share cleanup): builds the guard-owned
|
|
@@ -169,4 +169,65 @@ export interface AgentTaskCalls {
|
|
|
169
169
|
}
|
|
170
170
|
/** Token of {@link AgentTaskCalls} (plan D-6). */
|
|
171
171
|
export declare const SHIELD_AGENT_TASK_CALLS: unique symbol;
|
|
172
|
+
/** The app record a stored file is attached to (its type declares a `references: 'stored_file'` field). */
|
|
173
|
+
export interface FileShareParent {
|
|
174
|
+
readonly typeKey: string;
|
|
175
|
+
readonly id: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* What `shareWithRole` returns (SPEC §5 A, decision 3). `effective` is false and `missing` is
|
|
179
|
+
* `['identity:stored_file:read']` when the role does not hold that key; the share is written
|
|
180
|
+
* anyway and takes effect once the key is granted.
|
|
181
|
+
*/
|
|
182
|
+
export interface FileShareResult {
|
|
183
|
+
readonly created: boolean;
|
|
184
|
+
readonly effective: boolean;
|
|
185
|
+
readonly missing: readonly string[];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The file-share port (SPEC §5 A, B): an app service shares a stored file with a role of the same
|
|
189
|
+
* company only when the caller may `update` a parent record whose type declares a
|
|
190
|
+
* `references: 'stored_file'` field holding that file, and may itself read the file. Rows are
|
|
191
|
+
* written under the declared operation `shield:file-share` (Shield #9) with provenance, in one
|
|
192
|
+
* transaction with their audit. No method takes an actor, tenant, owner or company: those come
|
|
193
|
+
* from the request's session only. Every refusal is a {@link FileShareError}.
|
|
194
|
+
*/
|
|
195
|
+
export interface FileSharePort {
|
|
196
|
+
shareWithRole(fileId: string, roleId: string, parent: FileShareParent): Promise<FileShareResult>;
|
|
197
|
+
unshare(fileId: string, roleId: string, parent: FileShareParent): Promise<{
|
|
198
|
+
removed: boolean;
|
|
199
|
+
}>;
|
|
200
|
+
revokeForParent(parent: FileShareParent): Promise<{
|
|
201
|
+
removed: number;
|
|
202
|
+
}>;
|
|
203
|
+
listForParent(parent: FileShareParent): Promise<readonly {
|
|
204
|
+
fileId: string;
|
|
205
|
+
roleId: string;
|
|
206
|
+
createdAtMs: number;
|
|
207
|
+
}[]>;
|
|
208
|
+
reconcileFile(fileId: string): Promise<{
|
|
209
|
+
removed: number;
|
|
210
|
+
}>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* `FileSharePort`, bound by `@astram/identity`'s `IdentityFeatureModule` in a framework module,
|
|
214
|
+
* request-scoped (the request's `RecordsService`: the actor is the request principal, the tenant
|
|
215
|
+
* the session's active tenant). Hosted by a framework module, so an agent capability that lists it
|
|
216
|
+
* in `inject` fails agent boot (`inject_framework`). Unbound without identity.
|
|
217
|
+
*/
|
|
218
|
+
export declare const SHIELD_FILE_SHARE: unique symbol;
|
|
219
|
+
/** The fixed error codes of the file-share port (SPEC §10). */
|
|
220
|
+
export declare const FILE_SHARE_ERROR_CODES: readonly ["file_share_invalid", "file_share_not_found", "file_share_denied", "file_share_unavailable"];
|
|
221
|
+
/** One of {@link FILE_SHARE_ERROR_CODES}. */
|
|
222
|
+
export type FileShareErrorCode = (typeof FILE_SHARE_ERROR_CODES)[number];
|
|
223
|
+
/**
|
|
224
|
+
* The one error the file-share port throws (SPEC §10): a fixed `code`, its fixed message and HTTP
|
|
225
|
+
* status. The constructor takes only the code, so a message can never carry an id, a file name or
|
|
226
|
+
* a table. An unknown code becomes `file_share_unavailable` (fail closed).
|
|
227
|
+
*/
|
|
228
|
+
export declare class FileShareError extends Error {
|
|
229
|
+
readonly code: FileShareErrorCode;
|
|
230
|
+
readonly httpStatus: number;
|
|
231
|
+
constructor(code: FileShareErrorCode);
|
|
232
|
+
}
|
|
172
233
|
//# sourceMappingURL=shield-tokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-tokens.d.ts","sourceRoot":"","sources":["../../src/module/shield-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,yBAAyB,E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E,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAChG,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE,aAAa,CACX,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,SAAS;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IAC/E,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAE7D,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,wGAKxB,CAAC;AAEZ,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAezE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,IAAI,EAAE,kBAAkB;CAUrC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* with no cycle. `shield.module.ts` re-exports these for the public barrel.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SHIELD_AGENT_TASK_CALLS = exports.SHIELD_PROPOSAL_READER = exports.SHIELD_PROPOSAL_PORT = exports.SHIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = void 0;
|
|
10
|
+
exports.FileShareError = exports.FILE_SHARE_ERROR_CODES = exports.SHIELD_FILE_SHARE = exports.SHIELD_AGENT_TASK_CALLS = exports.SHIELD_PROPOSAL_READER = exports.SHIELD_PROPOSAL_PORT = exports.SHIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = void 0;
|
|
11
11
|
/**
|
|
12
12
|
* The Core decision authority (`@astram/core`'s `DecisionAuthority`) — the single
|
|
13
13
|
* ADR-0001 decision entry both the global enforcement guard and the engine's
|
|
@@ -66,3 +66,47 @@ exports.SHIELD_PROPOSAL_PORT = Symbol('SHIELD_PROPOSAL_PORT');
|
|
|
66
66
|
exports.SHIELD_PROPOSAL_READER = Symbol('SHIELD_PROPOSAL_READER');
|
|
67
67
|
/** Token of {@link AgentTaskCalls} (plan D-6). */
|
|
68
68
|
exports.SHIELD_AGENT_TASK_CALLS = Symbol('SHIELD_AGENT_TASK_CALLS');
|
|
69
|
+
/**
|
|
70
|
+
* `FileSharePort`, bound by `@astram/identity`'s `IdentityFeatureModule` in a framework module,
|
|
71
|
+
* request-scoped (the request's `RecordsService`: the actor is the request principal, the tenant
|
|
72
|
+
* the session's active tenant). Hosted by a framework module, so an agent capability that lists it
|
|
73
|
+
* in `inject` fails agent boot (`inject_framework`). Unbound without identity.
|
|
74
|
+
*/
|
|
75
|
+
exports.SHIELD_FILE_SHARE = Symbol('SHIELD_FILE_SHARE');
|
|
76
|
+
/** The fixed error codes of the file-share port (SPEC §10). */
|
|
77
|
+
exports.FILE_SHARE_ERROR_CODES = Object.freeze([
|
|
78
|
+
'file_share_invalid',
|
|
79
|
+
'file_share_not_found',
|
|
80
|
+
'file_share_denied',
|
|
81
|
+
'file_share_unavailable',
|
|
82
|
+
]);
|
|
83
|
+
/** Fixed English message and HTTP status per code (SPEC §10). */
|
|
84
|
+
const FILE_SHARE_ERRORS = Object.freeze({
|
|
85
|
+
file_share_invalid: Object.freeze({ message: 'Invalid file share request.', httpStatus: 400 }),
|
|
86
|
+
file_share_not_found: Object.freeze({ message: 'Not found.', httpStatus: 404 }),
|
|
87
|
+
file_share_denied: Object.freeze({ message: 'Not permitted.', httpStatus: 403 }),
|
|
88
|
+
file_share_unavailable: Object.freeze({
|
|
89
|
+
message: 'File sharing is unavailable.',
|
|
90
|
+
httpStatus: 503,
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* The one error the file-share port throws (SPEC §10): a fixed `code`, its fixed message and HTTP
|
|
95
|
+
* status. The constructor takes only the code, so a message can never carry an id, a file name or
|
|
96
|
+
* a table. An unknown code becomes `file_share_unavailable` (fail closed).
|
|
97
|
+
*/
|
|
98
|
+
class FileShareError extends Error {
|
|
99
|
+
code;
|
|
100
|
+
httpStatus;
|
|
101
|
+
constructor(code) {
|
|
102
|
+
const known = Object.prototype.hasOwnProperty.call(FILE_SHARE_ERRORS, code)
|
|
103
|
+
? code
|
|
104
|
+
: 'file_share_unavailable';
|
|
105
|
+
const spec = FILE_SHARE_ERRORS[known];
|
|
106
|
+
super(spec.message);
|
|
107
|
+
this.name = 'FileShareError';
|
|
108
|
+
this.code = known;
|
|
109
|
+
this.httpStatus = spec.httpStatus;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.FileShareError = FileShareError;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework authz migration — provenance on `<authz>.record_share` for the file-share port (GAPS #57;
|
|
3
|
+
* spec `docs/features/file-share-port/SPEC.md` v1 §4 A; id 126 per `docs/migrations/RESERVATIONS.md`).
|
|
4
|
+
*
|
|
5
|
+
* Adds three columns, all `NOT NULL DEFAULT ''` ('' on all three = an owner-made share):
|
|
6
|
+
* - `rs_source_type_key` VARCHAR(64) parent object type key;
|
|
7
|
+
* - `rs_source_record_uuid` VARCHAR(36) parent record id;
|
|
8
|
+
* - `rs_source_operation` VARCHAR(64) `shield:file-share` for a port row.
|
|
9
|
+
* Not nullable on purpose: MariaDB treats NULLs as distinct in a UNIQUE index, so nullable source
|
|
10
|
+
* columns would stop de-duplicating owner re-shares.
|
|
11
|
+
*
|
|
12
|
+
* Constraints and indexes (all named):
|
|
13
|
+
* - `ck_rs_source_complete` CHECK: the three source columns are all '' or all non-empty;
|
|
14
|
+
* - `uq_rs_grant_source` UNIQUE (tenant, type, record, grantee kind, grantee, action, source type,
|
|
15
|
+
* source record) replaces `uq_rs_grant`, which is dropped only once the new index exists (owner
|
|
16
|
+
* shares keep their old uniqueness under source ''; each parent gets its own row);
|
|
17
|
+
* - `idx_rs_source` (tenant, source type, source record) for `revokeForParent`.
|
|
18
|
+
* No foreign key (the parent lives in an app table in another database; `record_share` has none).
|
|
19
|
+
*
|
|
20
|
+
* Idempotent: every column, the check and each index is added only when `information_schema` shows it
|
|
21
|
+
* absent; a half-applied state is completed and a re-run issues no DDL. No data change: existing rows
|
|
22
|
+
* take the defaults (owner-made). No ids hard-coded.
|
|
23
|
+
*
|
|
24
|
+
* `down` refuses (throws a fixed message, changes nothing) while any row has a non-empty source: it
|
|
25
|
+
* never deletes shares. Otherwise it re-creates `uq_rs_grant` first, then drops `uq_rs_grant_source`,
|
|
26
|
+
* `idx_rs_source`, the check and the three columns, each only when present.
|
|
27
|
+
*
|
|
28
|
+
* Database name from `ctx.schemas` (`frameworkSchemasForMigration(...).authz`), so the four-database,
|
|
29
|
+
* namespace and single layouts all work. Sorts after `...014` (creates `record_share`) and above every
|
|
30
|
+
* published and reserved id (120 published, 121–125 reserved).
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const { frameworkSchemasForMigration } = require('@astram/core');
|
|
34
|
+
|
|
35
|
+
const MIGRATION = '1710000000126-AddRecordShareSource';
|
|
36
|
+
const TABLE = 'record_share';
|
|
37
|
+
const CHECK = 'ck_rs_source_complete';
|
|
38
|
+
const OLD_UNIQUE = 'uq_rs_grant';
|
|
39
|
+
const NEW_UNIQUE = 'uq_rs_grant_source';
|
|
40
|
+
const SOURCE_INDEX = 'idx_rs_source';
|
|
41
|
+
|
|
42
|
+
/** In table order; each placed after the previous one (the first after `rs_created_at`). */
|
|
43
|
+
const COLUMNS = [
|
|
44
|
+
{ name: 'rs_source_type_key', type: 'VARCHAR(64)', after: 'rs_created_at' },
|
|
45
|
+
{ name: 'rs_source_record_uuid', type: 'VARCHAR(36)', after: 'rs_source_type_key' },
|
|
46
|
+
{ name: 'rs_source_operation', type: 'VARCHAR(64)', after: 'rs_source_record_uuid' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const GRANT_KEY = 'rs_tenant_uuid, rs_type_key, rs_record_uuid, rs_grantee_kind, rs_grantee_uuid, rs_action';
|
|
50
|
+
const CHECK_CLAUSE =
|
|
51
|
+
"(rs_source_type_key = '' AND rs_source_record_uuid = '' AND rs_source_operation = '') OR " +
|
|
52
|
+
"(rs_source_type_key <> '' AND rs_source_record_uuid <> '' AND rs_source_operation <> '')";
|
|
53
|
+
|
|
54
|
+
const DOWN_REFUSED =
|
|
55
|
+
`${MIGRATION}: refusing to roll back: record_share holds shares made through the file-share port ` +
|
|
56
|
+
'(non-empty source columns). Revoke them first (revokeForParent); nothing was changed.';
|
|
57
|
+
|
|
58
|
+
async function exists(query, sql, params) {
|
|
59
|
+
const rows = await query(sql, params);
|
|
60
|
+
return Array.isArray(rows) && rows.length > 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const tableExists = (query, schema) =>
|
|
64
|
+
exists(
|
|
65
|
+
query,
|
|
66
|
+
`SELECT 1 AS n FROM information_schema.TABLES
|
|
67
|
+
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? LIMIT 1`,
|
|
68
|
+
[schema, TABLE],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const columnExists = (query, schema, column) =>
|
|
72
|
+
exists(
|
|
73
|
+
query,
|
|
74
|
+
`SELECT 1 AS n FROM information_schema.COLUMNS
|
|
75
|
+
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ? LIMIT 1`,
|
|
76
|
+
[schema, TABLE, column],
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const checkExists = (query, schema) =>
|
|
80
|
+
exists(
|
|
81
|
+
query,
|
|
82
|
+
`SELECT 1 AS n FROM information_schema.CHECK_CONSTRAINTS
|
|
83
|
+
WHERE CONSTRAINT_SCHEMA = ? AND TABLE_NAME = ? AND CONSTRAINT_NAME = ? LIMIT 1`,
|
|
84
|
+
[schema, TABLE, CHECK],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const indexExists = (query, schema, index) =>
|
|
88
|
+
exists(
|
|
89
|
+
query,
|
|
90
|
+
`SELECT 1 AS n FROM information_schema.STATISTICS
|
|
91
|
+
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND INDEX_NAME = ? LIMIT 1`,
|
|
92
|
+
[schema, TABLE, index],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const tbl = (schema) => `\`${schema}\`.\`${TABLE}\``;
|
|
96
|
+
|
|
97
|
+
async function up(ctx) {
|
|
98
|
+
const { query } = ctx;
|
|
99
|
+
const AUTHZ = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
100
|
+
const T = tbl(AUTHZ);
|
|
101
|
+
|
|
102
|
+
if (!(await tableExists(query, AUTHZ))) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`${MIGRATION}: ${AUTHZ}.${TABLE} does not exist; run 1710000000014-CreateRecordShare first.`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 1. Columns: one ALTER (atomic) adding only the absent ones.
|
|
109
|
+
const add = [];
|
|
110
|
+
for (const c of COLUMNS) {
|
|
111
|
+
if (!(await columnExists(query, AUTHZ, c.name))) {
|
|
112
|
+
add.push(`ADD COLUMN IF NOT EXISTS ${c.name} ${c.type} NOT NULL DEFAULT '' AFTER ${c.after}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (add.length > 0) {
|
|
116
|
+
await query(`ALTER TABLE ${T} ${add.join(', ')}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 2. The completeness check (existing rows hold the '' defaults and pass).
|
|
120
|
+
if (!(await checkExists(query, AUTHZ))) {
|
|
121
|
+
await query(`ALTER TABLE ${T} ADD CONSTRAINT ${CHECK} CHECK (${CHECK_CLAUSE})`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 3. The source-aware unique, then drop the old one only once the new one is confirmed present.
|
|
125
|
+
if (!(await indexExists(query, AUTHZ, NEW_UNIQUE))) {
|
|
126
|
+
await query(
|
|
127
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS ${NEW_UNIQUE} ON ${T}
|
|
128
|
+
(${GRANT_KEY}, rs_source_type_key, rs_source_record_uuid)`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (await indexExists(query, AUTHZ, OLD_UNIQUE)) {
|
|
132
|
+
if (!(await indexExists(query, AUTHZ, NEW_UNIQUE))) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`${MIGRATION}: ${NEW_UNIQUE} is missing on ${AUTHZ}.${TABLE}; ${OLD_UNIQUE} was kept. Re-run.`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
await query(`DROP INDEX IF EXISTS ${OLD_UNIQUE} ON ${T}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 4. The revokeForParent lookup index.
|
|
141
|
+
if (!(await indexExists(query, AUTHZ, SOURCE_INDEX))) {
|
|
142
|
+
await query(
|
|
143
|
+
`CREATE INDEX IF NOT EXISTS ${SOURCE_INDEX} ON ${T}
|
|
144
|
+
(rs_tenant_uuid, rs_source_type_key, rs_source_record_uuid)`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function down(ctx) {
|
|
150
|
+
const { query } = ctx;
|
|
151
|
+
const AUTHZ = frameworkSchemasForMigration(ctx, process.env).authz;
|
|
152
|
+
const T = tbl(AUTHZ);
|
|
153
|
+
|
|
154
|
+
if (!(await tableExists(query, AUTHZ))) return;
|
|
155
|
+
|
|
156
|
+
const present = [];
|
|
157
|
+
for (const c of COLUMNS) {
|
|
158
|
+
if (await columnExists(query, AUTHZ, c.name)) present.push(c.name);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Refuse before any change while a port row exists (never delete shares).
|
|
162
|
+
if (present.length > 0) {
|
|
163
|
+
const where = present.map((name) => `${name} <> ''`).join(' OR ');
|
|
164
|
+
if (await exists(query, `SELECT 1 AS n FROM ${T} WHERE ${where} LIMIT 1`, [])) {
|
|
165
|
+
throw new Error(DOWN_REFUSED);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// With every source '' the old six-column key is unique again: restore it before dropping the new one.
|
|
170
|
+
if (!(await indexExists(query, AUTHZ, OLD_UNIQUE))) {
|
|
171
|
+
await query(`CREATE UNIQUE INDEX IF NOT EXISTS ${OLD_UNIQUE} ON ${T} (${GRANT_KEY})`);
|
|
172
|
+
}
|
|
173
|
+
if (await indexExists(query, AUTHZ, NEW_UNIQUE)) {
|
|
174
|
+
await query(`DROP INDEX IF EXISTS ${NEW_UNIQUE} ON ${T}`);
|
|
175
|
+
}
|
|
176
|
+
if (await indexExists(query, AUTHZ, SOURCE_INDEX)) {
|
|
177
|
+
await query(`DROP INDEX IF EXISTS ${SOURCE_INDEX} ON ${T}`);
|
|
178
|
+
}
|
|
179
|
+
if (await checkExists(query, AUTHZ)) {
|
|
180
|
+
await query(`ALTER TABLE ${T} DROP CONSTRAINT IF EXISTS ${CHECK}`);
|
|
181
|
+
}
|
|
182
|
+
if (present.length > 0) {
|
|
183
|
+
await query(`ALTER TABLE ${T} ${present.map((name) => `DROP COLUMN IF EXISTS ${name}`).join(', ')}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = { up, down };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.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/
|
|
40
|
-
"@astram/
|
|
39
|
+
"@astram/core": "1.19.0",
|
|
40
|
+
"@astram/engine": "0.20.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nestjs/common": "^11",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nestjs/platform-express": "^11",
|
|
46
46
|
"reflect-metadata": "^0.2",
|
|
47
47
|
"rxjs": "^7",
|
|
48
|
-
"@astram/messaging": "^0.1.
|
|
48
|
+
"@astram/messaging": "^0.1.22"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@astram/messaging": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.7.0",
|
|
69
69
|
"unplugin-swc": "^1.5.1",
|
|
70
70
|
"vitest": "^2.1.8",
|
|
71
|
-
"@astram/messaging": "0.1.
|
|
71
|
+
"@astram/messaging": "0.1.22"
|
|
72
72
|
},
|
|
73
73
|
"repository": {
|
|
74
74
|
"type": "git",
|