@reventlessdev/reventless-core 3.0.0-alpha.311 → 3.0.0-alpha.313
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/CHANGELOG.md +40 -0
- package/package.json +6 -6
- package/src/Message.res +23 -6
- package/src/Message.res.mjs +14 -6
- package/src/adapter/Secrets/Secrets_Node_Backend.res +41 -2
- package/src/adapter/Secrets/Secrets_Node_Backend.res.mjs +65 -23
- package/src/components/Api/SuryToJsonSchema.res +19 -0
- package/src/components/Api/SuryToJsonSchema.res.mjs +26 -5
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +2 -2
- package/src/components/CommandGenerator/CommandGenerator.res +3 -1
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +0 -1
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +0 -2
- package/src/components/CommandTopic/CommandTopic_Callback.res +3 -1
- package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +2 -1
- package/src/components/Counter/Counter_Callback.res.mjs +1 -1
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +1 -1
- package/src/components/EventLog/EventLog_Operations.res +1 -1
- package/src/components/EventLog/EventLog_Operations.res.mjs +1 -1
- package/src/components/Heartbeat/Heartbeat_Callback.res +0 -1
- package/src/components/Heartbeat/Heartbeat_Callback.res.mjs +0 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +1 -1
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +2 -2
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +1 -1
- package/src/util/CommandPublisher.res.mjs +1 -1
- package/src/util/LogFormat.res +22 -4
- package/src/util/LogFormat.res.mjs +26 -5
- package/src/util/Logger.res +11 -2
- package/src/util/Logger.res.mjs +3 -2
- package/tests/Secrets_Node_BackendTest.res +32 -0
- package/tests/Secrets_Node_BackendTest.res.mjs +29 -1
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +1 -1
- package/tests/logger/LogFormatTest.res +5 -3
- package/tests/message/MessageTest.res +9 -0
- package/tests/message/MessageTest.res.mjs +5 -0
- package/tests/message/MetaEnvelopeTest.res +37 -20
- package/tests/message/MetaEnvelopeTest.res.mjs +32 -17
- package/tests/pii/PiiMember.res +18 -0
- package/tests/pii/PiiMember.res.mjs +59 -0
- package/tests/pii/PiiPpxTest.res +128 -0
- package/tests/pii/PiiPpxTest.res.mjs +151 -0
- package/tests/plugin/HeartbeatDisconnectGraceTest.res.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.313 (2026-10-29)
|
|
7
|
+
|
|
8
|
+
* feat(ppx)!: `@pii` marks a value about a person, and an event reads it as `Pii.t` ([37174c1](https://github.com/ReventlessDev/reventless-core/commit/37174c10eb80e9e3adbb93a52ad7a9ef5def7100))
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* the ledger's events carry `address: Pii.t<Email.t>`. Pattern-match
|
|
13
|
+
`Value(address)` where the address is read.
|
|
14
|
+
|
|
15
|
+
The published per-platform PPX binary does not know `@pii` until it is republished.
|
|
16
|
+
|
|
17
|
+
Step PD2 of docs/plans/a-personal-field-is-marked-redacted-and-encrypted-at-the-seam.md.
|
|
18
|
+
Claude-Session: https://claude.ai/code/session_01HiQfdxVEsHwLHRoHSUcus1
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# 3.0.0-alpha.312 (2026-10-29)
|
|
23
|
+
|
|
24
|
+
* feat(registration)!: the ledger tags an address by its keyed fingerprint ([ccafddf](https://github.com/ReventlessDev/reventless-core/commit/ccafddfc7eb8039687afc62a483ce34b8e7081dd))
|
|
25
|
+
* feat(core)!: the caller's IP address leaves the messages a request causes ([aa9e8c7](https://github.com/ReventlessDev/reventless-core/commit/aa9e8c79c0360528a5cfeda2bb88d1da52f28674))
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **spec:** personal data has a type, three stored forms and a provider seam ([134c0d1](https://github.com/ReventlessDev/reventless-core/commit/134c0d1e0a3c97304a5cd418db76c7d6b3447dcb))
|
|
29
|
+
|
|
30
|
+
### BREAKING CHANGES
|
|
31
|
+
|
|
32
|
+
* `Secrets.t` has a third field, `fingerprint`; a hand-built provider
|
|
33
|
+
adds it. `Register` and `Invite` take `address`, and their `email` is the
|
|
34
|
+
fingerprint from `ContactAddressId.fingerprint`, not `makeFromString(address)`.
|
|
35
|
+
|
|
36
|
+
Step PD5 of docs/plans/a-personal-field-is-marked-redacted-and-encrypted-at-the-seam.md.
|
|
37
|
+
Claude-Session: https://claude.ai/code/session_01HiQfdxVEsHwLHRoHSUcus1
|
|
38
|
+
* `Message.generateMeta` no longer takes `~ip`. Drop the argument; a
|
|
39
|
+
message that must carry the address declares it as a field of its own payload.
|
|
40
|
+
|
|
41
|
+
Step PD3 of docs/plans/a-personal-field-is-marked-redacted-and-encrypted-at-the-seam.md.
|
|
42
|
+
Claude-Session: https://claude.ai/code/session_01HiQfdxVEsHwLHRoHSUcus1
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
6
46
|
# 3.0.0-alpha.311 (2026-10-29)
|
|
7
47
|
|
|
8
48
|
* refactor!: drop `dcbSources`, the cross-plugin DCB subscription nobody declared ([cf3b66d](https://github.com/ReventlessDev/reventless-core/commit/cf3b66d8c1b5d87673197b64eaee174598bb8253))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.313",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"sury": "11.0.0",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
31
|
"@reventlessdev/rescript-effect": "1.0.0-alpha.1",
|
|
32
|
-
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.23",
|
|
33
32
|
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
34
|
-
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
35
33
|
"@reventlessdev/rescript-node": "2.0.0-alpha.23",
|
|
34
|
+
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.23",
|
|
35
|
+
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
36
36
|
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
37
|
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.24",
|
|
38
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.208",
|
|
39
38
|
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
40
|
-
"@reventlessdev/reventless-
|
|
41
|
-
"@reventlessdev/reventless-interop": "3.0.0-alpha.42"
|
|
39
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.210",
|
|
40
|
+
"@reventlessdev/reventless-interop": "3.0.0-alpha.42",
|
|
41
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.181"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
package/src/Message.res
CHANGED
|
@@ -85,7 +85,14 @@ let uuid = Uuid.v4
|
|
|
85
85
|
let log: ('a, string) => 'a = (value, str) => {
|
|
86
86
|
logger.debug(
|
|
87
87
|
~comp="Message",
|
|
88
|
-
~data=value
|
|
88
|
+
~data=value
|
|
89
|
+
->JSON.stringifyAny
|
|
90
|
+
->Option.flatMap(s =>
|
|
91
|
+
try Some(JSON.parseOrThrow(s)) catch {
|
|
92
|
+
| _ => None
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
->Option.getOr(JSON.Encode.null),
|
|
89
96
|
str,
|
|
90
97
|
)
|
|
91
98
|
value
|
|
@@ -211,7 +218,6 @@ let hrtimeToString: (~hrtime: hrtime, ~now: float) => string = (~hrtime, ~now) =
|
|
|
211
218
|
|
|
212
219
|
let generateMeta = (
|
|
213
220
|
~service,
|
|
214
|
-
~ip=?,
|
|
215
221
|
~user=?,
|
|
216
222
|
~causationId=?,
|
|
217
223
|
~traceparent=?,
|
|
@@ -225,7 +231,6 @@ let generateMeta = (
|
|
|
225
231
|
time: nowAsISOString(),
|
|
226
232
|
msgId,
|
|
227
233
|
correlationId: correlationId->Option.getOr(msgId),
|
|
228
|
-
?ip,
|
|
229
234
|
?user,
|
|
230
235
|
?causationId,
|
|
231
236
|
?traceparent,
|
|
@@ -238,7 +243,9 @@ let generateMeta = (
|
|
|
238
243
|
// - fresh `msgId` and `time`
|
|
239
244
|
// - `correlationId` inherited (so the chain root id stays stable)
|
|
240
245
|
// - `causationId` = parent.msgId (the *direct* parent)
|
|
241
|
-
// - `
|
|
246
|
+
// - `user`, `traceparent`, `schemaVersion`, `headers` inherited as-is,
|
|
247
|
+
// never `ip`: the caller's address is personal data and stays out of every
|
|
248
|
+
// message a request causes
|
|
242
249
|
// except the stable-id mark: this id is fresh, so the child must not carry it
|
|
243
250
|
// - `service` overridable; defaults to parent's service
|
|
244
251
|
let deriveMeta = (~parent: meta, ~service=?) => {
|
|
@@ -247,7 +254,6 @@ let deriveMeta = (~parent: meta, ~service=?) => {
|
|
|
247
254
|
msgId: uuid(),
|
|
248
255
|
correlationId: parent.correlationId,
|
|
249
256
|
causationId: parent.msgId,
|
|
250
|
-
ip: ?parent.ip,
|
|
251
257
|
user: ?parent.user,
|
|
252
258
|
traceparent: ?parent.traceparent,
|
|
253
259
|
schemaVersion: ?parent.schemaVersion,
|
|
@@ -287,7 +293,16 @@ let composeMeta = (dict: dict<JSON.t>) => {
|
|
|
287
293
|
("msgId", dict->Dict.get("msgId")->Option.getOrThrow),
|
|
288
294
|
("correlationId", dict->Dict.get("correlationId")->Option.getOrThrow),
|
|
289
295
|
]
|
|
290
|
-
let optionalKeys = [
|
|
296
|
+
let optionalKeys = [
|
|
297
|
+
"ip",
|
|
298
|
+
"user",
|
|
299
|
+
"causationId",
|
|
300
|
+
"traceparent",
|
|
301
|
+
"schemaVersion",
|
|
302
|
+
"headers",
|
|
303
|
+
"dataClass",
|
|
304
|
+
"keyRef",
|
|
305
|
+
]
|
|
291
306
|
let optional =
|
|
292
307
|
optionalKeys
|
|
293
308
|
->Array.map(k => dict->Dict.get(k)->Option.map(v => (k, v)))
|
|
@@ -308,6 +323,8 @@ let metaKeys = [
|
|
|
308
323
|
"traceparent",
|
|
309
324
|
"schemaVersion",
|
|
310
325
|
"headers",
|
|
326
|
+
"dataClass",
|
|
327
|
+
"keyRef",
|
|
311
328
|
]
|
|
312
329
|
|
|
313
330
|
/*
|
package/src/Message.res.mjs
CHANGED
|
@@ -66,7 +66,13 @@ function uuid(prim) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function log(value, str) {
|
|
69
|
-
logger.debug("Message", Stdlib_Option.getOr(JSON.stringify(value),
|
|
69
|
+
logger.debug("Message", Stdlib_Option.getOr(Stdlib_Option.flatMap(JSON.stringify(value), s => {
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(s);
|
|
72
|
+
} catch (exn) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}), null), str);
|
|
70
76
|
return value;
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -170,12 +176,11 @@ function hrtimeToString(hrtime, now) {
|
|
|
170
176
|
return now.toString() + ("-" + ("0".repeat(9 - milLength | 0) + milString));
|
|
171
177
|
}
|
|
172
178
|
|
|
173
|
-
function generateMeta(service,
|
|
179
|
+
function generateMeta(service, user, causationId, traceparent, correlationId, schemaVersion, headers) {
|
|
174
180
|
let msgId = Uuid.v4();
|
|
175
181
|
return {
|
|
176
182
|
service: service,
|
|
177
183
|
time: new Date().toISOString(),
|
|
178
|
-
ip: ip,
|
|
179
184
|
user: user,
|
|
180
185
|
msgId: msgId,
|
|
181
186
|
correlationId: Stdlib_Option.getOr(correlationId, msgId),
|
|
@@ -190,7 +195,6 @@ function deriveMeta(parent, service) {
|
|
|
190
195
|
return {
|
|
191
196
|
service: Stdlib_Option.getOr(service, parent.service),
|
|
192
197
|
time: new Date().toISOString(),
|
|
193
|
-
ip: parent.ip,
|
|
194
198
|
user: parent.user,
|
|
195
199
|
msgId: Uuid.v4(),
|
|
196
200
|
correlationId: parent.correlationId,
|
|
@@ -251,7 +255,9 @@ function composeMeta(dict) {
|
|
|
251
255
|
"causationId",
|
|
252
256
|
"traceparent",
|
|
253
257
|
"schemaVersion",
|
|
254
|
-
"headers"
|
|
258
|
+
"headers",
|
|
259
|
+
"dataClass",
|
|
260
|
+
"keyRef"
|
|
255
261
|
];
|
|
256
262
|
let optional = Stdlib_Array.filterMap(optionalKeys.map(k => Stdlib_Option.map(dict[k], v => [
|
|
257
263
|
k,
|
|
@@ -270,7 +276,9 @@ let metaKeys = [
|
|
|
270
276
|
"causationId",
|
|
271
277
|
"traceparent",
|
|
272
278
|
"schemaVersion",
|
|
273
|
-
"headers"
|
|
279
|
+
"headers",
|
|
280
|
+
"dataClass",
|
|
281
|
+
"keyRef"
|
|
274
282
|
];
|
|
275
283
|
|
|
276
284
|
function storedEventToFlatJson(stored, idSchema) {
|
|
@@ -44,17 +44,56 @@ let _draw = (~length: int, ~from: string): string => {
|
|
|
44
44
|
out->Array.join("")
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** The environment variable a deployment states its fingerprint key in. */
|
|
48
|
+
let fingerprintKeyVariable = "REVENTLESS_FINGERPRINT_KEY"
|
|
49
|
+
|
|
50
|
+
/** The shortest fingerprint key accepted: 16 bytes as hex. A shorter one is
|
|
51
|
+
refused rather than used, since a guessable key makes every fingerprint an
|
|
52
|
+
address again. */
|
|
53
|
+
let minimumFingerprintKeyLength = 32
|
|
54
|
+
|
|
55
|
+
/** HMAC-SHA256 of `purpose`, a NUL and `input`, as hex. The NUL keeps a purpose
|
|
56
|
+
that is a prefix of another from colliding with it. */
|
|
57
|
+
let fingerprintWith = (~key: string, ~purpose: string, input: string): string =>
|
|
58
|
+
NodeCrypto.createHmac("sha256", key)
|
|
59
|
+
->NodeCrypto.hmacUpdate(`${purpose}\u0000${input}`)
|
|
60
|
+
->NodeCrypto.hmacDigest("hex")
|
|
61
|
+
|
|
47
62
|
/**
|
|
48
|
-
|
|
63
|
+
A source whose fingerprints are keyed by what `fingerprintKey` answers, asked on
|
|
64
|
+
every call so a key installed after start is used.
|
|
49
65
|
|
|
50
66
|
`length` is refused rather than clamped when it is not positive: a caller asking
|
|
51
67
|
for a zero-length token has a bug, and answering `""` would hand back something
|
|
52
68
|
that compares equal to nothing and settles every challenge.
|
|
53
69
|
*/
|
|
54
|
-
let
|
|
70
|
+
let make = (~fingerprintKey: unit => option<string>): Reventless.Secrets.t => {
|
|
55
71
|
randomToken: (~length, ~alphabet) =>
|
|
56
72
|
length <= 0
|
|
57
73
|
? Error(Unavailable(`a token needs a positive length, not ${length->Int.toString}`))
|
|
58
74
|
: Ok(_draw(~length, ~from=Reventless.Secrets.characters(alphabet))),
|
|
59
75
|
hash: input => Ok(NodeCrypto.sha256Hex(input)),
|
|
76
|
+
fingerprint: (~purpose, input) =>
|
|
77
|
+
switch fingerprintKey() {
|
|
78
|
+
| Some(key) if key->String.length >= minimumFingerprintKeyLength =>
|
|
79
|
+
Ok(fingerprintWith(~key, ~purpose, input))
|
|
80
|
+
| Some(_) =>
|
|
81
|
+
Error(
|
|
82
|
+
Unavailable(
|
|
83
|
+
`the fingerprint key is shorter than ${minimumFingerprintKeyLength->Int.toString} characters`,
|
|
84
|
+
),
|
|
85
|
+
)
|
|
86
|
+
| None => Error(Unavailable(`no fingerprint key: set ${fingerprintKeyVariable}`))
|
|
87
|
+
},
|
|
60
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
The provider a deployed runtime passes: its fingerprint key is the deployment's,
|
|
92
|
+
from `REVENTLESS_FINGERPRINT_KEY`, and fingerprints are refused while none is set.
|
|
93
|
+
*/
|
|
94
|
+
let provider: Reventless.Secrets.t = make(~fingerprintKey=() =>
|
|
95
|
+
switch NodeProcess.env->Dict.get(fingerprintKeyVariable) {
|
|
96
|
+
| Some("") | None => None
|
|
97
|
+
| Some(key) => Some(key)
|
|
98
|
+
}
|
|
99
|
+
)
|
|
@@ -31,39 +31,81 @@ function _draw(length, from) {
|
|
|
31
31
|
return out.join("");
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_0: {
|
|
39
|
-
TAG: "Unavailable",
|
|
40
|
-
_0: `a token needs a positive length, not ` + length.toString()
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
} else {
|
|
44
|
-
return {
|
|
45
|
-
TAG: "Ok",
|
|
46
|
-
_0: _draw(length, Secrets$Reventless.characters(alphabet))
|
|
47
|
-
};
|
|
48
|
-
}
|
|
34
|
+
let fingerprintKeyVariable = "REVENTLESS_FINGERPRINT_KEY";
|
|
35
|
+
|
|
36
|
+
function fingerprintWith(key, purpose, input) {
|
|
37
|
+
return Nodecrypto.createHmac("sha256", key).update(purpose + `\u0000` + input).digest("hex");
|
|
49
38
|
}
|
|
50
39
|
|
|
51
|
-
function
|
|
40
|
+
function make(fingerprintKey) {
|
|
52
41
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
randomToken: (length, alphabet) => {
|
|
43
|
+
if (length <= 0) {
|
|
44
|
+
return {
|
|
45
|
+
TAG: "Error",
|
|
46
|
+
_0: {
|
|
47
|
+
TAG: "Unavailable",
|
|
48
|
+
_0: `a token needs a positive length, not ` + length.toString()
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
return {
|
|
53
|
+
TAG: "Ok",
|
|
54
|
+
_0: _draw(length, Secrets$Reventless.characters(alphabet))
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
hash: input => ({
|
|
59
|
+
TAG: "Ok",
|
|
60
|
+
_0: NodeCrypto.sha256Hex(input)
|
|
61
|
+
}),
|
|
62
|
+
fingerprint: (purpose, input) => {
|
|
63
|
+
let key = fingerprintKey();
|
|
64
|
+
if (key !== undefined) {
|
|
65
|
+
if (key.length >= 32) {
|
|
66
|
+
return {
|
|
67
|
+
TAG: "Ok",
|
|
68
|
+
_0: fingerprintWith(key, purpose, input)
|
|
69
|
+
};
|
|
70
|
+
} else {
|
|
71
|
+
return {
|
|
72
|
+
TAG: "Error",
|
|
73
|
+
_0: {
|
|
74
|
+
TAG: "Unavailable",
|
|
75
|
+
_0: `the fingerprint key is shorter than ` + (32).toString() + ` characters`
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
return {
|
|
81
|
+
TAG: "Error",
|
|
82
|
+
_0: {
|
|
83
|
+
TAG: "Unavailable",
|
|
84
|
+
_0: `no fingerprint key: set ` + fingerprintKeyVariable
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
55
89
|
};
|
|
56
90
|
}
|
|
57
91
|
|
|
58
|
-
let provider = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
92
|
+
let provider = make(() => {
|
|
93
|
+
let key = process.env[fingerprintKeyVariable];
|
|
94
|
+
if (key !== undefined && key !== "") {
|
|
95
|
+
return key;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
let minimumFingerprintKeyLength = 32;
|
|
62
100
|
|
|
63
101
|
export {
|
|
64
102
|
_bytes,
|
|
65
103
|
accepts,
|
|
66
104
|
_draw,
|
|
105
|
+
fingerprintKeyVariable,
|
|
106
|
+
minimumFingerprintKeyLength,
|
|
107
|
+
fingerprintWith,
|
|
108
|
+
make,
|
|
67
109
|
provider,
|
|
68
110
|
}
|
|
69
|
-
/*
|
|
111
|
+
/* provider Not a pure module */
|
|
@@ -380,6 +380,7 @@ and objectRefToJsonSchema = (
|
|
|
380
380
|
~optional: array<string>=[],
|
|
381
381
|
~owners: array<string>=[],
|
|
382
382
|
~sensitive: array<string>=[],
|
|
383
|
+
~pii: array<(string, Reventless.Pii.marker)>=[],
|
|
383
384
|
~inputNames: bool=false,
|
|
384
385
|
fields: dict<SchemaType.schemaType>,
|
|
385
386
|
): JSON.t => {
|
|
@@ -431,6 +432,23 @@ and objectRefToJsonSchema = (
|
|
|
431
432
|
JSON.Encode.object(obj)
|
|
432
433
|
| None => withAnnotations
|
|
433
434
|
}
|
|
435
|
+
// `@pii`: whose data the field holds, so a tool can list the personal data an
|
|
436
|
+
// app keeps and a reader can route it without decoding it.
|
|
437
|
+
let withAnnotations = switch (
|
|
438
|
+
pii->Array.find(((name, _)) => name == fieldName),
|
|
439
|
+
withAnnotations->JSON.Decode.object,
|
|
440
|
+
) {
|
|
441
|
+
| (Some((_, {subject, forgettable})), Some(obj)) =>
|
|
442
|
+
obj->Dict.set(
|
|
443
|
+
"x-reventless-pii",
|
|
444
|
+
Dict.fromArray([
|
|
445
|
+
("subject", JSON.Encode.string(subject)),
|
|
446
|
+
("forgettable", JSON.Encode.bool(forgettable)),
|
|
447
|
+
])->JSON.Encode.object,
|
|
448
|
+
)
|
|
449
|
+
JSON.Encode.object(obj)
|
|
450
|
+
| _ => withAnnotations
|
|
451
|
+
}
|
|
434
452
|
props->Dict.set(fieldName, withAnnotations)
|
|
435
453
|
|
|
436
454
|
// Optional two ways, because neither source answers alone. `optional` is
|
|
@@ -475,6 +493,7 @@ let deriveObjectSchema = (
|
|
|
475
493
|
~optional=SchemaType.optionalFieldNames(schema),
|
|
476
494
|
~owners=Reventless.Owner.fieldNames(schema),
|
|
477
495
|
~sensitive=Reventless.Sensitive.fieldNames(schema),
|
|
496
|
+
~pii=Reventless.Pii.fieldsOf(schema),
|
|
478
497
|
~inputNames,
|
|
479
498
|
fields,
|
|
480
499
|
)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
4
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
5
6
|
import * as Owner$Reventless from "@reventlessdev/reventless-spec/src/components/Owner.res.mjs";
|
|
6
7
|
import * as Sensitive$Reventless from "@reventlessdev/reventless-spec/src/components/Sensitive.res.mjs";
|
|
7
8
|
import * as Logger$ReventlessCore from "../../util/Logger.res.mjs";
|
|
@@ -249,7 +250,7 @@ function fromSchemaType(_inputNamesOpt, _st) {
|
|
|
249
250
|
]
|
|
250
251
|
]);
|
|
251
252
|
case "ObjectRef" :
|
|
252
|
-
let base = objectRefToJsonSchema(undefined, undefined, undefined, undefined, inputNames, st._1);
|
|
253
|
+
let base = objectRefToJsonSchema(undefined, undefined, undefined, undefined, undefined, inputNames, st._1);
|
|
253
254
|
if (inputNames) {
|
|
254
255
|
return withGraphqlInput(base, st._0);
|
|
255
256
|
} else {
|
|
@@ -308,7 +309,7 @@ function armToJsonSchema(inputNamesOpt, tag, armType) {
|
|
|
308
309
|
if (armType.TAG !== "ObjectRef") {
|
|
309
310
|
return fromSchemaType(inputNames, armType);
|
|
310
311
|
}
|
|
311
|
-
let base = objectRefToJsonSchema(undefined, undefined, undefined, undefined, inputNames, armType._1);
|
|
312
|
+
let base = objectRefToJsonSchema(undefined, undefined, undefined, undefined, undefined, inputNames, armType._1);
|
|
312
313
|
let obj = Stdlib_JSON.Decode.object(base);
|
|
313
314
|
if (obj === undefined) {
|
|
314
315
|
return base;
|
|
@@ -391,10 +392,11 @@ function withSemantic(fieldSchema, sem) {
|
|
|
391
392
|
return obj;
|
|
392
393
|
}
|
|
393
394
|
|
|
394
|
-
function objectRefToJsonSchema(annotations, optionalOpt, ownersOpt, sensitiveOpt, inputNamesOpt, fields) {
|
|
395
|
+
function objectRefToJsonSchema(annotations, optionalOpt, ownersOpt, sensitiveOpt, piiOpt, inputNamesOpt, fields) {
|
|
395
396
|
let optional = optionalOpt !== undefined ? optionalOpt : [];
|
|
396
397
|
let owners = ownersOpt !== undefined ? ownersOpt : [];
|
|
397
398
|
let sensitive = sensitiveOpt !== undefined ? sensitiveOpt : [];
|
|
399
|
+
let pii = piiOpt !== undefined ? piiOpt : [];
|
|
398
400
|
let inputNames = inputNamesOpt !== undefined ? inputNamesOpt : false;
|
|
399
401
|
let props = {};
|
|
400
402
|
let required = [];
|
|
@@ -427,7 +429,26 @@ function objectRefToJsonSchema(annotations, optionalOpt, ownersOpt, sensitiveOpt
|
|
|
427
429
|
} else {
|
|
428
430
|
withAnnotations$2 = withAnnotations$1;
|
|
429
431
|
}
|
|
430
|
-
|
|
432
|
+
let match = pii.find(param => param[0] === fieldName);
|
|
433
|
+
let match$1 = Stdlib_JSON.Decode.object(withAnnotations$2);
|
|
434
|
+
let withAnnotations$3;
|
|
435
|
+
if (match !== undefined && match$1 !== undefined) {
|
|
436
|
+
let match$2 = match[1];
|
|
437
|
+
match$1["x-reventless-pii"] = Object.fromEntries([
|
|
438
|
+
[
|
|
439
|
+
"subject",
|
|
440
|
+
match$2.subject
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
"forgettable",
|
|
444
|
+
match$2.forgettable
|
|
445
|
+
]
|
|
446
|
+
]);
|
|
447
|
+
withAnnotations$3 = match$1;
|
|
448
|
+
} else {
|
|
449
|
+
withAnnotations$3 = withAnnotations$2;
|
|
450
|
+
}
|
|
451
|
+
props[fieldName] = withAnnotations$3;
|
|
431
452
|
if (!optional.includes(fieldName) && !isNullableType(fieldType)) {
|
|
432
453
|
required.push(fieldName);
|
|
433
454
|
return;
|
|
@@ -463,7 +484,7 @@ function deriveObjectSchema(inputNamesOpt, typeNameOpt, schema) {
|
|
|
463
484
|
]]);
|
|
464
485
|
}
|
|
465
486
|
let annotations = StateAnnotations$Reventless.getSpec(schema);
|
|
466
|
-
let objSchema = objectRefToJsonSchema(annotations, SchemaType$ReventlessCore.optionalFieldNames(schema), Owner$Reventless.fieldNames(schema), Sensitive$Reventless.fieldNames(schema), inputNames, fields);
|
|
487
|
+
let objSchema = objectRefToJsonSchema(annotations, SchemaType$ReventlessCore.optionalFieldNames(schema), Owner$Reventless.fieldNames(schema), Sensitive$Reventless.fieldNames(schema), Pii$Reventless.fieldsOf(schema), inputNames, fields);
|
|
467
488
|
if (annotations === undefined) {
|
|
468
489
|
return objSchema;
|
|
469
490
|
}
|
|
@@ -49,7 +49,7 @@ function todoRowSchemaFor(itemSchema) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function tickEvent(key, at) {
|
|
52
|
-
let newrecord = {...Message$ReventlessCore.generateMeta(Clock$Reventless.name, undefined, undefined, undefined, undefined, undefined, undefined
|
|
52
|
+
let newrecord = {...Message$ReventlessCore.generateMeta(Clock$Reventless.name, undefined, undefined, undefined, undefined, undefined, undefined)};
|
|
53
53
|
return Object.fromEntries([
|
|
54
54
|
[
|
|
55
55
|
"id",
|
|
@@ -83,7 +83,7 @@ function Make(Spec) {
|
|
|
83
83
|
return changes;
|
|
84
84
|
};
|
|
85
85
|
let readsClock = Automation.mappings.some(M => M.sourceName === Clock$Reventless.name);
|
|
86
|
-
let makeMeta = () => Message$ReventlessCore.generateMeta(Spec.targetName, undefined, undefined, undefined, undefined, undefined, undefined
|
|
86
|
+
let makeMeta = () => Message$ReventlessCore.generateMeta(Spec.targetName, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
87
87
|
let processingTimeoutMs = 15 * 60 * 1000;
|
|
88
88
|
let afterFailedAttempt = row => {
|
|
89
89
|
let retryCount = row.retryCount + 1 | 0;
|
|
@@ -13,7 +13,9 @@ The `id` field is the envelope id for the produced command message:
|
|
|
13
13
|
source of truth.
|
|
14
14
|
*/
|
|
15
15
|
type arguments = {id: string}
|
|
16
|
-
|
|
16
|
+
// `ip` is what a resolver written before the caller's address left the envelope
|
|
17
|
+
// still sends; nothing reads it, so it never reaches a message.
|
|
18
|
+
type meta = {ip?: array<string>, user: string, info: string}
|
|
17
19
|
type payload = {
|
|
18
20
|
command: string,
|
|
19
21
|
arguments: arguments,
|
|
@@ -64,13 +64,11 @@ function makeGenerateCommand(publishJsons, publishJsonsAndWait, serviceName, com
|
|
|
64
64
|
let msgId = Message$ReventlessCore.uuid();
|
|
65
65
|
let scope = OwnerScope$Reventless.resolve(payload.identity, undefined);
|
|
66
66
|
let meta_time = Message$ReventlessCore.nowAsISOString();
|
|
67
|
-
let meta_ip = Stdlib_Option.getOr(payload.meta.ip.shift(), "");
|
|
68
67
|
let meta_user = payload.meta.user;
|
|
69
68
|
let meta_callerClaim = OwnerScope$Reventless.toClaim(scope);
|
|
70
69
|
let meta = {
|
|
71
70
|
service: serviceName,
|
|
72
71
|
time: meta_time,
|
|
73
|
-
ip: meta_ip,
|
|
74
72
|
user: meta_user,
|
|
75
73
|
msgId: msgId,
|
|
76
74
|
correlationId: msgId,
|
|
@@ -17,7 +17,9 @@ module Make = (Spec: ReventlessInfra.CommandTopic.T, Ops: Ops with module Spec =
|
|
|
17
17
|
switch json->Message.decodeCommand'(Spec.Id.schema, Spec.commandSchema) {
|
|
18
18
|
| command' => Some({ReventlessInfra.CommandTopic.reference, command: command'})
|
|
19
19
|
| exception err =>
|
|
20
|
-
|
|
20
|
+
// The command as it may be logged: a command that failed to decode is
|
|
21
|
+
// exactly one whose fields the schema could not vouch for.
|
|
22
|
+
let commandStr = json->Reventless.LogRedaction.redactJson->JSON.stringify
|
|
21
23
|
let errMsg = err->Reventless.Util_Sury.exnMessage
|
|
22
24
|
EffectLogger.logError(~comp, `decode failed: ${commandStr} err=${errMsg}`)->Effect.runSync
|
|
23
25
|
None
|
|
@@ -5,6 +5,7 @@ import * as Stream from "effect/Stream";
|
|
|
5
5
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
6
6
|
import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
|
|
7
7
|
import * as Message$ReventlessCore from "../../Message.res.mjs";
|
|
8
|
+
import * as LogRedaction$Reventless from "@reventlessdev/reventless-spec/src/util/LogRedaction.res.mjs";
|
|
8
9
|
import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
|
|
9
10
|
|
|
10
11
|
function Make(Spec) {
|
|
@@ -19,7 +20,7 @@ function Make(Spec) {
|
|
|
19
20
|
command$p = Message$ReventlessCore.decodeCommand$p(json, Spec.Id.schema, Spec.commandSchema);
|
|
20
21
|
} catch (raw_err) {
|
|
21
22
|
let err = Primitive_exceptions.internalToException(raw_err);
|
|
22
|
-
let commandStr = JSON.stringify(json);
|
|
23
|
+
let commandStr = JSON.stringify(LogRedaction$Reventless.redactJson(json));
|
|
23
24
|
let errMsg = Util_Sury$Reventless.exnMessage(err, undefined);
|
|
24
25
|
Effect.runSync(EffectLogger$ReventlessCore.logError(comp, undefined, `decode failed: ` + commandStr + ` err=` + errMsg));
|
|
25
26
|
return;
|
|
@@ -39,7 +39,7 @@ function Make(Spec) {
|
|
|
39
39
|
if (count === 0) {
|
|
40
40
|
let match$1 = Counter$ReventlessCore.unmakeId(id);
|
|
41
41
|
Effect.runSync(EffectLogger$ReventlessCore.logInfo("Counter_Callback-ReventlessCore", undefined, `counterHandler: counted down ` + Spec.name + `(` + id + `) to ` + count.toString()));
|
|
42
|
-
let meta = Message$ReventlessCore.generateMeta(ComponentType$ReventlessCore.toName("Counter"),
|
|
42
|
+
let meta = Message$ReventlessCore.generateMeta(ComponentType$ReventlessCore.toName("Counter"), "Counter", undefined, undefined, undefined, undefined, undefined);
|
|
43
43
|
return Object.fromEntries([
|
|
44
44
|
[
|
|
45
45
|
"id",
|
|
@@ -17,7 +17,7 @@ function Make(Ops) {
|
|
|
17
17
|
let serviceName = Ops.serviceName;
|
|
18
18
|
let publishToEventTopic = async rawEvents => {
|
|
19
19
|
let re = rawEvents[0];
|
|
20
|
-
let representativeMeta = re !== undefined ? re.meta : Message$ReventlessCore.generateMeta(serviceName, undefined, undefined, undefined, undefined, undefined, undefined
|
|
20
|
+
let representativeMeta = re !== undefined ? re.meta : Message$ReventlessCore.generateMeta(serviceName, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
21
21
|
let rawEventsJson = rawEvents.map(rawEvent => Message$ReventlessCore.combineMessage(rawEvent.eventType, Stdlib_Option.getOr(Stdlib_JSON.Decode.object(rawEvent.data), {})));
|
|
22
22
|
let hook = EventPublish_Callback$ReventlessCore.beforePublishHook.contents;
|
|
23
23
|
let finalRawEventsJson;
|
|
@@ -212,7 +212,7 @@ module Make = (Spec: ReventlessInfra.EventLog.T, Ops: Ops with module Spec = Spe
|
|
|
212
212
|
} catch {
|
|
213
213
|
| exn =>
|
|
214
214
|
JsError.throwWithMessage(
|
|
215
|
-
`EventLog.replay: Error: id:${id}: Couldn't decode
|
|
215
|
+
`EventLog.replay: Error: id:${id}: Couldn't decode the event's meta: ${Reventless.Util_Sury.exnMessage(
|
|
216
216
|
exn,
|
|
217
217
|
)}`,
|
|
218
218
|
)
|
|
@@ -193,7 +193,7 @@ function Make(Spec) {
|
|
|
193
193
|
return Util_Sury$Reventless.fromJson(Message$ReventlessCore.composeMeta(Stdlib_Option.getOrThrow(Stdlib_JSON.Decode.object(json), undefined)), Message$ReventlessCore.metaSchema);
|
|
194
194
|
} catch (raw_exn) {
|
|
195
195
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
196
|
-
return Stdlib_JsError.throwWithMessage(`EventLog.replay: Error: id:` + id + `: Couldn't decode
|
|
196
|
+
return Stdlib_JsError.throwWithMessage(`EventLog.replay: Error: id:` + id + `: Couldn't decode the event's meta: ` + Util_Sury$Reventless.exnMessage(exn, undefined));
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
199
|
let replayStream$p = (id, fromSeq) => {
|
|
@@ -151,7 +151,7 @@ function Make(Spec) {
|
|
|
151
151
|
return Translation => {
|
|
152
152
|
let auditLog = {};
|
|
153
153
|
let sensitive = Sensitive$Reventless.fieldNames(Spec.externalInputSchema);
|
|
154
|
-
let makeMeta = () => Message$ReventlessCore.generateMeta(Spec.targetName, undefined, undefined, undefined, undefined, undefined, undefined
|
|
154
|
+
let makeMeta = () => Message$ReventlessCore.generateMeta(Spec.targetName, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
155
155
|
let messageOf = (exn, fallback) => Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message), fallback);
|
|
156
156
|
let failWith = (requestId, input, door, caller, errorCode, error) => {
|
|
157
157
|
auditLog[requestId] = {
|
|
@@ -46,7 +46,7 @@ function todoRowSchemaFor(itemSchema) {
|
|
|
46
46
|
function Make(Spec) {
|
|
47
47
|
return Translation => {
|
|
48
48
|
let todoItems = {};
|
|
49
|
-
let makeMeta = () => Message$ReventlessCore.generateMeta(Stdlib_Option.getOr(Spec.targetName, `OutboundTranslationSlice:` + Spec.name), undefined, undefined, undefined, undefined, undefined, undefined
|
|
49
|
+
let makeMeta = () => Message$ReventlessCore.generateMeta(Stdlib_Option.getOr(Spec.targetName, `OutboundTranslationSlice:` + Spec.name), undefined, undefined, undefined, undefined, undefined, undefined);
|
|
50
50
|
let afterFailedAttempt = (row, lastError) => {
|
|
51
51
|
let retryCount = row.retryCount + 1 | 0;
|
|
52
52
|
let newrecord = {...row};
|