@reventlessdev/reventless-registration 1.0.0-alpha.4 → 1.0.0-alpha.41

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.
Files changed (30) hide show
  1. package/README.md +10 -0
  2. package/i18n/en.json +8 -0
  3. package/package.json +7 -6
  4. package/src/Registration/ContactAddressId.res +27 -3
  5. package/src/Registration/ContactAddressId.res.mjs +26 -2
  6. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  7. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +3 -3
  8. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +9 -6
  9. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +16 -9
  10. package/src/Registration/InboundTranslation/SignUp.res +19 -8
  11. package/src/Registration/InboundTranslation/SignUp.res.mjs +15 -6
  12. package/src/Registration/InboundTranslation/SignUp_Translation.res +51 -15
  13. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +50 -8
  14. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +9 -3
  15. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +7 -3
  16. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -7
  17. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +17 -8
  18. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +39 -7
  19. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +27 -11
  20. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -44
  21. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +203 -61
  22. package/src/Registration/StateChange/RegistrationPolicy.res +3 -0
  23. package/src/Registration/StateChange/RegistrationPolicy.res.mjs +3 -0
  24. package/src/Registration/StateChange/RegistrationPolicy_Decision.res +6 -5
  25. package/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs +22 -15
  26. package/src/Registration/StateChange/Registrations.res +79 -27
  27. package/src/Registration/StateChange/Registrations.res.mjs +85 -39
  28. package/src/Registration/StateChange/Registrations_Decision.res +96 -36
  29. package/src/Registration/StateChange/Registrations_Decision.res.mjs +119 -52
  30. package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +1 -1
@@ -1,7 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
- import * as Duration$Reventless from "@reventlessdev/reventless-spec/src/semantic/Duration.res.mjs";
4
+ import * as Text$Reventless from "@reventlessdev/reventless-spec/src/i18n/Text.res.mjs";
5
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
5
6
  import * as Messaging$Reventless from "@reventlessdev/reventless-spec/src/semantic/Messaging.res.mjs";
6
7
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
7
8
  import * as RegistrationChallenge$ReventlessRegistration from "../../RegistrationChallenge.res.mjs";
