@reventlessdev/reventless-registration 1.0.0-alpha.20 → 1.0.0-alpha.22

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 (21) hide show
  1. package/package.json +5 -5
  2. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  3. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +2 -2
  4. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +1 -1
  5. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +1 -1
  6. package/src/Registration/InboundTranslation/SignUp.res +3 -3
  7. package/src/Registration/InboundTranslation/SignUp.res.mjs +4 -3
  8. package/src/Registration/InboundTranslation/SignUp_Translation.res +5 -5
  9. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +4 -4
  10. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +5 -5
  11. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +5 -5
  12. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +8 -8
  13. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +12 -12
  14. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +12 -12
  15. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +11 -11
  16. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +18 -18
  17. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +30 -30
  18. package/src/Registration/StateChange/Registrations.res +44 -44
  19. package/src/Registration/StateChange/Registrations.res.mjs +42 -42
  20. package/src/Registration/StateChange/Registrations_Decision.res +34 -34
  21. package/src/Registration/StateChange/Registrations_Decision.res.mjs +33 -33
@@ -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.Pii.t<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,
@@ -55,8 +55,8 @@ let noticeCooldown = 3600
55
55
 
56
56
  /** The contact a challenge is held against. The guards only compare it, so the
57
57
  ledger's id for the address serves, and no address is needed to decide. */
