@reventlessdev/reventless-registration 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (48) hide show
  1. package/README.md +87 -2
  2. package/conformance/Registration/InboundTranslation/CompleteRegistration_Conformance_GWT.res +65 -0
  3. package/conformance/Registration/InboundTranslation/CompleteRegistration_Conformance_GWT.res.mjs +123 -0
  4. package/conformance/Registration/InboundTranslation/SignUp_Conformance_GWT.res +136 -0
  5. package/conformance/Registration/InboundTranslation/SignUp_Conformance_GWT.res.mjs +212 -0
  6. package/conformance/Registration/OutboundTranslation/CreateRegisteredPrincipal_Conformance_GWT.res +102 -0
  7. package/conformance/Registration/OutboundTranslation/CreateRegisteredPrincipal_Conformance_GWT.res.mjs +179 -0
  8. package/conformance/Registration/OutboundTranslation/SendRegistrationChallenge_Conformance_GWT.res +312 -0
  9. package/conformance/Registration/OutboundTranslation/SendRegistrationChallenge_Conformance_GWT.res.mjs +360 -0
  10. package/conformance/Registration/Registration_Conformance_Examples.res +58 -0
  11. package/conformance/Registration/Registration_Conformance_Examples.res.mjs +106 -0
  12. package/conformance/Registration/StateChange/RegistrationPolicy_Conformance_GWT.res +108 -0
  13. package/conformance/Registration/StateChange/RegistrationPolicy_Conformance_GWT.res.mjs +161 -0
  14. package/conformance/Registration/StateChange/RegistrationsByInvitation_Conformance_GWT.res +155 -0
  15. package/conformance/Registration/StateChange/RegistrationsByInvitation_Conformance_GWT.res.mjs +216 -0
  16. package/conformance/Registration/StateChange/Registrations_Conformance_GWT.res +469 -0
  17. package/conformance/Registration/StateChange/Registrations_Conformance_GWT.res.mjs +512 -0
  18. package/conformance/Registration/StateViewStream/RegistrationWindows_Conformance_GWT.res +33 -0
  19. package/conformance/Registration/StateViewStream/RegistrationWindows_Conformance_GWT.res.mjs +87 -0
  20. package/i18n/en.json +8 -0
  21. package/package.json +10 -6
  22. package/rescript.json +6 -1
  23. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  24. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +3 -3
  25. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +1 -1
  26. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +1 -1
  27. package/src/Registration/InboundTranslation/SignUp.res +19 -9
  28. package/src/Registration/InboundTranslation/SignUp.res.mjs +14 -7
  29. package/src/Registration/InboundTranslation/SignUp_Translation.res +32 -7
  30. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +41 -8
  31. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +5 -5
  32. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +6 -5
  33. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -8
  34. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +18 -10
  35. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +24 -13
  36. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +26 -16
  37. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -44
  38. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +204 -66
  39. package/src/Registration/StateChange/RegistrationPolicy.res +3 -0
  40. package/src/Registration/StateChange/RegistrationPolicy.res.mjs +3 -0
  41. package/src/Registration/StateChange/RegistrationPolicy_Decision.res +6 -5
  42. package/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs +22 -15
  43. package/src/Registration/StateChange/Registrations.res +67 -41
  44. package/src/Registration/StateChange/Registrations.res.mjs +84 -51
  45. package/src/Registration/StateChange/Registrations_Decision.res +82 -39
  46. package/src/Registration/StateChange/Registrations_Decision.res.mjs +116 -58
  47. package/src/Registration/StateViewStream/RegistrationWindows.res +4 -0
  48. package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +3 -3
@@ -10,8 +10,8 @@ module V = ContactVerification
10
10
  module Guards = ContactVerification_Guards
11
11
 
12
12
  type policyState =
13
- /** Nothing recorded about the role: open if the app declares it
14
- self-service, closed otherwise. */
13
+ /** Nothing recorded about the role: the deployment's starting state if the app
14
+ declares it self-service, closed otherwise. */
15
15
  | Unset
