@reventlessdev/reventless-registration 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (23) hide show
  1. package/package.json +4 -4
  2. package/src/Registration/ContactAddressId.res +27 -3
  3. package/src/Registration/ContactAddressId.res.mjs +26 -2
  4. package/src/Registration/InboundTranslation/CompleteRegistration.res +2 -2
  5. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +2 -2
  6. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +9 -6
  7. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +16 -9
  8. package/src/Registration/InboundTranslation/SignUp.res +3 -2
  9. package/src/Registration/InboundTranslation/SignUp.res.mjs +6 -2
  10. package/src/Registration/InboundTranslation/SignUp_Translation.res +24 -13
  11. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +13 -4
  12. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +9 -3
  13. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +7 -3
  14. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +10 -7
  15. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +17 -8
  16. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +27 -6
  17. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +13 -6
  18. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +19 -17
  19. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +73 -33
  20. package/src/Registration/StateChange/Registrations.res +58 -27
  21. package/src/Registration/StateChange/Registrations.res.mjs +58 -28
  22. package/src/Registration/StateChange/Registrations_Decision.res +67 -26
  23. package/src/Registration/StateChange/Registrations_Decision.res.mjs +91 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-registration",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.21",
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.206",
17
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.108",
18
- "@reventlessdev/reventless-spec": "3.0.0-alpha.177"
16
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.194",
17
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.111",
18
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.223"
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 */
@@ -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
  }));
@@ -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
+ emailId: 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
+ emailId: id,
46
+ proofHash: proofHash,
40
47
  presentedAt: new Date().toISOString()
41
48
  }
42
49
  ]]
@@ -18,12 +18,13 @@
18
18
  /** `role` may be left out where exactly one role is open to visitors; with
19
19
  several, a sign-up has to say which. */
20
20
  @schema
21
- type externalInput = {email: string, role?: string}
21
+ type externalInput = {@sensitive email: string, role?: string}
22
22
 
23
23
  @schema
24
24
  type command =
25
25
  | Register({
26
- email: ContactAddressId.t,
26
+ emailId: ContactAddressId.t,
27
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
27
28
  role: Reventless.Role.name,
28
29
  requestedAt: Reventless.DateTime.t,
29
30
  })
@@ -1,19 +1,23 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Sury from "sury";
4
+ import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
4
5
  import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
6
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
5
7
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
8
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
9
+ import * as Sensitive$Reventless from "@reventlessdev/reventless-spec/src/components/Sensitive.res.mjs";
7
10
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
8
11
 
9
12
  let externalInputSchema = Sury.$schema(s => ({
10
- email: s.m(Sury.string),
13
+ email: s.m(Sensitive$Reventless.string),
11
14
  role: s.m(Sury.$option(Sury.string))
12
15
  }));
13
16
 
14
17
  let commandSchema = Sury.$schema(s => ({
15
18
  TAG: "Register",
16
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
19
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
20
+ email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
17
21
  role: s.m(Role$Reventless.nameSchema),
18
22
  requestedAt: s.m(DateTime$Reventless.schema)
19
23
  }));
@@ -13,10 +13,14 @@ 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
- | (Ok(email), role) =>
23
+ | (Ok(typed), role) =>
20
24
  switch role
21
25
  ->Option.map(String.trim)
22
26
  ->Option.filter(r => r != "")
@@ -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 email = typed->ContactAddressId.normalize
32
+ switch ContactAddressId.fingerprint(capabilities.secrets, email) {
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
+ emailId: id,
42
+ email,
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 email = ContactAddressId$ReventlessRegistration.normalize(match._0);
36
+ let why = ContactAddressId$ReventlessRegistration.fingerprint(capabilities.secrets, email);
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
+ emailId: id,
51
+ email: email,
43
52
  role: role,
44
53
  requestedAt: new Date().toISOString()
45
54
  }
@@ -15,16 +15,22 @@
15
15
  @schema
16
16
  type consumedEvent =