58
- let contactOf = (email: ContactAddressId.t): ContactVerification.contact => ByEmail(
59
- Reventless.Email.unsafe(email->ContactAddressId.toString),
58
+ let contactOf = (emailId: ContactAddressId.t): ContactVerification.contact => ByEmail(
59
+ Reventless.Email.unsafe(emailId->ContactAddressId.toString),
60
60
  )
61
61
 
62
62
  let purposeOf = (p: pending) => RegistrationChallenge.purposeOf(~invitedBy=p.invitedBy)
@@ -69,14 +69,14 @@ let evolve = (state, event) =>
69
69
  switch event {
70
70
  | RegistrationOpened({?until}) => {...state, admission: Open(until)}
71
71
  | RegistrationClosed(_) => {...state, admission: Closed}
72
- | RegistrationRequested({address, roles, requestedAt}) => {
72
+ | RegistrationRequested({email, roles, requestedAt}) => {
73
73
  ...state,
74
- stage: Pending({address, requestedAt, roles, challenge: None, proofHash: None}),
74
+ stage: Pending({email, requestedAt, roles, challenge: None, proofHash: None}),
75
75
  }
76
- | RegistrationInvited({address, roles, invitedBy, invitedAt}) => {
76
+ | RegistrationInvited({email, roles, invitedBy, invitedAt}) => {
77
77
  ...state,
78
78
  stage: Pending({
79
- address,
79
+ email,
80
80
  requestedAt: invitedAt,
81
81
  roles,
82
82
  invitedBy,
@@ -89,14 +89,14 @@ let evolve = (state, event) =>
89
89
  ...state,
90
90
  lastNoticeAt: Some(attemptedAt),
91
91
  }
92
- | RegistrationChallengeIssued({email, proofHash, issuedAt}) =>
92
+ | RegistrationChallengeIssued({emailId, proofHash, issuedAt}) =>
93
93
  switch state.stage {
94
94
  | Pending(p) => {
95
95
  ...state,
96
96
  stage: Pending({
97
97
  ...p,
98
98
  challenge: Some({
99
- contact: contactOf(email),
99
+ contact: contactOf(emailId),
100
100
  purpose: purposeOf(p),
101
101
  issuedAt,
102
102
  attempts: 0,
@@ -185,7 +185,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
185
185
  // decision: the policy is consulted before the address, so a closed
186
186
  // deployment sends nothing — not even the notice to an address that is
187
187
  // already registered.
188
- | Register({email, address, role, requestedAt}) =>
188
+ | Register({emailId, email, role, requestedAt}) =>
189
189
  if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt) {
190
190
  Ok([])
191
191
  } else {
@@ -199,8 +199,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
199
199
  | _ =>
200
200
  Ok([
201
201
  RegistrationAttemptedOnTakenAddress({
202
- email,
203
- address: Value(address),
202
+ emailId,
203
+ email: Value(email),
204
204
  attemptedAt: requestedAt,
205
205
  }),
206
206
  ])
@@ -210,25 +210,25 @@ module Make = (App: Reventless.Admission.Declaration) => {
210
210
  | Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
211
211
  | Pending(_) =>
212
212
  Ok([
213
- RegistrationExpired({email: email}),
214
- RegistrationRequested({email, address: Value(address), roles, requestedAt}),
213
+ RegistrationExpired({emailId: emailId}),
214
+ RegistrationRequested({emailId, email: Value(email), roles, requestedAt}),
215
215
  ])
216
216
  | Unclaimed =>
217
- Ok([RegistrationRequested({email, address: Value(address), roles, requestedAt})])
217
+ Ok([RegistrationRequested({emailId, email: Value(email), roles, requestedAt})])
218
218
  }
219
219
  }
220
220
 
221
221
  // The policy is not consulted: it says whether visitors may sign themselves
222
222
  // up, and an invitation is not that. The table is, because it is the hard
223
223
  // cap on how each role is admitted.
224
- | Invite({email, address, roles, invitedBy, requestedAt}) =>
224
+ | Invite({emailId, email, roles, invitedBy, requestedAt}) =>
225
225
  switch roles->Array.find(r => !isByInvitation(App.table, r)) {
226
226
  | Some(role) => Error(NotByInvitation({role: (role :> string)}))
227
227
  | None if roles == [] => Error(NoRoleToGrant)
228
228
  | None =>
229
229
  let invited = RegistrationInvited({
230
- email,
231
- address: Value(address),
230
+ emailId,
231
+ email: Value(email),
232
232
  roles: roles->Array.map(r => (r :> string)),
233
233
  invitedBy,
234
234
  invitedAt: requestedAt,
@@ -238,21 +238,21 @@ module Make = (App: Reventless.Admission.Declaration) => {
238
238
  // twice; granting it roles is not registration.
239
239
  | Completed | Verified => Ok([])
240
240
  | Pending(p) if !hasLapsed(p, ~now=requestedAt) => Ok([])
241
- | Pending(_) => Ok([RegistrationExpired({email: email}), invited])
241
+ | Pending(_) => Ok([RegistrationExpired({emailId: emailId}), invited])
242
242
  | Unclaimed => Ok([invited])
243
243
  }
244
244
  }
245
245
 
246
- | IssueRegistrationChallenge({email, proofHash, issuedAt}) =>
246
+ | IssueRegistrationChallenge({emailId, proofHash, issuedAt}) =>
247
247
  switch state.stage {
248
248
  | Pending(p) =>
249
249
  switch Guards.onIssueRequested(
250
- ~contact=contactOf(email),
250
+ ~contact=contactOf(emailId),
251
251
  ~existing=p.challenge,
252
252
  ~now=issuedAt,
253
253
  ~policy=policyOf(p),
254
254
  ) {
255
- | Issue => Ok([RegistrationChallengeIssued({email, proofHash, issuedAt})])
255
+ | Issue => Ok([RegistrationChallengeIssued({emailId, proofHash, issuedAt})])
256
256
  // A redelivered request mints nothing, and because nothing is emitted,
257
257
  // sends nothing either.
258
258
  | AlreadyOpen => Ok([])
@@ -264,15 +264,15 @@ module Make = (App: Reventless.Admission.Declaration) => {
264
264
  // replaced by a second in flight, and the first to arrive would be the one
265
265
  // recorded. And not twice within the resend cooldown, so a door that
266
266
  // reaches this cannot be used to flood an inbox.
267
- | ReissueRegistrationChallenge({email, requestedAt}) =>
267
+ | ReissueRegistrationChallenge({emailId, requestedAt}) =>
268
268
  switch state.stage {
269
269
  | Pending({challenge: Some(c)} as p)
270
270
  if Guards.elapsedSeconds(~from=c.issuedAt, ~to_=requestedAt) >=
271
271
  policyOf(p).resendCooldown =>
272
272
  Ok([
273
273
  RegistrationChallengeReissued({
274
- email,
275
- address: p.address,
274
+ emailId,
275
+ email: p.email,
276
276
  reissuedAt: requestedAt,
277
277
  invitedBy: ?p.invitedBy,
278
278
  }),
@@ -280,7 +280,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
280
280
  | _ => Ok([])
281
281
  }
282
282
 
283
- | SubmitRegistrationProof({email, proofHash, presentedAt}) =>
283
+ | SubmitRegistrationProof({emailId, proofHash, presentedAt}) =>
284
284
  switch state.stage {
285
285
  | Pending({challenge: Some(c), proofHash: Some(held), roles} as p) =>
286
286
  switch Guards.onProofPresented(
@@ -290,8 +290,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
290
290
  ~now=presentedAt,
291
291
  ~policy=policyOf(p),
292
292
  ) {
293
- | Settle => Ok([RegistrationProofAccepted({email, address: p.address, roles, proofHash})])
294
- | Refuse(reason) => Ok([RegistrationProofRefused({email, reason: refusalReason(reason)})])
293
+ | Settle => Ok([RegistrationProofAccepted({emailId, email: p.email, roles, proofHash})])
294
+ | Refuse(reason) => Ok([RegistrationProofRefused({emailId, reason: refusalReason(reason)})])
295
295
  }
296
296
  // No challenge to answer: nothing to count it against, and nothing to say.
297
297
  | _ => Ok([])
@@ -299,23 +299,23 @@ module Make = (App: Reventless.Admission.Declaration) => {
299
299
 
300
300
  // Only a claim nobody has proved: once a proof settled, an account is on
301
301
  // its way, and withdrawing the claim would not stop it.
302
- | WithdrawRegistration({email, withdrawnAt}) =>
302
+ | WithdrawRegistration({emailId, withdrawnAt}) =>
303
303
  switch state.stage {
304
- | Pending(_) => Ok([RegistrationWithdrawn({email, withdrawnAt})])
304
+ | Pending(_) => Ok([RegistrationWithdrawn({emailId, withdrawnAt})])
305
305
  | Unclaimed | Verified | Completed => Ok([])
306
306
  }
307
307
 
308
308
  // Only an account: a claim nobody proved is withdrawn, and one being turned
309
309
  // into an account is released once the account exists and is erased.
310
- | ReleaseRegistration({email, releasedAt}) =>
310
+ | ReleaseRegistration({emailId, releasedAt}) =>
311
311
  switch state.stage {
312
- | Completed => Ok([RegistrationReleased({email, releasedAt})])
312
+ | Completed => Ok([RegistrationReleased({emailId, releasedAt})])
313
313
  | Unclaimed | Pending(_) | Verified => Ok([])
314
314
  }
315
315
 
316
- | RecordRegistrationCompleted({email}) =>
316
+ | RecordRegistrationCompleted({emailId}) =>
317
317
  switch state.stage {
318
- | Verified => Ok([RegistrationCompleted({email: email})])
318
+ | Verified => Ok([RegistrationCompleted({emailId: emailId})])
319
319
  | _ => Ok([])
320
320
  }
321
321
  }
@@ -14,10 +14,10 @@ let initialState = {
14
14
  lastNoticeAt: undefined
15
15
  };
16
16
 
17
- function contactOf(email) {
17
+ function contactOf(emailId) {
18
18
  return {
19
19
  TAG: "ByEmail",
20
- _0: ContactAddressId$ReventlessRegistration.toString(email)
20
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId)
21
21
  };
22
22
  }
23
23
 
@@ -52,7 +52,7 @@ function evolve(state, event) {
52
52
  stage: {
53
53
  TAG: "Pending",
54
54
  _0: {
55
- address: event.address,
55
+ email: event.email,
56
56
  requestedAt: event.requestedAt,
57
57
  roles: event.roles,
58
58
  challenge: undefined,
@@ -67,7 +67,7 @@ function evolve(state, event) {
67
67
  stage: {
68
68
  TAG: "Pending",
69
69
  _0: {
70
- address: event.address,
70
+ email: event.email,
71
71
  requestedAt: event.invitedAt,
72
72
  roles: event.roles,
73
73
  invitedBy: event.invitedBy,
@@ -118,7 +118,7 @@ function evolve(state, event) {
118
118
  _0: (newrecord$1.proofHash = event.proofHash, newrecord$1.challenge = {
119
119
  contact: {
120
120
  TAG: "ByEmail",
121
- _0: ContactAddressId$ReventlessRegistration.toString(event.email)
121
+ _0: ContactAddressId$ReventlessRegistration.toString(event.emailId)
122
122
  },
123
123
  purpose: RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy),
124
124
  issuedAt: event.issuedAt,
@@ -225,8 +225,8 @@ function Make(App) {
225
225
  case "Register" :
226
226
  let requestedAt = command.requestedAt;
227
227
  let role = command.role;
228
- let address = command.address;
229
228
  let email = command.email;
229
+ let emailId = command.emailId;
230
230
  if (!admits(state.admission, App.table, role, requestedAt)) {
231
231
  return {
232
232
  TAG: "Ok",
@@ -242,14 +242,14 @@ function Make(App) {
242
242
  _0: [
243
243
  {
244
244
  TAG: "RegistrationExpired",
245
- email: email
245
+ emailId: emailId
246
246
  },
247
247
  {
248
248
  TAG: "RegistrationRequested",
249
- email: email,
250
- address: {
249
+ emailId: emailId,
250
+ email: {
251
251
  TAG: "Value",
252
- _0: address
252
+ _0: email
253
253
  },
254
254
  roles: roles,
255
255
  requestedAt: requestedAt
@@ -269,10 +269,10 @@ function Make(App) {
269
269
  TAG: "Ok",
270
270
  _0: [{
271
271
  TAG: "RegistrationRequested",
272
- email: email,
273
- address: {
272
+ emailId: emailId,
273
+ email: {
274
274
  TAG: "Value",
275
- _0: address
275
+ _0: email
276
276
  },
277
277
  roles: roles,
278
278
  requestedAt: requestedAt
@@ -295,10 +295,10 @@ function Make(App) {
295
295
  TAG: "Ok",
296
296
  _0: [{
297
297
  TAG: "RegistrationAttemptedOnTakenAddress",
298
- email: email,
299
- address: {
298
+ emailId: emailId,
299
+ email: {
300
300
  TAG: "Value",
301
- _0: address
301
+ _0: email
302
302
  },
303
303
  attemptedAt: requestedAt
304
304
  }]
@@ -307,7 +307,7 @@ function Make(App) {
307
307
  break;
308
308
  case "IssueRegistrationChallenge" :
309
309
  let issuedAt = command.issuedAt;
310
- let email$1 = command.email;
310
+ let emailId$1 = command.emailId;
311
311
  let p$1 = state.stage;
312
312
  if (typeof p$1 !== "object") {
313
313
  return {
@@ -318,14 +318,14 @@ function Make(App) {
318
318
  let p$2 = p$1._0;
319
319
  let match = ContactVerification_Guards$ReventlessRegistration.onIssueRequested({
320
320
  TAG: "ByEmail",
321
- _0: ContactAddressId$ReventlessRegistration.toString(email$1)
321
+ _0: ContactAddressId$ReventlessRegistration.toString(emailId$1)
322
322
  }, p$2.challenge, issuedAt, RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy)));
323
323
  if (match === "Issue") {
324
324
  return {
325
325
  TAG: "Ok",
326
326
  _0: [{
327
327
  TAG: "RegistrationChallengeIssued",
328
- email: email$1,
328
+ emailId: emailId$1,
329
329
  proofHash: command.proofHash,
330
330
  issuedAt: issuedAt
331
331
  }]
@@ -338,7 +338,7 @@ function Make(App) {
338
338
  }
339
339
  case "SubmitRegistrationProof" :
340
340
  let proofHash = command.proofHash;
341
- let email$2 = command.email;
341
+ let emailId$2 = command.emailId;
342
342
  let p$3 = state.stage;
343
343
  if (typeof p$3 !== "object") {
344
344
  return {
@@ -367,8 +367,8 @@ function Make(App) {
367
367
  TAG: "Ok",
368
368
  _0: [{
369
369
  TAG: "RegistrationProofAccepted",
370
- email: email$2,
371
- address: p$4.address,
370
+ emailId: emailId$2,
371
+ email: p$4.email,
372
372
  roles: p$4.roles,
373
373
  proofHash: proofHash
374
374
  }]
@@ -378,7 +378,7 @@ function Make(App) {
378
378
  TAG: "Ok",
379
379
  _0: [{
380
380
  TAG: "RegistrationProofRefused",
381
- email: email$2,
381
+ emailId: emailId$2,
382
382
  reason: refusalReason(reason._0)
383
383
  }]
384
384
  };
@@ -391,7 +391,7 @@ function Make(App) {
391
391
  TAG: "Ok",
392
392
  _0: [{
393
393
  TAG: "RegistrationCompleted",
394
- email: command.email
394
+ emailId: command.emailId
395
395
  }]
396
396
  };
397
397
  } else {
@@ -409,7 +409,7 @@ function Make(App) {
409
409
  case "Invite" :
410
410
  let requestedAt$1 = command.requestedAt;
411
411
  let roles$1 = command.roles;
412
- let email$3 = command.email;
412
+ let emailId$3 = command.emailId;
413
413
  let role$1 = roles$1.find(r => !isByInvitation(App.table, r));
414
414
  if (role$1 !== undefined) {
415
415
  return {
@@ -428,14 +428,14 @@ function Make(App) {
428
428
  }
429
429
  let invited_1 = {
430
430
  TAG: "Value",
431
- _0: command.address
431
+ _0: command.email
432
432
  };
433
433
  let invited_2 = roles$1.map(r => r);
434
434
  let invited_3 = command.invitedBy;
435
435
  let invited = {
436
436
  TAG: "RegistrationInvited",
437
- email: email$3,
438
- address: invited_1,
437
+ emailId: emailId$3,
438
+ email: invited_1,
439
439
  roles: invited_2,
440
440
  invitedBy: invited_3,
441
441
  invitedAt: requestedAt$1
@@ -448,7 +448,7 @@ function Make(App) {
448
448
  _0: [
449
449
  {
450
450
  TAG: "RegistrationExpired",
451
- email: email$3
451
+ emailId: emailId$3
452
452
  },
453
453
  invited
454
454
  ]
@@ -490,8 +490,8 @@ function Make(App) {
490
490
  TAG: "Ok",
491
491
  _0: [{
492
492
  TAG: "RegistrationChallengeReissued",
493
- email: command.email,
494
- address: p$7.address,
493
+ emailId: command.emailId,
494
+ email: p$7.email,
495
495
  reissuedAt: requestedAt$2,
496
496
  invitedBy: p$7.invitedBy
497
497
  }]
@@ -520,7 +520,7 @@ function Make(App) {
520
520
  TAG: "Ok",
521
521
  _0: [{
522
522
  TAG: "RegistrationWithdrawn",
523
- email: command.email,
523
+ emailId: command.emailId,
524
524
  withdrawnAt: command.withdrawnAt
525
525
  }]
526
526
  };
@@ -533,7 +533,7 @@ function Make(App) {
533
533
  TAG: "Ok",
534
534
  _0: [{
535
535
  TAG: "RegistrationReleased",
536
- email: command.email,
536
+ emailId: command.emailId,
537
537
  releasedAt: command.releasedAt
538
538
  }]
539
539
  };