@@ -10,82 +11,218 @@ function collect(event, param) {
10
11
  switch (event.TAG) {
11
12
  case "RegistrationRequested" :
12
13
  let email = event.email;
13
- return [[
14
- email + `:` + event.requestedAt,
15
- {
16
- email: email,
17
- alreadyRegistered: false
18
- }
19
- ]];
14
+ let emailId = event.emailId;
15
+ if (typeof email !== "object") {
16
+ if (email === "Erased") {
17
+ return [];
18
+ } else {
19
+ return [];
20
+ }
21
+ } else {
22
+ return [[
23
+ emailId + `:` + event.requestedAt,
24
+ {
25
+ emailId: emailId,
26
+ email: email._0,
27
+ alreadyRegistered: false,
28
+ language: event.language
29
+ }
30
+ ]];
31
+ }
20
32
  case "RegistrationAttemptedOnTakenAddress" :
21
33
  let email$1 = event.email;
22
- return [[
23
- email$1 + `:taken:` + event.attemptedAt,
24
- {
25
- email: email$1,
26
- alreadyRegistered: true
27
- }
28
- ]];
34
+ let emailId$1 = event.emailId;
35
+ if (typeof email$1 !== "object") {
36
+ if (email$1 === "Erased") {
37
+ return [];
38
+ } else {
39
+ return [];
40
+ }
41
+ } else {
42
+ return [[
43
+ emailId$1 + `:taken:` + event.attemptedAt,
44
+ {
45
+ emailId: emailId$1,
46
+ email: email$1._0,
47
+ alreadyRegistered: true
48
+ }
49
+ ]];
50
+ }
29
51
  case "RegistrationInvited" :
30
52
  let email$2 = event.email;
31
- return [[
32
- email$2 + `:invited:` + event.invitedAt,
33
- {
34
- email: email$2,
35
- alreadyRegistered: false,
36
- invited: true,
37
- roles: event.roles
38
- }
39
- ]];
53
+ let emailId$2 = event.emailId;
54
+ if (typeof email$2 !== "object") {
55
+ if (email$2 === "Erased") {
56
+ return [];
57
+ } else {
58
+ return [];
59
+ }
60
+ } else {
61
+ return [[
62
+ emailId$2 + `:invited:` + event.invitedAt,
63
+ {
64
+ emailId: emailId$2,
65
+ email: email$2._0,
66
+ alreadyRegistered: false,
67
+ invited: true,
68
+ roles: event.roles,
69
+ language: event.language
70
+ }
71
+ ]];
72
+ }
40
73
  case "RegistrationChallengeReissued" :
41
74
  let email$3 = event.email;
42
- return [[
43
- email$3 + `:reissued:` + event.reissuedAt,
44
- {
45
- email: email$3,
46
- alreadyRegistered: false,
47
- invited: Stdlib_Option.isSome(event.invitedBy)
48
- }
49
- ]];
75
+ let emailId$3 = event.emailId;
76
+ if (typeof email$3 !== "object") {
77
+ if (email$3 === "Erased") {
78
+ return [];
79
+ } else {
80
+ return [];
81
+ }
82
+ } else {
83
+ return [[
84
+ emailId$3 + `:reissued:` + event.reissuedAt,
85
+ {
86
+ emailId: emailId$3,
87
+ email: email$3._0,
88
+ alreadyRegistered: false,
89
+ invited: Stdlib_Option.isSome(event.invitedBy),
90
+ language: event.language
91
+ }
92
+ ]];
93
+ }
50
94
  }
51
95
  }
52
96
 
97
+ let challengeSubject = {
98
+ key: "registration.challenge.subject",
99
+ source: "Finish your registration"
100
+ };
101
+
102
+ let challengeBody = {
103
+ key: "registration.challenge.body",
104
+ source: "Your registration code is {token}. Enter it with a password of your choice to finish. It expires in {expiresIn}."
105
+ };
106
+
107
+ let invitedSubject = {
108
+ key: "registration.invited.subject",
109
+ source: "You are invited to create an account"
110
+ };
111
+
112
+ let invitedBody = {
113
+ key: "registration.invited.body",
114
+ source: "You have been invited to create an account{hasRoles, select, yes { as {roles}} other {}}. Your code is {token}. Enter it with this address and a password of your choice to accept. It expires in {expiresIn}."
115
+ };
116
+
117
+ let takenSubject = {
118
+ key: "registration.taken.subject",
119
+ source: "Someone tried to register with your address"
120
+ };
121
+
122
+ let takenBody = {
123
+ key: "registration.taken.body",
124
+ source: "Someone asked to register an account with this address, which already has one. If it was you, sign in instead. If it was not, there is nothing to do: no account was changed."
125
+ };
126
+
127
+ let all = [
128
+ challengeSubject,
129
+ challengeBody,
130
+ invitedSubject,
131
+ invitedBody,
132
+ takenSubject,
133
+ takenBody
134
+ ];
135
+
136
+ let Messages = {
137
+ challengeSubject: challengeSubject,
138
+ challengeBody: challengeBody,
139
+ invitedSubject: invitedSubject,
140
+ invitedBody: invitedBody,
141
+ takenSubject: takenSubject,
142
+ takenBody: takenBody,
143
+ all: all
144
+ };
145
+
53
146
  function expiresIn(invited) {
54
- return Duration$Reventless.format(RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(invited)).tokenTtl);
147
+ return RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(invited)).tokenTtl;
55
148
  }
56
149
 
