@reventlessdev/reventless-registration 1.0.0-alpha.3 → 1.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/i18n/en.json +8 -0
- package/package.json +7 -6
- package/src/Registration/ContactAddressId.res +27 -3
- package/src/Registration/ContactAddressId.res.mjs +26 -2
- package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
- package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +3 -3
- package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +9 -6
- package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +16 -9
- package/src/Registration/InboundTranslation/SignUp.res +6 -3
- package/src/Registration/InboundTranslation/SignUp.res.mjs +11 -5
- package/src/Registration/InboundTranslation/SignUp_Translation.res +34 -13
- package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +26 -5
- package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +9 -3
- package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +7 -3
- package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -7
- package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +17 -8
- package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +36 -7
- package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +24 -11
- package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -44
- package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +203 -61
- package/src/Registration/StateChange/Registrations.res +76 -27
- package/src/Registration/StateChange/Registrations.res.mjs +83 -39
- package/src/Registration/StateChange/Registrations_Decision.res +74 -26
- package/src/Registration/StateChange/Registrations_Decision.res.mjs +106 -47
- package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
|
+
import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
|
|
4
5
|
import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
|
|
6
|
+
import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
|
|
5
7
|
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
6
8
|
import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
|
|
7
9
|
import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
|
|
@@ -19,99 +21,125 @@ let consumedEventSchema = Sury.union([
|
|
|
19
21
|
})),
|
|
20
22
|
Sury.$schema(s => ({
|
|
21
23
|
TAG: "RegistrationRequested",
|
|
22
|
-
|
|
24
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
25
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
23
26
|
roles: s.m(Sury.array(Sury.string)),
|
|
24
|
-
requestedAt: s.m(DateTime$Reventless.schema)
|
|
27
|
+
requestedAt: s.m(DateTime$Reventless.schema),
|
|
28
|
+
language: s.m(Sury.$option(Sury.string))
|
|
25
29
|
})),
|
|
26
30
|
Sury.$schema(s => ({
|
|
27
31
|
TAG: "RegistrationExpired",
|
|
28
|
-
|
|
32
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
|
|
29
33
|
})),
|
|
30
34
|
Sury.$schema(s => ({
|
|
31
35
|
TAG: "RegistrationInvited",
|
|
32
|
-
|
|
36
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
37
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
33
38
|
roles: s.m(Sury.array(Sury.string)),
|
|
34
39
|
invitedBy: s.m(Sury.string),
|
|
35
|
-
invitedAt: s.m(DateTime$Reventless.schema)
|
|
40
|
+
invitedAt: s.m(DateTime$Reventless.schema),
|
|
41
|
+
language: s.m(Sury.$option(Sury.string))
|
|
36
42
|
})),
|
|
37
43
|
Sury.$schema(s => ({
|
|
38
44
|
TAG: "RegistrationChallengeReissued",
|
|
39
|
-
|
|
45
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
46
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
40
47
|
reissuedAt: s.m(DateTime$Reventless.schema),
|
|
41
|
-
invitedBy: s.m(Sury.$option(Sury.string))
|
|
48
|
+
invitedBy: s.m(Sury.$option(Sury.string)),
|
|
49
|
+
language: s.m(Sury.$option(Sury.string))
|
|
42
50
|
})),
|
|
43
51
|
Sury.$schema(s => ({
|
|
44
52
|
TAG: "RegistrationWithdrawn",
|
|
45
|
-
|
|
53
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
46
54
|
withdrawnAt: s.m(DateTime$Reventless.schema)
|
|
47
55
|
})),
|
|
48
56
|
Sury.$schema(s => ({
|
|
49
57
|
TAG: "RegistrationAttemptedOnTakenAddress",
|
|
50
|
-
|
|
58
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
59
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
51
60
|
attemptedAt: s.m(DateTime$Reventless.schema)
|
|
52
61
|
})),
|
|
53
62
|
Sury.$schema(s => ({
|
|
54
63
|
TAG: "RegistrationChallengeIssued",
|
|
55
|
-
|
|
64
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
56
65
|
proofHash: s.m(Sury.string),
|
|
57
|
-
issuedAt: s.m(DateTime$Reventless.schema)
|
|
66
|
+
issuedAt: s.m(DateTime$Reventless.schema),
|
|
67
|
+
language: s.m(Sury.$option(Sury.string)),
|
|
68
|
+
messageKey: s.m(Sury.$option(Sury.string))
|
|
58
69
|
})),
|
|
59
70
|
Sury.$schema(s => ({
|
|
60
71
|
TAG: "RegistrationProofAccepted",
|
|
61
|
-
|
|
72
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
73
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
62
74
|
roles: s.m(Sury.array(Sury.string)),
|
|
63
75
|
proofHash: s.m(Sury.string)
|
|
64
76
|
})),
|
|
65
77
|
Sury.$schema(s => ({
|
|
66
78
|
TAG: "RegistrationProofRefused",
|
|
67
|
-
|
|
79
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
68
80
|
reason: s.m(Sury.string)
|
|
69
81
|
})),
|
|
70
82
|
Sury.$schema(s => ({
|
|
71
83
|
TAG: "RegistrationCompleted",
|
|
72
|
-
|
|
84
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
|
|
85
|
+
})),
|
|
86
|
+
Sury.$schema(s => ({
|
|
87
|
+
TAG: "RegistrationReleased",
|
|
88
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
89
|
+
releasedAt: s.m(DateTime$Reventless.schema)
|
|
73
90
|
}))
|
|
74
91
|
]);
|
|
75
92
|
|
|
76
93
|
let commandSchema = Sury.union([
|
|
77
94
|
Sury.$schema(s => ({
|
|
78
95
|
TAG: "Register",
|
|
79
|
-
|
|
96
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
97
|
+
email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
|
|
80
98
|
role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
|
|
81
|
-
requestedAt: s.m(DateTime$Reventless.schema)
|
|
99
|
+
requestedAt: s.m(DateTime$Reventless.schema),
|
|
100
|
+
language: s.m(Sury.$option(Sury.string))
|
|
82
101
|
})),
|
|
83
102
|
Sury.$schema(s => ({
|
|
84
103
|
TAG: "IssueRegistrationChallenge",
|
|
85
|
-
|
|
104
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
86
105
|
proofHash: s.m(Sury.string),
|
|
87
|
-
issuedAt: s.m(DateTime$Reventless.schema)
|
|
106
|
+
issuedAt: s.m(DateTime$Reventless.schema),
|
|
107
|
+
language: s.m(Sury.$option(Sury.string)),
|
|
108
|
+
messageKey: s.m(Sury.$option(Sury.string))
|
|
88
109
|
})),
|
|
89
110
|
Sury.$schema(s => ({
|
|
90
111
|
TAG: "SubmitRegistrationProof",
|
|
91
|
-
|
|
112
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
92
113
|
proofHash: s.m(Sury.string),
|
|
93
114
|
presentedAt: s.m(DateTime$Reventless.schema)
|
|
94
115
|
})),
|
|
95
116
|
Sury.$schema(s => ({
|
|
96
117
|
TAG: "RecordRegistrationCompleted",
|
|
97
|
-
|
|
118
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
|
|
98
119
|
})),
|
|
99
120
|
Sury.$schema(s => ({
|
|
100
121
|
TAG: "Invite",
|
|
101
|
-
|
|
122
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
123
|
+
email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
|
|
102
124
|
roles: s.m(Sury.array(Role$Reventless.nameSchema)),
|
|
103
125
|
invitedBy: s.m(Sury.string),
|
|
104
|
-
requestedAt: s.m(DateTime$Reventless.schema)
|
|
126
|
+
requestedAt: s.m(DateTime$Reventless.schema),
|
|
127
|
+
language: s.m(Sury.$option(Sury.string))
|
|
105
128
|
})),
|
|
106
129
|
Sury.$schema(s => ({
|
|
107
130
|
TAG: "ReissueRegistrationChallenge",
|
|
108
|
-
|
|
131
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
109
132
|
requestedAt: s.m(DateTime$Reventless.schema)
|
|
110
133
|
})),
|
|
111
134
|
Sury.$schema(s => ({
|
|
112
135
|
TAG: "WithdrawRegistration",
|
|
113
|
-
|
|
136
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
114
137
|
withdrawnAt: s.m(DateTime$Reventless.schema)
|
|
138
|
+
})),
|
|
139
|
+
Sury.$schema(s => ({
|
|
140
|
+
TAG: "ReleaseRegistration",
|
|
141
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
142
|
+
releasedAt: s.m(DateTime$Reventless.schema)
|
|
115
143
|
}))
|
|
116
144
|
]);
|
|
117
145
|
|
|
@@ -126,57 +154,72 @@ let errorSchema = Sury.union([
|
|
|
126
154
|
let eventSchema = Sury.union([
|
|
127
155
|
Sury.$schema(s => ({
|
|
128
156
|
TAG: "RegistrationRequested",
|
|
129
|
-
|
|
157
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
158
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
130
159
|
roles: s.m(Sury.array(Sury.string)),
|
|
131
|
-
requestedAt: s.m(DateTime$Reventless.schema)
|
|
160
|
+
requestedAt: s.m(DateTime$Reventless.schema),
|
|
161
|
+
language: s.m(Sury.$option(Sury.string))
|
|
132
162
|
})),
|
|
133
163
|
Sury.$schema(s => ({
|
|
134
164
|
TAG: "RegistrationExpired",
|
|
135
|
-
|
|
165
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
|
|
136
166
|
})),
|
|
137
167
|
Sury.$schema(s => ({
|
|
138
168
|
TAG: "RegistrationInvited",
|
|
139
|
-
|
|
169
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
170
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
140
171
|
roles: s.m(Sury.array(Sury.string)),
|
|
141
172
|
invitedBy: s.m(Sury.string),
|
|
142
|
-
invitedAt: s.m(DateTime$Reventless.schema)
|
|
173
|
+
invitedAt: s.m(DateTime$Reventless.schema),
|
|
174
|
+
language: s.m(Sury.$option(Sury.string))
|
|
143
175
|
})),
|
|
144
176
|
Sury.$schema(s => ({
|
|
145
177
|
TAG: "RegistrationChallengeReissued",
|
|
146
|
-
|
|
178
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
179
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
147
180
|
reissuedAt: s.m(DateTime$Reventless.schema),
|
|
148
|
-
invitedBy: s.m(Sury.$option(Sury.string))
|
|
181
|
+
invitedBy: s.m(Sury.$option(Sury.string)),
|
|
182
|
+
language: s.m(Sury.$option(Sury.string))
|
|
149
183
|
})),
|
|
150
184
|
Sury.$schema(s => ({
|
|
151
185
|
TAG: "RegistrationWithdrawn",
|
|
152
|
-
|
|
186
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
153
187
|
withdrawnAt: s.m(DateTime$Reventless.schema)
|
|
154
188
|
})),
|
|
155
189
|
Sury.$schema(s => ({
|
|
156
190
|
TAG: "RegistrationAttemptedOnTakenAddress",
|
|
157
|
-
|
|
191
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
192
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
158
193
|
attemptedAt: s.m(DateTime$Reventless.schema)
|
|
159
194
|
})),
|
|
160
195
|
Sury.$schema(s => ({
|
|
161
196
|
TAG: "RegistrationChallengeIssued",
|
|
162
|
-
|
|
197
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
163
198
|
proofHash: s.m(Sury.string),
|
|
164
|
-
issuedAt: s.m(DateTime$Reventless.schema)
|
|
199
|
+
issuedAt: s.m(DateTime$Reventless.schema),
|
|
200
|
+
language: s.m(Sury.$option(Sury.string)),
|
|
201
|
+
messageKey: s.m(Sury.$option(Sury.string))
|
|
165
202
|
})),
|
|
166
203
|
Sury.$schema(s => ({
|
|
167
204
|
TAG: "RegistrationProofAccepted",
|
|
168
|
-
|
|
205
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
206
|
+
email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
|
|
169
207
|
roles: s.m(Sury.array(Sury.string)),
|
|
170
208
|
proofHash: s.m(Sury.string)
|
|
171
209
|
})),
|
|
172
210
|
Sury.$schema(s => ({
|
|
173
211
|
TAG: "RegistrationProofRefused",
|
|
174
|
-
|
|
212
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
175
213
|
reason: s.m(Sury.string)
|
|
176
214
|
})),
|
|
177
215
|
Sury.$schema(s => ({
|
|
178
216
|
TAG: "RegistrationCompleted",
|
|
179
|
-
|
|
217
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
|
|
218
|
+
})),
|
|
219
|
+
Sury.$schema(s => ({
|
|
220
|
+
TAG: "RegistrationReleased",
|
|
221
|
+
emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
|
|
222
|
+
releasedAt: s.m(DateTime$Reventless.schema)
|
|
180
223
|
}))
|
|
181
224
|
]);
|
|
182
225
|
|
|
@@ -187,7 +230,8 @@ let commandSchema$1 = Api$ReventlessInfra.markNoApiVariants(commandSchema, [
|
|
|
187
230
|
"RecordRegistrationCompleted",
|
|
188
231
|
"Invite",
|
|
189
232
|
"ReissueRegistrationChallenge",
|
|
190
|
-
"WithdrawRegistration"
|
|
233
|
+
"WithdrawRegistration",
|
|
234
|
+
"ReleaseRegistration"
|
|
191
235
|
]);
|
|
192
236
|
|
|
193
237
|
function authorizationOf(param) {
|
|
@@ -17,6 +17,9 @@ type policyState =
|
|
|
17
17
|
| Open(option<Reventless.DateTime.t>)
|
|
18
18
|
|
|
19
19
|
type pending = {
|
|
20
|
+
/** The address the claim was made for: where its code goes, and what an
|
|
21
|
+
accepted proof makes an account for. */
|
|
22
|
+
email: Reventless.Pii.t<Reventless.Email.t>,
|
|
20
23
|
/** When the claim was made, or its code last reissued: what a claim with no
|
|
21
24
|
challenge out lapses from. */
|
|
22
25
|
requestedAt: Reventless.DateTime.t,
|
|
@@ -24,6 +27,9 @@ type pending = {
|
|
|
24
27
|
roles: array<string>,
|
|
25
28
|
/** Who invited, for a claim an inviter made. */
|
|
26
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,
|
|
27
33
|
challenge: option<Guards.challenge>,
|
|
28
34
|
proofHash: option<string>,
|
|
29
35
|
}
|
|
@@ -50,6 +56,12 @@ let initialState = {admission: Unset, stage: Unclaimed, lastNoticeAt: None}
|
|
|
50
56
|
so the door cannot be used to flood a registered person's inbox. */
|
|
51
57
|
let noticeCooldown = 3600
|
|
52
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
|
+
|
|
53
65
|
let purposeOf = (p: pending) => RegistrationChallenge.purposeOf(~invitedBy=p.invitedBy)
|
|
54
66
|
|
|
55
67
|
/** The challenge rules a pending registration is held to: an invitation's code
|
|
@@ -60,27 +72,35 @@ let evolve = (state, event) =>
|
|
|
60
72
|
switch event {
|
|
61
73
|
| RegistrationOpened({?until}) => {...state, admission: Open(until)}
|
|
62
74
|
| RegistrationClosed(_) => {...state, admission: Closed}
|
|
63
|
-
| RegistrationRequested({roles, requestedAt}) => {
|
|
75
|
+
| RegistrationRequested({email, roles, requestedAt, ?language}) => {
|
|
64
76
|
...state,
|
|
65
|
-
stage: Pending({requestedAt, roles, challenge: None, proofHash: None}),
|
|
77
|
+
stage: Pending({email, requestedAt, roles, ?language, challenge: None, proofHash: None}),
|
|
66
78
|
}
|
|
67
|
-
| RegistrationInvited({roles, invitedBy, invitedAt}) => {
|
|
79
|
+
| RegistrationInvited({email, roles, invitedBy, invitedAt, ?language}) => {
|
|
68
80
|
...state,
|
|
69
|
-
stage: Pending({
|
|
81
|
+
stage: Pending({
|
|
82
|
+
email,
|
|
83
|
+
requestedAt: invitedAt,
|
|
84
|
+
roles,
|
|
85
|
+
invitedBy,
|
|
86
|
+
?language,
|
|
87
|
+
challenge: None,
|
|
88
|
+
proofHash: None,
|
|
89
|
+
}),
|
|
70
90
|
}
|
|
71
91
|
| RegistrationExpired(_) | RegistrationWithdrawn(_) => {...state, stage: Unclaimed}
|
|
72
92
|
| RegistrationAttemptedOnTakenAddress({attemptedAt}) => {
|
|
73
93
|
...state,
|
|
74
94
|
lastNoticeAt: Some(attemptedAt),
|
|
75
95
|
}
|
|
76
|
-
| RegistrationChallengeIssued({
|
|
96
|
+
| RegistrationChallengeIssued({emailId, proofHash, issuedAt}) =>
|
|
77
97
|
switch state.stage {
|
|
78
98
|
| Pending(p) => {
|
|
79
99
|
...state,
|
|
80
100
|
stage: Pending({
|
|
81
101
|
...p,
|
|
82
102
|
challenge: Some({
|
|
83
|
-
contact:
|
|
103
|
+
contact: contactOf(emailId),
|
|
84
104
|
purpose: purposeOf(p),
|
|
85
105
|
issuedAt,
|
|
86
106
|
attempts: 0,
|
|
@@ -112,6 +132,9 @@ let evolve = (state, event) =>
|
|
|
112
132
|
}
|
|
113
133
|
| RegistrationProofAccepted(_) => {...state, stage: Verified}
|
|
114
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}
|
|
115
138
|
}
|
|
116
139
|
|
|
117
140
|
/** Whether the policy admits a registration for `role` that arrived at `at`.
|
|
@@ -166,7 +189,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
|
|
|
166
189
|
// decision: the policy is consulted before the address, so a closed
|
|
167
190
|
// deployment sends nothing — not even the notice to an address that is
|
|
168
191
|
// already registered.
|
|
169
|
-
| Register({email, role, requestedAt}) =>
|
|
192
|
+
| Register({emailId, email, role, requestedAt, ?language}) =>
|
|
170
193
|
if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt) {
|
|
171
194
|
Ok([])
|
|
172
195
|
} else {
|
|
@@ -177,54 +200,65 @@ module Make = (App: Reventless.Admission.Declaration) => {
|
|
|
177
200
|
switch state.lastNoticeAt {
|
|
178
201
|
| Some(last) if Guards.elapsedSeconds(~from=last, ~to_=requestedAt) < noticeCooldown =>
|
|
179
202
|
Ok([])
|
|
180
|
-
| _ =>
|
|
203
|
+
| _ =>
|
|
204
|
+
Ok([
|
|
205
|
+
RegistrationAttemptedOnTakenAddress({
|
|
206
|
+
emailId,
|
|
207
|
+
email: Value(email),
|
|
208
|
+
attemptedAt: requestedAt,
|
|
209
|
+
}),
|
|
210
|
+
])
|
|
181
211
|
}
|
|
182
212
|
| Verified => Ok([])
|
|
183
213
|
// A visitor cannot take over a claim, an inviter's included, while it holds.
|
|
184
214
|
| Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
|
|
185
215
|
| Pending(_) =>
|
|
186
216
|
Ok([
|
|
187
|
-
RegistrationExpired({
|
|
188
|
-
RegistrationRequested({email, roles, requestedAt}),
|
|
217
|
+
RegistrationExpired({emailId: emailId}),
|
|
218
|
+
RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language}),
|
|
189
219
|
])
|
|
190
|
-
| Unclaimed =>
|
|
220
|
+
| Unclaimed =>
|
|
221
|
+
Ok([RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language})])
|
|
191
222
|
}
|
|
192
223
|
}
|
|
193
224
|
|
|
194
225
|
// The policy is not consulted: it says whether visitors may sign themselves
|
|
195
226
|
// up, and an invitation is not that. The table is, because it is the hard
|
|
196
227
|
// cap on how each role is admitted.
|
|
197
|
-
| Invite({email, roles, invitedBy, requestedAt}) =>
|
|
228
|
+
| Invite({emailId, email, roles, invitedBy, requestedAt, ?language}) =>
|
|
198
229
|
switch roles->Array.find(r => !isByInvitation(App.table, r)) {
|
|
199
230
|
| Some(role) => Error(NotByInvitation({role: (role :> string)}))
|
|
200
231
|
| None if roles == [] => Error(NoRoleToGrant)
|
|
201
232
|
| None =>
|
|
202
233
|
let invited = RegistrationInvited({
|
|
203
|
-
|
|
234
|
+
emailId,
|
|
235
|
+
email: Value(email),
|
|
204
236
|
roles: roles->Array.map(r => (r :> string)),
|
|
205
237
|
invitedBy,
|
|
206
238
|
invitedAt: requestedAt,
|
|
239
|
+
?language,
|
|
207
240
|
})
|
|
208
241
|
switch state.stage {
|
|
209
242
|
// An address that holds an account, or is about to, is not registered
|
|
210
243
|
// twice; granting it roles is not registration.
|
|
211
244
|
| Completed | Verified => Ok([])
|
|
212
245
|
| Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
|
|
213
|
-
| Pending(_) => Ok([RegistrationExpired({
|
|
246
|
+
| Pending(_) => Ok([RegistrationExpired({emailId: emailId}), invited])
|
|
214
247
|
| Unclaimed => Ok([invited])
|
|
215
248
|
}
|
|
216
249
|
}
|
|
217
250
|
|
|
218
|
-
| IssueRegistrationChallenge({
|
|
251
|
+
| IssueRegistrationChallenge({emailId, proofHash, issuedAt, ?language, ?messageKey}) =>
|
|
219
252
|
switch state.stage {
|
|
220
253
|
| Pending(p) =>
|
|
221
254
|
switch Guards.onIssueRequested(
|
|
222
|
-
~contact=
|
|
255
|
+
~contact=contactOf(emailId),
|
|
223
256
|
~existing=p.challenge,
|
|
224
257
|
~now=issuedAt,
|
|
225
258
|
~policy=policyOf(p),
|
|
226
259
|
) {
|
|
227
|
-
| Issue =>
|
|
260
|
+
| Issue =>
|
|
261
|
+
Ok([RegistrationChallengeIssued({emailId, proofHash, issuedAt, ?language, ?messageKey})])
|
|
228
262
|
// A redelivered request mints nothing, and because nothing is emitted,
|
|
229
263
|
// sends nothing either.
|
|
230
264
|
| AlreadyOpen => Ok([])
|
|
@@ -236,18 +270,24 @@ module Make = (App: Reventless.Admission.Declaration) => {
|
|
|
236
270
|
// replaced by a second in flight, and the first to arrive would be the one
|
|
237
271
|
// recorded. And not twice within the resend cooldown, so a door that
|
|
238
272
|
// reaches this cannot be used to flood an inbox.
|
|
239
|
-
| ReissueRegistrationChallenge({
|
|
273
|
+
| ReissueRegistrationChallenge({emailId, requestedAt}) =>
|
|
240
274
|
switch state.stage {
|
|
241
275
|
| Pending({challenge: Some(c)} as p)
|
|
242
276
|
if Guards.elapsedSeconds(~from=c.issuedAt, ~to_=requestedAt) >=
|
|
243
277
|
policyOf(p).resendCooldown =>
|
|
244
278
|
Ok([
|
|
245
|
-
RegistrationChallengeReissued({
|
|
279
|
+
RegistrationChallengeReissued({
|
|
280
|
+
emailId,
|
|
281
|
+
email: p.email,
|
|
282
|
+
reissuedAt: requestedAt,
|
|
283
|
+
invitedBy: ?p.invitedBy,
|
|
284
|
+
language: ?p.language,
|
|
285
|
+
}),
|
|
246
286
|
])
|
|
247
287
|
| _ => Ok([])
|
|
248
288
|
}
|
|
249
289
|
|
|
250
|
-
| SubmitRegistrationProof({
|
|
290
|
+
| SubmitRegistrationProof({emailId, proofHash, presentedAt}) =>
|
|
251
291
|
switch state.stage {
|
|
252
292
|
| Pending({challenge: Some(c), proofHash: Some(held), roles} as p) =>
|
|
253
293
|
switch Guards.onProofPresented(
|
|
@@ -257,8 +297,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
|
|
|
257
297
|
~now=presentedAt,
|
|
258
298
|
~policy=policyOf(p),
|
|
259
299
|
) {
|
|
260
|
-
| Settle => Ok([RegistrationProofAccepted({email, roles, proofHash})])
|
|
261
|
-
| Refuse(reason) => Ok([RegistrationProofRefused({
|
|
300
|
+
| Settle => Ok([RegistrationProofAccepted({emailId, email: p.email, roles, proofHash})])
|
|
301
|
+
| Refuse(reason) => Ok([RegistrationProofRefused({emailId, reason: refusalReason(reason)})])
|
|
262
302
|
}
|
|
263
303
|
// No challenge to answer: nothing to count it against, and nothing to say.
|
|
264
304
|
| _ => Ok([])
|
|
@@ -266,15 +306,23 @@ module Make = (App: Reventless.Admission.Declaration) => {
|
|
|
266
306
|
|
|
267
307
|
// Only a claim nobody has proved: once a proof settled, an account is on
|
|
268
308
|
// its way, and withdrawing the claim would not stop it.
|
|
269
|
-
| WithdrawRegistration({
|
|
309
|
+
| WithdrawRegistration({emailId, withdrawnAt}) =>
|
|
270
310
|
switch state.stage {
|
|
271
|
-
| Pending(_) => Ok([RegistrationWithdrawn({
|
|
311
|
+
| Pending(_) => Ok([RegistrationWithdrawn({emailId, withdrawnAt})])
|
|
272
312
|
| Unclaimed | Verified | Completed => Ok([])
|
|
273
313
|
}
|
|
274
314
|
|
|
275
|
-
|
|
315
|
+
// Only an account: a claim nobody proved is withdrawn, and one being turned
|
|
316
|
+
// into an account is released once the account exists and is erased.
|
|
317
|
+
| ReleaseRegistration({emailId, releasedAt}) =>
|
|
318
|
+
switch state.stage {
|
|
319
|
+
| Completed => Ok([RegistrationReleased({emailId, releasedAt})])
|
|
320
|
+
| Unclaimed | Pending(_) | Verified => Ok([])
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
| RecordRegistrationCompleted({emailId}) =>
|
|
276
324
|
switch state.stage {
|
|
277
|
-
| Verified => Ok([RegistrationCompleted({
|
|
325
|
+
| Verified => Ok([RegistrationCompleted({emailId: emailId})])
|
|
278
326
|
| _ => Ok([])
|
|
279
327
|
}
|
|
280
328
|
}
|