17
17
  | RegistrationProofAccepted({
18
- email: string,
18
+ emailId: string,
19
+ @pii({subject: "emailId"}) email: 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
+ emailId: string,
27
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
28
+ roles: array<Reventless.Role.name>,
29
+ proofHash: string,
30
+ }
25
31
 
26
32
  @schema
27
- type inboundCommand = RecordRegistrationCompleted({email: ContactAddressId.t})
33
+ type inboundCommand = RecordRegistrationCompleted({emailId: ContactAddressId.t})
28
34
 
29
35
  // For a provider that is down. The password is put back before each retry, so a
30
36
  // retry finds it; once the budget is spent, it expires.
@@ -1,26 +1,30 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Sury from "sury";
4
+ import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
4
5
  import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
6
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
5
7
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
8
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
7
9
 
8
10
  let consumedEventSchema = Sury.$schema(s => ({
9
11
  TAG: "RegistrationProofAccepted",
10
- email: s.m(Sury.string),
12
+ emailId: s.m(DcbTag$Reventless.string),
13
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
11
14
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
12
15
  proofHash: s.m(Sury.string)
13
16
  }));
14
17
 
15
18
  let outboundItemSchema = Sury.$schema(s => ({
16
- email: s.m(Sury.string),
19
+ emailId: s.m(Sury.string),
20
+ email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
17
21
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
18
22
  proofHash: s.m(Sury.string)
19
23
  }));
20
24
 
21
25
  let inboundCommandSchema = Sury.$schema(s => ({
22
26
  TAG: "RecordRegistrationCompleted",
23
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
27
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
24
28
  }));
25
29
 
26
30
  let sourceNames = [];
@@ -9,13 +9,16 @@ 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({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
- let completed = (email: string) => Ok(
18
- 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)}))),
19
22
  )
20
23
 
21
24
  let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabilities.t) =>
@@ -26,14 +29,14 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
26
29
  | Ok(None) => Error("the password expired before the account was made")
27
30
  | Ok(Some(password)) =>
28
31
  switch await capabilities.identityProvider.createPrincipal(
29
- ~contact=ToEmail(Reventless.Email.unsafe(item.email)),
32
+ ~contact=ToEmail(item.email),
30
33
  ~credential=Password(password),
31
34
  ~groups=groupsOf(item.roles),
32
35
  ) {
33
- | Ok(_) => completed(item.email)
36
+ | Ok(_) => completed(item.emailId)
34
37
  // The provider already holds this address — an account declared before
35
38
  // registration existed, say. It is as registered as one made here.
36
- | Error(Conflict) => completed(item.email)
39
+ | Error(Conflict) => completed(item.emailId)
37
40
  | Error(Unavailable(why)) =>
38
41
  // Put back so the retry finds it. Failing that, the retry reports the
39
42
  // password gone, which is true.
@@ -9,26 +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,
25
+ emailId: emailId,
26
+ email: email._0,
18
27
  roles: event.roles,
19
28
  proofHash: proofHash
20
29
  }
21
30
  ]];
22
31
  }
23
32
 
