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

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 +3 -3
  2. package/src/Registration/ContactAddressId.res +27 -3
  3. package/src/Registration/ContactAddressId.res.mjs +26 -2
  4. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +9 -6
  5. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +16 -9
  6. package/src/Registration/InboundTranslation/SignUp.res +1 -0
  7. package/src/Registration/InboundTranslation/SignUp.res.mjs +2 -0
  8. package/src/Registration/InboundTranslation/SignUp_Translation.res +23 -12
  9. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +13 -4
  10. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +7 -1
  11. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +3 -0
  12. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +4 -3
  13. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +2 -1
  14. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +24 -3
  15. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +6 -0
  16. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +15 -15
  17. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +8 -4
  18. package/src/Registration/StateChange/Registrations.res +28 -2
  19. package/src/Registration/StateChange/Registrations.res.mjs +13 -0
  20. package/src/Registration/StateChange/Registrations_Decision.res +31 -14
  21. package/src/Registration/StateChange/Registrations_Decision.res.mjs +24 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-registration",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
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": [
@@ -13,9 +13,9 @@
13
13
  "dependencies": {
14
14
  "sury": "11.0.0",
15
15
  "sury-ppx": "11.0.0",
16
- "@reventlessdev/reventless-infra": "3.0.0-alpha.207",
16
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.209",
17
17
  "@reventlessdev/reventless-ppx": "1.0.0-alpha.108",
18
- "@reventlessdev/reventless-spec": "3.0.0-alpha.178"
18
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.180"
19
19
  },