16
16
  | Closed
17
17
  | Open(option<Reventless.DateTime.t>)
@@ -19,7 +19,7 @@ type policyState =
19
19
  type pending = {
20
20
  /** The address the claim was made for: where its code goes, and what an
21
21
  accepted proof makes an account for. */
22
- address: Reventless.Email.t,
22
+ email: Reventless.Pii.t<Reventless.Email.t>,
23
23
  /** When the claim was made, or its code last reissued: what a claim with no
24
24
  challenge out lapses from. */
25
25
  requestedAt: Reventless.DateTime.t,
@@ -27,6 +27,9 @@ type pending = {
27
27
  roles: array<string>,
28
28
  /** Who invited, for a claim an inviter made. */
29
29
  invitedBy?: string,
30
+ /** The language the claim was made in: what its codes are written in for a person with no
31
+ account to say. */
32
+ language?: string,
30
33
  challenge: option<Guards.challenge>,
31
34
  proofHash: option<string>,
32
35
  }
@@ -53,6 +56,12 @@ let initialState = {admission: Unset, stage: Unclaimed, lastNoticeAt: None}
53
56
  so the door cannot be used to flood a registered person's inbox. */
54
57
  let noticeCooldown = 3600
55
58
 
59
+ /** The contact a challenge is held against. The guards only compare it, so the
60
+ ledger's id for the address serves, and no address is needed to decide. */
61
+ let contactOf = (emailId: ContactAddressId.t): ContactVerification.contact => ByEmail(
62
+ Reventless.Email.unsafe(emailId->ContactAddressId.toString),
63
+ )
64
+
56
65
  let purposeOf = (p: pending) => RegistrationChallenge.purposeOf(~invitedBy=p.invitedBy)
57
66
 
58
67
  /** The challenge rules a pending registration is held to: an invitation's code
@@ -63,17 +72,18 @@ let evolve = (state, event) =>
63
72
  switch event {
64
73
  | RegistrationOpened({?until}) => {...state, admission: Open(until)}
65
74
  | RegistrationClosed(_) => {...state, admission: Closed}
66
- | RegistrationRequested({address, roles, requestedAt}) => {
75
+ | RegistrationRequested({email, roles, requestedAt, ?language}) => {
67
76
  ...state,
68
- stage: Pending({address, requestedAt, roles, challenge: None, proofHash: None}),
77
+ stage: Pending({email, requestedAt, roles, ?language, challenge: None, proofHash: None}),
69
78
  }
70
- | RegistrationInvited({address, roles, invitedBy, invitedAt}) => {
79
+ | RegistrationInvited({email, roles, invitedBy, invitedAt, ?language}) => {
71
80
  ...state,
72
81
  stage: Pending({
73
- address,
82
+ email,
74
83
  requestedAt: invitedAt,
75
84
  roles,
76
85
  invitedBy,
86
+ ?language,
77
87
  challenge: None,
78
88
  proofHash: None,
79
89
  }),
@@ -83,14 +93,14 @@ let evolve = (state, event) =>
83
93
  ...state,
84
94
  lastNoticeAt: Some(attemptedAt),
85
95
  }
86
- | RegistrationChallengeIssued({proofHash, issuedAt}) =>
96
+ | RegistrationChallengeIssued({emailId, proofHash, issuedAt}) =>
87
97
  switch state.stage {
88
98
  | Pending(p) => {
89
99
  ...state,
90
100
  stage: Pending({
91
101
  ...p,
92
102
  challenge: Some({
93
- contact: ByEmail(p.address),
103
+ contact: contactOf(emailId),
94
104
  purpose: purposeOf(p),
95
105
  issuedAt,
96
106
  attempts: 0,
@@ -122,19 +132,34 @@ let evolve = (state, event) =>
122
132
  }
123
133
  | RegistrationProofAccepted(_) => {...state, stage: Verified}
124
134
  | RegistrationCompleted(_) => {...state, stage: Completed}
135
+ // The account was erased: the address is nobody's, and nobody was told of an
136
+ // attempt on it.
137
+ | RegistrationReleased(_) => {...state, stage: Unclaimed, lastNoticeAt: None}
125
138
  }
126
139
 
127
- /** Whether the policy admits a registration for `role` that arrived at `at`.
128
- A role nobody has recorded anything about is open exactly when it is declared
129
- self-service; past an open window's end it refuses exactly as closed does,
130
- with no event to close it. */
131
- let admits = (admission, ~table, ~role, ~at) =>
140
+ /** Whether the policy admits a registration for `role` that arrived at `at`,
141
+ on a deployment that starts `initially`. A role nobody has recorded anything
142
+ about reads as the starting state, if it is declared self-service; so does one
143
+ past an open window's end, with no event to close it. A request stamped with no
144
+ starting state was made when every role started open. */
145
+ let admits = (
146
+ admission,
147
+ ~table,
148
+ ~role,
149
+ ~at,
150
+ ~initially: option<Reventless.Admission.initially>,
151
+ ) => {
152
+ let starting = () =>
153
+ table->Reventless.Admission.isSelfService(role) &&
154
+ initially->Option.getOr(Reventless.Admission.InitiallyOpen) ==
155
+ Reventless.Admission.InitiallyOpen
132
156
  switch admission {
133
- | Unset => table->Reventless.Admission.isSelfService(role)
157
+ | Unset => starting()
134
158
  | Closed => false
135
159
  | Open(None) => true
136
- | Open(Some(until)) => Reventless.DateTime.isBefore(at, until)
160
+ | Open(Some(until)) => Reventless.DateTime.isBefore(at, until) || starting()
137
161
  }
162
+ }
138
163
 
139
164
  /** Whether the app declares `role` as one a person is invited to. */
140
165
  let isByInvitation = (table, role) =>
@@ -176,8 +201,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
176
201
  // decision: the policy is consulted before the address, so a closed
177
202
  // deployment sends nothing — not even the notice to an address that is
178
203
  // already registered.
179
- | Register({email, address, role, requestedAt}) =>
180
- if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt) {
204
+ | Register({emailId, email, role, requestedAt, ?language, ?initially}) =>
205
+ if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt, ~initially) {
181
206
  Ok([])
182
207
  } else {
183
208
  let roles = [(role :> string)]
@@ -188,55 +213,64 @@ module Make = (App: Reventless.Admission.Declaration) => {
188
213
  | Some(last) if Guards.elapsedSeconds(~from=last, ~to_=requestedAt) < noticeCooldown =>
189
214
  Ok([])
190
215
  | _ =>
191
- Ok([RegistrationAttemptedOnTakenAddress({email, address, attemptedAt: requestedAt})])
216
+ Ok([
217
+ RegistrationAttemptedOnTakenAddress({
218
+ emailId,
219
+ email: Value(email),
220
+ attemptedAt: requestedAt,
221
+ }),
222
+ ])
192
223
  }
193
224
  | Verified => Ok([])
194
225
  // A visitor cannot take over a claim, an inviter's included, while it holds.
195
226
  | Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
196
227
  | Pending(_) =>
197
228
  Ok([
198
- RegistrationExpired({email: email}),
199
- RegistrationRequested({email, address, roles, requestedAt}),
229
+ RegistrationExpired({emailId: emailId}),
230
+ RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language}),
200
231
  ])