24
- function completed(email) {
33
+ function completed(emailId) {
25
34
  return {
26
35
  TAG: "Ok",
27
36
  _0: [
28
- email,
37
+ emailId,
29
38
  {
30
39
  TAG: "RecordRegistrationCompleted",
31
- email: ContactAddressId$ReventlessRegistration.makeFromString(email)
40
+ emailId: ContactAddressId$ReventlessRegistration.makeFromString(emailId)
32
41
  }
33
42
  ]
34
43
  };
@@ -57,11 +66,11 @@ async function translate(_id, item, capabilities) {
57
66
  _0: password
58
67
  }, item.roles.map(Role$Reventless.groupOf));
59
68
  if (match.TAG === "Ok") {
60
- return completed(item.email);
69
+ return completed(item.emailId);
61
70
  }
62
71
  let why = match._0;
63
72
  if (typeof why !== "object") {
64
- return completed(item.email);
73
+ return completed(item.emailId);
65
74
  }
66
75
  if (why.TAG !== "Unavailable") {
67
76
  return {
@@ -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,30 +18,48 @@
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
+ emailId: string,
23
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
24
+ requestedAt: Reventless.DateTime.t,
25
+ })
26
+ | RegistrationAttemptedOnTakenAddress({
27
+ emailId: string,
28
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
29
+ attemptedAt: Reventless.DateTime.t,
30
+ })
20
31
  | RegistrationInvited({
21
- email: string,
32
+ emailId: string,
33
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
22
34
  roles: array<string>,
23
35
  invitedBy: string,
24
36
  invitedAt: Reventless.DateTime.t,
25
37
  })
26
38
  | RegistrationChallengeReissued({
27
- email: string,
39
+ emailId: string,
40
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
28
41
  reissuedAt: Reventless.DateTime.t,
29
42
  invitedBy?: string,
30
43
  })
31
44
 
45
+ // `emailId` is the ledger's id for the address, `email` 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
+ emailId: string,
53
+ @pii({subject: "emailId"}) email: Reventless.Email.t,
54
+ alreadyRegistered: bool,
55
+ invited?: bool,
56
+ roles?: array<string>,
57
+ }
37
58
 
38
59
  @schema
39
60
  type inboundCommand =
40
61
  | IssueRegistrationChallenge({
41
- email: ContactAddressId.t,
62
+ emailId: ContactAddressId.t,
42
63
  proofHash: string,
43
64
  issuedAt: Reventless.DateTime.t,
44
65
  })
@@ -1,6 +1,8 @@
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";
5
+ import * as Email$Reventless from "@reventlessdev/reventless-spec/src/semantic/Email.res.mjs";
4
6
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
5
7
  import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
6
8
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
@@ -8,31 +10,36 @@ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.re
8
10
  let consumedEventSchema = Sury.union([
9
11
  Sury.$schema(s => ({
10
12
  TAG: "RegistrationRequested",
11
- email: s.m(Sury.string),
13
+ emailId: s.m(DcbTag$Reventless.string),
14
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
12
15
  requestedAt: s.m(DateTime$Reventless.schema)
13
16
  })),
14
17
  Sury.$schema(s => ({
15
18
  TAG: "RegistrationAttemptedOnTakenAddress",
16
- email: s.m(Sury.string),
19
+ emailId: s.m(DcbTag$Reventless.string),
20
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
17
21
  attemptedAt: s.m(DateTime$Reventless.schema)
18
22
  })),
19
23
  Sury.$schema(s => ({
20
24
  TAG: "RegistrationInvited",
21
- email: s.m(Sury.string),
25
+ emailId: s.m(DcbTag$Reventless.string),
26
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
22
27
  roles: s.m(Sury.array(Sury.string)),
23
28
  invitedBy: s.m(Sury.string),
24
29
  invitedAt: s.m(DateTime$Reventless.schema)
25
30
  })),
26
31
  Sury.$schema(s => ({
27
32
  TAG: "RegistrationChallengeReissued",
28
- email: s.m(Sury.string),
33
+ emailId: s.m(DcbTag$Reventless.string),
34
+ email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
29
35
  reissuedAt: s.m(DateTime$Reventless.schema),
30
36
  invitedBy: s.m(Sury.$option(Sury.string))
31
37
  }))
32
38
  ]);
33
39
 
34
40
  let outboundItemSchema = Sury.$schema(s => ({
35
- email: s.m(Sury.string),
41
+ emailId: s.m(Sury.string),
42
+ email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
36
43
  alreadyRegistered: s.m(Sury.boolean),
37
44
  invited: s.m(Sury.$option(Sury.boolean)),
38
45
  roles: s.m(Sury.$option(Sury.array(Sury.string)))
@@ -40,7 +47,7 @@ let outboundItemSchema = Sury.$schema(s => ({
40
47
 
41
48
  let inboundCommandSchema = Sury.$schema(s => ({
42
49
  TAG: "IssueRegistrationChallenge",
43
- email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
50
+ emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
44
51
  proofHash: s.m(Sury.string),
45
52
  issuedAt: s.m(DateTime$Reventless.schema)
46
53
  }));