@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
package/rescript.json CHANGED
@@ -16,12 +16,17 @@
16
16
  {
17
17
  "dir": "src",
18
18
  "subdirs": true
19
+ },
20
+ {
21
+ "dir": "conformance",
22
+ "subdirs": true
19
23
  }
20
24
  ],
21
25
  "dependencies": [
22
26
  "sury",
23
27
  "@reventlessdev/reventless-spec",
24
- "@reventlessdev/reventless-infra"
28
+ "@reventlessdev/reventless-infra",
29
+ "@reventlessdev/reventless-gwt"
25
30
  ],
26
31
  "compiler-flags": [],
27
32
  "suffix": ".res.mjs"
@@ -15,7 +15,7 @@
15
15
 
16
16
  @schema
17
17
  type externalInput = {
18
- email: string,
18
+ @sensitive email: string,
19
19
  @sensitive proof: string,
20
20
  @sensitive password: string,
21
21
  }
@@ -23,7 +23,7 @@ type externalInput = {
23
23
  @schema
24
24
  type command =
25
25
  | SubmitRegistrationProof({
26
- email: ContactAddressId.t,
26
+ emailId: ContactAddressId.t,
27
27
  proofHash: string,
28
28
  presentedAt: Reventless.DateTime.t,
29
29
  })
@@ -7,14 +7,14 @@ import * as Sensitive$Reventless from "@reventlessdev/reventless-spec/src/compon
7
7
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
8
8
 
9
9
  let externalInputSchema = Sury.$schema(s => ({
10
- email: s.m(Sury.string),
10
+ email: s.m(Sensitive$Reventless.string),
11
11
  proof: s.m(Sensitive$Reventless.string),
12
12
  password: s.m(Sensitive$Reventless.string)
13
13
  }));
14
14
 
15
15
  let commandSchema = Sury.$schema(s => ({
16
16
  TAG: "SubmitRegistrationProof",
17
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
17
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
18
18
  proofHash: s.m(Sury.string),
19
19
  presentedAt: s.m(DateTime$Reventless.schema)
20
20
  }));
@@ -33,7 +33,7 @@ let Id;
33
33
 
34
34
  let targetName = "Registrations";
35
35
 
36
- let admissionDoor = "Complete";
36
+ let admissionDoor = "complete";
37
37
 
38
38
  let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/InboundTranslation/CompleteRegistration.res.mjs";
39
39
 
@@ -32,7 +32,7 @@ let translate = async (
32
32
  (
33
33
  id->ContactAddressId.toString,
34
34
  SubmitRegistrationProof({
35
- email: id,
35
+ emailId: id,
36
36
  proofHash,
37
37
  presentedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
38
38
  }),
@@ -42,7 +42,7 @@ async function translate(input, capabilities, param) {
42
42
  ContactAddressId$ReventlessRegistration.toString(id),
43
43
  {
44
44
  TAG: "SubmitRegistrationProof",
45
- email: id,
45
+ emailId: id,
46
46
  proofHash: proofHash,
47
47
  presentedAt: new Date().toISOString()
48
48
  }
@@ -7,30 +7,40 @@
7
7
  // learns none of it: a closed role, a role no visitor may have, a taken address
8
8
  // and a fresh one all answer alike.
9
9
  //
10
- // Anonymous because the caller is trying to become someone. The local platform
11
- // honors that; a deployed one refuses the rule until it has a door of its own,
12
- // which is why a plugin listing these slices is hosted by the local platform
13
- // only.
10
+ // First it asks the person check whether a person sent the request; a missing,
11
+ // failed or unanswerable check relays nothing and says so, which names no address.
12
+ //
13
+ // Anonymous because the caller is trying to become someone. A deployed platform
14
+ // hosts it on a door for visitors, with its guards.
14
15
 
15
16
  @@reventless.spec
16
17
  @@reventless.authorize(AllowAnonymous)
17
18
 
18
19
  /** `role` may be left out where exactly one role is open to visitors; with
19
- several, a sign-up has to say which. */
20
+ several, a sign-up has to say which. `language` is the one the visitor reads the
21
+ shell in, which their mails are written in where the deployment offers it.
22
+ `personCheck` is the token of the widget the deployment names, if it names one. */
20
23
  @schema
21
- type externalInput = {email: string, role?: string}
24
+ type externalInput = {
25
+ @sensitive email: string,
26
+ role?: string,
27
+ language?: string,
28
+ @sensitive personCheck?: string,
29
+ }
22
30
 
23
31
  @schema
24
32
  type command =
25
33
  | Register({
26
- email: ContactAddressId.t,
27
- address: Reventless.Email.t,
34
+ emailId: ContactAddressId.t,
35
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
28
36
  role: Reventless.Role.name,
29
37
  requestedAt: Reventless.DateTime.t,
38
+ language?: string,
39
+ initially?: @s.matches(Reventless.Admission.initiallySchema) Reventless.Admission.initially,
30
40
  })
31
41
 
32
42
  let targetName = "Registrations"
33
- let capabilityNeeds: array<Reventless.CapabilityNeed.t> = []
43
+ let capabilityNeeds = [Reventless.CapabilityNeed.PersonCheck]
34
44
 
35
45
  /** This door starts a registration; the platform tells the shell so. */
36
46
  let admissionDoor = Reventless.Admission.Start
@@ -1,26 +1,33 @@
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";
5
6
  import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
6
7
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
7
8
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
9
+ import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
10
+ import * as Sensitive$Reventless from "@reventlessdev/reventless-spec/src/components/Sensitive.res.mjs";
8
11
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
9
12
 
10
13
  let externalInputSchema = Sury.$schema(s => ({
11
- email: s.m(Sury.string),
12
- role: s.m(Sury.$option(Sury.string))
14
+ email: s.m(Sensitive$Reventless.string),
15
+ role: s.m(Sury.$option(Sury.string)),
16
+ language: s.m(Sury.$option(Sury.string)),
17
+ personCheck: s.m(Sury.$option(Sensitive$Reventless.string))
13
18
  }));
14
19
 
15
20
  let commandSchema = Sury.$schema(s => ({
16
21
  TAG: "Register",
17
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
18
- address: s.m(Email$Reventless.schema),
22
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
23
+ email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
19
24
  role: s.m(Role$Reventless.nameSchema),
20
- requestedAt: s.m(DateTime$Reventless.schema)
25
+ requestedAt: s.m(DateTime$Reventless.schema),
26
+ language: s.m(Sury.$option(Sury.string)),
27
+ initially: s.m(Sury.$option(Admission$Reventless.initiallySchema))
21
28
  }));
22
29
 
23
- let capabilityNeeds = [];
30
+ let capabilityNeeds = ["PersonCheck"];
24
31
 
25
32
  function authorizationOf(param) {
26
33
  return "AllowAnonymous";
@@ -34,7 +41,7 @@ let Id;
34
41
 
35
42
  let targetName = "Registrations";
36
43
 
37
- let admissionDoor = "Start";
44
+ let admissionDoor = "start";
38
45
 
39
46
  let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/InboundTranslation/SignUp.res.mjs";
40
47
 
@@ -8,6 +8,23 @@ let defaultRole = (table: Reventless.Admission.t): option<Reventless.Role.name>
8
8
  | _ => None
9
9
  }
10
10
 
11
+ /** A language tag as a request gave it, or none where it does not look like one: it only
12
+ picks the words of a mail, so a malformed one is dropped rather than refused. */
13
+ let languageOf = (raw: option<string>): option<string> =>
14
+ raw
15
+ ->Option.map(String.trim)
16
+ ->Option.filter(tag =>
17
+ String.length(tag) <= 35 && /^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/->RegExp.test(tag)
18
+ )
19
+
20
+ /** What a sign-up is told when the check says no: the same whatever the address,
21
+ so it says nothing of one. */
22
+ let personCheckRejected = "the check that a person is signing up did not pass; try it again"
23
+
24
+ /** What it is told when the check cannot be asked. Refused rather than let through,
25
+ so a check that is down never opens the door to scripts. */
26
+ let personCheckUnavailable = "the check that a person is signing up cannot be reached; try again later"
27
+
11
28
  /** The door over the app's table, which picks the role a sign-up may leave out. */
12
29
  module Make = (App: Reventless.Admission.Declaration) => {
13
30
  module Spec = Spec
@@ -18,9 +35,15 @@ module Make = (App: Reventless.Admission.Declaration) => {
18
35
  ~capabilities: Reventless.Capabilities.t,
19
36
  ~caller as _,
20
37
  ) =>
21
- switch (Reventless.Email.fromString(input.email->String.trim), input.role) {
22
- | (Error(_), _) => Error("not an email address")
23
- | (Ok(email), role) =>
38
+ switch (
39
+ await capabilities.personCheck.verify(~token=input.personCheck->Option.getOr("")),
40
+ Reventless.Email.fromString(input.email->String.trim),
41
+ input.role,
42
+ ) {
43
+ | (Error(Rejected(_)), _, _) => Error(personCheckRejected)
44
+ | (Error(Unavailable(_)), _, _) => Error(personCheckUnavailable)
45
+ | (Ok(), Error(_), _) => Error("not an email address")
46
+ | (Ok(), Ok(typed), role) =>
24
47
  switch role
25
48
  ->Option.map(String.trim)
26
49
  ->Option.filter(r => r != "")
@@ -28,8 +51,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
28
51
  ->Option.orElse(defaultRole(App.table)) {
29
52
  | None => Error("say which role to sign up for")
30
53
  | Some(role) =>
31
- let address = email->ContactAddressId.normalize
32
- switch ContactAddressId.fingerprint(capabilities.secrets, address) {
54
+ let email = typed->ContactAddressId.normalize
55
+ switch ContactAddressId.fingerprint(capabilities.secrets, email) {
33
56
  | Error(why) => Error(why)
34
57
  | Ok(id) =>
35
58
  // The envelope id is the fingerprint too: an id is stored beside the
@@ -38,10 +61,12 @@ module Make = (App: Reventless.Admission.Declaration) => {
38
61
  (
39
62
  id->ContactAddressId.toString,
40
63
  Register({
41
- email: id,
42
- address,
64
+ emailId: id,
65
+ email,
43
66
  role,
44
67
  requestedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
68
+ language: ?languageOf(input.language),
69
+ initially: capabilities.selfRegistrationInitially,
45
70
  }),
46
71
  ),
47
72
  ])
@@ -15,25 +15,53 @@ function defaultRole(table) {
15
15
  }
16
16
  }
17
17
 
18
+ function languageOf(raw) {
19
+ return Stdlib_Option.filter(Stdlib_Option.map(raw, prim => prim.trim()), tag => {
20
+ if (tag.length <= 35) {
21
+ return /^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/.test(tag);
22
+ } else {
23
+ return false;
24
+ }
25
+ });
26
+ }
27
+
28
+ let personCheckRejected = "the check that a person is signing up did not pass; try it again";
29
+
30
+ let personCheckUnavailable = "the check that a person is signing up cannot be reached; try again later";
31
+
18
32
  function Make(App) {
19
33
  let translate = async (input, capabilities, param) => {
20
- let match = Email$Reventless.fromString(input.email.trim());
21
- let match$1 = input.role;
34
+ let match = await capabilities.personCheck.verify(Stdlib_Option.getOr(input.personCheck, ""));
35
+ let match$1 = Email$Reventless.fromString(input.email.trim());
36
+ let match$2 = input.role;
22
37
  if (match.TAG !== "Ok") {
38
+ if (match._0.TAG === "Rejected") {
39
+ return {
40
+ TAG: "Error",
41
+ _0: personCheckRejected
42
+ };
43
+ } else {
44
+ return {
45
+ TAG: "Error",
46
+ _0: personCheckUnavailable
47
+ };
48
+ }
49
+ }
50
+ if (match$1.TAG !== "Ok") {
23
51
  return {
24
52
  TAG: "Error",
25
53
  _0: "not an email address"
26
54
  };
27
55
  }
28
- let role = Stdlib_Option.orElse(Stdlib_Option.map(Stdlib_Option.filter(Stdlib_Option.map(match$1, prim => prim.trim()), r => r !== ""), prim => prim), defaultRole(App.table));
56
+ let role = Stdlib_Option.orElse(Stdlib_Option.map(Stdlib_Option.filter(Stdlib_Option.map(match$2, prim => prim.trim()), r => r !== ""), prim => prim), defaultRole(App.table));
29
57
  if (role === undefined) {
30
58
  return {
31
59
  TAG: "Error",
32
60
  _0: "say which role to sign up for"
33
61
  };
34
62
  }
35
- let address = ContactAddressId$ReventlessRegistration.normalize(match._0);
36
- let why = ContactAddressId$ReventlessRegistration.fingerprint(capabilities.secrets, address);
63
+ let email = ContactAddressId$ReventlessRegistration.normalize(match$1._0);
64
+ let why = ContactAddressId$ReventlessRegistration.fingerprint(capabilities.secrets, email);
37
65
  if (why.TAG !== "Ok") {
38
66
  return {
39
67
  TAG: "Error",
@@ -47,10 +75,12 @@ function Make(App) {
47
75
  ContactAddressId$ReventlessRegistration.toString(id),
48
76
  {
49
77
  TAG: "Register",
50
- email: id,
51
- address: address,
78
+ emailId: id,
79
+ email: email,
52
80
  role: role,
53
- requestedAt: new Date().toISOString()
81
+ requestedAt: new Date().toISOString(),
82
+ language: languageOf(input.language),
83
+ initially: capabilities.selfRegistrationInitially
54
84
  }
55
85
  ]]
56
86
  };
@@ -69,6 +99,9 @@ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/Inbound
69
99
  export {
70
100
  Spec,
71
101
  defaultRole,
102
+ languageOf,
103
+ personCheckRejected,
104
+ personCheckUnavailable,
72
105
  Make,
73
106
  moduleUrl,
74
107
  }
@@ -15,22 +15,22 @@
15
15
  @schema
16
16
  type consumedEvent =
17
17
  | RegistrationProofAccepted({
18
- email: string,
19
- address: Reventless.Email.t,
18
+ emailId: string,
19
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
20
20
  roles: array<Reventless.Role.name>,
21
21
  proofHash: string,
22
22
  })
23
23
 
24
24
  @schema
25
25
  type outboundItem = {
26
- email: string,
27
- address: Reventless.Email.t,
26
+ emailId: string,
27
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
28
28
  roles: array<Reventless.Role.name>,
29
29
  proofHash: string,
30
30
  }
31
31
 
32
32
  @schema
33
- type inboundCommand = RecordRegistrationCompleted({email: ContactAddressId.t})
33
+ type inboundCommand = RecordRegistrationCompleted({emailId: ContactAddressId.t})
34
34
 
35
35
  // For a provider that is down. The password is put back before each retry, so a
36
36
  // retry finds it; once the budget is spent, it expires.
@@ -1,6 +1,7 @@
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";
5
6
  import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
6
7
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
@@ -8,22 +9,22 @@ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.re
8
9
 
9
10
  let consumedEventSchema = Sury.$schema(s => ({
10
11
  TAG: "RegistrationProofAccepted",
11
- email: s.m(Sury.string),
12
- address: s.m(Email$Reventless.schema),
12
+ emailId: s.m(DcbTag$Reventless.string),
13
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
13
14
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
14
15
  proofHash: s.m(Sury.string)
15
16
  }));
16
17
 
17
18
  let outboundItemSchema = Sury.$schema(s => ({
18
- email: s.m(Sury.string),
19
- address: s.m(Email$Reventless.schema),
19
+ emailId: s.m(Sury.string),
20
+ email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
20
21
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
21
22
  proofHash: s.m(Sury.string)
22
23
  }));
23
24
 
24
25
  let inboundCommandSchema = Sury.$schema(s => ({
25
26
  TAG: "RecordRegistrationCompleted",
26
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
27
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
27
28
  }));
28
29
 
29
30
  let sourceNames = [];
@@ -9,14 +9,16 @@ let retryTtl = 600
9
9
 
10
10
  let collect = (event, ~sourceId as _) =>
11
11
  switch event {
12
- | RegistrationProofAccepted({email, address, roles, proofHash}) => [
13
- (`${email}:${proofHash}`, {email, address, roles, proofHash}),
12
+ | RegistrationProofAccepted({emailId, email: Value(email), roles, proofHash}) => [
13
+ (`${emailId}:${proofHash}`, {emailId, email, roles, proofHash}),
14
14
  ]
15
+ // An address that was erased or forgotten has nobody left to write to.
16
+ | _ => []
15
17
  }
16
18
 
17
- // `email` is already the ledger's id for the address: no key is needed to say so.
18
- let completed = (email: string) => Ok(
19
- Some((email, RecordRegistrationCompleted({email: ContactAddressId.makeFromString(email)}))),
19
+ // `emailId` is already the ledger's id for the address: no key is needed to say so.
20
+ let completed = (emailId: string) => Ok(
21
+ Some((emailId, RecordRegistrationCompleted({emailId: ContactAddressId.makeFromString(emailId)}))),
20
22
  )
21
23
 
22
24
  let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabilities.t) =>
@@ -27,14 +29,14 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
27
29
  | Ok(None) => Error("the password expired before the account was made")
28
30
  | Ok(Some(password)) =>
29
31
  switch await capabilities.identityProvider.createPrincipal(
30
- ~contact=ToEmail(item.address),
32
+ ~contact=ToEmail(item.email),
31
33
  ~credential=Password(password),
32
34
  ~groups=groupsOf(item.roles),
33
35
  ) {
34
- | Ok(_) => completed(item.email)
36
+ | Ok(_) => completed(item.emailId)
35
37
  // The provider already holds this address — an account declared before
36
38
  // registration existed, say. It is as registered as one made here.
37
- | Error(Conflict) => completed(item.email)
39
+ | Error(Conflict) => completed(item.emailId)
38
40
  | Error(Unavailable(why)) =>
39
41
  // Put back so the retry finds it. Failing that, the retry reports the
40
42
  // password gone, which is true.
@@ -9,27 +9,35 @@ function groupsOf(roles) {
9
9
  }
10
10
 
11
11
  function collect(event, param) {
12
- let proofHash = event.proofHash;
13
12
  let email = event.email;
13
+ let emailId = event.emailId;
14
+ if (typeof email !== "object") {
15
+ if (email === "Erased") {
16
+ return [];
17
+ } else {
18
+ return [];
19
+ }
20
+ }
21
+ let proofHash = event.proofHash;
14
22
  return [[
15
- email + `:` + proofHash,
23
+ emailId + `:` + proofHash,
16
24
  {
17
- email: email,
18
- address: event.address,
25
+ emailId: emailId,
26
+ email: email._0,
19
27
  roles: event.roles,
20
28
  proofHash: proofHash
21
29
  }
22
30
  ]];
23
31
  }
24
32
 
25
- function completed(email) {
33
+ function completed(emailId) {
26
34
  return {
27
35
  TAG: "Ok",
28
36
  _0: [
29
- email,
37
+ emailId,
30
38
  {
31
39
  TAG: "RecordRegistrationCompleted",
32
- email: ContactAddressId$ReventlessRegistration.makeFromString(email)
40
+ emailId: ContactAddressId$ReventlessRegistration.makeFromString(emailId)
33
41
  }
34
42
  ]
35
43
  };
@@ -52,17 +60,17 @@ async function translate(_id, item, capabilities) {
52
60
  }
53
61
  let match = await capabilities.identityProvider.createPrincipal({
54
62
  TAG: "ToEmail",
55
- _0: item.address
63
+ _0: item.email
56
64
  }, {
57
65
  TAG: "Password",
58
66
  _0: password
59
67
  }, item.roles.map(Role$Reventless.groupOf));
60
68
  if (match.TAG === "Ok") {
61
- return completed(item.email);
69
+ return completed(item.emailId);
62
70
  }
63
71
  let why = match._0;
64
72
  if (typeof why !== "object") {
65
- return completed(item.email);
73
+ return completed(item.emailId);
66
74
  }
67
75
  if (why.TAG !== "Unavailable") {
68
76
  return {
@@ -19,49 +19,57 @@
19
19
  @schema
20
20
  type consumedEvent =
21
21
  | RegistrationRequested({
22
- email: string,
23
- address: Reventless.Email.t,
22
+ emailId: string,
23
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
24
24
  requestedAt: Reventless.DateTime.t,
25
+ language?: string,
25
26
  })
26
27
  | RegistrationAttemptedOnTakenAddress({
27
- email: string,
28
- address: Reventless.Email.t,
28
+ emailId: string,
29
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
29
30
  attemptedAt: Reventless.DateTime.t,
30
31
  })
31
32
  | RegistrationInvited({
32
- email: string,
33
- address: Reventless.Email.t,
33
+ emailId: string,
34
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
34
35
  roles: array<string>,
35
36
  invitedBy: string,
36
37
  invitedAt: Reventless.DateTime.t,
38
+ language?: string,
37
39
  })
38
40
  | RegistrationChallengeReissued({
39
- email: string,
40
- address: Reventless.Email.t,
41
+ emailId: string,
42
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
41
43
  reissuedAt: Reventless.DateTime.t,
42
44
  invitedBy?: string,
45
+ language?: string,
43
46
  })
44
47
 
45
- // `email` is the ledger's id for the address, `address` the address the mail goes to.
48
+ // `emailId` is the ledger's id for the address, `email` the address the mail goes to.
46
49
 
47
50
  /** `invited` words the secret as an invitation; it is left out for a sign-up
48
51
  and for the notice. `roles` names what the invitation grants, where the
49
- event said: a reissued code does not. */
52
+ event said: a reissued code does not. `language` is the one the claim was made
53
+ in, for a person with no account to say; the notice to a taken address has none,
54
+ since its owner's account does. */
50
55
  @schema
51
56
  type outboundItem = {
52
- email: string,
53
- address: Reventless.Email.t,
57
+ emailId: string,
58
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
54
59
  alreadyRegistered: bool,
55
60
  invited?: bool,
56
61
  roles?: array<string>,
62
+ language?: string,
57
63
  }
58
64
 
59
65
  @schema
60
66
  type inboundCommand =
61
67
  | IssueRegistrationChallenge({
62
- email: ContactAddressId.t,
68
+ emailId: ContactAddressId.t,
63
69
  proofHash: string,
64
70
  issuedAt: Reventless.DateTime.t,
71
+ language?: string,
72
+ messageKey?: string,
65
73
  })
66
74
 
67
75
  // For a mail transport that is down. Exhausting them opens no challenge, which
@@ -70,3 +78,6 @@ let maxRetries = 3
70
78
  let targetName = Some("Registrations")
71
79
  let sourceNames: array<string> = []
72
80
  let capabilityNeeds = [Reventless.CapabilityNeed.Messaging]
81
+
82
+ /** This slice writes to the addresses visitors name; a deployment caps its mail per day. */
83
+ let admissionDoor = Reventless.Admission.Mail