201
- | Unclaimed => Ok([RegistrationRequested({email, address, roles, requestedAt})])
232
+ | Unclaimed =>
233
+ Ok([RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language})])
202
234
  }
203
235
  }
204
236
 
205
237
  // The policy is not consulted: it says whether visitors may sign themselves
206
238
  // up, and an invitation is not that. The table is, because it is the hard
207
239
  // cap on how each role is admitted.
208
- | Invite({email, address, roles, invitedBy, requestedAt}) =>
240
+ | Invite({emailId, email, roles, invitedBy, requestedAt, ?language}) =>
209
241
  switch roles->Array.find(r => !isByInvitation(App.table, r)) {
210
242
  | Some(role) => Error(NotByInvitation({role: (role :> string)}))
211
243
  | None if roles == [] => Error(NoRoleToGrant)
212
244
  | None =>
213
245
  let invited = RegistrationInvited({
214
- email,
215
- address,
246
+ emailId,
247
+ email: Value(email),
216
248
  roles: roles->Array.map(r => (r :> string)),
217
249
  invitedBy,
218
250
  invitedAt: requestedAt,
251
+ ?language,
219
252
  })
220
253
  switch state.stage {
221
254
  // An address that holds an account, or is about to, is not registered
222
255
  // twice; granting it roles is not registration.
223
256
  | Completed | Verified => Ok([])
224
257
  | Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
225
- | Pending(_) => Ok([RegistrationExpired({email: email}), invited])
258
+ | Pending(_) => Ok([RegistrationExpired({emailId: emailId}), invited])
226
259
  | Unclaimed => Ok([invited])
227
260
  }
228
261
  }