57
- function challengeBody(token) {
58
- return `Your registration code is ` + token + `. Enter it with a password of your choice to finish. It expires in ` + expiresIn(false) + `.`;
150
+ function challengeValues(token) {
151
+ return {
152
+ token: {
153
+ TAG: "Text",
154
+ _0: token
155
+ },
156
+ expiresIn: {
157
+ TAG: "Duration",
158
+ _0: RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(false)).tokenTtl
159
+ }
160
+ };
59
161
  }
60
162
 
61
- function asRoles(roles) {
62
- if (roles !== undefined && roles.length !== 0) {
63
- return ` as ` + roles.join(" and ");
64
- } else {
65
- return "";
66
- }
163
+ function invitationValues(token, roles) {
164
+ let roles$1 = Stdlib_Option.getOr(roles, []);
165
+ return {
166
+ token: {
167
+ TAG: "Text",
168
+ _0: token
169
+ },
170
+ expiresIn: {
171
+ TAG: "Duration",
172
+ _0: RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(true)).tokenTtl
173
+ },
174
+ hasRoles: {
175
+ TAG: "Text",
176
+ _0: Primitive_object.equal(roles$1, []) ? "no" : "yes"
177
+ },
178
+ roles: {
179
+ TAG: "List",
180
+ _0: roles$1
181
+ }
182
+ };
183
+ }
184
+
185
+ function challengeBody$1(token) {
186
+ return Text$Reventless.inSource(challengeBody, challengeValues(token));
67
187
  }
68
188
 
69
189
  function invitationBody(token, roles) {
70
- return `You have been invited to create an account` + asRoles(roles) + `. Your code is ` + token + `. Enter it with this address and a password of your choice to accept. It expires in ` + expiresIn(true) + `.`;
190
+ return Text$Reventless.inSource(invitedBody, invitationValues(token, roles));
71
191
  }
72
192
 
73
- let noticeBody = "Someone asked to register an account with this address, which already has one. If it was you, sign in instead. If it was not, there is nothing to do: no account was changed.";
193
+ let noticeBody = Text$Reventless.inSource(takenBody, undefined);
74
194
 
