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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-registration",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
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.209",
16
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.211",
17
17
  "@reventlessdev/reventless-ppx": "1.0.0-alpha.108",
18
- "@reventlessdev/reventless-spec": "3.0.0-alpha.180"
18
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.182"
19
19
  },
20
20
  "devDependencies": {
21
21
  "rescript": "12.3.1"
@@ -24,7 +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
+ @pii({subject: "email"}) address: Reventless.Email.t,
28
28
  role: Reventless.Role.name,
29
29
  requestedAt: Reventless.DateTime.t,
30
30
  })
@@ -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";
@@ -15,7 +16,7 @@ let externalInputSchema = Sury.$schema(s => ({
15
16
  let commandSchema = Sury.$schema(s => ({
16
17
  TAG: "Register",
17
18
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
18
- address: s.m(Email$Reventless.schema),
19
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
19
20
  role: s.m(Role$Reventless.nameSchema),
20
21
  requestedAt: s.m(DateTime$Reventless.schema)
21
22
  }));
@@ -16,7 +16,7 @@
16
16
  type consumedEvent =
17
17
  | RegistrationProofAccepted({
18
18
  email: string,
19
- address: Reventless.Email.t,
19
+ @pii({subject: "email"}) address: Reventless.Email.t,
20
20
  roles: array<Reventless.Role.name>,
21
21
  proofHash: string,
22
22
  })
@@ -24,7 +24,7 @@ type consumedEvent =
24
24
  @schema
25
25
  type outboundItem = {
26
26
  email: string,
27
- address: Reventless.Email.t,
27
+ @pii({subject: "email"}) address: Reventless.Email.t,
28
28
  roles: array<Reventless.Role.name>,
29
29
  proofHash: string,
30
30
  }
@@ -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";
@@ -9,14 +10,14 @@ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.re
9
10
  let consumedEventSchema = Sury.$schema(s => ({
10
11
  TAG: "RegistrationProofAccepted",
11
12
  email: s.m(Sury.string),
12
- address: s.m(Email$Reventless.schema),
13
+ address: s.m(Pii$Reventless.marked("email", 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
19
  email: s.m(Sury.string),
19
- address: s.m(Email$Reventless.schema),
20
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
20
21
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
21
22
  proofHash: s.m(Sury.string)
22
23
  }));
@@ -9,9 +9,11 @@ let retryTtl = 600
9
9
 
10
10
  let collect = (event, ~sourceId as _) =>
11
11
  switch event {
12
- | RegistrationProofAccepted({email, address, roles, proofHash}) => [
12
+ | RegistrationProofAccepted({email, address: Value(address), roles, proofHash}) => [
13
13
  (`${email}:${proofHash}`, {email, address, roles, proofHash}),
14
14
  ]
15
+ // An address that was erased or forgotten has nobody left to write to.
16
+ | _ => []
15
17
  }
16
18
 
17
19
  // `email` is already the ledger's id for the address: no key is needed to say so.
@@ -9,13 +9,21 @@ function groupsOf(roles) {
9
9
  }
10
10
 
11
11
  function collect(event, param) {
12
- let proofHash = event.proofHash;
12
+ let address = event.address;
13
13
  let email = event.email;
14
+ if (typeof address !== "object") {
15
+ if (address === "Erased") {
16
+ return [];
17
+ } else {
18
+ return [];
19
+ }
20
+ }
21
+ let proofHash = event.proofHash;
14
22
  return [[
15
23
  email + `:` + proofHash,
16
24
  {
17
25
  email: email,
18
- address: event.address,
26
+ address: address._0,
19
27
  roles: event.roles,
20
28
  proofHash: proofHash
21
29
  }
@@ -20,24 +20,24 @@
20
20
  type consumedEvent =
21
21
  | RegistrationRequested({
22
22
  email: string,
23
- address: Reventless.Email.t,
23
+ @pii({subject: "email"}) address: Reventless.Email.t,
24
24
  requestedAt: Reventless.DateTime.t,
25
25
  })
26
26
  | RegistrationAttemptedOnTakenAddress({
27
27
  email: string,
28
- address: Reventless.Email.t,
28
+ @pii({subject: "email"}) address: Reventless.Email.t,
29
29
  attemptedAt: Reventless.DateTime.t,
30
30
  })
31
31
  | RegistrationInvited({
32
32
  email: string,
33
- address: Reventless.Email.t,
33
+ @pii({subject: "email"}) address: Reventless.Email.t,
34
34
  roles: array<string>,
35
35
  invitedBy: string,
36
36
  invitedAt: Reventless.DateTime.t,
37
37
  })
38
38
  | RegistrationChallengeReissued({
39
39
  email: string,
40
- address: Reventless.Email.t,
40
+ @pii({subject: "email"}) address: Reventless.Email.t,
41
41
  reissuedAt: Reventless.DateTime.t,
42
42
  invitedBy?: string,
43
43
  })
@@ -50,7 +50,7 @@ type consumedEvent =
50
50
  @schema
51
51
  type outboundItem = {
52
52
  email: string,
53
- address: Reventless.Email.t,
53
+ @pii({subject: "email"}) address: Reventless.Email.t,
54
54
  alreadyRegistered: bool,
55
55
  invited?: bool,
56
56
  roles?: array<string>,
@@ -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 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";
@@ -10,19 +11,19 @@ let consumedEventSchema = Sury.union([
10
11
  Sury.$schema(s => ({
11
12
  TAG: "RegistrationRequested",
12
13
  email: s.m(Sury.string),
13
- address: s.m(Email$Reventless.schema),
14
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
14
15
  requestedAt: s.m(DateTime$Reventless.schema)
15
16
  })),
16
17
  Sury.$schema(s => ({
17
18
  TAG: "RegistrationAttemptedOnTakenAddress",
18
19
  email: s.m(Sury.string),
19
- address: s.m(Email$Reventless.schema),
20
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
20
21
  attemptedAt: s.m(DateTime$Reventless.schema)
21
22
  })),
22
23
  Sury.$schema(s => ({
23
24
  TAG: "RegistrationInvited",
24
25
  email: s.m(Sury.string),
25
- address: s.m(Email$Reventless.schema),
26
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
26
27
  roles: s.m(Sury.array(Sury.string)),
27
28
  invitedBy: s.m(Sury.string),
28
29
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -30,7 +31,7 @@ let consumedEventSchema = Sury.union([
30
31
  Sury.$schema(s => ({
31
32
  TAG: "RegistrationChallengeReissued",
32
33
  email: s.m(Sury.string),
33
- address: s.m(Email$Reventless.schema),
34
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
34
35
  reissuedAt: s.m(DateTime$Reventless.schema),
35
36
  invitedBy: s.m(Sury.$option(Sury.string))
36
37
  }))
@@ -38,7 +39,7 @@ let consumedEventSchema = Sury.union([
38
39
 
39
40
  let outboundItemSchema = Sury.$schema(s => ({
40
41
  email: s.m(Sury.string),
41
- address: s.m(Email$Reventless.schema),
42
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
42
43
  alreadyRegistered: s.m(Sury.boolean),
43
44
  invited: s.m(Sury.$option(Sury.boolean)),
44
45
  roles: s.m(Sury.$option(Sury.array(Sury.string)))
@@ -4,30 +4,32 @@
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, address, requestedAt}) => [
7
+ | RegistrationRequested({email, address: Value(address), requestedAt}) => [
8
8
  (
9
9
  `${email}:${requestedAt->Reventless.DateTime.toString}`,
10
10
  {email, address, alreadyRegistered: false},
11
11
  ),
12
12
  ]
13
- | RegistrationInvited({email, address, roles, invitedAt}) => [
13
+ | RegistrationInvited({email, address: Value(address), roles, invitedAt}) => [
14
14
  (
15
15
  `${email}:invited:${invitedAt->Reventless.DateTime.toString}`,
16
16
  {email, address, alreadyRegistered: false, invited: true, roles},
17
17
  ),
18
18
  ]
19
- | RegistrationChallengeReissued({email, address, reissuedAt, ?invitedBy}) => [
19
+ | RegistrationChallengeReissued({email, address: Value(address), reissuedAt, ?invitedBy}) => [
20
20
  (
21
21
  `${email}:reissued:${reissuedAt->Reventless.DateTime.toString}`,
22
22
  {email, address, alreadyRegistered: false, invited: invitedBy->Option.isSome},
23
23
  ),
24
24
  ]
25
- | RegistrationAttemptedOnTakenAddress({email, address, attemptedAt}) => [
25
+ | RegistrationAttemptedOnTakenAddress({email, address: Value(address), attemptedAt}) => [
26
26
  (
27
27
  `${email}:taken:${attemptedAt->Reventless.DateTime.toString}`,
28
28
  {email, address, alreadyRegistered: true},
29
29
  ),
30
30
  ]
31
+ // An address that was erased or forgotten has nobody left to write to.
32
+ | _ => []
31
33
  }
32
34
 
33
35
  let expiresIn = (~invited) =>
@@ -9,48 +9,84 @@ import * as RegistrationChallenge$ReventlessRegistration from "../../Registratio
9
9
  function collect(event, param) {
10
10
  switch (event.TAG) {
11
11
  case "RegistrationRequested" :
12
+ let address = event.address;
12
13
  let email = event.email;
13
- return [[
14
- email + `:` + event.requestedAt,
15
- {
16
- email: email,
17
- address: event.address,
18
- alreadyRegistered: false
19
- }
20
- ]];
14
+ if (typeof address !== "object") {
15
+ if (address === "Erased") {
16
+ return [];
17
+ } else {
18
+ return [];
19
+ }
20
+ } else {
21
+ return [[
22
+ email + `:` + event.requestedAt,
23
+ {
24
+ email: email,
25
+ address: address._0,
26
+ alreadyRegistered: false
27
+ }
28
+ ]];
29
+ }
21
30
  case "RegistrationAttemptedOnTakenAddress" :
31
+ let address$1 = event.address;
22
32
  let email$1 = event.email;
23
- return [[
24
- email$1 + `:taken:` + event.attemptedAt,
25
- {
26
- email: email$1,
27
- address: event.address,
28
- alreadyRegistered: true
29
- }
30
- ]];
33
+ if (typeof address$1 !== "object") {
34
+ if (address$1 === "Erased") {
35
+ return [];
36
+ } else {
37
+ return [];
38
+ }
39
+ } else {
40
+ return [[
41
+ email$1 + `:taken:` + event.attemptedAt,
42
+ {
43
+ email: email$1,
44
+ address: address$1._0,
45
+ alreadyRegistered: true
46
+ }
47
+ ]];
48
+ }
31
49
  case "RegistrationInvited" :
50
+ let address$2 = event.address;
32
51
  let email$2 = event.email;
33
- return [[
34
- email$2 + `:invited:` + event.invitedAt,
35
- {
36
- email: email$2,
37
- address: event.address,
38
- alreadyRegistered: false,
39
- invited: true,
40
- roles: event.roles
41
- }
42
- ]];
52
+ if (typeof address$2 !== "object") {
53
+ if (address$2 === "Erased") {
54
+ return [];
55
+ } else {
56
+ return [];
57
+ }
58
+ } else {
59
+ return [[
60
+ email$2 + `:invited:` + event.invitedAt,
61
+ {
62
+ email: email$2,
63
+ address: address$2._0,
64
+ alreadyRegistered: false,
65
+ invited: true,
66
+ roles: event.roles
67
+ }
68
+ ]];
69
+ }
43
70
  case "RegistrationChallengeReissued" :
71
+ let address$3 = event.address;
44
72
  let email$3 = event.email;
45
- return [[
46
- email$3 + `:reissued:` + event.reissuedAt,
47
- {
48
- email: email$3,
49
- address: event.address,
50
- alreadyRegistered: false,
51
- invited: Stdlib_Option.isSome(event.invitedBy)
52
- }
53
- ]];
73
+ if (typeof address$3 !== "object") {
74
+ if (address$3 === "Erased") {
75
+ return [];
76
+ } else {
77
+ return [];
78
+ }
79
+ } else {
80
+ return [[
81
+ email$3 + `:reissued:` + event.reissuedAt,
82
+ {
83
+ email: email$3,
84
+ address: address$3._0,
85
+ alreadyRegistered: false,
86
+ invited: Stdlib_Option.isSome(event.invitedBy)
87
+ }
88
+ ]];
89
+ }
54
90
  }
55
91
  }
56
92
 
@@ -41,28 +41,28 @@ type consumedEvent =
41
41
  })
42
42
  | RegistrationRequested({
43
43
  email: ContactAddressId.t,
44
- address: Reventless.Email.t,
44
+ @pii({subject: "email"}) address: Reventless.Email.t,
45
45
  roles: array<string>,
46
46
  requestedAt: Reventless.DateTime.t,
47
47
  })
48
48
  | RegistrationExpired({email: ContactAddressId.t})
49
49
  | RegistrationInvited({
50
50
  email: ContactAddressId.t,
51
- address: Reventless.Email.t,
51
+ @pii({subject: "email"}) address: Reventless.Email.t,
52
52
  roles: array<string>,
53
53
  invitedBy: string,
54
54
  invitedAt: Reventless.DateTime.t,
55
55
  })
56
56
  | RegistrationChallengeReissued({
57
57
  email: ContactAddressId.t,
58
- address: Reventless.Email.t,
58
+ @pii({subject: "email"}) address: Reventless.Email.t,
59
59
  reissuedAt: Reventless.DateTime.t,
60
60
  invitedBy?: string,
61
61
  })
62
62
  | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
63
63
  | RegistrationAttemptedOnTakenAddress({
64
64
  email: ContactAddressId.t,
65
- address: Reventless.Email.t,
65
+ @pii({subject: "email"}) address: Reventless.Email.t,
66
66
  attemptedAt: Reventless.DateTime.t,
67
67
  })
68
68
  | RegistrationChallengeIssued({
@@ -72,7 +72,7 @@ type consumedEvent =
72
72
  })
73
73
  | RegistrationProofAccepted({
74
74
  email: ContactAddressId.t,
75
- address: Reventless.Email.t,
75
+ @pii({subject: "email"}) address: Reventless.Email.t,
76
76
  roles: array<string>,
77
77
  proofHash: string,
78
78
  })
@@ -93,7 +93,7 @@ type command =
93
93
  | @noApi
94
94
  Register({
95
95
  email: ContactAddressId.t,
96
- address: Reventless.Email.t,
96
+ @pii({subject: "email"}) address: Reventless.Email.t,
97
97
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
98
98
  requestedAt: Reventless.DateTime.t,
99
99
  })
@@ -116,7 +116,7 @@ type command =
116
116
  | @noApi
117
117
  Invite({
118
118
  email: ContactAddressId.t,
119
- address: Reventless.Email.t,
119
+ @pii({subject: "email"}) address: Reventless.Email.t,
120
120
  roles: array<Reventless.Role.name>,
121
121
  invitedBy: string,
122
122
  requestedAt: Reventless.DateTime.t,
@@ -144,28 +144,28 @@ type error =
144
144
  type event =
145
145
  | RegistrationRequested({
146
146
  email: ContactAddressId.t,
147
- address: Reventless.Email.t,
147
+ @pii({subject: "email"}) address: Reventless.Email.t,
148
148
  roles: array<string>,
149
149
  requestedAt: Reventless.DateTime.t,
150
150
  })
151
151
  | RegistrationExpired({email: ContactAddressId.t})
152
152
  | RegistrationInvited({
153
153
  email: ContactAddressId.t,
154
- address: Reventless.Email.t,
154
+ @pii({subject: "email"}) address: Reventless.Email.t,
155
155
  roles: array<string>,
156
156
  invitedBy: string,
157
157
  invitedAt: Reventless.DateTime.t,
158
158
  })
159
159
  | RegistrationChallengeReissued({
160
160
  email: ContactAddressId.t,
161
- address: Reventless.Email.t,
161
+ @pii({subject: "email"}) address: Reventless.Email.t,
162
162
  reissuedAt: Reventless.DateTime.t,
163
163
  invitedBy?: string,
164
164
  })
165
165
  | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
166
166
  | RegistrationAttemptedOnTakenAddress({
167
167
  email: ContactAddressId.t,
168
- address: Reventless.Email.t,
168
+ @pii({subject: "email"}) address: Reventless.Email.t,
169
169
  attemptedAt: Reventless.DateTime.t,
170
170
  })
171
171
  | RegistrationChallengeIssued({
@@ -175,7 +175,7 @@ type event =
175
175
  })
176
176
  | RegistrationProofAccepted({
177
177
  email: ContactAddressId.t,
178
- address: Reventless.Email.t,
178
+ @pii({subject: "email"}) address: Reventless.Email.t,
179
179
  roles: array<string>,
180
180
  proofHash: string,
181
181
  })
@@ -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";
@@ -21,7 +22,7 @@ let consumedEventSchema = Sury.union([
21
22
  Sury.$schema(s => ({
22
23
  TAG: "RegistrationRequested",
23
24
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
24
- address: s.m(Email$Reventless.schema),
25
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
25
26
  roles: s.m(Sury.array(Sury.string)),
26
27
  requestedAt: s.m(DateTime$Reventless.schema)
27
28
  })),
@@ -32,7 +33,7 @@ let consumedEventSchema = Sury.union([
32
33
  Sury.$schema(s => ({
33
34
  TAG: "RegistrationInvited",
34
35
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
35
- address: s.m(Email$Reventless.schema),
36
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
36
37
  roles: s.m(Sury.array(Sury.string)),
37
38
  invitedBy: s.m(Sury.string),
38
39
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -40,7 +41,7 @@ let consumedEventSchema = Sury.union([
40
41
  Sury.$schema(s => ({
41
42
  TAG: "RegistrationChallengeReissued",
42
43
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
43
- address: s.m(Email$Reventless.schema),
44
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
44
45
  reissuedAt: s.m(DateTime$Reventless.schema),
45
46
  invitedBy: s.m(Sury.$option(Sury.string))
46
47
  })),
@@ -52,7 +53,7 @@ let consumedEventSchema = Sury.union([
52
53
  Sury.$schema(s => ({
53
54
  TAG: "RegistrationAttemptedOnTakenAddress",
54
55
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
55
- address: s.m(Email$Reventless.schema),
56
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
56
57
  attemptedAt: s.m(DateTime$Reventless.schema)
57
58
  })),
58
59
  Sury.$schema(s => ({
@@ -64,7 +65,7 @@ let consumedEventSchema = Sury.union([
64
65
  Sury.$schema(s => ({
65
66
  TAG: "RegistrationProofAccepted",
66
67
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
67
- address: s.m(Email$Reventless.schema),
68
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
68
69
  roles: s.m(Sury.array(Sury.string)),
69
70
  proofHash: s.m(Sury.string)
70
71
  })),
@@ -83,7 +84,7 @@ let commandSchema = Sury.union([
83
84
  Sury.$schema(s => ({
84
85
  TAG: "Register",
85
86
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
86
- address: s.m(Email$Reventless.schema),
87
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
87
88
  role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
88
89
  requestedAt: s.m(DateTime$Reventless.schema)
89
90
  })),
@@ -106,7 +107,7 @@ let commandSchema = Sury.union([
106
107
  Sury.$schema(s => ({
107
108
  TAG: "Invite",
108
109
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
109
- address: s.m(Email$Reventless.schema),
110
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
110
111
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
111
112
  invitedBy: s.m(Sury.string),
112
113
  requestedAt: s.m(DateTime$Reventless.schema)
@@ -135,7 +136,7 @@ let eventSchema = Sury.union([
135
136
  Sury.$schema(s => ({
136
137
  TAG: "RegistrationRequested",
137
138
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
138
- address: s.m(Email$Reventless.schema),
139
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
139
140
  roles: s.m(Sury.array(Sury.string)),
140
141
  requestedAt: s.m(DateTime$Reventless.schema)
141
142
  })),
@@ -146,7 +147,7 @@ let eventSchema = Sury.union([
146
147
  Sury.$schema(s => ({
147
148
  TAG: "RegistrationInvited",
148
149
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
149
- address: s.m(Email$Reventless.schema),
150
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
150
151
  roles: s.m(Sury.array(Sury.string)),
151
152
  invitedBy: s.m(Sury.string),
152
153
  invitedAt: s.m(DateTime$Reventless.schema)
@@ -154,7 +155,7 @@ let eventSchema = Sury.union([
154
155
  Sury.$schema(s => ({
155
156
  TAG: "RegistrationChallengeReissued",
156
157
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
157
- address: s.m(Email$Reventless.schema),
158
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
158
159
  reissuedAt: s.m(DateTime$Reventless.schema),
159
160
  invitedBy: s.m(Sury.$option(Sury.string))
160
161
  })),
@@ -166,7 +167,7 @@ let eventSchema = Sury.union([
166
167
  Sury.$schema(s => ({
167
168
  TAG: "RegistrationAttemptedOnTakenAddress",
168
169
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
169
- address: s.m(Email$Reventless.schema),
170
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
170
171
  attemptedAt: s.m(DateTime$Reventless.schema)
171
172
  })),
172
173
  Sury.$schema(s => ({
@@ -178,7 +179,7 @@ let eventSchema = Sury.union([
178
179
  Sury.$schema(s => ({
179
180
  TAG: "RegistrationProofAccepted",
180
181
  email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
181
- address: s.m(Email$Reventless.schema),
182
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
182
183
  roles: s.m(Sury.array(Sury.string)),
183
184
  proofHash: s.m(Sury.string)
184
185
  })),
@@ -19,7 +19,7 @@ type policyState =
19
19
  type pending = {
20
20
  /** The address the claim was made for: where its code goes, and what an
21
21
  accepted proof makes an account for. */
22
- address: Reventless.Email.t,
22
+ address: Reventless.Pii.t<Reventless.Email.t>,
23
23
  /** When the claim was made, or its code last reissued: what a claim with no
24
24
  challenge out lapses from. */
25
25
  requestedAt: Reventless.DateTime.t,
@@ -53,6 +53,12 @@ let initialState = {admission: Unset, stage: Unclaimed, lastNoticeAt: None}
53
53
  so the door cannot be used to flood a registered person's inbox. */
54
54
  let noticeCooldown = 3600
55
55
 
56
+ /** The contact a challenge is held against. The guards only compare it, so the
57
+ ledger's id for the address serves, and no address is needed to decide. */
58
+ let contactOf = (email: ContactAddressId.t): ContactVerification.contact => ByEmail(
59
+ Reventless.Email.unsafe(email->ContactAddressId.toString),
60
+ )
61
+
56
62
  let purposeOf = (p: pending) => RegistrationChallenge.purposeOf(~invitedBy=p.invitedBy)
57
63
 
58
64
  /** The challenge rules a pending registration is held to: an invitation's code
@@ -83,14 +89,14 @@ let evolve = (state, event) =>
83
89
  ...state,
84
90
  lastNoticeAt: Some(attemptedAt),
85
91
  }
86
- | RegistrationChallengeIssued({proofHash, issuedAt}) =>
92
+ | RegistrationChallengeIssued({email, proofHash, issuedAt}) =>
87
93
  switch state.stage {
88
94
  | Pending(p) => {
89
95
  ...state,
90
96
  stage: Pending({
91
97
  ...p,
92
98
  challenge: Some({
93
- contact: ByEmail(p.address),
99
+ contact: contactOf(email),
94
100
  purpose: purposeOf(p),
95
101
  issuedAt,
96
102
  attempts: 0,
@@ -188,7 +194,13 @@ module Make = (App: Reventless.Admission.Declaration) => {
188
194
  | Some(last) if Guards.elapsedSeconds(~from=last, ~to_=requestedAt) < noticeCooldown =>
189
195
  Ok([])
190
196
  | _ =>
191
- Ok([RegistrationAttemptedOnTakenAddress({email, address, attemptedAt: requestedAt})])
197
+ Ok([
198
+ RegistrationAttemptedOnTakenAddress({
199
+ email,
200
+ address: Value(address),
201
+ attemptedAt: requestedAt,
202
+ }),
203
+ ])
192
204
  }
193
205
  | Verified => Ok([])
194
206
  // A visitor cannot take over a claim, an inviter's included, while it holds.
@@ -196,9 +208,10 @@ module Make = (App: Reventless.Admission.Declaration) => {
196
208
  | Pending(_) =>
197
209
  Ok([
198
210
  RegistrationExpired({email: email}),
199
- RegistrationRequested({email, address, roles, requestedAt}),
211
+ RegistrationRequested({email, address: Value(address), roles, requestedAt}),
200
212
  ])
201
- | Unclaimed => Ok([RegistrationRequested({email, address, roles, requestedAt})])
213
+ | Unclaimed =>
214
+ Ok([RegistrationRequested({email, address: Value(address), roles, requestedAt})])
202
215
  }
203
216
  }
204
217
 
@@ -212,7 +225,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
212
225
  | None =>
213
226
  let invited = RegistrationInvited({
214
227
  email,
215
- address,
228
+ address: Value(address),
216
229
  roles: roles->Array.map(r => (r :> string)),
217
230
  invitedBy,
218
231
  invitedAt: requestedAt,
@@ -231,7 +244,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
231
244
  switch state.stage {
232
245
  | Pending(p) =>
233
246
  switch Guards.onIssueRequested(
234
- ~contact=ByEmail(p.address),
247
+ ~contact=contactOf(email),
235
248
  ~existing=p.challenge,
236
249
  ~now=issuedAt,
237
250
  ~policy=policyOf(p),
@@ -4,6 +4,7 @@ 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";
7
8
  import * as RegistrationChallenge$ReventlessRegistration from "../../RegistrationChallenge.res.mjs";
8
9
  import * as ContactVerification_Guards$ReventlessRegistration from "../../ContactVerification_Guards.res.mjs";
9
10
 
@@ -13,6 +14,13 @@ let initialState = {
13
14
  lastNoticeAt: undefined
14
15
  };
15
16
 
17
+ function contactOf(email) {
18
+ return {
19
+ TAG: "ByEmail",
20
+ _0: ContactAddressId$ReventlessRegistration.toString(email)
21
+ };
22
+ }
23
+
16
24
  function purposeOf(p) {
17
25
  return RegistrationChallenge$ReventlessRegistration.purposeOf(p.invitedBy);
18
26
  }
@@ -110,7 +118,7 @@ function evolve(state, event) {
110
118
  _0: (newrecord$1.proofHash = event.proofHash, newrecord$1.challenge = {
111
119
  contact: {
112
120
  TAG: "ByEmail",
113
- _0: p$2.address
121
+ _0: ContactAddressId$ReventlessRegistration.toString(event.email)
114
122
  },
115
123
  purpose: RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy),
116
124
  issuedAt: event.issuedAt,
@@ -233,7 +241,10 @@ function Make(App) {
233
241
  {
234
242
  TAG: "RegistrationRequested",
235
243
  email: email,
236
- address: address,
244
+ address: {
245
+ TAG: "Value",
246
+ _0: address
247
+ },
237
248
  roles: roles,
238
249
  requestedAt: requestedAt
239
250
  }
@@ -253,7 +264,10 @@ function Make(App) {
253
264
  _0: [{
254
265
  TAG: "RegistrationRequested",
255
266
  email: email,
256
- address: address,
267
+ address: {
268
+ TAG: "Value",
269
+ _0: address
270
+ },
257
271
  roles: roles,
258
272
  requestedAt: requestedAt
259
273
  }]
@@ -265,37 +279,29 @@ function Make(App) {
265
279
  };
266
280
  case "Completed" :
267
281
  let last = state.lastNoticeAt;
268
- if (last !== undefined) {
269
- if (ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
270
- return {
271
- TAG: "Ok",
272
- _0: []
273
- };
274
- } else {
275
- return {
276
- TAG: "Ok",
277
- _0: [{
278
- TAG: "RegistrationAttemptedOnTakenAddress",
279
- email: email,
280
- address: address,
281
- attemptedAt: requestedAt
282
- }]
283
- };
284
- }
285
- } else {
282
+ if (last !== undefined && ContactVerification_Guards$ReventlessRegistration.elapsedSeconds(last, requestedAt) < 3600) {
286
283
  return {
287
284
  TAG: "Ok",
288
- _0: [{
289
- TAG: "RegistrationAttemptedOnTakenAddress",
290
- email: email,
291
- address: address,
292
- attemptedAt: requestedAt
293
- }]
285
+ _0: []
294
286
  };
295
287
  }
288
+ return {
289
+ TAG: "Ok",
290
+ _0: [{
291
+ TAG: "RegistrationAttemptedOnTakenAddress",
292
+ email: email,
293
+ address: {
294
+ TAG: "Value",
295
+ _0: address
296
+ },
297
+ attemptedAt: requestedAt
298
+ }]
299
+ };
296
300
  }
301
+ break;
297
302
  case "IssueRegistrationChallenge" :
298
303
  let issuedAt = command.issuedAt;
304
+ let email$1 = command.email;
299
305
  let p$1 = state.stage;
300
306
  if (typeof p$1 !== "object") {
301
307
  return {
@@ -306,14 +312,14 @@ function Make(App) {
306
312
  let p$2 = p$1._0;
307
313
  let match = ContactVerification_Guards$ReventlessRegistration.onIssueRequested({
308
314
  TAG: "ByEmail",
309
- _0: p$2.address
315
+ _0: ContactAddressId$ReventlessRegistration.toString(email$1)
310
316
  }, p$2.challenge, issuedAt, RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeOf(p$2.invitedBy)));
311
317
  if (match === "Issue") {
312
318
  return {
313
319
  TAG: "Ok",
314
320
  _0: [{
315
321
  TAG: "RegistrationChallengeIssued",
316
- email: command.email,
322
+ email: email$1,
317
323
  proofHash: command.proofHash,
318
324
  issuedAt: issuedAt
319
325
  }]
@@ -326,7 +332,7 @@ function Make(App) {
326
332
  }
327
333
  case "SubmitRegistrationProof" :
328
334
  let proofHash = command.proofHash;
329
- let email$1 = command.email;
335
+ let email$2 = command.email;
330
336
  let p$3 = state.stage;
331
337
  if (typeof p$3 !== "object") {
332
338
  return {
@@ -355,7 +361,7 @@ function Make(App) {
355
361
  TAG: "Ok",
356
362
  _0: [{
357
363
  TAG: "RegistrationProofAccepted",
358
- email: email$1,
364
+ email: email$2,
359
365
  address: p$4.address,
360
366
  roles: p$4.roles,
361
367
  proofHash: proofHash
@@ -366,7 +372,7 @@ function Make(App) {
366
372
  TAG: "Ok",
367
373
  _0: [{
368
374
  TAG: "RegistrationProofRefused",
369
- email: email$1,
375
+ email: email$2,
370
376
  reason: refusalReason(reason._0)
371
377
  }]
372
378
  };
@@ -397,7 +403,7 @@ function Make(App) {
397
403
  case "Invite" :
398
404
  let requestedAt$1 = command.requestedAt;
399
405
  let roles$1 = command.roles;
400
- let email$2 = command.email;
406
+ let email$3 = command.email;
401
407
  let role$1 = roles$1.find(r => !isByInvitation(App.table, r));
402
408
  if (role$1 !== undefined) {
403
409
  return {
@@ -414,12 +420,15 @@ function Make(App) {
414
420
  _0: "NoRoleToGrant"
415
421
  };
416
422
  }
417
- let invited_1 = command.address;
423
+ let invited_1 = {
424
+ TAG: "Value",
425
+ _0: command.address
426
+ };
418
427
  let invited_2 = roles$1.map(r => r);
419
428
  let invited_3 = command.invitedBy;
420
429
  let invited = {
421
430
  TAG: "RegistrationInvited",
422
- email: email$2,
431
+ email: email$3,
423
432
  address: invited_1,
424
433
  roles: invited_2,
425
434
  invitedBy: invited_3,
@@ -433,7 +442,7 @@ function Make(App) {
433
442
  _0: [
434
443
  {
435
444
  TAG: "RegistrationExpired",
436
- email: email$2
445
+ email: email$3
437
446
  },
438
447
  invited
439
448
  ]
@@ -537,6 +546,7 @@ export {
537
546
  Guards,
538
547
  initialState,
539
548
  noticeCooldown,
549
+ contactOf,
540
550
  purposeOf,
541
551
  policyOf,
542
552
  evolve,