229
262
 
230
- | IssueRegistrationChallenge({email, proofHash, issuedAt}) =>
263
+ | IssueRegistrationChallenge({emailId, proofHash, issuedAt, ?language, ?messageKey}) =>
231
264
  switch state.stage {
232
265
  | Pending(p) =>
233
266
  switch Guards.onIssueRequested(
234
- ~contact=ByEmail(p.address),
267
+ ~contact=contactOf(emailId),
235
268
  ~existing=p.challenge,
236
269
  ~now=issuedAt,
237
270
  ~policy=policyOf(p),
238
271
  ) {
239
- | Issue => Ok([RegistrationChallengeIssued({email, proofHash, issuedAt})])
272
+ | Issue =>
273
+ Ok([RegistrationChallengeIssued({emailId, proofHash, issuedAt, ?language, ?messageKey})])
240
274
  // A redelivered request mints nothing, and because nothing is emitted,
241
275
  // sends nothing either.
242
276
  | AlreadyOpen => Ok([])
@@ -248,23 +282,24 @@ module Make = (App: Reventless.Admission.Declaration) => {
248
282
  // replaced by a second in flight, and the first to arrive would be the one
249
283
  // recorded. And not twice within the resend cooldown, so a door that
250
284
  // reaches this cannot be used to flood an inbox.
251
- | ReissueRegistrationChallenge({email, requestedAt}) =>
285
+ | ReissueRegistrationChallenge({emailId, requestedAt}) =>
252
286
  switch state.stage {
253
287
  | Pending({challenge: Some(c)} as p)
254
288
  if Guards.elapsedSeconds(~from=c.issuedAt, ~to_=requestedAt) >=
255
289
  policyOf(p).resendCooldown =>
256
290
  Ok([
257
291
  RegistrationChallengeReissued({
258
- email,
259
- address: p.address,
292
+ emailId,
293
+ email: p.email,
260
294
  reissuedAt: requestedAt,
261
295
  invitedBy: ?p.invitedBy,
296
+ language: ?p.language,
262
297
  }),
263
298
  ])
264
299
  | _ => Ok([])
265
300
  }
266
301
 
267
- | SubmitRegistrationProof({email, proofHash, presentedAt}) =>
302
+ | SubmitRegistrationProof({emailId, proofHash, presentedAt}) =>
268
303
  switch state.stage {
269
304
  | Pending({challenge: Some(c), proofHash: Some(held), roles} as p) =>
270
305
  switch Guards.onProofPresented(
@@ -274,8 +309,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
274
309
  ~now=presentedAt,
275
310
  ~policy=policyOf(p),
276
311
  ) {
277
- | Settle => Ok([RegistrationProofAccepted({email, address: p.address, roles, proofHash})])
278
- | Refuse(reason) => Ok([RegistrationProofRefused({email, reason: refusalReason(reason)})])
312
+ | Settle => Ok([RegistrationProofAccepted({emailId, email: p.email, roles, proofHash})])
313
+ | Refuse(reason) => Ok([RegistrationProofRefused({emailId, reason: refusalReason(reason)})])
279
314
  }
280
315
  // No challenge to answer: nothing to count it against, and nothing to say.
281
316
  | _ => Ok([])
@@ -283,15 +318,23 @@ module Make = (App: Reventless.Admission.Declaration) => {
283
318
 
284
319
  // Only a claim nobody has proved: once a proof settled, an account is on
285
320
  // its way, and withdrawing the claim would not stop it.
286
- | WithdrawRegistration({email, withdrawnAt}) =>
321
+ | WithdrawRegistration({emailId, withdrawnAt}) =>
287
322
  switch state.stage {
288
- | Pending(_) => Ok([RegistrationWithdrawn({email, withdrawnAt})])
323
+ | Pending(_) => Ok([RegistrationWithdrawn({emailId, withdrawnAt})])
289
324
  | Unclaimed | Verified | Completed => Ok([])
290
325
  }
291
326
 
292
- | RecordRegistrationCompleted({email}) =>
327
+ // Only an account: a claim nobody proved is withdrawn, and one being turned
328
+ // into an account is released once the account exists and is erased.
329
+ | ReleaseRegistration({emailId, releasedAt}) =>
330
+ switch state.stage {
331
+ | Completed => Ok([RegistrationReleased({emailId, releasedAt})])
332
+ | Unclaimed | Pending(_) | Verified => Ok([])
333
+ }
334
+
335
+ | RecordRegistrationCompleted({emailId}) =>
293
336
  switch state.stage {
294
- | Verified => Ok([RegistrationCompleted({email: email})])
337
+ | Verified => Ok([RegistrationCompleted({emailId: emailId})])
295
338
  | _ => Ok([])
296
339
  }
297
340
  }
@@ -1,9 +1,11 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
3
4
  import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
4
5
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
5
6
  import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
6
7
  import * as Registrations$ReventlessRegistration from "./Registrations.res.mjs";
8
+ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
7
9
  import * as RegistrationChallenge$ReventlessRegistration from "../../RegistrationChallenge.res.mjs";
8
10
  import * as ContactVerification_Guards$ReventlessRegistration from "../../ContactVerification_Guards.res.mjs";
9
11
 
@@ -13,6 +15,13 @@ let initialState = {
13
15
  lastNoticeAt: undefined
14
16
  };
15
17
 
18
+ function contactOf(emailId) {
19
+ return {
20
+ TAG: "ByEmail",
21
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId)
22
+ };
23
+ }
24
+
16
25
  function purposeOf(p) {
17
26
  return RegistrationChallenge$ReventlessRegistration.purposeOf(p.invitedBy);
18
27
  }
@@ -44,9 +53,10 @@ function evolve(state, event) {
44
53
  stage: {
45
54
  TAG: "Pending",
46
55
  _0: {
47
- address: event.address,
56
+ email: event.email,
48
57
  requestedAt: event.requestedAt,
49
58
  roles: event.roles,
59
+ language: event.language,
50
60
  challenge: undefined,
51
61
  proofHash: undefined
52
62
  }
@@ -59,10 +69,11 @@ function evolve(state, event) {
59
69
  stage: {
60
70
  TAG: "Pending",
61
71
  _0: {
62
- address: event.address,
72
+ email: event.email,
63
73
  requestedAt: event.invitedAt,
64
74
  roles: event.roles,
65
75
  invitedBy: event.invitedBy,
76
+ language: event.language,
66
77
  challenge: undefined,
67
78
  proofHash: undefined
68
79
  }
@@ -110,7 +121,7 @@ function evolve(state, event) {
110
121
  _0: (newrecord$1.proofHash = event.proofHash, newrecord$1.challenge = {
111
122
  contact: {
112
123
  TAG: "ByEmail",
113
- _0: p$2.address
124
+ _0: ContactAddressId$ReventlessRegistration.toString(event.emailId)
114
125
  },
115
126
  purpose: RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy),
116
127
  issuedAt: event.issuedAt,
@@ -157,20 +168,33 @@ function evolve(state, event) {
157
168
  stage: "Completed",
158
169
  lastNoticeAt: state.lastNoticeAt
159
170
  };
171
+ case "RegistrationReleased" :
172
+ return {
173
+ admission: state.admission,
174
+ stage: "Unclaimed",
175
+ lastNoticeAt: undefined
176
+ };
160
177
  }
161
178
  }
162
179
 
163
- function admits(admission, table, role, at) {
180
+ function admits(admission, table, role, at, initially) {
181
+ let starting = () => {
182
+ if (Admission$Reventless.isSelfService(table, role)) {
183
+ return Stdlib_Option.getOr(initially, "open") === "open";
184
+ } else {
185
+ return false;
186
+ }
187
+ };
164
188
  if (typeof admission !== "object") {
165
189
  if (admission === "Unset") {
166
- return Admission$Reventless.isSelfService(table, role);
190
+ return starting();
167
191
  } else {
168
192
  return false;
169
193
  }
170
194
  }
171
195
  let until = admission._0;
172
- if (until !== undefined) {
173
- return DateTime$Reventless.isBefore(at, until);
196
+ if (until !== undefined && !DateTime$Reventless.isBefore(at, until)) {
197
+ return starting();
174
198
  } else {
175
199
  return true;
176
200
  }
@@ -209,11 +233,12 @@ function Make(App) {
209
233
  let decide = (state, command) => {
210
234
  switch (command.TAG) {
211
235
  case "Register" :
236
+ let language = command.language;
212
237
  let requestedAt = command.requestedAt;
213
238
  let role = command.role;
214
- let address = command.address;
215
239
  let email = command.email;
216
- if (!admits(state.admission, App.table, role, requestedAt)) {
240
+ let emailId = command.emailId;
241
+ if (!admits(state.admission, App.table, role, requestedAt, command.initially)) {
217
242
  return {
218
243
  TAG: "Ok",
219
244
  _0: []
@@ -228,14 +253,18 @@ function Make(App) {
228
253
  _0: [
229
254
  {
230
255
  TAG: "RegistrationExpired",
231
- email: email
256
+ emailId: emailId
232
257
  },
233
258
  {
234
259
  TAG: "RegistrationRequested",
235
- email: email,
236
- address: address,
260
+ emailId: emailId,
261
+ email: {
262
+ TAG: "Value",
263
+ _0: email
264
+ },
237
265
  roles: roles,
238
- requestedAt: requestedAt
266
+ requestedAt: requestedAt,
267
+ language: language
239
268
  }
240
269
  ]
241
270
  };
@@ -252,10 +281,14 @@ function Make(App) {
252
281
  TAG: "Ok",
253
282
  _0: [{
254
283
  TAG: "RegistrationRequested",
255
- email: email,
256
- address: address,
284
+ emailId: emailId,
285
+ email: {
286
+ TAG: "Value",
287
+ _0: email
288
+ },
257
289
  roles: roles,
258
- requestedAt: requestedAt
290
+ requestedAt: requestedAt,
291
+ language: language
259
292
  }]
260
293
  };
261
294
  case "Verified" :
@@ -265,37 +298,29 @@ function Make(App) {
265
298
  };
266
299
  case "Completed" :
267
300
  let last = state.lastNoticeAt;
268
- if (last !== undefined) {
269
- if (ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
270
- return {
271
- TAG: "Ok",
272
- _0: []
273
- };
274
- } else {
275
- return {
276
- TAG: "Ok",
277
- _0: [{
278
- TAG: "RegistrationAttemptedOnTakenAddress",
279
- email: email,
280
- address: address,
281
- attemptedAt: requestedAt
282
- }]
283
- };
284
- }
285
- } else {
301
+ if (last !== undefined && ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
286
302
  return {
287
303
  TAG: "Ok",
288
- _0: [{
289
- TAG: "RegistrationAttemptedOnTakenAddress",
290
- email: email,
291
- address: address,
292
- attemptedAt: requestedAt
293
- }]
304
+ _0: []
294
305
  };
295
306
  }
307
+ return {
308
+ TAG: "Ok",
309
+ _0: [{
310
+ TAG: "RegistrationAttemptedOnTakenAddress",
311
+ emailId: emailId,
312
+ email: {
313
+ TAG: "Value",
314
+ _0: email
315
+ },
316
+ attemptedAt: requestedAt
317
+ }]
318
+ };
296
319
  }
320
+ break;
297
321
  case "IssueRegistrationChallenge" :
298
322
  let issuedAt = command.issuedAt;
323
+ let emailId$1 = command.emailId;
299
324
  let p$1 = state.stage;
300
325
  if (typeof p$1 !== "object") {
301
326
  return {
@@ -306,16 +331,18 @@ function Make(App) {
306
331
  let p$2 = p$1._0;
307
332
  let match = ContactVerification_Guards$ReventlessRegistration.onIssueRequested({
308
333
  TAG: "ByEmail",
309
- _0: p$2.address
334
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId$1)
310
335
  }, p$2.challenge, issuedAt, RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy)));
311
336
  if (match === "Issue") {
312
337
  return {
313
338
  TAG: "Ok",
314
339
  _0: [{
315
340
  TAG: "RegistrationChallengeIssued",
316
- email: command.email,
341
+ emailId: emailId$1,
317
342
  proofHash: command.proofHash,
318
- issuedAt: issuedAt
343
+ issuedAt: issuedAt,
344
+ language: command.language,
345
+ messageKey: command.messageKey
319
346
  }]
320
347
  };
321
348
  } else {
@@ -326,7 +353,7 @@ function Make(App) {
326
353
  }
327
354
  case "SubmitRegistrationProof" :
328
355
  let proofHash = command.proofHash;
329
- let email$1 = command.email;
356
+ let emailId$2 = command.emailId;
330
357
  let p$3 = state.stage;
331
358
  if (typeof p$3 !== "object") {
332
359
  return {
@@ -355,8 +382,8 @@ function Make(App) {
355
382
  TAG: "Ok",
356
383
  _0: [{
357
384
  TAG: "RegistrationProofAccepted",
358
- email: email$1,
359
- address: p$4.address,
385
+ emailId: emailId$2,
386
+ email: p$4.email,
360
387
  roles: p$4.roles,
361
388
  proofHash: proofHash
362
389
  }]
@@ -366,7 +393,7 @@ function Make(App) {
366
393
  TAG: "Ok",
367
394
  _0: [{
368
395
  TAG: "RegistrationProofRefused",
369
- email: email$1,
396
+ emailId: emailId$2,
370
397
  reason: refusalReason(reason._0)
371
398
  }]
372
399
  };
@@ -379,7 +406,7 @@ function Make(App) {
379
406
  TAG: "Ok",
380
407
  _0: [{
381
408
  TAG: "RegistrationCompleted",
382
- email: command.email
409
+ emailId: command.emailId
383
410
  }]
384
411
  };
385
412
  } else {
@@ -397,7 +424,7 @@ function Make(App) {
397
424
  case "Invite" :
398
425
  let requestedAt$1 = command.requestedAt;
399
426
  let roles$1 = command.roles;
400
- let email$2 = command.email;
427
+ let emailId$3 = command.emailId;
401
428
  let role$1 = roles$1.find(r => !isByInvitation(App.table, r));
402
429
  if (role$1 !== undefined) {
403
430
  return {
@@ -414,16 +441,21 @@ function Make(App) {
414
441
  _0: "NoRoleToGrant"
415
442
  };
416
443
  }
417
- let invited_1 = command.address;
444
+ let invited_1 = {
445
+ TAG: "Value",
446
+ _0: command.email
447
+ };
418
448
  let invited_2 = roles$1.map(r => r);
419
449
  let invited_3 = command.invitedBy;
450
+ let invited_5 = command.language;
420
451
  let invited = {
421
452
  TAG: "RegistrationInvited",
422
- email: email$2,
423
- address: invited_1,
453
+ emailId: emailId$3,
454
+ email: invited_1,
424
455
  roles: invited_2,
425
456
  invitedBy: invited_3,
426
- invitedAt: requestedAt$1
457
+ invitedAt: requestedAt$1,
458
+ language: invited_5
427
459
  };
428
460
  let p$5 = state.stage;
429
461
  if (typeof p$5 === "object") {
@@ -433,7 +465,7 @@ function Make(App) {
433
465
  _0: [
434
466
  {
435
467
  TAG: "RegistrationExpired",
436
- email: email$2
468
+ emailId: emailId$3
437
469
  },
438
470
  invited
439
471
  ]
@@ -475,10 +507,11 @@ function Make(App) {
475
507
  TAG: "Ok",
476
508
  _0: [{
477
509
  TAG: "RegistrationChallengeReissued",
478
- email: command.email,
479
- address: p$7.address,
510
+ emailId: command.emailId,
511
+ email: p$7.email,
480
512
  reissuedAt: requestedAt$2,
481
- invitedBy: p$7.invitedBy
513
+ invitedBy: p$7.invitedBy,
514
+ language: p$7.language
482
515
  }]
483
516
  };
484
517
  } else {
@@ -505,11 +538,35 @@ function Make(App) {
505
538
  TAG: "Ok",
506
539
  _0: [{
507
540
  TAG: "RegistrationWithdrawn",
508
- email: command.email,
541
+ emailId: command.emailId,
509
542
  withdrawnAt: command.withdrawnAt
510
543
  }]
511
544
  };
512
545
  }
546
+ case "ReleaseRegistration" :
547
+ let match$3 = state.stage;
548
+ if (typeof match$3 !== "object") {
549
+ if (match$3 === "Completed") {
550
+ return {
551
+ TAG: "Ok",
552
+ _0: [{
553
+ TAG: "RegistrationReleased",
554
+ emailId: command.emailId,
555
+ releasedAt: command.releasedAt
556
+ }]
557
+ };
558
+ } else {
559
+ return {
560
+ TAG: "Ok",
561
+ _0: []
562
+ };
563
+ }
564
+ } else {
565
+ return {
566
+ TAG: "Ok",
567
+ _0: []
568
+ };
569
+ }
513
570
  }
514
571
  };
515
572
  return {
@@ -537,6 +594,7 @@ export {
537
594
  Guards,
538
595
  initialState,
539
596
  noticeCooldown,
597
+ contactOf,
540
598
  purposeOf,
541
599
  policyOf,
542
600
  evolve,
@@ -8,9 +8,13 @@
8
8
  // A role with no row is open, since nothing recorded about a self-service role
9
9
  // is open; the shell learns which roles are self-service from the platform's
10
10
  // configuration and reads this view for the exceptions.
11
+ //
12
+ // Internal: the sign-in page reads it, and no menu offers it. What an
13
+ // administrator reads about a window is `RegistrationOpenings`.
11
14
 
12
15
  @@reventless.spec
13
16
  @@reventless.authorize(AllowAnonymous)
17
+ @@reventless.visibility(Internal)
14
18
 
15
19
  @schema
16
20
  type state = {
@@ -45,14 +45,14 @@ let stateSchema$1 = Sury.$Metadata_set(stateSchema, StateAnnotations$Reventless.
45
45
  metric: [],
46
46
  lifecycle: undefined,
47
47
  groupBy: undefined,
48
- visibility: undefined,
48
+ visibility: "Internal",
49
49
  live: undefined,
50
50
  retired: undefined
51
51
  });
52
52
 
53
53
  let name = "RegistrationWindows";
54
54
 
55
- let admissionDoor = "OpenRoles";
55
+ let admissionDoor = "openRoles";
56
56
 
57
57
  let Id;
58
58
 
@@ -62,7 +62,7 @@ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateVi
62
62
 
63
63
  let authorization = "AllowAnonymous";
64
64
 
65
- let visibility = "Public";
65
+ let visibility = "Internal";
66
66
 
67
67
  export {
68
68
  name,