@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
@@ -0,0 +1,512 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Decision_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Decision_GWT.res.mjs";
4
+ import * as Registrations$ReventlessRegistration from "../../../src/Registration/StateChange/Registrations.res.mjs";
5
+ import * as ContactAddressId$ReventlessRegistration from "../../../src/Registration/ContactAddressId.res.mjs";
6
+ import * as Registrations_Decision$ReventlessRegistration from "../../../src/Registration/StateChange/Registrations_Decision.res.mjs";
7
+ import * as Registration_Conformance_Examples$ReventlessRegistration from "../Registration_Conformance_Examples.res.mjs";
8
+
9
+ function Make(App) {
10
+ let AppLedger = Registrations_Decision$ReventlessRegistration.Make(App);
11
+ let include = Decision_GWT$ReventlessGwt.Make({
12
+ name: Registrations$ReventlessRegistration.name,
13
+ consumedEventSchema: Registrations$ReventlessRegistration.consumedEventSchema,
14
+ commandSchema: Registrations$ReventlessRegistration.commandSchema,
15
+ errorSchema: Registrations$ReventlessRegistration.errorSchema,
16
+ eventSchema: Registrations$ReventlessRegistration.eventSchema,
17
+ authorizationOf: Registrations$ReventlessRegistration.authorizationOf
18
+ })({
19
+ initialState: AppLedger.initialState,
20
+ evolve: AppLedger.evolve,
21
+ decide: AppLedger.decide
22
+ });
23
+ let describe = include.describe;
24
+ let todo = include.todo;
25
+ let test = include.test;
26
+ let givenEvents = include.givenEvents;
27
+ let whenCmd = include.whenCmd;
28
+ let thenEvent = include.thenEvent;
29
+ let thenEvents = include.thenEvents;
30
+ let thenNoEvent = include.thenNoEvent;
31
+ let thenError = include.thenError;
32
+ let thenAppendsConditionedOn = include.thenAppendsConditionedOn;
33
+ let needing = needs => ((name, body) => {
34
+ let why = Registration_Conformance_Examples$ReventlessRegistration.unmet(needs);
35
+ if (why !== undefined) {
36
+ return todo(name + ` (` + why + `)`);
37
+ } else {
38
+ return test(name, body);
39
+ }
40
+ });
41
+ let selfServiceRoles = Registration_Conformance_Examples$ReventlessRegistration.selfService(App.table);
42
+ let otherRoles = Registration_Conformance_Examples$ReventlessRegistration.notSelfService(App.table);
43
+ let aSelfServiceRole = Registration_Conformance_Examples$ReventlessRegistration.has(selfServiceRoles, "self-service");
44
+ let anOtherRole = Registration_Conformance_Examples$ReventlessRegistration.has(otherRoles, "non-self-service");
45
+ let role = Registration_Conformance_Examples$ReventlessRegistration.first(selfServiceRoles);
46
+ let roleName = Registration_Conformance_Examples$ReventlessRegistration.nameOf(role);
47
+ let other = Registration_Conformance_Examples$ReventlessRegistration.first(otherRoles);
48
+ let roles = [roleName];
49
+ let requestedAt = "2026-10-24T09:00:00.000Z";
50
+ let issuedAt = "2026-10-24T09:00:05.000Z";
51
+ let soonAfter = "2026-10-24T09:10:00.000Z";
52
+ let halfAMinuteOn = "2026-10-24T09:00:35.000Z";
53
+ let nextDay = "2026-10-25T09:00:06.000Z";
54
+ let nextDayLater = "2026-10-25T09:30:00.000Z";
55
+ let twoHoursOn = "2026-10-25T11:00:07.000Z";
56
+ let windowEnd = "2026-10-24T08:00:00.000Z";
57
+ let opened = [{
58
+ TAG: "RegistrationOpened",
59
+ role: role
60
+ }];
61
+ let requested = [{
62
+ TAG: "RegistrationRequested",
63
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
64
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
65
+ roles: roles,
66
+ requestedAt: requestedAt
67
+ }];
68
+ let challenged = requested.concat([{
69
+ TAG: "RegistrationChallengeIssued",
70
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
71
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
72
+ issuedAt: issuedAt
73
+ }]);
74
+ let verified = challenged.concat([{
75
+ TAG: "RegistrationProofAccepted",
76
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
77
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
78
+ roles: roles,
79
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash
80
+ }]);
81
+ let completed = verified.concat([{
82
+ TAG: "RegistrationCompleted",
83
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice
84
+ }]);
85
+ let wrong = {
86
+ TAG: "RegistrationProofRefused",
87
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
88
+ reason: "ProofMismatch"
89
+ };
90
+ let reissued = challenged.concat([{
91
+ TAG: "RegistrationChallengeReissued",
92
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
93
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
94
+ reissuedAt: soonAfter
95
+ }]);
96
+ let register = (roleOpt, atOpt, initially) => {
97
+ let role$1 = roleOpt !== undefined ? roleOpt : role;
98
+ let at = atOpt !== undefined ? atOpt : requestedAt;
99
+ return {
100
+ TAG: "Register",
101
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
102
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
103
+ role: role$1,
104
+ requestedAt: at,
105
+ initially: initially
106
+ };
107
+ };
108
+ let submit = (hashOpt, atOpt) => {
109
+ let hash = hashOpt !== undefined ? hashOpt : Registration_Conformance_Examples$ReventlessRegistration.secretHash;
110
+ let at = atOpt !== undefined ? atOpt : soonAfter;
111
+ return {
112
+ TAG: "SubmitRegistrationProof",
113
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
114
+ proofHash: hash,
115
+ presentedAt: at
116
+ };
117
+ };
118
+ describe("Registrations StateChangeSlice", () => {
119
+ let test = needing([aSelfServiceRole]);
120
+ test("a registration is conditioned on the policy as well as the address", () => thenAppendsConditionedOn(whenCmd(givenEvents([]), register(undefined, undefined, undefined)), [
121
+ {
122
+ eventTypes: [
123
+ "RegistrationOpened",
124
+ "RegistrationClosed",
125
+ "RegistrationRequested",
126
+ "RegistrationExpired",
127
+ "RegistrationInvited",
128
+ "RegistrationChallengeReissued",
129
+ "RegistrationWithdrawn",
130
+ "RegistrationAttemptedOnTakenAddress",
131
+ "RegistrationChallengeIssued",
132
+ "RegistrationProofAccepted",
133
+ "RegistrationProofRefused",
134
+ "RegistrationCompleted",
135
+ "RegistrationReleased"
136
+ ],
137
+ tags: [{
138
+ key: "contactAddress",
139
+ value: ContactAddressId$ReventlessRegistration.toString(Registration_Conformance_Examples$ReventlessRegistration.alice)
140
+ }]
141
+ },
142
+ {
143
+ eventTypes: [
144
+ "RegistrationOpened",
145
+ "RegistrationClosed"
146
+ ],
147
+ tags: [{
148
+ key: "role",
149
+ value: roleName
150
+ }]
151
+ }
152
+ ]));
153
+ test("a role nobody knows records nothing", () => thenNoEvent(whenCmd(givenEvents([]), register(Registration_Conformance_Examples$ReventlessRegistration.unknownRole(App.table), undefined, undefined))));
154
+ test("a self-service role claims the address before anything is recorded", () => thenEvent(whenCmd(givenEvents([]), register(undefined, undefined, undefined)), {
155
+ TAG: "RegistrationRequested",
156
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
157
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
158
+ roles: roles,
159
+ requestedAt: requestedAt
160
+ }));
161
+ test("a closed self-service role records nothing", () => thenNoEvent(whenCmd(givenEvents([{
162
+ TAG: "RegistrationClosed",
163
+ role: role
164
+ }]), register(undefined, undefined, undefined))));
165
+ test("past an open window's end, a deployment that starts closed refuses", () => thenNoEvent(whenCmd(givenEvents([{
166
+ TAG: "RegistrationOpened",
167
+ role: role,
168
+ until: windowEnd
169
+ }]), register(undefined, undefined, "closed"))));
170
+ test("past an open window's end, a deployment that starts open claims the address", () => thenEvent(whenCmd(givenEvents([{
171
+ TAG: "RegistrationOpened",
172
+ role: role,
173
+ until: windowEnd
174
+ }]), register(undefined, undefined, "open")), {
175
+ TAG: "RegistrationRequested",
176
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
177
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
178
+ roles: roles,
179
+ requestedAt: requestedAt
180
+ }));
181
+ test("with nothing recorded, a deployment that starts closed refuses", () => thenNoEvent(whenCmd(givenEvents([]), register(undefined, undefined, "closed"))));
182
+ test("with nothing recorded, a request with no starting state claims the address", () => thenEvent(whenCmd(givenEvents([]), register(undefined, undefined, undefined)), {
183
+ TAG: "RegistrationRequested",
184
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
185
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
186
+ roles: roles,
187
+ requestedAt: requestedAt
188
+ }));
189
+ test("within an open window's end, it claims the address", () => thenEvent(whenCmd(givenEvents([{
190
+ TAG: "RegistrationOpened",
191
+ role: role,
192
+ until: nextDay
193
+ }]), register(undefined, undefined, undefined)), {
194
+ TAG: "RegistrationRequested",
195
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
196
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
197
+ roles: roles,
198
+ requestedAt: requestedAt
199
+ }));
200
+ test("closing the policy stops registrations it had admitted", () => thenNoEvent(whenCmd(givenEvents(opened.concat([{
201
+ TAG: "RegistrationClosed",
202
+ role: role
203
+ }])), register(undefined, undefined, undefined))));
204
+ test("a second request while one is pending records nothing", () => thenNoEvent(whenCmd(givenEvents(challenged), register(undefined, soonAfter, undefined))));
205
+ test("a registered address records the attempt, not a registration", () => thenEvent(whenCmd(givenEvents(completed), register(undefined, nextDay, undefined)), {
206
+ TAG: "RegistrationAttemptedOnTakenAddress",
207
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
208
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
209
+ attemptedAt: nextDay
210
+ }));
211
+ test("a second attempt on a registered address within the hour sends no second notice", () => thenNoEvent(whenCmd(givenEvents(completed.concat([{
212
+ TAG: "RegistrationAttemptedOnTakenAddress",
213
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
214
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
215
+ attemptedAt: nextDay
216
+ }])), register(undefined, nextDayLater, undefined))));
217
+ test("after the hour, a registered address is told again", () => thenEvent(whenCmd(givenEvents(completed.concat([{
218
+ TAG: "RegistrationAttemptedOnTakenAddress",
219
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
220
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
221
+ attemptedAt: nextDay
222
+ }])), register(undefined, twoHoursOn, undefined)), {
223
+ TAG: "RegistrationAttemptedOnTakenAddress",
224
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
225
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
226
+ attemptedAt: twoHoursOn
227
+ }));
228
+ test("an abandoned registration releases the address", () => thenEvents(whenCmd(givenEvents(challenged), register(undefined, nextDay, undefined)), [
229
+ {
230
+ TAG: "RegistrationExpired",
231
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice
232
+ },
233
+ {
234
+ TAG: "RegistrationRequested",
235
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
236
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
237
+ roles: roles,
238
+ requestedAt: nextDay
239
+ }
240
+ ]));
241
+ test("a pending registration opens a challenge against a hash", () => thenEvent(whenCmd(givenEvents(requested), {
242
+ TAG: "IssueRegistrationChallenge",
243
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
244
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
245
+ issuedAt: issuedAt
246
+ }), {
247
+ TAG: "RegistrationChallengeIssued",
248
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
249
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
250
+ issuedAt: issuedAt
251
+ }));
252
+ test("a registration keeps the language it was asked in", () => thenEvent(whenCmd(givenEvents([]), {
253
+ TAG: "Register",
254
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
255
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
256
+ role: role,
257
+ requestedAt: requestedAt,
258
+ language: "de"
259
+ }), {
260
+ TAG: "RegistrationRequested",
261
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
262
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
263
+ roles: roles,
264
+ requestedAt: requestedAt,
265
+ language: "de"
266
+ }));
267
+ test("a challenge records the language and key of the mail that carried it", () => thenEvent(whenCmd(givenEvents(requested), {
268
+ TAG: "IssueRegistrationChallenge",
269
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
270
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
271
+ issuedAt: issuedAt,
272
+ language: "de",
273
+ messageKey: "registration.challenge.body"
274
+ }), {
275
+ TAG: "RegistrationChallengeIssued",
276
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
277
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
278
+ issuedAt: issuedAt,
279
+ language: "de",
280
+ messageKey: "registration.challenge.body"
281
+ }));
282
+ test("a reissued code is asked for in the claim's language", () => thenEvent(whenCmd(givenEvents([
283
+ {
284
+ TAG: "RegistrationRequested",
285
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
286
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
287
+ roles: roles,
288
+ requestedAt: requestedAt,
289
+ language: "de"
290
+ },
291
+ {
292
+ TAG: "RegistrationChallengeIssued",
293
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
294
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash,
295
+ issuedAt: issuedAt
296
+ }
297
+ ]), {
298
+ TAG: "ReissueRegistrationChallenge",
299
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
300
+ requestedAt: soonAfter
301
+ }), {
302
+ TAG: "RegistrationChallengeReissued",
303
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
304
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
305
+ reissuedAt: soonAfter,
306
+ language: "de"
307
+ }));
308
+ test("a redelivered challenge request opens nothing", () => thenNoEvent(whenCmd(givenEvents(challenged), {
309
+ TAG: "IssueRegistrationChallenge",
310
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
311
+ proofHash: "another",
312
+ issuedAt: soonAfter
313
+ })));
314
+ test("the right proof settles the registration", () => thenEvent(whenCmd(givenEvents(challenged), submit(undefined, undefined)), {
315
+ TAG: "RegistrationProofAccepted",
316
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
317
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
318
+ roles: roles,
319
+ proofHash: Registration_Conformance_Examples$ReventlessRegistration.secretHash
320
+ }));
321
+ test("a wrong proof is counted, not settled", () => thenEvent(whenCmd(givenEvents(challenged), submit("hash-of-a-guess", undefined)), {
322
+ TAG: "RegistrationProofRefused",
323
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
324
+ reason: "ProofMismatch"
325
+ }));
326
+ test("a proof after the challenge lapsed is refused", () => thenEvent(whenCmd(givenEvents(challenged), submit(undefined, nextDay)), {
327
+ TAG: "RegistrationProofRefused",
328
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
329
+ reason: "ChallengeExpired"
330
+ }));
331
+ test("the right proof after the attempts are spent is refused", () => thenEvent(whenCmd(givenEvents(challenged.concat([
332
+ wrong,
333
+ wrong,
334
+ wrong,
335
+ wrong,
336
+ wrong
337
+ ])), submit(undefined, undefined)), {
338
+ TAG: "RegistrationProofRefused",
339
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
340
+ reason: "AttemptsExhausted"
341
+ }));
342
+ test("a settled proof settles once", () => thenNoEvent(whenCmd(givenEvents(completed), submit(undefined, undefined))));
343
+ test("a proof with no challenge outstanding records nothing", () => thenNoEvent(whenCmd(givenEvents([]), submit(undefined, undefined))));
344
+ test("an account made for a settled proof completes the registration", () => thenEvent(whenCmd(givenEvents(verified), {
345
+ TAG: "RecordRegistrationCompleted",
346
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice
347
+ }), {
348
+ TAG: "RegistrationCompleted",
349
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice
350
+ }));
351
+ test("completion without a settled proof records nothing", () => thenNoEvent(whenCmd(givenEvents(challenged), {
352
+ TAG: "RecordRegistrationCompleted",
353
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice
354
+ })));
355
+ test("a code that went out is reissued", () => thenEvent(whenCmd(givenEvents(challenged), {
356
+ TAG: "ReissueRegistrationChallenge",
357
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
358
+ requestedAt: soonAfter
359
+ }), {
360
+ TAG: "RegistrationChallengeReissued",
361
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
362
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
363
+ reissuedAt: soonAfter
364
+ }));
365
+ test("a code is not reissued within the resend cooldown", () => thenNoEvent(whenCmd(givenEvents(challenged), {
366
+ TAG: "ReissueRegistrationChallenge",
367
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
368
+ requestedAt: halfAMinuteOn
369
+ })));
370
+ test("a code still on its way is not reissued", () => thenNoEvent(whenCmd(givenEvents(requested), {
371
+ TAG: "ReissueRegistrationChallenge",
372
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
373
+ requestedAt: soonAfter
374
+ })));
375
+ test("a reissued code settles where the spent one could not", () => thenEvent(whenCmd(givenEvents(challenged.concat([
376
+ wrong,
377
+ wrong,
378
+ wrong,
379
+ wrong,
380
+ wrong
381
+ ]).concat([
382
+ {
383
+ TAG: "RegistrationChallengeReissued",
384
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
385
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
386
+ reissuedAt: soonAfter
387
+ },
388
+ {
389
+ TAG: "RegistrationChallengeIssued",
390
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
391
+ proofHash: "hash-of-the-new-secret",
392
+ issuedAt: soonAfter
393
+ }
394
+ ])), submit("hash-of-the-new-secret", undefined)), {
395
+ TAG: "RegistrationProofAccepted",
396
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
397
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
398
+ roles: roles,
399
+ proofHash: "hash-of-the-new-secret"
400
+ }));
401
+ test("the voided code no longer settles anything", () => thenNoEvent(whenCmd(givenEvents(reissued), submit(undefined, soonAfter))));
402
+ test("withdrawing a pending registration releases the address", () => thenEvent(whenCmd(givenEvents(challenged), {
403
+ TAG: "WithdrawRegistration",
404
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
405
+ withdrawnAt: soonAfter
406
+ }), {
407
+ TAG: "RegistrationWithdrawn",
408
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
409
+ withdrawnAt: soonAfter
410
+ }));
411
+ test("a settled registration is not withdrawn", () => thenNoEvent(whenCmd(givenEvents(verified), {
412
+ TAG: "WithdrawRegistration",
413
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
414
+ withdrawnAt: soonAfter
415
+ })));
416
+ test("releasing an erased account frees the address", () => thenEvent(whenCmd(givenEvents(completed), {
417
+ TAG: "ReleaseRegistration",
418
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
419
+ releasedAt: nextDay
420
+ }), {
421
+ TAG: "RegistrationReleased",
422
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
423
+ releasedAt: nextDay
424
+ }));
425
+ test("a released address registers again", () => thenEvent(whenCmd(givenEvents(completed.concat([{
426
+ TAG: "RegistrationReleased",
427
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
428
+ releasedAt: nextDay
429
+ }])), register(undefined, nextDayLater, undefined)), {
430
+ TAG: "RegistrationRequested",
431
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
432
+ email: Registration_Conformance_Examples$ReventlessRegistration.personal,
433
+ roles: roles,
434
+ requestedAt: nextDayLater
435
+ }));
436
+ test("a pending registration is not released", () => thenNoEvent(whenCmd(givenEvents(challenged), {
437
+ TAG: "ReleaseRegistration",
438
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
439
+ releasedAt: soonAfter
440
+ })));
441
+ test("a role the app does not declare by invitation is refused to an inviter", () => thenError(whenCmd(givenEvents([]), {
442
+ TAG: "Invite",
443
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
444
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
445
+ roles: [role],
446
+ invitedBy: "u_admin",
447
+ requestedAt: requestedAt
448
+ }), {
449
+ TAG: "NotByInvitation",
450
+ role: roleName
451
+ }));
452
+ let test$1 = needing([anOtherRole]);
453
+ test$1("a role no visitor may have records nothing", () => thenNoEvent(whenCmd(givenEvents([]), register(other, undefined, undefined))));
454
+ test$1("a role that is not self-service is refused on a deployment that starts open", () => thenNoEvent(whenCmd(givenEvents([]), register(other, undefined, "open"))));
455
+ });
456
+ return {
457
+ Ledger: undefined,
458
+ AppLedger: AppLedger,
459
+ Spec: include.Spec,
460
+ describe: describe,
461
+ todo: todo,
462
+ test: test,
463
+ givenEvents: givenEvents,
464
+ Caller: include.Caller,
465
+ asCaller: include.asCaller,
466
+ whenCmd: whenCmd,
467
+ whenCmdSent: include.whenCmdSent,
468
+ thenEvent: thenEvent,
469
+ thenEvents: thenEvents,
470
+ thenNoEvent: thenNoEvent,
471
+ thenEventWithError: include.thenEventWithError,
472
+ thenEventsWithError: include.thenEventsWithError,
473
+ thenError: thenError,
474
+ thenForbidden: include.thenForbidden,
475
+ thenRefusedBy: include.thenRefusedBy,
476
+ thenAppendsConditionedOn: thenAppendsConditionedOn,
477
+ thenAppendsConditionedOnExactly: include.thenAppendsConditionedOnExactly,
478
+ needing: needing,
479
+ selfServiceRoles: selfServiceRoles,
480
+ otherRoles: otherRoles,
481
+ aSelfServiceRole: aSelfServiceRole,
482
+ anOtherRole: anOtherRole,
483
+ emailId: Registration_Conformance_Examples$ReventlessRegistration.alice,
484
+ email: Registration_Conformance_Examples$ReventlessRegistration.aliceMail,
485
+ role: role,
486
+ roleName: roleName,
487
+ other: other,
488
+ roles: roles,
489
+ requestedAt: requestedAt,
490
+ issuedAt: issuedAt,
491
+ soonAfter: soonAfter,
492
+ halfAMinuteOn: halfAMinuteOn,
493
+ nextDay: nextDay,
494
+ nextDayLater: nextDayLater,
495
+ twoHoursOn: twoHoursOn,
496
+ windowEnd: windowEnd,
497
+ opened: opened,
498
+ requested: requested,
499
+ challenged: challenged,
500
+ verified: verified,
501
+ completed: completed,
502
+ wrong: wrong,
503
+ reissued: reissued,
504
+ register: register,
505
+ submit: submit
506
+ };
507
+ }
508
+
509
+ export {
510
+ Make,
511
+ }
512
+ /* Decision_GWT-ReventlessGwt Not a pure module */
@@ -0,0 +1,33 @@
1
+ // What a visitor may read about registration: whether a role is open, and until when. One row
2
+ // per role an administrator has said anything about; a role with no row is open.
3
+
4
+ module Make = (App: Reventless.Admission.Declaration) => {
5
+ module Windows = RegistrationWindows
6
+ open Windows
7
+ include ReventlessGwt.Projection_GWT.Make(Windows, RegistrationWindows_Projection)
8
+ open Registration_Conformance_Examples
9
+
10
+ let roleName = App.table->selfService->first->nameOf
11
+ let until = "2026-10-31T00:00:00.000Z"
12
+
13
+ describe("RegistrationWindows StateViewSliceStream", () => {
14
+ // scenario-id: 7a4c2e9b-3d1f-4b6a-8e5c-2f0d9a1b3c4e
15
+ test("a closed role has a closed row", () =>
16
+ givenEvents([])
17
+ ->whenEvent(RegistrationClosed({role: roleName}))
18
+ ->thenStateWithId(roleName, {role: roleName, isOpen: false})
19
+ )
20
+
21
+ // scenario-id: b5d3f1a7-8c2e-4d9b-a6f0-4e1c7b9d2a3f
22
+ test("opening a role again shows it open, with its end", () =>
23
+ givenEvents([RegistrationClosed({role: roleName})])
24
+ ->whenEvent(RegistrationOpened({role: roleName, until}))
25
+ ->thenStateWithId(roleName, {role: roleName, isOpen: true, until})
26
+ )
27
+
28
+ // scenario-id: c9e2a4d6-1f3b-4e7a-9c5d-8b0e2f4a6c1d
29
+ test("a role nobody has said anything about has no row", () =>
30
+ givenEvents([])->whenEvents([])->thenNoState
31
+ )
32
+ })
33
+ }
@@ -0,0 +1,87 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
4
+ import * as Projection_GWT$ReventlessGwt from "@reventlessdev/reventless-gwt/src/Projection_GWT.res.mjs";
5
+ import * as RegistrationWindows$ReventlessRegistration from "../../../src/Registration/StateViewStream/RegistrationWindows.res.mjs";
6
+ import * as RegistrationWindows_Projection$ReventlessRegistration from "../../../src/Registration/StateViewStream/RegistrationWindows_Projection.res.mjs";
7
+ import * as Registration_Conformance_Examples$ReventlessRegistration from "../Registration_Conformance_Examples.res.mjs";
8
+
9
+ function Make(App) {
10
+ let include = Projection_GWT$ReventlessGwt.Make({
11
+ name: RegistrationWindows$ReventlessRegistration.name,
12
+ stateSchema: RegistrationWindows$ReventlessRegistration.stateSchema,
13
+ Id: {
14
+ schema: Id$Reventless.StringPure.schema,
15
+ make: prim => prim,
16
+ makeFromString: prim => prim,
17
+ toString: prim => prim,
18
+ cmp: Id$Reventless.StringPure.cmp
19
+ },
20
+ consumedEventSchema: RegistrationWindows$ReventlessRegistration.consumedEventSchema,
21
+ subIdConfig: undefined,
22
+ authorization: RegistrationWindows$ReventlessRegistration.authorization
23
+ })({
24
+ project: RegistrationWindows_Projection$ReventlessRegistration.project
25
+ });
26
+ let describe = include.describe;
27
+ let test = include.test;
28
+ let givenEvents = include.givenEvents;
29
+ let whenEvent = include.whenEvent;
30
+ let whenEvents = include.whenEvents;
31
+ let thenStateWithId = include.thenStateWithId;
32
+ let thenNoState = include.thenNoState;
33
+ let roleName = Registration_Conformance_Examples$ReventlessRegistration.nameOf(Registration_Conformance_Examples$ReventlessRegistration.first(Registration_Conformance_Examples$ReventlessRegistration.selfService(App.table)));
34
+ let until = "2026-10-31T00:00:00.000Z";
35
+ describe("RegistrationWindows StateViewSliceStream", () => {
36
+ test("a closed role has a closed row", undefined, () => thenStateWithId(whenEvent(givenEvents([]), {
37
+ TAG: "RegistrationClosed",
38
+ role: roleName
39
+ }), roleName, {
40
+ role: roleName,
41
+ isOpen: false
42
+ }));
43
+ test("opening a role again shows it open, with its end", undefined, () => thenStateWithId(whenEvent(givenEvents([{
44
+ TAG: "RegistrationClosed",
45
+ role: roleName
46
+ }]), {
47
+ TAG: "RegistrationOpened",
48
+ role: roleName,
49
+ until: until
50
+ }), roleName, {
51
+ role: roleName,
52
+ isOpen: true,
53
+ until: until
54
+ }));
55
+ test("a role nobody has said anything about has no row", undefined, () => thenNoState(whenEvents(givenEvents([]), [])));
56
+ });
57
+ return {
58
+ Windows: undefined,
59
+ Spec: include.Spec,
60
+ describe: describe,
61
+ describeWithId: include.describeWithId,
62
+ todo: include.todo,
63
+ test: test,
64
+ givenEvents: givenEvents,
65
+ givenEventsAt: include.givenEventsAt,
66
+ whenEvent: whenEvent,
67
+ whenEvents: whenEvents,
68
+ thenStates: include.thenStates,
69
+ thenStatesWithId: include.thenStatesWithId,
70
+ thenAllStates: include.thenAllStates,
71
+ thenState: include.thenState,
72
+ thenStateWithId: thenStateWithId,
73
+ thenNoState: thenNoState,
74
+ thenThrow: include.thenThrow,
75
+ thenFail: include.thenFail,
76
+ Caller: include.Caller,
77
+ asCaller: include.asCaller,
78
+ readableBy: include.readableBy,
79
+ roleName: roleName,
80
+ until: until
81
+ };
82
+ }
83
+
84
+ export {
85
+ Make,
86
+ }
87
+ /* Id-Reventless Not a pure module */
package/i18n/en.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "registration.challenge.body": "Your registration code is {token}. Enter it with a password of your choice to finish. It expires in {expiresIn}.",
3
+ "registration.challenge.subject": "Finish your registration",
4
+ "registration.invited.body": "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}.",
5
+ "registration.invited.subject": "You are invited to create an account",
6
+ "registration.taken.body": "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.",
7
+ "registration.taken.subject": "Someone tried to register with your address"
8
+ }
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-registration",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.50",
4
4
  "description": "Self-registration as a library of slices: a person with no account proves control of an address and ends up with one, admitted per role as the app declares",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
7
  "src/**/*.res",
8
8
  "src/**/*.resi",
9
9
  "src/**/*.res.mjs",
10
+ "conformance/**/*.res",
11
+ "conformance/**/*.res.mjs",
12
+ "i18n/*.json",
10
13
  "rescript.json",
11
14
  "README.md"
12
15
  ],
13
16
  "dependencies": {
14
- "sury": "11.0.0",
15
- "sury-ppx": "11.0.0",
16
- "@reventlessdev/reventless-infra": "3.0.0-alpha.209",
17
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.108",
18
- "@reventlessdev/reventless-spec": "3.0.0-alpha.180"
17
+ "sury": "11.1.0",
18
+ "sury-ppx": "11.1.0",
19
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.251",
20
+ "@reventlessdev/reventless-ppx": "^1.0.0-alpha.123",
21
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.220",
22
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.307"
19
23
  },
20
24
  "devDependencies": {
21
25
  "rescript": "12.3.1"