@adaptic/backend 0.0.1038 → 0.0.1040
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/esm/auth/authorization-map.d.ts +13 -1
- package/esm/auth/authorization-map.d.ts.map +1 -1
- package/esm/auth/authorization-map.js.map +1 -1
- package/esm/auth/authorization-map.mjs +14 -1
- package/esm/auth/credential-fields.d.ts +19 -0
- package/esm/auth/credential-fields.d.ts.map +1 -0
- package/esm/auth/credential-fields.js.map +1 -0
- package/esm/auth/credential-fields.mjs +42 -0
- package/esm/auth/credential-redaction.d.ts +56 -0
- package/esm/auth/credential-redaction.d.ts.map +1 -0
- package/esm/auth/credential-redaction.js.map +1 -0
- package/esm/auth/credential-redaction.mjs +99 -0
- package/esm/auth/mutation-authorization.d.ts +206 -0
- package/esm/auth/mutation-authorization.d.ts.map +1 -0
- package/esm/auth/mutation-authorization.js.map +1 -0
- package/esm/auth/mutation-authorization.mjs +271 -0
- package/esm/auth/nested-write-inspector.d.ts +94 -0
- package/esm/auth/nested-write-inspector.d.ts.map +1 -0
- package/esm/auth/nested-write-inspector.js.map +1 -0
- package/esm/auth/nested-write-inspector.mjs +185 -0
- package/esm/auth/nested-write-policy.d.ts +95 -0
- package/esm/auth/nested-write-policy.d.ts.map +1 -0
- package/esm/auth/nested-write-policy.js.map +1 -0
- package/esm/auth/nested-write-policy.mjs +154 -0
- package/esm/auth/service-token.d.ts +11 -1
- package/esm/auth/service-token.d.ts.map +1 -1
- package/esm/auth/service-token.js.map +1 -1
- package/esm/auth/service-token.mjs +31 -5
- package/esm/auth/token-verifier.d.ts +9 -1
- package/esm/auth/token-verifier.d.ts.map +1 -1
- package/esm/auth/token-verifier.js.map +1 -1
- package/esm/auth/user-write-content.d.ts +41 -0
- package/esm/auth/user-write-content.d.ts.map +1 -0
- package/esm/auth/user-write-content.js.map +1 -0
- package/esm/auth/user-write-content.mjs +100 -0
- package/esm/middleware/__tests__/credential-field-coverage.harness.d.ts +55 -0
- package/esm/middleware/__tests__/credential-field-coverage.harness.d.ts.map +1 -0
- package/esm/middleware/__tests__/credential-field-coverage.harness.js.map +1 -0
- package/esm/middleware/__tests__/credential-field-coverage.harness.mjs +438 -0
- package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +49 -0
- package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts.map +1 -0
- package/esm/middleware/__tests__/mutation-auth-guard.harness.js.map +1 -0
- package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +402 -0
- package/esm/middleware/__tests__/ts-node-harness.d.ts +10 -0
- package/esm/middleware/__tests__/ts-node-harness.d.ts.map +1 -0
- package/esm/middleware/__tests__/ts-node-harness.js.map +1 -0
- package/esm/middleware/__tests__/ts-node-harness.mjs +71 -0
- package/esm/middleware/audit-logger.d.ts +18 -1
- package/esm/middleware/audit-logger.d.ts.map +1 -1
- package/esm/middleware/audit-logger.js.map +1 -1
- package/esm/middleware/audit-logger.mjs +36 -13
- package/esm/middleware/audit-payload-guard.d.ts +85 -0
- package/esm/middleware/audit-payload-guard.d.ts.map +1 -0
- package/esm/middleware/audit-payload-guard.js.map +1 -0
- package/esm/middleware/audit-payload-guard.mjs +97 -0
- package/esm/middleware/credential-field-guard.d.ts +55 -7
- package/esm/middleware/credential-field-guard.d.ts.map +1 -1
- package/esm/middleware/credential-field-guard.js.map +1 -1
- package/esm/middleware/credential-field-guard.mjs +275 -106
- package/esm/middleware/generated-type-names.d.ts +44 -0
- package/esm/middleware/generated-type-names.d.ts.map +1 -0
- package/esm/middleware/generated-type-names.js.map +1 -0
- package/esm/middleware/generated-type-names.mjs +73 -0
- package/esm/middleware/guard-log-throttle.d.ts +80 -0
- package/esm/middleware/guard-log-throttle.d.ts.map +1 -0
- package/esm/middleware/guard-log-throttle.js.map +1 -0
- package/esm/middleware/guard-log-throttle.mjs +87 -0
- package/esm/middleware/mutation-account-facts.d.ts +140 -0
- package/esm/middleware/mutation-account-facts.d.ts.map +1 -0
- package/esm/middleware/mutation-account-facts.js.map +1 -0
- package/esm/middleware/mutation-account-facts.mjs +212 -0
- package/esm/middleware/mutation-auth-guard.d.ts +82 -0
- package/esm/middleware/mutation-auth-guard.d.ts.map +1 -0
- package/esm/middleware/mutation-auth-guard.js.map +1 -0
- package/esm/middleware/mutation-auth-guard.mjs +425 -0
- package/esm/middleware/mutation-tenant-facts.d.ts +58 -0
- package/esm/middleware/mutation-tenant-facts.d.ts.map +1 -0
- package/esm/middleware/mutation-tenant-facts.js.map +1 -0
- package/esm/middleware/mutation-tenant-facts.mjs +75 -0
- package/esm/middleware/trading-policy-audit.d.ts +172 -0
- package/esm/middleware/trading-policy-audit.d.ts.map +1 -0
- package/esm/middleware/trading-policy-audit.js.map +1 -0
- package/esm/middleware/trading-policy-audit.mjs +309 -0
- package/package.json +1 -1
- package/server.cjs +27 -2
|
@@ -36,13 +36,25 @@ export declare const IR_MODELS: readonly EnhanceModelName[];
|
|
|
36
36
|
/**
|
|
37
37
|
* Models whose READ actions are decorated as well as their deletes.
|
|
38
38
|
*
|
|
39
|
-
* These
|
|
39
|
+
* These four answer to anyone today. A read-only probe of the deployed API
|
|
40
40
|
* with no Authorization header returns a real organisation name, a real user's
|
|
41
41
|
* email address, and a real membership row, so the standing escalation is not
|
|
42
42
|
* theoretical. They were outside the checker entirely: `_all` covers the five
|
|
43
43
|
* investor-relations models, everything else got delete coverage only, and a
|
|
44
44
|
* query the checker never runs for is a query it cannot even count.
|
|
45
45
|
*
|
|
46
|
+
* `AuditLog` joined them on 2026-09-26, on the same admission criterion and by
|
|
47
|
+
* measurement rather than by inspection. It is the largest of the four by some
|
|
48
|
+
* distance and the only one carrying correlatable personal data: a census of
|
|
49
|
+
* the anonymously readable rows found, across roughly 70,000 rows, at most five
|
|
50
|
+
* distinct email identities, 33 distinct IP addresses, at most four person
|
|
51
|
+
* names and two user agents. Report that as a small number of data subjects
|
|
52
|
+
* with a great many records about each, NOT as a large exposure — the row count
|
|
53
|
+
* is a true number answering a question nobody asked. Note also that 27,964
|
|
54
|
+
* `accountName` rows, first classified as an account label, were hash-matched
|
|
55
|
+
* in-database against the users table to three real email addresses, so
|
|
56
|
+
* per-subject completeness is higher than a field-name reading suggests.
|
|
57
|
+
*
|
|
46
58
|
* Decorating them changes NO behaviour while the checker is in shadow — a
|
|
47
59
|
* would-deny is logged and counted and then allowed. What it changes is that
|
|
48
60
|
* the exposure becomes measurable. Enforcement cannot be argued from a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-map.d.ts","sourceRoot":"","sources":["../../../src/auth/authorization-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AAIzC,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,gBAAgB,EAMhD,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"authorization-map.d.ts","sourceRoot":"","sources":["../../../src/auth/authorization-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AAIzC,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,gBAAgB,EAMhD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,gBAAgB,EAKhE,CAAC;AAmCF,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,oDAAoD;IACpD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,4FAA4F;IAC5F,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAmBD,6DAA6D;AAC7D,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,qBAAqB,CAoEnE;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,IAAI,uBAAuB,CAcrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-map.js","sourceRoot":"","sources":["../../../src/auth/authorization-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,wBAAwB,GAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,cAAc,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAgC;IACpD,UAAU;IACV,SAAS;IACT,qBAAqB;IACrB,kBAAkB;IAClB,aAAa;CACd,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"authorization-map.js","sourceRoot":"","sources":["../../../src/auth/authorization-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,wBAAwB,GAEzB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AAc,CAAC;IACxB,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,2BAA2B,EAAE,CAAC;IACvD,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CACT,yGAAyG,EACzG,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAC3C,CAAC;IACJ,CAAC;IACD,cAAc,GAAG,OAAO,CAAC;IACzB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -44,13 +44,25 @@ export const IR_MODELS = [
|
|
|
44
44
|
/**
|
|
45
45
|
* Models whose READ actions are decorated as well as their deletes.
|
|
46
46
|
*
|
|
47
|
-
* These
|
|
47
|
+
* These four answer to anyone today. A read-only probe of the deployed API
|
|
48
48
|
* with no Authorization header returns a real organisation name, a real user's
|
|
49
49
|
* email address, and a real membership row, so the standing escalation is not
|
|
50
50
|
* theoretical. They were outside the checker entirely: `_all` covers the five
|
|
51
51
|
* investor-relations models, everything else got delete coverage only, and a
|
|
52
52
|
* query the checker never runs for is a query it cannot even count.
|
|
53
53
|
*
|
|
54
|
+
* `AuditLog` joined them on 2026-09-26, on the same admission criterion and by
|
|
55
|
+
* measurement rather than by inspection. It is the largest of the four by some
|
|
56
|
+
* distance and the only one carrying correlatable personal data: a census of
|
|
57
|
+
* the anonymously readable rows found, across roughly 70,000 rows, at most five
|
|
58
|
+
* distinct email identities, 33 distinct IP addresses, at most four person
|
|
59
|
+
* names and two user agents. Report that as a small number of data subjects
|
|
60
|
+
* with a great many records about each, NOT as a large exposure — the row count
|
|
61
|
+
* is a true number answering a question nobody asked. Note also that 27,964
|
|
62
|
+
* `accountName` rows, first classified as an account label, were hash-matched
|
|
63
|
+
* in-database against the users table to three real email addresses, so
|
|
64
|
+
* per-subject completeness is higher than a field-name reading suggests.
|
|
65
|
+
*
|
|
54
66
|
* Decorating them changes NO behaviour while the checker is in shadow — a
|
|
55
67
|
* would-deny is logged and counted and then allowed. What it changes is that
|
|
56
68
|
* the exposure becomes measurable. Enforcement cannot be argued from a
|
|
@@ -61,6 +73,7 @@ export const TENANT_SCOPED_READ_MODELS = [
|
|
|
61
73
|
'Organization',
|
|
62
74
|
'OrgMembership',
|
|
63
75
|
'User',
|
|
76
|
+
'AuditLog',
|
|
64
77
|
];
|
|
65
78
|
/**
|
|
66
79
|
* Action-name prefixes that MUTATE. Everything else on a generated CRUD
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stored credential columns, by Prisma model.
|
|
3
|
+
*
|
|
4
|
+
* One vocabulary for every place that has to know what a credential is: the
|
|
5
|
+
* credential-field guard (what may be read, filtered or grouped on), the
|
|
6
|
+
* redaction applied to audit payloads on write, and the redaction applied to
|
|
7
|
+
* audit payloads on read. It lives in a module that imports nothing, so each
|
|
8
|
+
* of those can depend on it without depending on the others.
|
|
9
|
+
*
|
|
10
|
+
* @module auth/credential-fields
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Every stored credential column, by Prisma model. A column belongs here when
|
|
14
|
+
* its value lets the holder act as someone: a broker or vendor API secret, an
|
|
15
|
+
* OAuth access / refresh / id token, a session token, a one-time verification
|
|
16
|
+
* or invite token.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CREDENTIAL_FIELDS: ReadonlyMap<string, ReadonlySet<string>>;
|
|
19
|
+
//# sourceMappingURL=credential-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-fields.d.ts","sourceRoot":"","sources":["../../../src/auth/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CA0BrE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-fields.js","sourceRoot":"","sources":["../../../src/auth/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA6C,IAAI,GAAG,CAGhF;IACA,CAAC,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IACnD,CAAC,kBAAkB,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IACtD;QACE,kBAAkB;QAClB,IAAI,GAAG,CAAC;YACN,cAAc;YACd,iBAAiB;YACjB,gBAAgB;YAChB,YAAY;YACZ,YAAY;YACZ,WAAW;YACX,cAAc;YACd,iBAAiB;SAClB,CAAC;KACH;IACD,CAAC,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IACnC,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IACnE,CAAC,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;IAC5D,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;IACtC,CAAC,mBAAmB,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,CAAC,uBAAuB,EAAE,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACzD,CAAC,aAAa,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stored credential columns, by Prisma model.
|
|
3
|
+
*
|
|
4
|
+
* One vocabulary for every place that has to know what a credential is: the
|
|
5
|
+
* credential-field guard (what may be read, filtered or grouped on), the
|
|
6
|
+
* redaction applied to audit payloads on write, and the redaction applied to
|
|
7
|
+
* audit payloads on read. It lives in a module that imports nothing, so each
|
|
8
|
+
* of those can depend on it without depending on the others.
|
|
9
|
+
*
|
|
10
|
+
* @module auth/credential-fields
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Every stored credential column, by Prisma model. A column belongs here when
|
|
14
|
+
* its value lets the holder act as someone: a broker or vendor API secret, an
|
|
15
|
+
* OAuth access / refresh / id token, a session token, a one-time verification
|
|
16
|
+
* or invite token.
|
|
17
|
+
*/
|
|
18
|
+
export const CREDENTIAL_FIELDS = new Map([
|
|
19
|
+
['AlpacaAccount', new Set(['APIKey', 'APISecret'])],
|
|
20
|
+
['BrokerageAccount', new Set(['apiKey', 'apiSecret'])],
|
|
21
|
+
[
|
|
22
|
+
'LlmConfiguration',
|
|
23
|
+
new Set([
|
|
24
|
+
'openaiApiKey',
|
|
25
|
+
'anthropicApiKey',
|
|
26
|
+
'deepseekApiKey',
|
|
27
|
+
'kimiApiKey',
|
|
28
|
+
'qwenApiKey',
|
|
29
|
+
'xaiApiKey',
|
|
30
|
+
'geminiApiKey',
|
|
31
|
+
'deepinfraApiKey',
|
|
32
|
+
]),
|
|
33
|
+
],
|
|
34
|
+
['User', new Set(['openaiAPIKey'])],
|
|
35
|
+
['Account', new Set(['refresh_token', 'access_token', 'id_token'])],
|
|
36
|
+
['LinkedProvider', new Set(['accessToken', 'refreshToken'])],
|
|
37
|
+
['Session', new Set(['sessionToken'])],
|
|
38
|
+
['VerificationToken', new Set(['token'])],
|
|
39
|
+
['AccountLinkingRequest', new Set(['verificationToken'])],
|
|
40
|
+
['InviteToken', new Set(['token'])],
|
|
41
|
+
]);
|
|
42
|
+
//# sourceMappingURL=credential-fields.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact stored-credential values from a payload before it is persisted or
|
|
3
|
+
* logged.
|
|
4
|
+
*
|
|
5
|
+
* The audit trail records what a mutation asked for, and a mutation that
|
|
6
|
+
* writes a broker key carries the key in its arguments. An audit row is read
|
|
7
|
+
* by far more people and processes than the credential column itself, so a
|
|
8
|
+
* credential copied into one is a second, unguarded copy of the secret. A
|
|
9
|
+
* payload bound for `AuditLog.changedFields` / `metadata` should pass through
|
|
10
|
+
* here before it is stored, and the audit payload guard
|
|
11
|
+
* (`middleware/audit-payload-guard`) applies the same rule when a row is read,
|
|
12
|
+
* which also covers rows stored before any writer redacted.
|
|
13
|
+
*
|
|
14
|
+
* Key-directed rather than type-directed on purpose: audit payloads are
|
|
15
|
+
* persisted as JSON with no GraphQL type attached, and over-redacting a
|
|
16
|
+
* non-secret that shares a credential column's name costs an audit reader one
|
|
17
|
+
* field, while under-redacting leaks a key. The key set is exactly the
|
|
18
|
+
* credential columns {@link CREDENTIAL_FIELDS} guards on the read side.
|
|
19
|
+
*
|
|
20
|
+
* @module auth/credential-redaction
|
|
21
|
+
*/
|
|
22
|
+
/** The placeholder a redacted value is replaced with. */
|
|
23
|
+
export declare const REDACTED = "[REDACTED]";
|
|
24
|
+
/** Every credential column name across all models. */
|
|
25
|
+
export declare const CREDENTIAL_KEY_NAMES: ReadonlySet<string>;
|
|
26
|
+
/**
|
|
27
|
+
* A deep copy of `value` with every credential-named key's value replaced by
|
|
28
|
+
* {@link REDACTED}. An absent or null credential value is kept as-is, so the
|
|
29
|
+
* audit row still shows whether a credential was set, cleared or untouched.
|
|
30
|
+
*
|
|
31
|
+
* @param value - Any JSON-shaped value.
|
|
32
|
+
* @returns The redacted copy.
|
|
33
|
+
*/
|
|
34
|
+
export declare function redactCredentials(value: unknown, depth?: number): unknown;
|
|
35
|
+
/** One value {@link redactCredentials} replaces, located by key path. */
|
|
36
|
+
export interface CredentialKeyPath {
|
|
37
|
+
/** Dotted key path from the payload root, array indices included. */
|
|
38
|
+
path: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the replaced value held anything: a non-empty string, a number or
|
|
41
|
+
* a boolean somewhere inside it. A key set to `""` or `{ set: "" }` is
|
|
42
|
+
* replaced all the same, but it disclosed nothing.
|
|
43
|
+
*/
|
|
44
|
+
carriesValue: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Every place {@link redactCredentials} replaces a value in `value`, in
|
|
48
|
+
* traversal order. It walks by the same rules (credential key names, the null
|
|
49
|
+
* exemption, the depth limit), so it is empty exactly when redaction leaves
|
|
50
|
+
* the payload as it was. Paths name keys only, never values.
|
|
51
|
+
*
|
|
52
|
+
* @param value - Any JSON-shaped value.
|
|
53
|
+
* @returns The replaced locations.
|
|
54
|
+
*/
|
|
55
|
+
export declare function credentialKeyPaths(value: unknown, depth?: number, path?: string): CredentialKeyPath[];
|
|
56
|
+
//# sourceMappingURL=credential-redaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-redaction.d.ts","sourceRoot":"","sources":["../../../src/auth/credential-redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,yDAAyD;AACzD,eAAO,MAAM,QAAQ,eAAe,CAAC;AAKrC,sDAAsD;AACtD,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAEpD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAcpE;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,EAAE,IAAI,SAAK,GAAG,iBAAiB,EAAE,CAY5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-redaction.js","sourceRoot":"","sources":["../../../src/auth/credential-redaction.ts"],"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EAAE,KAAK,GAAG,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAC9D,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,MAAc,EAAE,GAAW;IAC3C,OAAO,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAClD,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,yEAAyE;IACzE,IAAI,KAAK,IAAI,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,QAAQ,GAAc,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAgC,CAAC,CAAC;IAC3G,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact stored-credential values from a payload before it is persisted or
|
|
3
|
+
* logged.
|
|
4
|
+
*
|
|
5
|
+
* The audit trail records what a mutation asked for, and a mutation that
|
|
6
|
+
* writes a broker key carries the key in its arguments. An audit row is read
|
|
7
|
+
* by far more people and processes than the credential column itself, so a
|
|
8
|
+
* credential copied into one is a second, unguarded copy of the secret. A
|
|
9
|
+
* payload bound for `AuditLog.changedFields` / `metadata` should pass through
|
|
10
|
+
* here before it is stored, and the audit payload guard
|
|
11
|
+
* (`middleware/audit-payload-guard`) applies the same rule when a row is read,
|
|
12
|
+
* which also covers rows stored before any writer redacted.
|
|
13
|
+
*
|
|
14
|
+
* Key-directed rather than type-directed on purpose: audit payloads are
|
|
15
|
+
* persisted as JSON with no GraphQL type attached, and over-redacting a
|
|
16
|
+
* non-secret that shares a credential column's name costs an audit reader one
|
|
17
|
+
* field, while under-redacting leaks a key. The key set is exactly the
|
|
18
|
+
* credential columns {@link CREDENTIAL_FIELDS} guards on the read side.
|
|
19
|
+
*
|
|
20
|
+
* @module auth/credential-redaction
|
|
21
|
+
*/
|
|
22
|
+
// From the leaf module, not the guard: the guard redacts audit payloads on
|
|
23
|
+
// read, so importing it here would make the two modules import each other.
|
|
24
|
+
import { CREDENTIAL_FIELDS } from './credential-fields.mjs';
|
|
25
|
+
/** The placeholder a redacted value is replaced with. */
|
|
26
|
+
export const REDACTED = '[REDACTED]';
|
|
27
|
+
/** Deepest nesting walked; anything deeper is replaced wholesale. */
|
|
28
|
+
const MAX_DEPTH = 12;
|
|
29
|
+
/** Every credential column name across all models. */
|
|
30
|
+
export const CREDENTIAL_KEY_NAMES = new Set([...CREDENTIAL_FIELDS.values()].flatMap((fields) => [...fields]));
|
|
31
|
+
/**
|
|
32
|
+
* A deep copy of `value` with every credential-named key's value replaced by
|
|
33
|
+
* {@link REDACTED}. An absent or null credential value is kept as-is, so the
|
|
34
|
+
* audit row still shows whether a credential was set, cleared or untouched.
|
|
35
|
+
*
|
|
36
|
+
* @param value - Any JSON-shaped value.
|
|
37
|
+
* @returns The redacted copy.
|
|
38
|
+
*/
|
|
39
|
+
export function redactCredentials(value, depth = 0) {
|
|
40
|
+
if (value === null || value === undefined)
|
|
41
|
+
return value;
|
|
42
|
+
if (depth >= MAX_DEPTH)
|
|
43
|
+
return REDACTED;
|
|
44
|
+
if (Array.isArray(value))
|
|
45
|
+
return value.map((item) => redactCredentials(item, depth + 1));
|
|
46
|
+
if (typeof value !== 'object')
|
|
47
|
+
return value;
|
|
48
|
+
if (value instanceof Date)
|
|
49
|
+
return value.toISOString();
|
|
50
|
+
const out = {};
|
|
51
|
+
for (const [key, child] of Object.entries(value)) {
|
|
52
|
+
out[key] =
|
|
53
|
+
CREDENTIAL_KEY_NAMES.has(key) && child !== null && child !== undefined
|
|
54
|
+
? REDACTED
|
|
55
|
+
: redactCredentials(child, depth + 1);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Every place {@link redactCredentials} replaces a value in `value`, in
|
|
61
|
+
* traversal order. It walks by the same rules (credential key names, the null
|
|
62
|
+
* exemption, the depth limit), so it is empty exactly when redaction leaves
|
|
63
|
+
* the payload as it was. Paths name keys only, never values.
|
|
64
|
+
*
|
|
65
|
+
* @param value - Any JSON-shaped value.
|
|
66
|
+
* @returns The replaced locations.
|
|
67
|
+
*/
|
|
68
|
+
export function credentialKeyPaths(value, depth = 0, path = '') {
|
|
69
|
+
if (value === null || value === undefined)
|
|
70
|
+
return [];
|
|
71
|
+
if (depth >= MAX_DEPTH)
|
|
72
|
+
return [{ path: path || '<root>', carriesValue: carriesValue(value) }];
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
return value.flatMap((item, index) => credentialKeyPaths(item, depth + 1, joinPath(path, String(index))));
|
|
75
|
+
}
|
|
76
|
+
if (typeof value !== 'object' || value instanceof Date)
|
|
77
|
+
return [];
|
|
78
|
+
return Object.entries(value).flatMap(([key, child]) => CREDENTIAL_KEY_NAMES.has(key) && child !== null && child !== undefined
|
|
79
|
+
? [{ path: joinPath(path, key), carriesValue: carriesValue(child) }]
|
|
80
|
+
: credentialKeyPaths(child, depth + 1, joinPath(path, key)));
|
|
81
|
+
}
|
|
82
|
+
function joinPath(parent, key) {
|
|
83
|
+
return parent === '' ? key : `${parent}.${key}`;
|
|
84
|
+
}
|
|
85
|
+
/** Whether `value` holds a non-empty string, a number or a boolean anywhere. */
|
|
86
|
+
function carriesValue(value, depth = 0) {
|
|
87
|
+
if (value === null || value === undefined)
|
|
88
|
+
return false;
|
|
89
|
+
if (typeof value === 'string')
|
|
90
|
+
return value.length > 0;
|
|
91
|
+
if (typeof value !== 'object')
|
|
92
|
+
return true;
|
|
93
|
+
// Too deep to inspect: assume it does, as the redaction assumes it must.
|
|
94
|
+
if (depth >= MAX_DEPTH)
|
|
95
|
+
return true;
|
|
96
|
+
const children = Array.isArray(value) ? value : Object.values(value);
|
|
97
|
+
return children.some((child) => carriesValue(child, depth + 1));
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=credential-redaction.js.map
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutation authorization — pure decision logic.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* The `/graphql` context admits a request with no bearer token as a null
|
|
7
|
+
* principal (context-level enforcement is staged per
|
|
8
|
+
* `docs/security/2026-08-23-graphql-auth-enforcement-runbook.md`), and the
|
|
9
|
+
* generated typegraphql-prisma resolvers expose a create / update / upsert /
|
|
10
|
+
* delete mutation for every model. Together that let any caller who can reach
|
|
11
|
+
* the endpoint rewrite the system of record — including the
|
|
12
|
+
* `TradingPolicy.realtimeTradingEnabled` flag that arms a LIVE brokerage
|
|
13
|
+
* account — with nothing recording who did it.
|
|
14
|
+
*
|
|
15
|
+
* A write is authorised by WHO is asking and WHAT they are writing, so the
|
|
16
|
+
* decision needs both the verified principal and the model the mutation lands
|
|
17
|
+
* on. This module owns that decision; `src/middleware/mutation-auth-guard.ts`
|
|
18
|
+
* wires it into the request lifecycle and supplies the database facts
|
|
19
|
+
* (account ownership) the decision needs.
|
|
20
|
+
*
|
|
21
|
+
* ## Who may write what
|
|
22
|
+
*
|
|
23
|
+
* - `server` (the engine's service JWT, or the static server token) and
|
|
24
|
+
* `admin` may run every mutation. The engine is the system's own writer.
|
|
25
|
+
* - `user` may write only where the product has an ownership model:
|
|
26
|
+
* - `account_owned` — `TradingPolicy` and `AlpacaAccount`: the account must
|
|
27
|
+
* belong to the caller, or be bound to a fund the caller is entitled to
|
|
28
|
+
* (the same OrgMembership / FundAssignment entitlement the tenancy scoping
|
|
29
|
+
* uses). Bulk actions are never user-writable: a `where` filter over many
|
|
30
|
+
* accounts has no single owner to check.
|
|
31
|
+
* - `self` — `User`: only the caller's own row, and only its profile and
|
|
32
|
+
* onboarding fields (`./user-write-content.ts`).
|
|
33
|
+
* - `tenant_scoped` — the tenancy-governed models: the row (for an update,
|
|
34
|
+
* upsert or delete) or the payload's tenant (for a create) must lie in the
|
|
35
|
+
* caller's OrgMembership / FundAssignment entitlement. The guard checks
|
|
36
|
+
* this itself, whatever `TENANCY_SCOPING_MODE` says, because fund
|
|
37
|
+
* entitlement is what authorises `account_owned` writes on fund-bridged
|
|
38
|
+
* accounts: a scope that only observes would let a caller mint the
|
|
39
|
+
* entitlement it is then checked against.
|
|
40
|
+
* - `authenticated` — user-authored content with no finer ownership model
|
|
41
|
+
* yet, restricted per model to the actions the platform performs, and for
|
|
42
|
+
* `AuditLog` and `Configuration` to content a user may author
|
|
43
|
+
* (`./user-write-content.ts`).
|
|
44
|
+
* - `resolver_authorized` — custom mutations whose resolver performs its own
|
|
45
|
+
* authorization.
|
|
46
|
+
* - everything else is `service_only`.
|
|
47
|
+
* - no principal may run no mutation.
|
|
48
|
+
*
|
|
49
|
+
* Nested relation writes are decided hop by hop in `./nested-write-policy.ts`.
|
|
50
|
+
*
|
|
51
|
+
* ## Modes
|
|
52
|
+
*
|
|
53
|
+
* `MUTATION_AUTH_MODE`: `shadow` (count, log and audit what enforcement would
|
|
54
|
+
* deny, change nothing) is the value an UNSET variable resolves to, so the
|
|
55
|
+
* first deploy changes no behaviour and the would-deny series can be read
|
|
56
|
+
* before anything is refused. `enforce` refuses. `off` disables the decision.
|
|
57
|
+
* A value that is SET but unrecognised resolves to `enforce`: an operator who
|
|
58
|
+
* tried to configure the guard and mistyped it must get a guard that refuses,
|
|
59
|
+
* not one that silently observes.
|
|
60
|
+
*
|
|
61
|
+
* `MUTATION_AUTH_ENFORCE_MODELS` (comma-separated model names) escalates the
|
|
62
|
+
* listed models to `enforce` while the global mode is `shadow`, so the
|
|
63
|
+
* capital-bearing models can be contained before every browser-side platform
|
|
64
|
+
* write has migrated to a verified principal. Two rules keep an escalation
|
|
65
|
+
* from being bypassed:
|
|
66
|
+
*
|
|
67
|
+
* - a mutation is decided at the STRICTEST mode among its root model and
|
|
68
|
+
* every model its nested writes reach, so `updateOneUser → alpacaAccounts →
|
|
69
|
+
* tradingPolicy` is enforced when TradingPolicy is;
|
|
70
|
+
* - escalating an account model (`TradingPolicy`, `AlpacaAccount`) escalates
|
|
71
|
+
* the entitlement-source models (`OrgMembership`, `FundAssignment`, `Fund`,
|
|
72
|
+
* `BrokerageAccount`) with it, because the account rule admits a caller on
|
|
73
|
+
* fund entitlement read from those rows.
|
|
74
|
+
*
|
|
75
|
+
* @module auth/mutation-authorization
|
|
76
|
+
*/
|
|
77
|
+
import type { BackendPrincipal } from './token-verifier';
|
|
78
|
+
/** Operating mode of the mutation guard. See the module doc. */
|
|
79
|
+
export type MutationAuthMode = 'off' | 'shadow' | 'enforce';
|
|
80
|
+
/** Environment variable selecting the global mode. */
|
|
81
|
+
export declare const MUTATION_AUTH_MODE_ENV = "MUTATION_AUTH_MODE";
|
|
82
|
+
/** Environment variable listing models escalated to `enforce`. */
|
|
83
|
+
export declare const MUTATION_AUTH_ENFORCE_MODELS_ENV = "MUTATION_AUTH_ENFORCE_MODELS";
|
|
84
|
+
/**
|
|
85
|
+
* Resolve the global mode. Unset or blank → `shadow`; a recognised value →
|
|
86
|
+
* itself; anything else → `enforce`.
|
|
87
|
+
*
|
|
88
|
+
* @param env - Environment source; injectable for tests.
|
|
89
|
+
* @returns The resolved {@link MutationAuthMode}.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getMutationAuthMode(env?: Record<string, string | undefined>): MutationAuthMode;
|
|
92
|
+
/**
|
|
93
|
+
* The models escalated to `enforce` by {@link MUTATION_AUTH_ENFORCE_MODELS_ENV}.
|
|
94
|
+
*
|
|
95
|
+
* @param env - Environment source; injectable for tests.
|
|
96
|
+
* @returns The set of model names (exact, case-sensitive Prisma names).
|
|
97
|
+
*/
|
|
98
|
+
export declare function getEnforcedModels(env?: Record<string, string | undefined>): ReadonlySet<string>;
|
|
99
|
+
/** The models whose user writes are authorised by row ownership or fund entitlement. */
|
|
100
|
+
export declare const ACCOUNT_MODELS: readonly string[];
|
|
101
|
+
/**
|
|
102
|
+
* The models fund entitlement and the fund-to-account bridge are read from:
|
|
103
|
+
* `resolveEntitlement` reads OrgMembership, Fund and FundAssignment, and a
|
|
104
|
+
* BrokerageAccount binds an AlpacaAccount to its fund.
|
|
105
|
+
*/
|
|
106
|
+
export declare const ENTITLEMENT_SOURCE_MODELS: readonly string[];
|
|
107
|
+
/**
|
|
108
|
+
* The escalation list with its implied members: an escalated account model
|
|
109
|
+
* brings every entitlement-source model with it.
|
|
110
|
+
*/
|
|
111
|
+
export declare function expandEnforcedModels(enforcedModels: ReadonlySet<string>): ReadonlySet<string>;
|
|
112
|
+
/**
|
|
113
|
+
* The mode a mutation is decided in. `off` is a kill switch and wins; a
|
|
114
|
+
* global `enforce` covers every model; under `shadow`, the mutation enforces
|
|
115
|
+
* when ANY model it writes — the root or one reached by a nested write — is
|
|
116
|
+
* escalated (directly, or through {@link expandEnforcedModels}).
|
|
117
|
+
*
|
|
118
|
+
* @param models - The root model and every nested write's model.
|
|
119
|
+
* @param mode - The global mode.
|
|
120
|
+
* @param enforcedModels - The escalation list as configured.
|
|
121
|
+
*/
|
|
122
|
+
export declare function effectiveModeFor(models: readonly string[], mode: MutationAuthMode, enforcedModels: ReadonlySet<string>): MutationAuthMode;
|
|
123
|
+
/** What a generated mutation does to its model. */
|
|
124
|
+
export type MutationAction = 'create' | 'update' | 'upsert' | 'delete';
|
|
125
|
+
/** Whether the mutation addresses one row (by a unique `where`) or many. */
|
|
126
|
+
export type MutationCardinality = 'one' | 'many';
|
|
127
|
+
/** A mutation root field resolved onto its model. */
|
|
128
|
+
export interface MutationTarget {
|
|
129
|
+
/** Prisma model name, or `custom:<field>` for a hand-written mutation. */
|
|
130
|
+
readonly model: string;
|
|
131
|
+
readonly action: MutationAction | 'custom';
|
|
132
|
+
readonly cardinality: MutationCardinality;
|
|
133
|
+
readonly fieldName: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Resolve a root mutation field name onto its model and action. A field that
|
|
137
|
+
* is not `<prefix><KnownModel>` is a custom mutation.
|
|
138
|
+
*
|
|
139
|
+
* @param fieldName - `info.fieldName` of a root Mutation field.
|
|
140
|
+
* @param models - Every Prisma model name.
|
|
141
|
+
*/
|
|
142
|
+
export declare function classifyMutationField(fieldName: string, models: ReadonlySet<string>): MutationTarget;
|
|
143
|
+
/** How a `user` principal may write a model. See the module doc. */
|
|
144
|
+
export type UserWritePolicy = 'service_only' | 'account_owned' | 'self' | 'tenant_scoped' | 'authenticated' | 'resolver_authorized';
|
|
145
|
+
/** A model's user policy plus the actions a user may perform under it. */
|
|
146
|
+
export interface ModelWriteRule {
|
|
147
|
+
readonly policy: UserWritePolicy;
|
|
148
|
+
/** Actions a user may perform; absent means every action. */
|
|
149
|
+
readonly userActions?: ReadonlySet<MutationAction | 'custom'>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Explicit user-write rules. Every model absent here is `service_only`.
|
|
153
|
+
*
|
|
154
|
+
* The `authenticated` rows are the writes the platform's server routes make
|
|
155
|
+
* as the signed-in user today (see the caller inventory in
|
|
156
|
+
* `docs/security/2026-09-24-mutation-authorization-runbook.md`), narrowed to
|
|
157
|
+
* the actions those routes perform. Each is a model with no finer ownership
|
|
158
|
+
* model yet; tightening one to an ownership rule is a follow-up, never a
|
|
159
|
+
* reason to widen another.
|
|
160
|
+
*/
|
|
161
|
+
export declare const MODEL_WRITE_RULES: ReadonlyMap<string, ModelWriteRule>;
|
|
162
|
+
/** The write rule for a model. */
|
|
163
|
+
export declare function ruleFor(model: string): ModelWriteRule;
|
|
164
|
+
/** Why a mutation was admitted or refused. A bounded metric label. */
|
|
165
|
+
export type MutationAuthReason = 'guard_off' | 'guard_error' | 'service_principal' | 'admin_principal' | 'account_owner' | 'account_fund_entitled' | 'self' | 'tenant_scoped' | 'authenticated_user_model' | 'resolver_authorized' | 'unauthenticated' | 'model_not_user_writable' | 'action_not_user_writable' | 'bulk_not_user_writable' | 'not_account_owner' | 'account_unresolved' | 'not_self' | 'tenant_out_of_scope' | 'tenant_unresolved' | 'field_not_user_writable' | 'reserved_audit_source' | 'audit_actor_mismatch' | 'config_key_not_user_scoped' | 'nested_write_not_user_writable' | 'nested_entitlement_write';
|
|
166
|
+
/** Ownership facts the middleware resolved for an `account_owned` write. */
|
|
167
|
+
export type AccountOwnership = {
|
|
168
|
+
readonly kind: 'owner';
|
|
169
|
+
} | {
|
|
170
|
+
readonly kind: 'fund_entitled';
|
|
171
|
+
} | {
|
|
172
|
+
readonly kind: 'other';
|
|
173
|
+
} | {
|
|
174
|
+
readonly kind: 'unresolved';
|
|
175
|
+
};
|
|
176
|
+
/** For a `tenant_scoped` write: whether the row or payload lies in the caller's entitlement. */
|
|
177
|
+
export type TenantScope = 'in_scope' | 'out_of_scope';
|
|
178
|
+
/** Everything the decision needs beyond the principal and target. */
|
|
179
|
+
export interface MutationFacts {
|
|
180
|
+
/** For `account_owned`: whether the caller owns every account touched. */
|
|
181
|
+
readonly ownership?: AccountOwnership;
|
|
182
|
+
/** For `self`: whether the `where` names the caller's own row. */
|
|
183
|
+
readonly targetsSelf?: boolean;
|
|
184
|
+
/** For `tenant_scoped`: the guard's own scope check; absent = not yet resolved. */
|
|
185
|
+
readonly tenantScope?: TenantScope;
|
|
186
|
+
/** The refusal from `./nested-write-policy.ts`, if any nested write is refused. */
|
|
187
|
+
readonly nestedRefusal?: 'nested_write_not_user_writable' | 'nested_entitlement_write' | null;
|
|
188
|
+
/** The refusal from `./user-write-content.ts`, if the payload's content is refused. */
|
|
189
|
+
readonly contentRefusal?: 'field_not_user_writable' | 'reserved_audit_source' | 'audit_actor_mismatch' | 'config_key_not_user_scoped' | null;
|
|
190
|
+
}
|
|
191
|
+
/** The decision for one mutation, before the mode is applied. */
|
|
192
|
+
export interface MutationAuthEvaluation {
|
|
193
|
+
readonly allowed: boolean;
|
|
194
|
+
readonly reason: MutationAuthReason;
|
|
195
|
+
/** HTTP-shaped class of a refusal: no principal (401) or wrong one (403). */
|
|
196
|
+
readonly refusal?: 'unauthenticated' | 'forbidden';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Decide whether a principal may run a mutation. Pure; performs no I/O.
|
|
200
|
+
*
|
|
201
|
+
* @param principal - The verified principal, or `null` for none.
|
|
202
|
+
* @param target - The classified root mutation field.
|
|
203
|
+
* @param facts - Ownership facts resolved by the caller (user principals only).
|
|
204
|
+
*/
|
|
205
|
+
export declare function evaluateMutationAccess(principal: BackendPrincipal | null, target: MutationTarget, facts?: MutationFacts): MutationAuthEvaluation;
|
|
206
|
+
//# sourceMappingURL=mutation-authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-authorization.d.ts","sourceRoot":"","sources":["../../../src/auth/mutation-authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5D,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAE3D,kEAAkE;AAClE,eAAO,MAAM,gCAAgC,iCAAiC,CAAC;AAE/E;;;;;;GAMG;AACH,wBAAgB,mB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