75
- function send(capabilities, email, subject, body) {
76
- return capabilities.messaging.send({
195
+ async function send(capabilities, email, requested, subject, body, values) {
196
+ let recipient = {
77
197
  TAG: "ToEmail",
78
198
  _0: email
79
- }, {
80
- subject: subject,
81
- body: body
82
- });
199
+ };
200
+ let reason = await Text$Reventless.compose(capabilities.text, recipient, requested, subject, body, values);
201
+ if (reason.TAG !== "Ok") {
202
+ return {
203
+ TAG: "Error",
204
+ _0: reason._0
205
+ };
206
+ }
207
+ let message = reason._0;
208
+ let failure = await capabilities.messaging.send(recipient, message);
209
+ if (failure.TAG === "Ok") {
210
+ return {
211
+ TAG: "Ok",
212
+ _0: message.language
213
+ };
214
+ } else {
215
+ return {
216
+ TAG: "Error",
217
+ _0: Messaging$Reventless.failureReason(failure._0)
218
+ };
219
+ }
83
220
  }
84
221
 
85
222
  async function translate(_id, item, capabilities) {
86
223
  if (item.alreadyRegistered) {
87
- let failure = await send(capabilities, item.email, "Someone tried to register with your address", noticeBody);
88
- if (failure.TAG === "Ok") {
224
+ let reason = await send(capabilities, item.email, undefined, takenSubject, takenBody, {});
225
+ if (reason.TAG === "Ok") {
89
226
  return {
90
227
  TAG: "Ok",
91
228
  _0: undefined
@@ -93,7 +230,7 @@ async function translate(_id, item, capabilities) {
93
230
  } else {
94
231
  return {
95
232
  TAG: "Error",
96
- _0: Messaging$Reventless.failureReason(failure._0)
233
+ _0: reason._0
97
234
  };
98
235
  }
99
236
  }
@@ -114,24 +251,27 @@ async function translate(_id, item, capabilities) {
114
251
  _0: `cannot hash a secret: ` + proofHash._0._0
115
252
  };
116
253
  }
117
- let failure$1 = await send(capabilities, item.email, invited ? "You are invited to create an account" : "Finish your registration", invited ? invitationBody(token$1, item.roles) : challengeBody(token$1));
118
- if (failure$1.TAG === "Ok") {
254
+ let body = invited ? invitedBody : challengeBody;
255
+ let language = await send(capabilities, item.email, item.language, invited ? invitedSubject : challengeSubject, body, invited ? invitationValues(token$1, item.roles) : challengeValues(token$1));
256
+ if (language.TAG === "Ok") {
119
257
  return {
120
258
  TAG: "Ok",
121
259
  _0: [
122
- item.email,
260
+ item.emailId,
123
261
  {
124
262
  TAG: "IssueRegistrationChallenge",
125
- email: ContactAddressId$ReventlessRegistration.makeFromString(item.email),
263
+ emailId: ContactAddressId$ReventlessRegistration.makeFromString(item.emailId),
126
264
  proofHash: proofHash._0,
127
- issuedAt: new Date().toISOString()
265
+ issuedAt: new Date().toISOString(),
266
+ language: language._0,
267
+ messageKey: body.key
128
268
  }
129
269
  ]
130
270
  };
131
271
  } else {
132
272
  return {
133
273
  TAG: "Error",
134
- _0: Messaging$Reventless.failureReason(failure$1._0)
274
+ _0: language._0
135
275
  };
136
276
  }
137
277
  }
@@ -147,9 +287,11 @@ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/Outboun
147
287
  export {
148
288
  Spec,
149
289
  collect,
290
+ Messages,
150
291
  expiresIn,
151
- challengeBody,
152
- asRoles,
292
+ challengeValues,
293
+ invitationValues,
294
+ challengeBody$1 as challengeBody,
153
295
  invitationBody,
154
296
  noticeBody,
155
297
  send,
@@ -157,4 +299,4 @@ export {
157
299
  onExhausted,
158
300
  moduleUrl,
159
301
  }
160
- /* Duration-Reventless Not a pure module */
302
+ /* noticeBody Not a pure module */
@@ -56,3 +56,6 @@ type event =
56
56
  | RegistrationClosed({
57
57
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
58
58
  })
59
+
60
+ /** This decision opens and closes a role; the platform tells the shell so. */
61
+ let admissionDoor = Reventless.Admission.Policy
@@ -65,6 +65,8 @@ let name = "RegistrationPolicy";
65
65
 
66
66
  let Id;
67
67
 
68
+ let admissionDoor = "policy";
69
+
68
70
  let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateChange/RegistrationPolicy.res.mjs";
69
71
 
70
72
  let readConsistency = "EscalateOnRetry";
@@ -77,6 +79,7 @@ export {
77
79
  commandSchema,
78
80
  errorSchema,
79
81
  eventSchema,
82
+ admissionDoor,
80
83
  moduleUrl,
81
84
  authorizationOf,
82
85
  readConsistency,
@@ -1,14 +1,15 @@
1
1
  @@reventless.decision
2
2
 
3
- // Nothing recorded is open: a role reaches this slice only if the app declares
4
- // it self-service. Opening an open role with the same end, or closing a closed
5
- // one, changes nothing and records nothing.
3
+ // Nothing recorded is the deployment's starting state, which this slice does not
4
+ // know: from it, opening and closing both record. Opening an open role with the
5
+ // same end, or closing a closed one, changes nothing and records nothing.
6
6
 
7
7
  type state =
8
+ | Unset
8
9
  | Closed
9
10
  | Open(option<Reventless.DateTime.t>)
10
11
 
11
- let initialState = Open(None)
12
+ let initialState = Unset
12
13
 
13
14
  let evolve = (_state, event) =>
14
15
  switch event {
@@ -36,7 +37,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
36
37
  | (Open(current), OpenRegistration({?until})) if current == until => Ok([])
37
38
  | (_, OpenRegistration({role, ?until})) => Ok([RegistrationOpened({role, ?until})])
38
39
  | (Closed, CloseRegistration(_)) => Ok([])
39
- | (Open(_), CloseRegistration({role})) => Ok([RegistrationClosed({role: role})])
40
+ | (Open(_) | Unset, CloseRegistration({role})) => Ok([RegistrationClosed({role: role})])
40
41
  }
41
42
  }
42
43
  }
@@ -4,11 +4,6 @@ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js
4
4
  import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
5
5
  import * as RegistrationPolicy$ReventlessRegistration from "./RegistrationPolicy.res.mjs";
6
6
 
7
- let initialState = {
8
- TAG: "Open",
9
- _0: undefined
10
- };
11
-
12
7
  function evolve(_state, event) {
13
8
  if (event.TAG === "RegistrationOpened") {
14
9
  return {
@@ -33,7 +28,7 @@ function Make(App) {
33
28
  };
34
29
  }
35
30
  if (typeof state !== "object") {
36
- if (command.TAG !== "OpenRegistration") {
31
+ if (state !== "Unset" && command.TAG !== "OpenRegistration") {
37
32
  return {
38
33
  TAG: "Ok",
39
34
  _0: []
@@ -56,19 +51,29 @@ function Make(App) {
56
51
  };
57
52
  }
58
53
  }
59
- return {
60
- TAG: "Ok",
61
- _0: [{
62
- TAG: "RegistrationOpened",
63
- role: command.role,
64
- until: command.until
65
- }]
66
- };
54
+ if (command.TAG === "OpenRegistration") {
55
+ return {
56
+ TAG: "Ok",
57
+ _0: [{
58
+ TAG: "RegistrationOpened",
59
+ role: command.role,
60
+ until: command.until
61
+ }]
62
+ };
63
+ } else {
64
+ return {
65
+ TAG: "Ok",
66
+ _0: [{
67
+ TAG: "RegistrationClosed",
68
+ role: command.role
69
+ }]
70
+ };
71
+ }
67
72
  };
68
73
  return {
69
74
  Spec: undefined,
70
75
  moduleUrl: RegistrationPolicy$ReventlessRegistration.moduleUrl,
71
- initialState: initialState,
76
+ initialState: "Unset",
72
77
  evolve: evolve,
73
78
  decide: decide
74
79
  };
@@ -76,6 +81,8 @@ function Make(App) {
76
81
 
77
82
  let Spec;
78
83
 
84
+ let initialState = "Unset";
85
+
79
86
  let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs";
80
87
 
81
88
  export {
@@ -15,6 +15,12 @@
15
15
  // translations in this chapter: they stamp the time a request arrived, and they
16
16
  // hash a presented proof so its plaintext never reaches this slice or the log.
17
17
  //
18
+ // **The address is not the key.** `emailId` is the address's keyed fingerprint
19
+ // (`ContactAddressId`), which is what tags and partitions the ledger; an index key
20
+ // cannot be erased. The address itself rides in `email`, on the events that must
21
+ // reach the person and on the commands that start a claim, so it lives only where
22
+ // a payload field can be encrypted or erased.
23
+ //
18
24
  // **Its answers do not tell an anonymous caller anything.** A closed policy, a
19
25
  // pending registration and an address already registered all leave the door
20
26
  // answering the same way; only what is sent to the address differs.
@@ -34,35 +40,52 @@ type consumedEvent =
34
40
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
35
41
  })
36
42
  | RegistrationRequested({
37
- email: ContactAddressId.t,
43
+ emailId: ContactAddressId.t,
44
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
38
45
  roles: array<string>,
39
46
  requestedAt: Reventless.DateTime.t,
47
+ language?: string,
40
48
  })
41
- | RegistrationExpired({email: ContactAddressId.t})
49
+ | RegistrationExpired({emailId: ContactAddressId.t})
42
50
  | RegistrationInvited({
43
- email: ContactAddressId.t,
51
+ emailId: ContactAddressId.t,
52
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
44
53
  roles: array<string>,
45
54
  invitedBy: string,
46
55
  invitedAt: Reventless.DateTime.t,
56
+ language?: string,
47
57
  })
48
58
  | RegistrationChallengeReissued({
49
- email: ContactAddressId.t,
59
+ emailId: ContactAddressId.t,
60
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
50
61
  reissuedAt: Reventless.DateTime.t,
51
62
  invitedBy?: string,
63
+ language?: string,
52
64
  })
53
- | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
65
+ | RegistrationWithdrawn({emailId: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
54
66
  | RegistrationAttemptedOnTakenAddress({
55
- email: ContactAddressId.t,
67
+ emailId: ContactAddressId.t,
68
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
56
69
  attemptedAt: Reventless.DateTime.t,
57
70
  })
58
71
  | RegistrationChallengeIssued({
59
- email: ContactAddressId.t,
72
+ emailId: ContactAddressId.t,
60
73
  proofHash: string,
61
74
  issuedAt: Reventless.DateTime.t,
75
+ /** The language the code went out in, and the key of the mail that carried it: what is
76
+ recorded of a sent mail, never its text. */
77
+ language?: string,
78
+ messageKey?: string,
79
+ })
80
+ | RegistrationProofAccepted({
81
+ emailId: ContactAddressId.t,
82
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
83
+ roles: array<string>,
84
+ proofHash: string,
62
85
  })
63
- | RegistrationProofAccepted({email: ContactAddressId.t, roles: array<string>, proofHash: string})
64
- | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
65
- | RegistrationCompleted({email: ContactAddressId.t})
86
+ | RegistrationProofRefused({emailId: ContactAddressId.t, reason: string})
87
+ | RegistrationCompleted({emailId: ContactAddressId.t})
88
+ | RegistrationReleased({emailId: ContactAddressId.t, releasedAt: Reventless.DateTime.t})
66
89
 
67
90
  // `Register` names the role asked for, and the policy is read by it. The
68
91
  // registration records the roles it grants as
@@ -77,42 +100,54 @@ type consumedEvent =
77
100
  type command =
78
101
  | @noApi
79
102
  Register({
80
- email: ContactAddressId.t,
103
+ emailId: ContactAddressId.t,
104
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
81
105
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
82
106
  requestedAt: Reventless.DateTime.t,
107
+ language?: string,
108
+ /** The deployment's starting state, stamped by the door: what the role is
109
+ while nobody has opened or closed it. */
110
+ initially?: @s.matches(Reventless.Admission.initiallySchema) Reventless.Admission.initially,
83
111
  })
84
112
  | @noApi
85
113
  IssueRegistrationChallenge({
86
- email: ContactAddressId.t,
114
+ emailId: ContactAddressId.t,
87
115
  proofHash: string,
88
116
  issuedAt: Reventless.DateTime.t,
117
+ language?: string,
118
+ messageKey?: string,
89
119
  })
90
120
  | @noApi
91
121
  SubmitRegistrationProof({
92
- email: ContactAddressId.t,
122
+ emailId: ContactAddressId.t,
93
123
  proofHash: string,
94
124
  presentedAt: Reventless.DateTime.t,
95
125
  })
96
- | @noApi RecordRegistrationCompleted({email: ContactAddressId.t})
126
+ | @noApi RecordRegistrationCompleted({emailId: ContactAddressId.t})
97
127
  // A signed-in inviter claims the address for someone else, as the roles the
98
128
  // app declares by invitation. No door here reaches it: a plugin that provides
99
129
  // invitations marks its door `Invite` and checks the inviter before relaying.
100
130
  | @noApi
101
131
  Invite({
102
- email: ContactAddressId.t,
132
+ emailId: ContactAddressId.t,
133
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
103
134
  roles: array<Reventless.Role.name>,
104
135
  invitedBy: string,
105
136
  requestedAt: Reventless.DateTime.t,
137
+ language?: string,
106
138
  })
107
139
  // Voids the code a pending registration holds, so a new one is sent: a code
108
140
  // lost, or its attempts spent. Held to one per resend cooldown.
109
141
  | @noApi
110
142
  ReissueRegistrationChallenge({
111
- email: ContactAddressId.t,
143
+ emailId: ContactAddressId.t,
112
144
  requestedAt: Reventless.DateTime.t,
113
145
  })
114
146
  // Releases an address a registration holds and nobody has proved yet.
115
- | @noApi WithdrawRegistration({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
147
+ | @noApi WithdrawRegistration({emailId: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
148
+ // Releases the address of an account that was erased, so its person may
149
+ // register again. Only the erasure workflow sends it, after the account is gone.
150
+ | @noApi ReleaseRegistration({emailId: ContactAddressId.t, releasedAt: Reventless.DateTime.t})
116
151
 
117
152
  // Every outcome of a command relayed for an anonymous caller is a recorded fact
118
153
  // or a quiet no-op, never an error: an error is the one answer a caller could
@@ -126,32 +161,49 @@ type error =
126
161
  @schema
127
162
  type event =
128
163
  | RegistrationRequested({
129
- email: ContactAddressId.t,
164
+ emailId: ContactAddressId.t,
165
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
130
166
  roles: array<string>,
131
167
  requestedAt: Reventless.DateTime.t,
168
+ language?: string,
132
169
  })
133
- | RegistrationExpired({email: ContactAddressId.t})
170
+ | RegistrationExpired({emailId: ContactAddressId.t})
134
171
  | RegistrationInvited({
135
- email: ContactAddressId.t,
172
+ emailId: ContactAddressId.t,
173
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
136
174
  roles: array<string>,
137
175
  invitedBy: string,
138
176
  invitedAt: Reventless.DateTime.t,
177
+ language?: string,
139
178
  })
140
179
  | RegistrationChallengeReissued({
141
- email: ContactAddressId.t,
180
+ emailId: ContactAddressId.t,
181
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
142
182
  reissuedAt: Reventless.DateTime.t,
143
183
  invitedBy?: string,
184
+ language?: string,
144
185
  })
145
- | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
186
+ | RegistrationWithdrawn({emailId: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
146
187
  | RegistrationAttemptedOnTakenAddress({
147
- email: ContactAddressId.t,
188
+ emailId: ContactAddressId.t,
189
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
148
190
  attemptedAt: Reventless.DateTime.t,
149
191
  })
150
192
  | RegistrationChallengeIssued({
151
- email: ContactAddressId.t,
193
+ emailId: ContactAddressId.t,
152
194
  proofHash: string,
153
195
  issuedAt: Reventless.DateTime.t,
196
+ /** The language the code went out in, and the key of the mail that carried it: what is
197
+ recorded of a sent mail, never its text. */
198
+ language?: string,
199
+ messageKey?: string,
200
+ })
201
+ | RegistrationProofAccepted({
202
+ emailId: ContactAddressId.t,
203
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
204
+ roles: array<string>,
205
+ proofHash: string,
154
206
  })
155
- | RegistrationProofAccepted({email: ContactAddressId.t, roles: array<string>, proofHash: string})
156
- | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
157
- | RegistrationCompleted({email: ContactAddressId.t})
207
+ | RegistrationProofRefused({emailId: ContactAddressId.t, reason: string})
208
+ | RegistrationCompleted({emailId: ContactAddressId.t})
209
+ | RegistrationReleased({emailId: ContactAddressId.t, releasedAt: Reventless.DateTime.t})