20
20
  "devDependencies": {
21
21
  "rescript": "12.3.1"
@@ -1,6 +1,30 @@
1
- // The address a registration claims: the partition the registration ledger
2
- // decides about, and the tag that makes "this address is taken" one fact on
3
- // every platform. Its value is the address itself, lower-cased.
1
+ // The address a registration claims, as the ledger knows it: the partition it
2
+ // decides about, and the tag that makes "this address is taken" one fact on every
3
+ // platform.
4
+ //
5
+ // Its value is a keyed fingerprint of the lower-cased address, never the address.
6
+ // A tag is an index key, and an index key cannot be encrypted or erased, so the
7
+ // address itself is carried beside it in a field of its own on the events that
8
+ // must reach the person. The key is the deployment's (`secrets.fingerprint`) and
9
+ // is never rotated: rotating it would orphan every registration recorded under
10
+ // the old one.
4
11
  include Reventless.Id.Make({
5
12
  let key = "contactAddress"
6
13
  })
14
+
15
+ /** What the fingerprint is taken under, so no other use of the deployment's key
16
+ can produce the same value for an address. */
17
+ let purpose = "contactAddress"
18
+
19
+ /** The form every door takes the fingerprint of: an address differing only in
20
+ case or surrounding spaces is the same registration. */
21
+ let normalize = (address: Reventless.Email.t): Reventless.Email.t =>
22
+ address->Reventless.Email.toString->String.trim->String.toLowerCase->Reventless.Email.unsafe
23
+
24
+ /** The ledger's id for an address. Refused, never degraded to the address, when
25
+ the deployment holds no key. */
26
+ let fingerprint = (secrets: Reventless.Secrets.t, address: Reventless.Email.t): result<t, string> =>
27
+ switch secrets.fingerprint(~purpose, address->normalize->Reventless.Email.toString) {
28
+ | Ok(value) => Ok(makeFromString(value))
29
+ | Error(Unavailable(why)) => Error(`cannot fingerprint the address: ${why}`)
30
+ }
@@ -6,12 +6,33 @@ let include = Id$Reventless.Make({
6
6
  key: "contactAddress"
7
7
  });
8
8
 
9
+ let makeFromString = include.makeFromString;
10
+
11
+ let purpose = "contactAddress";
12
+
13
+ function normalize(address) {
14
+ return address.trim().toLowerCase();
15
+ }
16
+
17
+ function fingerprint(secrets, address) {
18
+ let value = secrets.fingerprint(purpose, address.trim().toLowerCase());
19
+ if (value.TAG === "Ok") {
20
+ return {
21
+ TAG: "Ok",
22
+ _0: makeFromString(value._0)
23
+ };
24
+ } else {
25
+ return {
26
+ TAG: "Error",
27
+ _0: `cannot fingerprint the address: ` + value._0._0
28
+ };
29
+ }
30
+ }
31
+
9
32
  let schema = include.schema;
10
33
 
11
34
  let make = include.make;
12
35
 
13
- let makeFromString = include.makeFromString;
14
-
15
36
  let toString = include.toString;
16
37
 
17
38
  let cmp = include.cmp;
@@ -25,5 +46,8 @@ export {
25
46
  toString,
26
47
  cmp,
27
48
  key,
49
+ purpose,
50
+ normalize,
51
+ fingerprint,
28
52
  }
29
53
  /* include Not a pure module */
@@ -17,19 +17,22 @@ let translate = async (
17
17
  | Ok(_) if input.password->String.length < minimumPasswordLength =>
18
18
  Error(`a password needs at least ${minimumPasswordLength->Int.toString} characters`)
19
19
  | Ok(email) =>
20
- let email = email->Reventless.Email.toString->String.toLowerCase
21
- switch capabilities.secrets.hash(input.proof->String.trim) {
22
- | Error(Unavailable(why)) => Error(`cannot hash the proof: ${why}`)
23
- | Ok(proofHash) =>
20
+ switch (
21
+ ContactAddressId.fingerprint(capabilities.secrets, email),
22
+ capabilities.secrets.hash(input.proof->String.trim),
23
+ ) {
24
+ | (Error(why), _) => Error(why)
25
+ | (_, Error(Unavailable(why))) => Error(`cannot hash the proof: ${why}`)
26
+ | (Ok(id), Ok(proofHash)) =>
24
27
  switch await capabilities.stash.put(~key=proofHash, ~value=input.password, ~ttl=passwordTtl) {
25
28
  | Error(failure) =>
26
29
  Error(`cannot hold the password: ${failure->Reventless.Stash.failureReason}`)
27
30
  | Ok() =>
28
31
  Ok([
29
32
  (
30
- email,
33
+ id->ContactAddressId.toString,
31
34
  SubmitRegistrationProof({
32
- email: ContactAddressId.makeFromString(email),
35
+ email: id,
33
36
  proofHash,
34
37
  presentedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
35
38
  }),
@@ -18,25 +18,32 @@ async function translate(input, capabilities, param) {
18
18
  _0: `a password needs at least ` + (12).toString() + ` characters`
19
19
  };
20
20
  }
21
- let email$1 = email._0.toLowerCase();
22
- let proofHash = capabilities.secrets.hash(input.proof.trim());
23
- if (proofHash.TAG !== "Ok") {
21
+ let match = ContactAddressId$ReventlessRegistration.fingerprint(capabilities.secrets, email._0);
22
+ let match$1 = capabilities.secrets.hash(input.proof.trim());
23
+ if (match.TAG !== "Ok") {
24
24
  return {
25
25
  TAG: "Error",
26
- _0: `cannot hash the proof: ` + proofHash._0._0
26
+ _0: match._0
27
27
  };
28
28
  }
29
- let proofHash$1 = proofHash._0;
30
- let failure = await capabilities.stash.put(proofHash$1, input.password, 600);
29
+ let id = match._0;
30
+ if (match$1.TAG !== "Ok") {
31
+ return {
32
+ TAG: "Error",
33
+ _0: `cannot hash the proof: ` + match$1._0._0
34
+ };
35
+ }
36
+ let proofHash = match$1._0;
37
+ let failure = await capabilities.stash.put(proofHash, input.password, 600);
31
38
  if (failure.TAG === "Ok") {
32
39
  return {
33
40
  TAG: "Ok",
34
41
  _0: [[
35
- email$1,
42
+ ContactAddressId$ReventlessRegistration.toString(id),
36
43
  {
37
44
  TAG: "SubmitRegistrationProof",
38
- email: ContactAddressId$ReventlessRegistration.makeFromString(email$1),
39
- proofHash: proofHash$1,
45
+ email: id,
46
+ proofHash: proofHash,
40
47
  presentedAt: new Date().toISOString()
41
48
  }
42
49
  ]]
@@ -24,6 +24,7 @@ type externalInput = {email: string, role?: string}
24
24
  type command =
25
25
  | Register({
26
26
  email: ContactAddressId.t,
27
+ address: Reventless.Email.t,
27
28
  role: Reventless.Role.name,
28
29
  requestedAt: Reventless.DateTime.t,
29
30
  })
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as Sury from "sury";
4
4
  import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
5
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
5
6
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
7
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
7
8
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
@@ -14,6 +15,7 @@ let externalInputSchema = Sury.$schema(s => ({
14
15
  let commandSchema = Sury.$schema(s => ({
15
16
  TAG: "Register",
16
17
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
18
+ address: s.m(Email$Reventless.schema),
17
19
  role: s.m(Role$Reventless.nameSchema),
18
20
  requestedAt: s.m(DateTime$Reventless.schema)
19
21
  }));
@@ -13,7 +13,11 @@ module Make = (App: Reventless.Admission.Declaration) => {
13
13
  module Spec = Spec
14
14
  let moduleUrl = moduleUrl
15
15
 
16
- let translate = async (input: externalInput, ~capabilities as _, ~caller as _) =>
16
+ let translate = async (
17
+ input: externalInput,
18
+ ~capabilities: Reventless.Capabilities.t,
19
+ ~caller as _,
20
+ ) =>
17
21
  switch (Reventless.Email.fromString(input.email->String.trim), input.role) {
18
22
  | (Error(_), _) => Error("not an email address")
19
23
  | (Ok(email), role) =>
@@ -24,17 +28,24 @@ module Make = (App: Reventless.Admission.Declaration) => {
24
28
  ->Option.orElse(defaultRole(App.table)) {
25
29
  | None => Error("say which role to sign up for")
26
30
  | Some(role) =>
27
- let email = email->Reventless.Email.toString->String.toLowerCase
28
- Ok([
29
- (
30
- email,
31
- Register({
32
- email: ContactAddressId.makeFromString(email),
33
- role,
34
- requestedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
35
- }),
36
- ),
37
- ])
31
+ let address = email->ContactAddressId.normalize
32
+ switch ContactAddressId.fingerprint(capabilities.secrets, address) {
33
+ | Error(why) => Error(why)
34
+ | Ok(id) =>
35
+ // The envelope id is the fingerprint too: an id is stored beside the
36
+ // event, where the address must not be.
37
+ Ok([
38
+ (
39
+ id->ContactAddressId.toString,
40
+ Register({
41
+ email: id,
42
+ address,
43
+ role,
44
+ requestedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
45
+ }),
46
+ ),
47
+ ])
48
+ }
38
49
  }
39
50
  }
40
51
  }
@@ -16,7 +16,7 @@ function defaultRole(table) {
16
16
  }
17
17
 
18
18
  function Make(App) {
19
- let translate = async (input, param, param$1) => {
19
+ let translate = async (input, capabilities, param) => {
20
20
  let match = Email$Reventless.fromString(input.email.trim());
21
21
  let match$1 = input.role;
22
22
  if (match.TAG !== "Ok") {
@@ -32,14 +32,23 @@ function Make(App) {
32
32
  _0: "say which role to sign up for"
33
33
  };
34
34
  }
35
- let email = match._0.toLowerCase();
35
+ let address = ContactAddressId$ReventlessRegistration.normalize(match._0);
36
+ let why = ContactAddressId$ReventlessRegistration.fingerprint(capabilities.secrets, address);
37
+ if (why.TAG !== "Ok") {
38
+ return {
39
+ TAG: "Error",
40
+ _0: why._0
41
+ };
42
+ }
43
+ let id = why._0;
36
44
  return {
37
45
  TAG: "Ok",
38
46
  _0: [[
39
- email,
47
+ ContactAddressId$ReventlessRegistration.toString(id),
40
48
  {
41
49
  TAG: "Register",
42
- email: ContactAddressId$ReventlessRegistration.makeFromString(email),
50
+ email: id,
51
+ address: address,
43
52
  role: role,
44
53
  requestedAt: new Date().toISOString()
45
54
  }
@@ -16,12 +16,18 @@
16
16
  type consumedEvent =
17
17
  | RegistrationProofAccepted({
18
18
  email: string,
19
+ address: Reventless.Email.t,
19
20
  roles: array<Reventless.Role.name>,
20
21
  proofHash: string,
21
22
  })
22
23
 
23
24
  @schema
24
- type outboundItem = {email: string, roles: array<Reventless.Role.name>, proofHash: string}
25
+ type outboundItem = {
26
+ email: string,
27
+ address: Reventless.Email.t,
28
+ roles: array<Reventless.Role.name>,
29
+ proofHash: string,
30
+ }
25
31
 
26
32
  @schema
27
33
  type inboundCommand = RecordRegistrationCompleted({email: ContactAddressId.t})
@@ -2,18 +2,21 @@
2
2
 
3
3
  import * as Sury from "sury";
4
4
  import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
5
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
5
6
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
7
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
7
8
 
8
9
  let consumedEventSchema = Sury.$schema(s => ({
9
10
  TAG: "RegistrationProofAccepted",
10
11
  email: s.m(Sury.string),
12
+ address: s.m(Email$Reventless.schema),
11
13
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
12
14
  proofHash: s.m(Sury.string)
13
15
  }));
14
16
 
15
17
  let outboundItemSchema = Sury.$schema(s => ({
16
18
  email: s.m(Sury.string),
19
+ address: s.m(Email$Reventless.schema),
17
20
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
18
21
  proofHash: s.m(Sury.string)
19
22
  }));
@@ -9,11 +9,12 @@ let retryTtl = 600
9
9
 
10
10
  let collect = (event, ~sourceId as _) =>
11
11
  switch event {
12
- | RegistrationProofAccepted({email, roles, proofHash}) => [
13
- (`${email}:${proofHash}`, {email, roles, proofHash}),
12
+ | RegistrationProofAccepted({email, address, roles, proofHash}) => [
13
+ (`${email}:${proofHash}`, {email, address, roles, proofHash}),
14
14
  ]
15
15
  }
16
16
 
17
+ // `email` is already the ledger's id for the address: no key is needed to say so.
17
18
  let completed = (email: string) => Ok(
18
19
  Some((email, RecordRegistrationCompleted({email: ContactAddressId.makeFromString(email)}))),
19
20
  )
@@ -26,7 +27,7 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
26
27
  | Ok(None) => Error("the password expired before the account was made")
27
28
  | Ok(Some(password)) =>
28
29
  switch await capabilities.identityProvider.createPrincipal(
29
- ~contact=ToEmail(Reventless.Email.unsafe(item.email)),
30
+ ~contact=ToEmail(item.address),
30
31
  ~credential=Password(password),
31
32
  ~groups=groupsOf(item.roles),
32
33
  ) {
@@ -15,6 +15,7 @@ function collect(event, param) {
15
15
  email + `:` + proofHash,
16
16
  {
17
17
  email: email,
18
+ address: event.address,
18
19
  roles: event.roles,
19
20
  proofHash: proofHash
20
21
  }
@@ -51,7 +52,7 @@ async function translate(_id, item, capabilities) {
51
52
  }
52
53
  let match = await capabilities.identityProvider.createPrincipal({
53
54
  TAG: "ToEmail",
54
- _0: item.email
55
+ _0: item.address
55
56
  }, {
56
57
  TAG: "Password",
57
58
  _0: password
@@ -1,5 +1,8 @@
1
1
  // SendRegistrationChallenge OutboundTranslationSlice.
2
2
  //
3
+ // Writes to the address a registration names. Work is keyed by the ledger's id
4
+ // for the address, its fingerprint, never by the address.
5
+ //
3
6
  // Writes to the address a registration names. A fresh registration gets a
4
7
  // secret to prove control of the address, and the ledger records its hash; an
5
8
  // invitation gets one too, worded as an invitation and holding for a week; a
@@ -15,25 +18,43 @@
15
18
 
16
19
  @schema
17
20
  type consumedEvent =
18
- | RegistrationRequested({email: string, requestedAt: Reventless.DateTime.t})
19
- | RegistrationAttemptedOnTakenAddress({email: string, attemptedAt: Reventless.DateTime.t})
21
+ | RegistrationRequested({
22
+ email: string,
23
+ address: Reventless.Email.t,
24
+ requestedAt: Reventless.DateTime.t,
25
+ })
26
+ | RegistrationAttemptedOnTakenAddress({
27
+ email: string,
28
+ address: Reventless.Email.t,
29
+ attemptedAt: Reventless.DateTime.t,
30
+ })
20
31
  | RegistrationInvited({
21
32
  email: string,
33
+ address: Reventless.Email.t,
22
34
  roles: array<string>,
23
35
  invitedBy: string,
24
36
  invitedAt: Reventless.DateTime.t,
25
37
  })
26
38
  | RegistrationChallengeReissued({
27
39
  email: string,
40
+ address: Reventless.Email.t,
28
41
  reissuedAt: Reventless.DateTime.t,
29
42
  invitedBy?: string,
30
43
  })
31
44
 
45
+ // `email` is the ledger's id for the address, `address` the address the mail goes to.
46
+
32
47
  /** `invited` words the secret as an invitation; it is left out for a sign-up
33
48
  and for the notice. `roles` names what the invitation grants, where the
34
49
  event said: a reissued code does not. */
35
50
  @schema
36
- type outboundItem = {email: string, alreadyRegistered: bool, invited?: bool, roles?: array<string>}
51
+ type outboundItem = {
52
+ email: string,
53
+ address: Reventless.Email.t,
54
+ alreadyRegistered: bool,
55
+ invited?: bool,
56
+ roles?: array<string>,
57
+ }
37
58
 
38
59
  @schema
39
60
  type inboundCommand =
@@ -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 Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
4
5
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
5
6
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
6
7
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
@@ -9,16 +10,19 @@ let consumedEventSchema = Sury.union([
9
10
  Sury.$schema(s => ({
10
11
  TAG: "RegistrationRequested",
11
12
  email: s.m(Sury.string),
13
+ address: s.m(Email$Reventless.schema),
12
14
  requestedAt: s.m(DateTime$Reventless.schema)
13
15
  })),
14
16
  Sury.$schema(s => ({
15
17
  TAG: "RegistrationAttemptedOnTakenAddress",
16
18
  email: s.m(Sury.string),
19
+ address: s.m(Email$Reventless.schema),
17
20
  attemptedAt: s.m(DateTime$Reventless.schema)
18
21
  })),
19
22
  Sury.$schema(s => ({
20
23
  TAG: "RegistrationInvited",
21
24
  email: s.m(Sury.string),
25
+ address: s.m(Email$Reventless.schema),
22
26
  roles: s.m(Sury.array(Sury.string)),
23
27
  invitedBy: s.m(Sury.string),
24
28
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -26,6 +30,7 @@ let consumedEventSchema = Sury.union([
26
30
  Sury.$schema(s => ({
27
31
  TAG: "RegistrationChallengeReissued",
28
32
  email: s.m(Sury.string),
33
+ address: s.m(Email$Reventless.schema),
29
34
  reissuedAt: s.m(DateTime$Reventless.schema),
30
35
  invitedBy: s.m(Sury.$option(Sury.string))
31
36
  }))
@@ -33,6 +38,7 @@ let consumedEventSchema = Sury.union([
33
38
 
34
39
  let outboundItemSchema = Sury.$schema(s => ({
35
40
  email: s.m(Sury.string),
41
+ address: s.m(Email$Reventless.schema),
36
42
  alreadyRegistered: s.m(Sury.boolean),
37
43
  invited: s.m(Sury.$option(Sury.boolean)),
38
44
  roles: s.m(Sury.$option(Sury.array(Sury.string)))
@@ -4,25 +4,28 @@
4
4
  // or a code reissued, is new work rather than work already done.
5
5
  let collect = (event, ~sourceId as _) =>
6
6
  switch event {
7
- | RegistrationRequested({email, requestedAt}) => [
8
- (`${email}:${requestedAt->Reventless.DateTime.toString}`, {email, alreadyRegistered: false}),
7
+ | RegistrationRequested({email, address, requestedAt}) => [
8
+ (
9
+ `${email}:${requestedAt->Reventless.DateTime.toString}`,
10
+ {email, address, alreadyRegistered: false},
11
+ ),
9
12
  ]
10
- | RegistrationInvited({email, roles, invitedAt}) => [
13
+ | RegistrationInvited({email, address, roles, invitedAt}) => [
11
14
  (
12
15
  `${email}:invited:${invitedAt->Reventless.DateTime.toString}`,
13
- {email, alreadyRegistered: false, invited: true, roles},
16
+ {email, address, alreadyRegistered: false, invited: true, roles},
14
17
  ),
15
18
  ]
16
- | RegistrationChallengeReissued({email, reissuedAt, ?invitedBy}) => [
19
+ | RegistrationChallengeReissued({email, address, reissuedAt, ?invitedBy}) => [
17
20
  (
18
21
  `${email}:reissued:${reissuedAt->Reventless.DateTime.toString}`,
19
- {email, alreadyRegistered: false, invited: invitedBy->Option.isSome},
22
+ {email, address, alreadyRegistered: false, invited: invitedBy->Option.isSome},
20
23
  ),
21
24
  ]
22
- | RegistrationAttemptedOnTakenAddress({email, attemptedAt}) => [
25
+ | RegistrationAttemptedOnTakenAddress({email, address, attemptedAt}) => [
23
26
  (
24
27
  `${email}:taken:${attemptedAt->Reventless.DateTime.toString}`,
25
- {email, alreadyRegistered: true},
28
+ {email, address, alreadyRegistered: true},
26
29
  ),
27
30
  ]
28
31
  }
@@ -54,11 +57,8 @@ let invitationBody = (~token, ~roles=?) =>
54
57
 
55
58
  let noticeBody = "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."
56
59
 
57
- let send = (capabilities: Reventless.Capabilities.t, ~email, ~subject, ~body) =>
58
- capabilities.messaging.send(
59
- ~recipient=ToEmail(Reventless.Email.unsafe(email)),
60
- ~message={subject, body},
61
- )
60
+ let send = (capabilities: Reventless.Capabilities.t, ~address, ~subject, ~body) =>
61
+ capabilities.messaging.send(~recipient=ToEmail(address), ~message={subject, body})
62
62
 
63
63
  /**
64
64
  Draw a secret, send it, and open a challenge against its hash — sending first,
@@ -68,7 +68,7 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
68
68
  if item.alreadyRegistered {
69
69
  switch await send(
70
70
  capabilities,
71
- ~email=item.email,
71
+ ~address=item.address,
72
72
  ~subject="Someone tried to register with your address",
73
73
  ~body=noticeBody,
74
74
  ) {
@@ -89,7 +89,7 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
89
89
  | Ok(proofHash) =>
90
90
  switch await send(
91
91
  capabilities,
92
- ~email=item.email,
92
+ ~address=item.address,
93
93
  ~subject=invited ? "You are invited to create an account" : "Finish your registration",
94
94
  ~body=invited ? invitationBody(~token, ~roles=?item.roles) : challengeBody(~token),
95
95
  ) {
@@ -14,6 +14,7 @@ function collect(event, param) {
14
14
  email + `:` + event.requestedAt,
15
15
  {
16
16
  email: email,
17
+ address: event.address,
17
18
  alreadyRegistered: false
18
19
  }
19
20
  ]];
@@ -23,6 +24,7 @@ function collect(event, param) {
23
24
  email$1 + `:taken:` + event.attemptedAt,
24
25
  {
25
26
  email: email$1,
27
+ address: event.address,
26
28
  alreadyRegistered: true
27
29
  }
28
30
  ]];
@@ -32,6 +34,7 @@ function collect(event, param) {
32
34
  email$2 + `:invited:` + event.invitedAt,
33
35
  {
34
36
  email: email$2,
37
+ address: event.address,
35
38
  alreadyRegistered: false,
36
39
  invited: true,
37
40
  roles: event.roles
@@ -43,6 +46,7 @@ function collect(event, param) {
43
46
  email$3 + `:reissued:` + event.reissuedAt,
44
47
  {
45
48
  email: email$3,
49
+ address: event.address,
46
50
  alreadyRegistered: false,
47
51
  invited: Stdlib_Option.isSome(event.invitedBy)
48
52
  }
@@ -72,10 +76,10 @@ function invitationBody(token, roles) {
72
76
 
73
77
  let noticeBody = "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.";
74
78
 
75
- function send(capabilities, email, subject, body) {
79
+ function send(capabilities, address, subject, body) {
76
80
  return capabilities.messaging.send({
77
81
  TAG: "ToEmail",
78
- _0: email
82
+ _0: address
79
83
  }, {
80
84
  subject: subject,
81
85
  body: body
@@ -84,7 +88,7 @@ function send(capabilities, email, subject, body) {
84
88
 
85
89
  async function translate(_id, item, capabilities) {
86
90
  if (item.alreadyRegistered) {
87
- let failure = await send(capabilities, item.email, "Someone tried to register with your address", noticeBody);
91
+ let failure = await send(capabilities, item.address, "Someone tried to register with your address", noticeBody);
88
92
  if (failure.TAG === "Ok") {
89
93
  return {
90
94
  TAG: "Ok",
@@ -114,7 +118,7 @@ async function translate(_id, item, capabilities) {
114
118
  _0: `cannot hash a secret: ` + proofHash._0._0
115
119
  };
116
120
  }
117
- let failure$1 = await send(capabilities, item.email, invited ? "You are invited to create an account" : "Finish your registration", invited ? invitationBody(token$1, item.roles) : challengeBody(token$1));
121
+ let failure$1 = await send(capabilities, item.address, invited ? "You are invited to create an account" : "Finish your registration", invited ? invitationBody(token$1, item.roles) : challengeBody(token$1));
118
122
  if (failure$1.TAG === "Ok") {
119
123
  return {
120
124
  TAG: "Ok",
@@ -15,6 +15,12 @@
15
15
  // translations in this chapter: they stamp the time a request arrived, and they
16
16
  // hash a presented proof so its plaintext never reaches this slice or the log.
17
17
  //
18
+ // **The address is not the key.** `email` is the address's keyed fingerprint
19
+ // (`ContactAddressId`), which is what tags and partitions the ledger; an index key
20
+ // cannot be erased. The address itself rides in `address`, on the events that must
21
+ // reach the person and on the commands that start a claim, so it lives only where
22
+ // a payload field can be encrypted or erased.
23
+ //
18
24
  // **Its answers do not tell an anonymous caller anything.** A closed policy, a
19
25
  // pending registration and an address already registered all leave the door
20
26
  // answering the same way; only what is sent to the address differs.
@@ -35,24 +41,28 @@ type consumedEvent =
35
41
  })
36
42
  | RegistrationRequested({
37
43
  email: ContactAddressId.t,
44
+ address: Reventless.Email.t,
38
45
  roles: array<string>,
39
46
  requestedAt: Reventless.DateTime.t,
40
47
  })
41
48
  | RegistrationExpired({email: ContactAddressId.t})
42
49
  | RegistrationInvited({
43
50
  email: ContactAddressId.t,
51
+ address: Reventless.Email.t,
44
52
  roles: array<string>,
45
53
  invitedBy: string,
46
54
  invitedAt: Reventless.DateTime.t,
47
55
  })
48
56
  | RegistrationChallengeReissued({
49
57
  email: ContactAddressId.t,
58
+ address: Reventless.Email.t,
50
59
  reissuedAt: Reventless.DateTime.t,
51
60
  invitedBy?: string,
52
61
  })
53
62
  | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
54
63
  | RegistrationAttemptedOnTakenAddress({
55
64
  email: ContactAddressId.t,
65
+ address: Reventless.Email.t,
56
66
  attemptedAt: Reventless.DateTime.t,
57
67
  })
58
68
  | RegistrationChallengeIssued({
@@ -60,7 +70,12 @@ type consumedEvent =
60
70
  proofHash: string,
61
71
  issuedAt: Reventless.DateTime.t,
62
72
  })
63
- | RegistrationProofAccepted({email: ContactAddressId.t, roles: array<string>, proofHash: string})
73
+ | RegistrationProofAccepted({
74
+ email: ContactAddressId.t,
75
+ address: Reventless.Email.t,
76
+ roles: array<string>,
77
+ proofHash: string,
78
+ })
64
79
  | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
65
80
  | RegistrationCompleted({email: ContactAddressId.t})
66
81
 
@@ -78,6 +93,7 @@ type command =
78
93
  | @noApi
79
94
  Register({
80
95
  email: ContactAddressId.t,
96
+ address: Reventless.Email.t,
81
97
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
82
98
  requestedAt: Reventless.DateTime.t,
83
99
  })
@@ -100,6 +116,7 @@ type command =
100
116
  | @noApi
101
117
  Invite({
102
118
  email: ContactAddressId.t,
119
+ address: Reventless.Email.t,
103
120
  roles: array<Reventless.Role.name>,
104
121
  invitedBy: string,
105
122
  requestedAt: Reventless.DateTime.t,
@@ -127,24 +144,28 @@ type error =
127
144
  type event =
128
145
  | RegistrationRequested({
129
146
  email: ContactAddressId.t,
147
+ address: Reventless.Email.t,
130
148
  roles: array<string>,
131
149
  requestedAt: Reventless.DateTime.t,
132
150
  })
133
151
  | RegistrationExpired({email: ContactAddressId.t})
134
152
  | RegistrationInvited({
135
153
  email: ContactAddressId.t,
154
+ address: Reventless.Email.t,
136
155
  roles: array<string>,
137
156
  invitedBy: string,
138
157
  invitedAt: Reventless.DateTime.t,
139
158
  })
140
159
  | RegistrationChallengeReissued({
141
160
  email: ContactAddressId.t,
161
+ address: Reventless.Email.t,
142
162
  reissuedAt: Reventless.DateTime.t,
143
163
  invitedBy?: string,
144
164
  })
145
165
  | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
146
166
  | RegistrationAttemptedOnTakenAddress({
147
167
  email: ContactAddressId.t,
168
+ address: Reventless.Email.t,
148
169
  attemptedAt: Reventless.DateTime.t,
149
170
  })
150
171
  | RegistrationChallengeIssued({
@@ -152,6 +173,11 @@ type event =
152
173
  proofHash: string,
153
174
  issuedAt: Reventless.DateTime.t,
154
175
  })
155
- | RegistrationProofAccepted({email: ContactAddressId.t, roles: array<string>, proofHash: string})
176
+ | RegistrationProofAccepted({
177
+ email: ContactAddressId.t,
178
+ address: Reventless.Email.t,
179
+ roles: array<string>,
180
+ proofHash: string,
181
+ })
156
182
  | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
157
183
  | RegistrationCompleted({email: ContactAddressId.t})
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as Sury from "sury";
4
4
  import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
5
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
5
6
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
7
  import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
7
8
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
@@ -20,6 +21,7 @@ let consumedEventSchema = Sury.union([
20
21
  Sury.$schema(s => ({
21
22
  TAG: "RegistrationRequested",
22
23
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
24
+ address: s.m(Email$Reventless.schema),
23
25
  roles: s.m(Sury.array(Sury.string)),
24
26
  requestedAt: s.m(DateTime$Reventless.schema)
25
27
  })),
@@ -30,6 +32,7 @@ let consumedEventSchema = Sury.union([
30
32
  Sury.$schema(s => ({
31
33
  TAG: "RegistrationInvited",
32
34
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
35
+ address: s.m(Email$Reventless.schema),
33
36
  roles: s.m(Sury.array(Sury.string)),
34
37
  invitedBy: s.m(Sury.string),
35
38
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -37,6 +40,7 @@ let consumedEventSchema = Sury.union([
37
40
  Sury.$schema(s => ({
38
41
  TAG: "RegistrationChallengeReissued",
39
42
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
43
+ address: s.m(Email$Reventless.schema),
40
44
  reissuedAt: s.m(DateTime$Reventless.schema),
41
45
  invitedBy: s.m(Sury.$option(Sury.string))
42
46
  })),
@@ -48,6 +52,7 @@ let consumedEventSchema = Sury.union([
48
52
  Sury.$schema(s => ({
49
53
  TAG: "RegistrationAttemptedOnTakenAddress",
50
54
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
55
+ address: s.m(Email$Reventless.schema),
51
56
  attemptedAt: s.m(DateTime$Reventless.schema)
52
57
  })),
53
58
  Sury.$schema(s => ({
@@ -59,6 +64,7 @@ let consumedEventSchema = Sury.union([
59
64
  Sury.$schema(s => ({
60
65
  TAG: "RegistrationProofAccepted",
61
66
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
67
+ address: s.m(Email$Reventless.schema),
62
68
  roles: s.m(Sury.array(Sury.string)),
63
69
  proofHash: s.m(Sury.string)
64
70
  })),
@@ -77,6 +83,7 @@ let commandSchema = Sury.union([
77
83
  Sury.$schema(s => ({
78
84
  TAG: "Register",
79
85
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
86
+ address: s.m(Email$Reventless.schema),
80
87
  role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
81
88
  requestedAt: s.m(DateTime$Reventless.schema)
82
89
  })),
@@ -99,6 +106,7 @@ let commandSchema = Sury.union([
99
106
  Sury.$schema(s => ({
100
107
  TAG: "Invite",
101
108
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
109
+ address: s.m(Email$Reventless.schema),
102
110
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
103
111
  invitedBy: s.m(Sury.string),
104
112
  requestedAt: s.m(DateTime$Reventless.schema)
@@ -127,6 +135,7 @@ let eventSchema = Sury.union([
127
135
  Sury.$schema(s => ({
128
136
  TAG: "RegistrationRequested",
129
137
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
138
+ address: s.m(Email$Reventless.schema),
130
139
  roles: s.m(Sury.array(Sury.string)),
131
140
  requestedAt: s.m(DateTime$Reventless.schema)
132
141
  })),
@@ -137,6 +146,7 @@ let eventSchema = Sury.union([
137
146
  Sury.$schema(s => ({
138
147
  TAG: "RegistrationInvited",
139
148
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
149
+ address: s.m(Email$Reventless.schema),
140
150
  roles: s.m(Sury.array(Sury.string)),
141
151
  invitedBy: s.m(Sury.string),
142
152
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -144,6 +154,7 @@ let eventSchema = Sury.union([
144
154
  Sury.$schema(s => ({
145
155
  TAG: "RegistrationChallengeReissued",
146
156
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
157
+ address: s.m(Email$Reventless.schema),
147
158
  reissuedAt: s.m(DateTime$Reventless.schema),
148
159
  invitedBy: s.m(Sury.$option(Sury.string))
149
160
  })),
@@ -155,6 +166,7 @@ let eventSchema = Sury.union([
155
166
  Sury.$schema(s => ({
156
167
  TAG: "RegistrationAttemptedOnTakenAddress",
157
168
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
169
+ address: s.m(Email$Reventless.schema),
158
170
  attemptedAt: s.m(DateTime$Reventless.schema)
159
171
  })),
160
172
  Sury.$schema(s => ({
@@ -166,6 +178,7 @@ let eventSchema = Sury.union([
166
178
  Sury.$schema(s => ({
167
179
  TAG: "RegistrationProofAccepted",
168
180
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
181
+ address: s.m(Email$Reventless.schema),
169
182
  roles: s.m(Sury.array(Sury.string)),
170
183
  proofHash: s.m(Sury.string)
171
184
  })),
@@ -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
+ address: 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,
@@ -60,27 +63,34 @@ let evolve = (state, event) =>
60
63
  switch event {
61
64
  | RegistrationOpened({?until}) => {...state, admission: Open(until)}
62
65
  | RegistrationClosed(_) => {...state, admission: Closed}
63
- | RegistrationRequested({roles, requestedAt}) => {
66
+ | RegistrationRequested({address, roles, requestedAt}) => {
64
67
  ...state,
65
- stage: Pending({requestedAt, roles, challenge: None, proofHash: None}),
68
+ stage: Pending({address, requestedAt, roles, challenge: None, proofHash: None}),
66
69
  }
67
- | RegistrationInvited({roles, invitedBy, invitedAt}) => {
70
+ | RegistrationInvited({address, roles, invitedBy, invitedAt}) => {
68
71
  ...state,
69
- stage: Pending({requestedAt: invitedAt, roles, invitedBy, challenge: None, proofHash: None}),
72
+ stage: Pending({
73
+ address,
74
+ requestedAt: invitedAt,
75
+ roles,
76
+ invitedBy,
77
+ challenge: None,
78
+ proofHash: None,
79
+ }),
70
80
  }
71
81
  | RegistrationExpired(_) | RegistrationWithdrawn(_) => {...state, stage: Unclaimed}
72
82
  | RegistrationAttemptedOnTakenAddress({attemptedAt}) => {
73
83
  ...state,
74
84
  lastNoticeAt: Some(attemptedAt),
75
85
  }
76
- | RegistrationChallengeIssued({email, proofHash, issuedAt}) =>
86
+ | RegistrationChallengeIssued({proofHash, issuedAt}) =>
77
87
  switch state.stage {
78
88
  | Pending(p) => {
79
89
  ...state,
80
90
  stage: Pending({
81
91
  ...p,
82
92
  challenge: Some({
83
- contact: ByEmail(Reventless.Email.unsafe(email->ContactAddressId.toString)),
93
+ contact: ByEmail(p.address),
84
94
  purpose: purposeOf(p),
85
95
  issuedAt,
86
96
  attempts: 0,
@@ -166,7 +176,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
166
176
  // decision: the policy is consulted before the address, so a closed
167
177
  // deployment sends nothing — not even the notice to an address that is
168
178
  // already registered.
169
- | Register({email, role, requestedAt}) =>
179
+ | Register({email, address, role, requestedAt}) =>
170
180
  if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt) {
171
181
  Ok([])
172
182
  } else {
@@ -177,7 +187,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
177
187
  switch state.lastNoticeAt {
178
188
  | Some(last) if Guards.elapsedSeconds(~from=last, ~to_=requestedAt) < noticeCooldown =>
179
189
  Ok([])
180
- | _ => Ok([RegistrationAttemptedOnTakenAddress({email, attemptedAt: requestedAt})])
190
+ | _ =>
191
+ Ok([RegistrationAttemptedOnTakenAddress({email, address, attemptedAt: requestedAt})])
181
192
  }
182
193
  | Verified => Ok([])
183
194
  // A visitor cannot take over a claim, an inviter's included, while it holds.
@@ -185,22 +196,23 @@ module Make = (App: Reventless.Admission.Declaration) => {
185
196
  | Pending(_) =>
186
197
  Ok([
187
198
  RegistrationExpired({email: email}),
188
- RegistrationRequested({email, roles, requestedAt}),
199
+ RegistrationRequested({email, address, roles, requestedAt}),
189
200
  ])
190
- | Unclaimed => Ok([RegistrationRequested({email, roles, requestedAt})])
201
+ | Unclaimed => Ok([RegistrationRequested({email, address, roles, requestedAt})])
191
202
  }
192
203
  }
193
204
 
194
205
  // The policy is not consulted: it says whether visitors may sign themselves
195
206
  // up, and an invitation is not that. The table is, because it is the hard
196
207
  // cap on how each role is admitted.
197
- | Invite({email, roles, invitedBy, requestedAt}) =>
208
+ | Invite({email, address, roles, invitedBy, requestedAt}) =>
198
209
  switch roles->Array.find(r => !isByInvitation(App.table, r)) {
199
210
  | Some(role) => Error(NotByInvitation({role: (role :> string)}))
200
211
  | None if roles == [] => Error(NoRoleToGrant)
201
212
  | None =>
202
213
  let invited = RegistrationInvited({
203
214
  email,
215
+ address,
204
216
  roles: roles->Array.map(r => (r :> string)),
205
217
  invitedBy,
206
218
  invitedAt: requestedAt,
@@ -219,7 +231,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
219
231
  switch state.stage {
220
232
  | Pending(p) =>
221
233
  switch Guards.onIssueRequested(
222
- ~contact=ByEmail(Reventless.Email.unsafe(email->ContactAddressId.toString)),
234
+ ~contact=ByEmail(p.address),
223
235
  ~existing=p.challenge,
224
236
  ~now=issuedAt,
225
237
  ~policy=policyOf(p),
@@ -242,7 +254,12 @@ module Make = (App: Reventless.Admission.Declaration) => {
242
254
  if Guards.elapsedSeconds(~from=c.issuedAt, ~to_=requestedAt) >=
243
255
  policyOf(p).resendCooldown =>
244
256
  Ok([
245
- RegistrationChallengeReissued({email, reissuedAt: requestedAt, invitedBy: ?p.invitedBy}),
257
+ RegistrationChallengeReissued({
258
+ email,
259
+ address: p.address,
260
+ reissuedAt: requestedAt,
261
+ invitedBy: ?p.invitedBy,
262
+ }),
246
263
  ])
247
264
  | _ => Ok([])
248
265
  }
@@ -257,7 +274,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
257
274
  ~now=presentedAt,
258
275
  ~policy=policyOf(p),
259
276
  ) {
260
- | Settle => Ok([RegistrationProofAccepted({email, roles, proofHash})])
277
+ | Settle => Ok([RegistrationProofAccepted({email, address: p.address, roles, proofHash})])
261
278
  | Refuse(reason) => Ok([RegistrationProofRefused({email, reason: refusalReason(reason)})])
262
279
  }
263
280
  // No challenge to answer: nothing to count it against, and nothing to say.
@@ -4,7 +4,6 @@ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js
4
4
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
5
5
  import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
6
6
  import * as Registrations$ReventlessRegistration from "./Registrations.res.mjs";
7
- import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
8
7
  import * as RegistrationChallenge$ReventlessRegistration from "../../RegistrationChallenge.res.mjs";
9
8
  import * as ContactVerification_Guards$ReventlessRegistration from "../../ContactVerification_Guards.res.mjs";
10
9
 
@@ -45,6 +44,7 @@ function evolve(state, event) {
45
44
  stage: {
46
45
  TAG: "Pending",
47
46
  _0: {
47
+ address: event.address,
48
48
  requestedAt: event.requestedAt,
49
49
  roles: event.roles,
50
50
  challenge: undefined,
@@ -59,6 +59,7 @@ function evolve(state, event) {
59
59
  stage: {
60
60
  TAG: "Pending",
61
61
  _0: {
62
+ address: event.address,
62
63
  requestedAt: event.invitedAt,
63
64
  roles: event.roles,
64
65
  invitedBy: event.invitedBy,
@@ -109,7 +110,7 @@ function evolve(state, event) {
109
110
  _0: (newrecord$1.proofHash = event.proofHash, newrecord$1.challenge = {
110
111
  contact: {
111
112
  TAG: "ByEmail",
112
- _0: ContactAddressId$ReventlessRegistration.toString(event.email)
113
+ _0: p$2.address
113
114
  },
114
115
  purpose: RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy),
115
116
  issuedAt: event.issuedAt,
@@ -210,6 +211,7 @@ function Make(App) {
210
211
  case "Register" :
211
212
  let requestedAt = command.requestedAt;
212
213
  let role = command.role;
214
+ let address = command.address;
213
215
  let email = command.email;
214
216
  if (!admits(state.admission, App.table, role, requestedAt)) {
215
217
  return {
@@ -231,6 +233,7 @@ function Make(App) {
231
233
  {
232
234
  TAG: "RegistrationRequested",
233
235
  email: email,
236
+ address: address,
234
237
  roles: roles,
235
238
  requestedAt: requestedAt
236
239
  }
@@ -250,6 +253,7 @@ function Make(App) {
250
253
  _0: [{
251
254
  TAG: "RegistrationRequested",
252
255
  email: email,
256
+ address: address,
253
257
  roles: roles,
254
258
  requestedAt: requestedAt
255
259
  }]
@@ -273,6 +277,7 @@ function Make(App) {
273
277
  _0: [{
274
278
  TAG: "RegistrationAttemptedOnTakenAddress",
275
279
  email: email,
280
+ address: address,
276
281
  attemptedAt: requestedAt
277
282
  }]
278
283
  };
@@ -283,6 +288,7 @@ function Make(App) {
283
288
  _0: [{
284
289
  TAG: "RegistrationAttemptedOnTakenAddress",
285
290
  email: email,
291
+ address: address,
286
292
  attemptedAt: requestedAt
287
293
  }]
288
294
  };
@@ -290,7 +296,6 @@ function Make(App) {
290
296
  }
291
297
  case "IssueRegistrationChallenge" :
292
298
  let issuedAt = command.issuedAt;
293
- let email$1 = command.email;
294
299
  let p$1 = state.stage;
295
300
  if (typeof p$1 !== "object") {
296
301
  return {
@@ -301,14 +306,14 @@ function Make(App) {
301
306
  let p$2 = p$1._0;
302
307
  let match = ContactVerification_Guards$ReventlessRegistration.onIssueRequested({
303
308
  TAG: "ByEmail",
304
- _0: ContactAddressId$ReventlessRegistration.toString(email$1)
309
+ _0: p$2.address
305
310
  }, p$2.challenge, issuedAt, RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy)));
306
311
  if (match === "Issue") {
307
312
  return {
308
313
  TAG: "Ok",
309
314
  _0: [{
310
315
  TAG: "RegistrationChallengeIssued",
311
- email: email$1,
316
+ email: command.email,
312
317
  proofHash: command.proofHash,
313
318
  issuedAt: issuedAt
314
319
  }]
@@ -321,7 +326,7 @@ function Make(App) {
321
326
  }
322
327
  case "SubmitRegistrationProof" :
323
328
  let proofHash = command.proofHash;
324
- let email$2 = command.email;
329
+ let email$1 = command.email;
325
330
  let p$3 = state.stage;
326
331
  if (typeof p$3 !== "object") {
327
332
  return {
@@ -350,7 +355,8 @@ function Make(App) {
350
355
  TAG: "Ok",
351
356
  _0: [{
352
357
  TAG: "RegistrationProofAccepted",
353
- email: email$2,
358
+ email: email$1,
359
+ address: p$4.address,
354
360
  roles: p$4.roles,
355
361
  proofHash: proofHash
356
362
  }]
@@ -360,7 +366,7 @@ function Make(App) {
360
366
  TAG: "Ok",
361
367
  _0: [{
362
368
  TAG: "RegistrationProofRefused",
363
- email: email$2,
369
+ email: email$1,
364
370
  reason: refusalReason(reason._0)
365
371
  }]
366
372
  };
@@ -391,7 +397,7 @@ function Make(App) {
391
397
  case "Invite" :
392
398
  let requestedAt$1 = command.requestedAt;
393
399
  let roles$1 = command.roles;
394
- let email$3 = command.email;
400
+ let email$2 = command.email;
395
401
  let role$1 = roles$1.find(r => !isByInvitation(App.table, r));
396
402
  if (role$1 !== undefined) {
397
403
  return {
@@ -408,13 +414,15 @@ function Make(App) {
408
414
  _0: "NoRoleToGrant"
409
415
  };
410
416
  }
411
- let invited_1 = roles$1.map(r => r);
412
- let invited_2 = command.invitedBy;
417
+ let invited_1 = command.address;
418
+ let invited_2 = roles$1.map(r => r);
419
+ let invited_3 = command.invitedBy;
413
420
  let invited = {
414
421
  TAG: "RegistrationInvited",
415
- email: email$3,
416
- roles: invited_1,
417
- invitedBy: invited_2,
422
+ email: email$2,
423
+ address: invited_1,
424
+ roles: invited_2,
425
+ invitedBy: invited_3,
418
426
  invitedAt: requestedAt$1
419
427
  };
420
428
  let p$5 = state.stage;
@@ -425,7 +433,7 @@ function Make(App) {
425
433
  _0: [
426
434
  {
427
435
  TAG: "RegistrationExpired",
428
- email: email$3
436
+ email: email$2
429
437
  },
430
438
  invited
431
439
  ]
@@ -468,6 +476,7 @@ function Make(App) {
468
476
  _0: [{
469
477
  TAG: "RegistrationChallengeReissued",
470
478
  email: command.email,
479
+ address: p$7.address,
471
480
  reissuedAt: requestedAt$2,
472
481
  invitedBy: p$7.invitedBy
473
482
  }]