@reventlessdev/reventless-registration 1.0.0-alpha.26 → 1.0.0-alpha.28

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/README.md CHANGED
@@ -44,6 +44,16 @@ Reventless.Admission.Invite`, checks the inviter's roles, and relays `Invite` to
44
44
  ledger. The ledger refuses any role the app's table does not declare by invitation.
45
45
  An invitation's code holds a week; a sign-up's holds a day.
46
46
 
47
+ The mails are written in the recipient's language where the deployment has the words:
48
+ their keys are `registration.*`, and `i18n/en.json` holds their English. A deployment
49
+ lists `node_modules/@reventlessdev/reventless-registration/i18n` among its catalogue
50
+ sources, before its own, and translates the keys there. Without a translation the
51
+ mails go out in that English. A sign-up may say which language the visitor reads
52
+ (`language`, a tag such as `de`); the codes for that registration are written in it
53
+ where the deployment offers it, unless the address already holds an account, whose
54
+ own language wins. The ledger records the language and the key of the mail each code
55
+ went out in.
56
+
47
57
  The scenarios that pin these slices run in the plugins that list them, against that
48
58
  plugin's own table: in this repository, `examples/online-shop-hybrid/registration`.
49
59
 
package/i18n/en.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "registration.challenge.body": "Your registration code is {token}. Enter it with a password of your choice to finish. It expires in {expiresIn}.",
3
+ "registration.challenge.subject": "Finish your registration",
4
+ "registration.invited.body": "You have been invited to create an account{hasRoles, select, yes { as {roles}} other {}}. Your code is {token}. Enter it with this address and a password of your choice to accept. It expires in {expiresIn}.",
5
+ "registration.invited.subject": "You are invited to create an account",
6
+ "registration.taken.body": "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.",
7
+ "registration.taken.subject": "Someone tried to register with your address"
8
+ }
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-registration",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.28",
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": [
7
7
  "src/**/*.res",
8
8
  "src/**/*.resi",
9
9
  "src/**/*.res.mjs",
10
+ "i18n/*.json",
10
11
  "rescript.json",
11
12
  "README.md"
12
13
  ],
13
14
  "dependencies": {
14
15
  "sury": "11.1.0",
15
16
  "sury-ppx": "11.1.0",
16
- "@reventlessdev/reventless-infra": "3.0.0-alpha.228",
17
- "@reventlessdev/reventless-spec": "3.0.0-alpha.197",
17
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.230",
18
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.199",
18
19
  "@reventlessdev/reventless-ppx": "1.0.0-alpha.111"
19
20
  },
20
21
  "devDependencies": {
@@ -16,9 +16,10 @@
16
16
  @@reventless.authorize(AllowAnonymous)
17
17
 
18
18
  /** `role` may be left out where exactly one role is open to visitors; with
19
- several, a sign-up has to say which. */
19
+ several, a sign-up has to say which. `language` is the one the visitor reads the
20
+ shell in, which their mails are written in where the deployment offers it. */
20
21
  @schema
21
- type externalInput = {@sensitive email: string, role?: string}
22
+ type externalInput = {@sensitive email: string, role?: string, language?: string}
22
23
 
23
24
  @schema
24
25
  type command =
@@ -27,6 +28,7 @@ type command =
27
28
  @pii({subject: "emailId"}) email: Reventless.Email.t,
28
29
  role: Reventless.Role.name,
29
30
  requestedAt: Reventless.DateTime.t,
31
+ language?: string,
30
32
  })
31
33
 
32
34
  let targetName = "Registrations"
@@ -11,7 +11,8 @@ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.re
11
11
 
12
12
  let externalInputSchema = Sury.$schema(s => ({
13
13
  email: s.m(Sensitive$Reventless.string),
14
- role: s.m(Sury.$option(Sury.string))
14
+ role: s.m(Sury.$option(Sury.string)),
15
+ language: s.m(Sury.$option(Sury.string))
15
16
  }));
16
17
 
17
18
  let commandSchema = Sury.$schema(s => ({
@@ -19,7 +20,8 @@ let commandSchema = Sury.$schema(s => ({
19
20
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
20
21
  email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
21
22
  role: s.m(Role$Reventless.nameSchema),
22
- requestedAt: s.m(DateTime$Reventless.schema)
23
+ requestedAt: s.m(DateTime$Reventless.schema),
24
+ language: s.m(Sury.$option(Sury.string))
23
25
  }));
24
26
 
25
27
  let capabilityNeeds = [];
@@ -8,6 +8,15 @@ let defaultRole = (table: Reventless.Admission.t): option<Reventless.Role.name>
8
8
  | _ => None
9
9
  }
10
10
 
11
+ /** A language tag as a request gave it, or none where it does not look like one: it only
12
+ picks the words of a mail, so a malformed one is dropped rather than refused. */
13
+ let languageOf = (raw: option<string>): option<string> =>
14
+ raw
15
+ ->Option.map(String.trim)
16
+ ->Option.filter(tag =>
17
+ String.length(tag) <= 35 && /^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/->RegExp.test(tag)
18
+ )
19
+
11
20
  /** The door over the app's table, which picks the role a sign-up may leave out. */
12
21
  module Make = (App: Reventless.Admission.Declaration) => {
13
22
  module Spec = Spec
@@ -42,6 +51,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
42
51
  email,
43
52
  role,
44
53
  requestedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
54
+ language: ?languageOf(input.language),
45
55
  }),
46
56
  ),
47
57
  ])
@@ -15,6 +15,16 @@ function defaultRole(table) {
15
15
  }
16
16
  }
17
17
 
18
+ function languageOf(raw) {
19
+ return Stdlib_Option.filter(Stdlib_Option.map(raw, prim => prim.trim()), tag => {
20
+ if (tag.length <= 35) {
21
+ return /^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$/.test(tag);
22
+ } else {
23
+ return false;
24
+ }
25
+ });
26
+ }
27
+
18
28
  function Make(App) {
19
29
  let translate = async (input, capabilities, param) => {
20
30
  let match = Email$Reventless.fromString(input.email.trim());
@@ -50,7 +60,8 @@ function Make(App) {
50
60
  emailId: id,
51
61
  email: email,
52
62
  role: role,
53
- requestedAt: new Date().toISOString()
63
+ requestedAt: new Date().toISOString(),
64
+ language: languageOf(input.language)
54
65
  }
55
66
  ]]
56
67
  };
@@ -69,6 +80,7 @@ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/Inbound
69
80
  export {
70
81
  Spec,
71
82
  defaultRole,
83
+ languageOf,
72
84
  Make,
73
85
  moduleUrl,
74
86
  }
@@ -22,6 +22,7 @@ type consumedEvent =
22
22
  emailId: string,
23
23
  @pii({subject: "emailId"}) email: Reventless.Email.t,
24
24
  requestedAt: Reventless.DateTime.t,
25
+ language?: string,
25
26
  })
26
27
  | RegistrationAttemptedOnTakenAddress({
27
28
  emailId: string,
@@ -34,19 +35,23 @@ type consumedEvent =
34
35
  roles: array<string>,
35
36
  invitedBy: string,
36
37
  invitedAt: Reventless.DateTime.t,
38
+ language?: string,
37
39
  })
38
40
  | RegistrationChallengeReissued({
39
41
  emailId: string,
40
42
  @pii({subject: "emailId"}) email: Reventless.Email.t,
41
43
  reissuedAt: Reventless.DateTime.t,
42
44
  invitedBy?: string,
45
+ language?: string,
43
46
  })
44
47
 
45
48
  // `emailId` is the ledger's id for the address, `email` the address the mail goes to.
46
49
 
47
50
  /** `invited` words the secret as an invitation; it is left out for a sign-up
48
51
  and for the notice. `roles` names what the invitation grants, where the
49
- event said: a reissued code does not. */
52
+ event said: a reissued code does not. `language` is the one the claim was made
53
+ in, for a person with no account to say; the notice to a taken address has none,
54
+ since its owner's account does. */
50
55
  @schema
51
56
  type outboundItem = {
52
57
  emailId: string,
@@ -54,6 +59,7 @@ type outboundItem = {
54
59
  alreadyRegistered: bool,
55
60
  invited?: bool,
56
61
  roles?: array<string>,
62
+ language?: string,
57
63
  }
58
64
 
59
65
  @schema
@@ -62,6 +68,8 @@ type inboundCommand =
62
68
  emailId: ContactAddressId.t,
63
69
  proofHash: string,
64
70
  issuedAt: Reventless.DateTime.t,
71
+ language?: string,
72
+ messageKey?: string,
65
73
  })
66
74
 
67
75
  // For a mail transport that is down. Exhausting them opens no challenge, which
@@ -12,7 +12,8 @@ let consumedEventSchema = Sury.union([
12
12
  TAG: "RegistrationRequested",
13
13
  emailId: s.m(DcbTag$Reventless.string),
14
14
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
15
- requestedAt: s.m(DateTime$Reventless.schema)
15
+ requestedAt: s.m(DateTime$Reventless.schema),
16
+ language: s.m(Sury.$option(Sury.string))
16
17
  })),
17
18
  Sury.$schema(s => ({
18
19
  TAG: "RegistrationAttemptedOnTakenAddress",
@@ -26,14 +27,16 @@ let consumedEventSchema = Sury.union([
26
27
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
27
28
  roles: s.m(Sury.array(Sury.string)),
28
29
  invitedBy: s.m(Sury.string),
29
- invitedAt: s.m(DateTime$Reventless.schema)
30
+ invitedAt: s.m(DateTime$Reventless.schema),
31
+ language: s.m(Sury.$option(Sury.string))
30
32
  })),
31
33
  Sury.$schema(s => ({
32
34
  TAG: "RegistrationChallengeReissued",
33
35
  emailId: s.m(DcbTag$Reventless.string),
34
36
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
35
37
  reissuedAt: s.m(DateTime$Reventless.schema),
36
- invitedBy: s.m(Sury.$option(Sury.string))
38
+ invitedBy: s.m(Sury.$option(Sury.string)),
39
+ language: s.m(Sury.$option(Sury.string))
37
40
  }))
38
41
  ]);
39
42
 
@@ -42,14 +45,17 @@ let outboundItemSchema = Sury.$schema(s => ({
42
45
  email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
43
46
  alreadyRegistered: s.m(Sury.boolean),
44
47
  invited: s.m(Sury.$option(Sury.boolean)),
45
- roles: s.m(Sury.$option(Sury.array(Sury.string)))
48
+ roles: s.m(Sury.$option(Sury.array(Sury.string))),
49
+ language: s.m(Sury.$option(Sury.string))
46
50
  }));
47
51
 
48
52
  let inboundCommandSchema = Sury.$schema(s => ({
49
53
  TAG: "IssueRegistrationChallenge",
50
54
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
51
55
  proofHash: s.m(Sury.string),
52
- issuedAt: s.m(DateTime$Reventless.schema)
56
+ issuedAt: s.m(DateTime$Reventless.schema),
57
+ language: s.m(Sury.$option(Sury.string)),
58
+ messageKey: s.m(Sury.$option(Sury.string))
53
59
  }));
54
60
 
55
61
  let sourceNames = [];
@@ -4,22 +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({emailId, email: Value(email), requestedAt}) => [
7
+ | RegistrationRequested({emailId, email: Value(email), requestedAt, ?language}) => [
8
8
  (
9
9
  `${emailId}:${requestedAt->Reventless.DateTime.toString}`,
10
- {emailId, email, alreadyRegistered: false},
10
+ {emailId, email, alreadyRegistered: false, ?language},
11
11
  ),
12
12
  ]
13
- | RegistrationInvited({emailId, email: Value(email), roles, invitedAt}) => [
13
+ | RegistrationInvited({emailId, email: Value(email), roles, invitedAt, ?language}) => [
14
14
  (
15
15
  `${emailId}:invited:${invitedAt->Reventless.DateTime.toString}`,
16
- {emailId, email, alreadyRegistered: false, invited: true, roles},
16
+ {emailId, email, alreadyRegistered: false, invited: true, roles, ?language},
17
17
  ),
18
18
  ]
19
- | RegistrationChallengeReissued({emailId, email: Value(email), reissuedAt, ?invitedBy}) => [
19
+ | RegistrationChallengeReissued({
20
+ emailId,
21
+ email: Value(email),
22
+ reissuedAt,
23
+ ?invitedBy,
24
+ ?language,
25
+ }) => [
20
26
  (
21
27
  `${emailId}:reissued:${reissuedAt->Reventless.DateTime.toString}`,
22
- {emailId, email, alreadyRegistered: false, invited: invitedBy->Option.isSome},
28
+ {emailId, email, alreadyRegistered: false, invited: invitedBy->Option.isSome, ?language},
23
29
  ),
24
30
  ]
25
31
  | RegistrationAttemptedOnTakenAddress({emailId, email: Value(email), attemptedAt}) => [
@@ -32,35 +38,92 @@ let collect = (event, ~sourceId as _) =>
32
38
  | _ => []
33
39
  }
34
40
 
41
+ // The mails' words, by key, in the English a deployment with no catalogue sends. A translation
42
+ // is a catalogue's `registration.*` keys; `pnpm run check:server-catalogues` keeps
43
+ // `i18n/en.json` the same as these.
44
+ module Messages = {
45
+ let challengeSubject: Reventless.Text.message = {
46
+ key: "registration.challenge.subject",
47
+ source: "Finish your registration",
48
+ }
49
+ let challengeBody: Reventless.Text.message = {
50
+ key: "registration.challenge.body",
51
+ source: "Your registration code is {token}. Enter it with a password of your choice to finish. It expires in {expiresIn}.",
52
+ }
53
+ let invitedSubject: Reventless.Text.message = {
54
+ key: "registration.invited.subject",
55
+ source: "You are invited to create an account",
56
+ }
57
+ let invitedBody: Reventless.Text.message = {
58
+ key: "registration.invited.body",
59
+ source: "You have been invited to create an account{hasRoles, select, yes { as {roles}} other {}}. Your code is {token}. Enter it with this address and a password of your choice to accept. It expires in {expiresIn}.",
60
+ }
61
+ let takenSubject: Reventless.Text.message = {
62
+ key: "registration.taken.subject",
63
+ source: "Someone tried to register with your address",
64
+ }
65
+ let takenBody: Reventless.Text.message = {
66
+ key: "registration.taken.body",
67
+ source: "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.",
68
+ }
69
+ let all = [challengeSubject, challengeBody, invitedSubject, invitedBody, takenSubject, takenBody]
70
+ }
71
+
35
72
  let expiresIn = (~invited) =>
36
- RegistrationChallenge.policyFor(
37
- RegistrationChallenge.purposeFor(~invited),
38
- ).tokenTtl->Reventless.Duration.format
73
+ RegistrationChallenge.policyFor(RegistrationChallenge.purposeFor(~invited)).tokenTtl
39
74
 
40
- let challengeBody = (~token) =>
41
- `Your registration code is ${token}. Enter it with a password of your choice to finish. It expires in ${expiresIn(
42
- ~invited=false,
43
- )}.`
75
+ let challengeValues = (~token) =>
76
+ dict{
77
+ "token": Reventless.MessageFormat.Text(token),
78
+ "expiresIn": Duration(expiresIn(~invited=false)),
79
+ }
44
80
 
45
- /** What the invitation grants, as the mail says it: "as Merchandiser", or
46
- nothing where the event did not say. */
47
- let asRoles = (roles: option<array<string>>) =>
48
- switch roles {
49
- | Some([]) | None => ""
50
- | Some(roles) => ` as ${roles->Array.join(" and ")}`
81
+ /** What the invitation grants, as the mail says it: "as Merchandiser", or nothing where the
82
+ event did not say. */
83
+ let invitationValues = (~token, ~roles: option<array<string>>=?) => {
84
+ let roles = roles->Option.getOr([])
85
+ dict{
86
+ "token": Reventless.MessageFormat.Text(token),
87
+ "expiresIn": Duration(expiresIn(~invited=true)),
88
+ "hasRoles": Text(roles == [] ? "no" : "yes"),
89
+ "roles": List(roles),
51
90
  }
91
+ }
92
+
93
+ /** The mails in English, as a deployment with no catalogue sends them. */
94
+ let challengeBody = (~token) =>
95
+ Messages.challengeBody->Reventless.Text.inSource(~values=challengeValues(~token))
52
96
 
53
97
  let invitationBody = (~token, ~roles=?) =>
54
- `You have been invited to create an account${asRoles(
55
- roles,
56
- )}. Your code is ${token}. Enter it with this address and a password of your choice to accept. It expires in ${expiresIn(
57
- ~invited=true,
58
- )}.`
98
+ Messages.invitedBody->Reventless.Text.inSource(~values=invitationValues(~token, ~roles?))
59
99
 
60
- 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."
100
+ let noticeBody = Messages.takenBody->Reventless.Text.inSource
61
101
 
62
- let send = (capabilities: Reventless.Capabilities.t, ~email, ~subject, ~body) =>
63
- capabilities.messaging.send(~recipient=ToEmail(email), ~message={subject, body})
102
+ /** Write and send one mail; what it answers is the language it went out in. */
103
+ let send = async (
104
+ capabilities: Reventless.Capabilities.t,
105
+ ~email,
106
+ ~requested=?,
107
+ ~subject,
108
+ ~body,
109
+ ~values,
110
+ ) => {
111
+ let recipient: Reventless.Messaging.recipient = ToEmail(email)
112
+ switch await capabilities.text->Reventless.Text.compose(
113
+ ~recipient,
114
+ ~requested?,
115
+ ~subject,
116
+ ~body,
117
+ ~values,
118
+ ) {
119
+ | Error(reason) => Error(reason)
120
+ | Ok(message) =>
121
+ switch await capabilities.messaging.send(~recipient, ~message) {
122
+ | Ok(_) => Ok(message.language)
123
+ | Error(failure) => Error(Reventless.Messaging.failureReason(failure))
124
+ }
125
+ }
126
+ }
64
127
 
65
128
  /**
66
129
  Draw a secret, send it, and open a challenge against its hash — sending first,
@@ -71,11 +134,12 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
71
134
  switch await send(
72
135
  capabilities,
73
136
  ~email=item.email,
74
- ~subject="Someone tried to register with your address",
75
- ~body=noticeBody,
137
+ ~subject=Messages.takenSubject,
138
+ ~body=Messages.takenBody,
139
+ ~values=Dict.make(),
76
140
  ) {
77
141
  | Ok(_) => Ok(None)
78
- | Error(failure) => Error(Reventless.Messaging.failureReason(failure))
142
+ | Error(reason) => Error(reason)
79
143
  }
80
144
  } else {
81
145
  let invited = item.invited->Option.getOr(false)
@@ -89,13 +153,16 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
89
153
  switch capabilities.secrets.hash(token) {
90
154
  | Error(Unavailable(why)) => Error(`cannot hash a secret: ${why}`)
91
155
  | Ok(proofHash) =>
156
+ let body = invited ? Messages.invitedBody : Messages.challengeBody
92
157
  switch await send(
93
158
  capabilities,
94
159
  ~email=item.email,
95
- ~subject=invited ? "You are invited to create an account" : "Finish your registration",
96
- ~body=invited ? invitationBody(~token, ~roles=?item.roles) : challengeBody(~token),
160
+ ~requested=?item.language,
161
+ ~subject=invited ? Messages.invitedSubject : Messages.challengeSubject,
162
+ ~body,
163
+ ~values=invited ? invitationValues(~token, ~roles=?item.roles) : challengeValues(~token),
97
164
  ) {
98
- | Ok(_) =>
165
+ | Ok(language) =>
99
166
  Ok(
100
167
  Some((
101
168
  item.emailId,
@@ -103,10 +170,12 @@ let translate = async (_id, item: outboundItem, ~capabilities: Reventless.Capabi
103
170
  emailId: ContactAddressId.makeFromString(item.emailId),
104
171
  proofHash,
105
172
  issuedAt: Date.make()->Date.toISOString->Reventless.DateTime.unsafe,
173
+ ?language,
174
+ messageKey: body.key,
106
175
  }),
107
176
  )),
108
177
  )
109
- | Error(failure) => Error(Reventless.Messaging.failureReason(failure))
178
+ | Error(reason) => Error(reason)
110
179
  }
111
180
  }
112
181
  }
@@ -1,7 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
- import * as Duration$Reventless from "@reventlessdev/reventless-spec/src/semantic/Duration.res.mjs";
4
+ import * as Text$Reventless from "@reventlessdev/reventless-spec/src/i18n/Text.res.mjs";
5
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
5
6
  import * as Messaging$Reventless from "@reventlessdev/reventless-spec/src/semantic/Messaging.res.mjs";
6
7
  import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
7
8
  import * as RegistrationChallenge$ReventlessRegistration from "../../RegistrationChallenge.res.mjs";
@@ -23,7 +24,8 @@ function collect(event, param) {
23
24
  {
24
25
  emailId: emailId,
25
26
  email: email._0,
26
- alreadyRegistered: false
27
+ alreadyRegistered: false,
28
+ language: event.language
27
29
  }
28
30
  ]];
29
31
  }
@@ -63,7 +65,8 @@ function collect(event, param) {
63
65
  email: email$2._0,
64
66
  alreadyRegistered: false,
65
67
  invited: true,
66
- roles: event.roles
68
+ roles: event.roles,
69
+ language: event.language
67
70
  }
68
71
  ]];
69
72
  }
@@ -83,49 +86,143 @@ function collect(event, param) {
83
86
  emailId: emailId$3,
84
87
  email: email$3._0,
85
88
  alreadyRegistered: false,
86
- invited: Stdlib_Option.isSome(event.invitedBy)
89
+ invited: Stdlib_Option.isSome(event.invitedBy),
90
+ language: event.language
87
91
  }
88
92
  ]];
89
93
  }
90
94
  }
91
95
  }
92
96
 
97
+ let challengeSubject = {
98
+ key: "registration.challenge.subject",
99
+ source: "Finish your registration"
100
+ };
101
+
102
+ let challengeBody = {
103
+ key: "registration.challenge.body",
104
+ source: "Your registration code is {token}. Enter it with a password of your choice to finish. It expires in {expiresIn}."
105
+ };
106
+
107
+ let invitedSubject = {
108
+ key: "registration.invited.subject",
109
+ source: "You are invited to create an account"
110
+ };
111
+
112
+ let invitedBody = {
113
+ key: "registration.invited.body",
114
+ source: "You have been invited to create an account{hasRoles, select, yes { as {roles}} other {}}. Your code is {token}. Enter it with this address and a password of your choice to accept. It expires in {expiresIn}."
115
+ };
116
+
117
+ let takenSubject = {
118
+ key: "registration.taken.subject",
119
+ source: "Someone tried to register with your address"
120
+ };
121
+
122
+ let takenBody = {
123
+ key: "registration.taken.body",
124
+ source: "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."
125
+ };
126
+
127
+ let all = [
128
+ challengeSubject,
129
+ challengeBody,
130
+ invitedSubject,
131
+ invitedBody,
132
+ takenSubject,
133
+ takenBody
134
+ ];
135
+
136
+ let Messages = {
137
+ challengeSubject: challengeSubject,
138
+ challengeBody: challengeBody,
139
+ invitedSubject: invitedSubject,
140
+ invitedBody: invitedBody,
141
+ takenSubject: takenSubject,
142
+ takenBody: takenBody,
143
+ all: all
144
+ };
145
+
93
146
  function expiresIn(invited) {
94
- return Duration$Reventless.format(RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(invited)).tokenTtl);
147
+ return RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(invited)).tokenTtl;
95
148
  }
96
149
 
97
- function challengeBody(token) {
98
- return `Your registration code is ` + token + `. Enter it with a password of your choice to finish. It expires in ` + expiresIn(false) + `.`;
150
+ function challengeValues(token) {
151
+ return {
152
+ token: {
153
+ TAG: "Text",
154
+ _0: token
155
+ },
156
+ expiresIn: {
157
+ TAG: "Duration",
158
+ _0: RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(false)).tokenTtl
159
+ }
160
+ };
99
161
  }
100
162
 
101
- function asRoles(roles) {
102
- if (roles !== undefined && roles.length !== 0) {
103
- return ` as ` + roles.join(" and ");
104
- } else {
105
- return "";
106
- }
163
+ function invitationValues(token, roles) {
164
+ let roles$1 = Stdlib_Option.getOr(roles, []);
165
+ return {
166
+ token: {
167
+ TAG: "Text",
168
+ _0: token
169
+ },
170
+ expiresIn: {
171
+ TAG: "Duration",
172
+ _0: RegistrationChallenge$ReventlessRegistration.policyFor(RegistrationChallenge$ReventlessRegistration.purposeFor(true)).tokenTtl
173
+ },
174
+ hasRoles: {
175
+ TAG: "Text",
176
+ _0: Primitive_object.equal(roles$1, []) ? "no" : "yes"
177
+ },
178
+ roles: {
179
+ TAG: "List",
180
+ _0: roles$1
181
+ }
182
+ };
183
+ }
184
+
185
+ function challengeBody$1(token) {
186
+ return Text$Reventless.inSource(challengeBody, challengeValues(token));
107
187
  }
108
188
 
109
189
  function invitationBody(token, roles) {
110
- return `You have been invited to create an account` + asRoles(roles) + `. Your code is ` + token + `. Enter it with this address and a password of your choice to accept. It expires in ` + expiresIn(true) + `.`;
190
+ return Text$Reventless.inSource(invitedBody, invitationValues(token, roles));
111
191
  }
112
192
 
113
- 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.";
193
+ let noticeBody = Text$Reventless.inSource(takenBody, undefined);
114
194
 
115
- function send(capabilities, email, subject, body) {
116
- return capabilities.messaging.send({
195
+ async function send(capabilities, email, requested, subject, body, values) {
196
+ let recipient = {
117
197
  TAG: "ToEmail",
118
198
  _0: email
119
- }, {
120
- subject: subject,
121
- body: body
122
- });
199
+ };
200
+ let reason = await Text$Reventless.compose(capabilities.text, recipient, requested, subject, body, values);
201
+ if (reason.TAG !== "Ok") {
202
+ return {
203
+ TAG: "Error",
204
+ _0: reason._0
205
+ };
206
+ }
207
+ let message = reason._0;
208
+ let failure = await capabilities.messaging.send(recipient, message);
209
+ if (failure.TAG === "Ok") {
210
+ return {
211
+ TAG: "Ok",
212
+ _0: message.language
213
+ };
214
+ } else {
215
+ return {
216
+ TAG: "Error",
217
+ _0: Messaging$Reventless.failureReason(failure._0)
218
+ };
219
+ }
123
220
  }
124
221
 
125
222
  async function translate(_id, item, capabilities) {
126
223
  if (item.alreadyRegistered) {
127
- let failure = await send(capabilities, item.email, "Someone tried to register with your address", noticeBody);
128
- if (failure.TAG === "Ok") {
224
+ let reason = await send(capabilities, item.email, undefined, takenSubject, takenBody, {});
225
+ if (reason.TAG === "Ok") {
129
226
  return {
130
227
  TAG: "Ok",
131
228
  _0: undefined
@@ -133,7 +230,7 @@ async function translate(_id, item, capabilities) {
133
230
  } else {
134
231
  return {
135
232
  TAG: "Error",
136
- _0: Messaging$Reventless.failureReason(failure._0)
233
+ _0: reason._0
137
234
  };
138
235
  }
139
236
  }
@@ -154,8 +251,9 @@ async function translate(_id, item, capabilities) {
154
251
  _0: `cannot hash a secret: ` + proofHash._0._0
155
252
  };
156
253
  }
157
- 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));
158
- if (failure$1.TAG === "Ok") {
254
+ let body = invited ? invitedBody : challengeBody;
255
+ let language = await send(capabilities, item.email, item.language, invited ? invitedSubject : challengeSubject, body, invited ? invitationValues(token$1, item.roles) : challengeValues(token$1));
256
+ if (language.TAG === "Ok") {
159
257
  return {
160
258
  TAG: "Ok",
161
259
  _0: [
@@ -164,14 +262,16 @@ async function translate(_id, item, capabilities) {
164
262
  TAG: "IssueRegistrationChallenge",
165
263
  emailId: ContactAddressId$ReventlessRegistration.makeFromString(item.emailId),
166
264
  proofHash: proofHash._0,
167
- issuedAt: new Date().toISOString()
265
+ issuedAt: new Date().toISOString(),
266
+ language: language._0,
267
+ messageKey: body.key
168
268
  }
169
269
  ]
170
270
  };
171
271
  } else {
172
272
  return {
173
273
  TAG: "Error",
174
- _0: Messaging$Reventless.failureReason(failure$1._0)
274
+ _0: language._0
175
275
  };
176
276
  }
177
277
  }
@@ -187,9 +287,11 @@ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/Outboun
187
287
  export {
188
288
  Spec,
189
289
  collect,
290
+ Messages,
190
291
  expiresIn,
191
- challengeBody,
192
- asRoles,
292
+ challengeValues,
293
+ invitationValues,
294
+ challengeBody$1 as challengeBody,
193
295
  invitationBody,
194
296
  noticeBody,
195
297
  send,
@@ -197,4 +299,4 @@ export {
197
299
  onExhausted,
198
300
  moduleUrl,
199
301
  }
200
- /* Duration-Reventless Not a pure module */
302
+ /* noticeBody Not a pure module */
@@ -44,6 +44,7 @@ type consumedEvent =
44
44
  @pii({subject: "emailId"}) email: Reventless.Email.t,
45
45
  roles: array<string>,
46
46
  requestedAt: Reventless.DateTime.t,
47
+ language?: string,
47
48
  })
48
49
  | RegistrationExpired({emailId: ContactAddressId.t})
49
50
  | RegistrationInvited({
@@ -52,12 +53,14 @@ type consumedEvent =
52
53
  roles: array<string>,
53
54
  invitedBy: string,
54
55
  invitedAt: Reventless.DateTime.t,
56
+ language?: string,
55
57
  })
56
58
  | RegistrationChallengeReissued({
57
59
  emailId: ContactAddressId.t,
58
60
  @pii({subject: "emailId"}) email: Reventless.Email.t,
59
61
  reissuedAt: Reventless.DateTime.t,
60
62
  invitedBy?: string,
63
+ language?: string,
61
64
  })
62
65
  | RegistrationWithdrawn({emailId: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
63
66
  | RegistrationAttemptedOnTakenAddress({
@@ -69,6 +72,10 @@ type consumedEvent =
69
72
  emailId: ContactAddressId.t,
70
73
  proofHash: string,
71
74
  issuedAt: Reventless.DateTime.t,
75
+ /** The language the code went out in, and the key of the mail that carried it: what is
76
+ recorded of a sent mail, never its text. */
77
+ language?: string,
78
+ messageKey?: string,
72
79
  })
73
80
  | RegistrationProofAccepted({
74
81
  emailId: ContactAddressId.t,
@@ -97,12 +104,15 @@ type command =
97
104
  @pii({subject: "emailId"}) email: Reventless.Email.t,
98
105
  role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
99
106
  requestedAt: Reventless.DateTime.t,
107
+ language?: string,
100
108
  })
101
109
  | @noApi
102
110
  IssueRegistrationChallenge({
103
111
  emailId: ContactAddressId.t,
104
112
  proofHash: string,
105
113
  issuedAt: Reventless.DateTime.t,
114
+ language?: string,
115
+ messageKey?: string,
106
116
  })
107
117
  | @noApi
108
118
  SubmitRegistrationProof({
@@ -121,6 +131,7 @@ type command =
121
131
  roles: array<Reventless.Role.name>,
122
132
  invitedBy: string,
123
133
  requestedAt: Reventless.DateTime.t,
134
+ language?: string,
124
135
  })
125
136
  // Voids the code a pending registration holds, so a new one is sent: a code
126
137
  // lost, or its attempts spent. Held to one per resend cooldown.
@@ -151,6 +162,7 @@ type event =
151
162
  @pii({subject: "emailId"}) email: Reventless.Email.t,
152
163
  roles: array<string>,
153
164
  requestedAt: Reventless.DateTime.t,
165
+ language?: string,
154
166
  })
155
167
  | RegistrationExpired({emailId: ContactAddressId.t})
156
168
  | RegistrationInvited({
@@ -159,12 +171,14 @@ type event =
159
171
  roles: array<string>,
160
172
  invitedBy: string,
161
173
  invitedAt: Reventless.DateTime.t,
174
+ language?: string,
162
175
  })
163
176
  | RegistrationChallengeReissued({
164
177
  emailId: ContactAddressId.t,
165
178
  @pii({subject: "emailId"}) email: Reventless.Email.t,
166
179
  reissuedAt: Reventless.DateTime.t,
167
180
  invitedBy?: string,
181
+ language?: string,
168
182
  })
169
183
  | RegistrationWithdrawn({emailId: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
170
184
  | RegistrationAttemptedOnTakenAddress({
@@ -176,6 +190,10 @@ type event =
176
190
  emailId: ContactAddressId.t,
177
191
  proofHash: string,
178
192
  issuedAt: Reventless.DateTime.t,
193
+ /** The language the code went out in, and the key of the mail that carried it: what is
194
+ recorded of a sent mail, never its text. */
195
+ language?: string,
196
+ messageKey?: string,
179
197
  })
180
198
  | RegistrationProofAccepted({
181
199
  emailId: ContactAddressId.t,
@@ -24,7 +24,8 @@ let consumedEventSchema = Sury.union([
24
24
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
25
25
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
26
26
  roles: s.m(Sury.array(Sury.string)),
27
- requestedAt: s.m(DateTime$Reventless.schema)
27
+ requestedAt: s.m(DateTime$Reventless.schema),
28
+ language: s.m(Sury.$option(Sury.string))
28
29
  })),
29
30
  Sury.$schema(s => ({
30
31
  TAG: "RegistrationExpired",
@@ -36,14 +37,16 @@ let consumedEventSchema = Sury.union([
36
37
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
37
38
  roles: s.m(Sury.array(Sury.string)),
38
39
  invitedBy: s.m(Sury.string),
39
- invitedAt: s.m(DateTime$Reventless.schema)
40
+ invitedAt: s.m(DateTime$Reventless.schema),
41
+ language: s.m(Sury.$option(Sury.string))
40
42
  })),
41
43
  Sury.$schema(s => ({
42
44
  TAG: "RegistrationChallengeReissued",
43
45
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
44
46
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
45
47
  reissuedAt: s.m(DateTime$Reventless.schema),
46
- invitedBy: s.m(Sury.$option(Sury.string))
48
+ invitedBy: s.m(Sury.$option(Sury.string)),
49
+ language: s.m(Sury.$option(Sury.string))
47
50
  })),
48
51
  Sury.$schema(s => ({
49
52
  TAG: "RegistrationWithdrawn",
@@ -60,7 +63,9 @@ let consumedEventSchema = Sury.union([
60
63
  TAG: "RegistrationChallengeIssued",
61
64
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
62
65
  proofHash: s.m(Sury.string),
63
- issuedAt: s.m(DateTime$Reventless.schema)
66
+ issuedAt: s.m(DateTime$Reventless.schema),
67
+ language: s.m(Sury.$option(Sury.string)),
68
+ messageKey: s.m(Sury.$option(Sury.string))
64
69
  })),
65
70
  Sury.$schema(s => ({
66
71
  TAG: "RegistrationProofAccepted",
@@ -91,13 +96,16 @@ let commandSchema = Sury.union([
91
96
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
92
97
  email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
93
98
  role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
94
- requestedAt: s.m(DateTime$Reventless.schema)
99
+ requestedAt: s.m(DateTime$Reventless.schema),
100
+ language: s.m(Sury.$option(Sury.string))
95
101
  })),
96
102
  Sury.$schema(s => ({
97
103
  TAG: "IssueRegistrationChallenge",
98
104
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
99
105
  proofHash: s.m(Sury.string),
100
- issuedAt: s.m(DateTime$Reventless.schema)
106
+ issuedAt: s.m(DateTime$Reventless.schema),
107
+ language: s.m(Sury.$option(Sury.string)),
108
+ messageKey: s.m(Sury.$option(Sury.string))
101
109
  })),
102
110
  Sury.$schema(s => ({
103
111
  TAG: "SubmitRegistrationProof",
@@ -115,7 +123,8 @@ let commandSchema = Sury.union([
115
123
  email: s.m(Pii$Reventless.mark("emailId", undefined, Email$Reventless.schema)),
116
124
  roles: s.m(Sury.array(Role$Reventless.nameSchema)),
117
125
  invitedBy: s.m(Sury.string),
118
- requestedAt: s.m(DateTime$Reventless.schema)
126
+ requestedAt: s.m(DateTime$Reventless.schema),
127
+ language: s.m(Sury.$option(Sury.string))
119
128
  })),
120
129
  Sury.$schema(s => ({
121
130
  TAG: "ReissueRegistrationChallenge",
@@ -148,7 +157,8 @@ let eventSchema = Sury.union([
148
157
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
149
158
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
150
159
  roles: s.m(Sury.array(Sury.string)),
151
- requestedAt: s.m(DateTime$Reventless.schema)
160
+ requestedAt: s.m(DateTime$Reventless.schema),
161
+ language: s.m(Sury.$option(Sury.string))
152
162
  })),
153
163
  Sury.$schema(s => ({
154
164
  TAG: "RegistrationExpired",
@@ -160,14 +170,16 @@ let eventSchema = Sury.union([
160
170
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
161
171
  roles: s.m(Sury.array(Sury.string)),
162
172
  invitedBy: s.m(Sury.string),
163
- invitedAt: s.m(DateTime$Reventless.schema)
173
+ invitedAt: s.m(DateTime$Reventless.schema),
174
+ language: s.m(Sury.$option(Sury.string))
164
175
  })),
165
176
  Sury.$schema(s => ({
166
177
  TAG: "RegistrationChallengeReissued",
167
178
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
168
179
  email: s.m(Pii$Reventless.marked("emailId", undefined, Email$Reventless.schema)),
169
180
  reissuedAt: s.m(DateTime$Reventless.schema),
170
- invitedBy: s.m(Sury.$option(Sury.string))
181
+ invitedBy: s.m(Sury.$option(Sury.string)),
182
+ language: s.m(Sury.$option(Sury.string))
171
183
  })),
172
184
  Sury.$schema(s => ({
173
185
  TAG: "RegistrationWithdrawn",
@@ -184,7 +196,9 @@ let eventSchema = Sury.union([
184
196
  TAG: "RegistrationChallengeIssued",
185
197
  emailId: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
186
198
  proofHash: s.m(Sury.string),
187
- issuedAt: s.m(DateTime$Reventless.schema)
199
+ issuedAt: s.m(DateTime$Reventless.schema),
200
+ language: s.m(Sury.$option(Sury.string)),
201
+ messageKey: s.m(Sury.$option(Sury.string))
188
202
  })),
189
203
  Sury.$schema(s => ({
190
204
  TAG: "RegistrationProofAccepted",
@@ -27,6 +27,9 @@ type pending = {
27
27
  roles: array<string>,
28
28
  /** Who invited, for a claim an inviter made. */
29
29
  invitedBy?: string,
30
+ /** The language the claim was made in: what its codes are written in for a person with no
31
+ account to say. */
32
+ language?: string,
30
33
  challenge: option<Guards.challenge>,
31
34
  proofHash: option<string>,
32
35
  }
@@ -69,17 +72,18 @@ let evolve = (state, event) =>
69
72
  switch event {
70
73
  | RegistrationOpened({?until}) => {...state, admission: Open(until)}
71
74
  | RegistrationClosed(_) => {...state, admission: Closed}
72
- | RegistrationRequested({email, roles, requestedAt}) => {
75
+ | RegistrationRequested({email, roles, requestedAt, ?language}) => {
73
76
  ...state,
74
- stage: Pending({email, requestedAt, roles, challenge: None, proofHash: None}),
77
+ stage: Pending({email, requestedAt, roles, ?language, challenge: None, proofHash: None}),
75
78
  }
76
- | RegistrationInvited({email, roles, invitedBy, invitedAt}) => {
79
+ | RegistrationInvited({email, roles, invitedBy, invitedAt, ?language}) => {
77
80
  ...state,
78
81
  stage: Pending({
79
82
  email,
80
83
  requestedAt: invitedAt,
81
84
  roles,
82
85
  invitedBy,
86
+ ?language,
83
87
  challenge: None,
84
88
  proofHash: None,
85
89
  }),
@@ -185,7 +189,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
185
189
  // decision: the policy is consulted before the address, so a closed
186
190
  // deployment sends nothing — not even the notice to an address that is
187
191
  // already registered.
188
- | Register({emailId, email, role, requestedAt}) =>
192
+ | Register({emailId, email, role, requestedAt, ?language}) =>
189
193
  if !admits(state.admission, ~table=App.table, ~role, ~at=requestedAt) {
190
194
  Ok([])
191
195
  } else {
@@ -211,17 +215,17 @@ module Make = (App: Reventless.Admission.Declaration) => {
211
215
  | Pending(_) =>
212
216
  Ok([
213
217
  RegistrationExpired({emailId: emailId}),
214
- RegistrationRequested({emailId, email: Value(email), roles, requestedAt}),
218
+ RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language}),
215
219
  ])
216
220
  | Unclaimed =>
217
- Ok([RegistrationRequested({emailId, email: Value(email), roles, requestedAt})])
221
+ Ok([RegistrationRequested({emailId, email: Value(email), roles, requestedAt, ?language})])
218
222
  }
219
223
  }
220
224
 
221
225
  // The policy is not consulted: it says whether visitors may sign themselves
222
226
  // up, and an invitation is not that. The table is, because it is the hard
223
227
  // cap on how each role is admitted.
224
- | Invite({emailId, email, roles, invitedBy, requestedAt}) =>
228
+ | Invite({emailId, email, roles, invitedBy, requestedAt, ?language}) =>
225
229
  switch roles->Array.find(r => !isByInvitation(App.table, r)) {
226
230
  | Some(role) => Error(NotByInvitation({role: (role :> string)}))
227
231
  | None if roles == [] => Error(NoRoleToGrant)
@@ -232,6 +236,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
232
236
  roles: roles->Array.map(r => (r :> string)),
233
237
  invitedBy,
234
238
  invitedAt: requestedAt,
239
+ ?language,
235
240
  })
236
241
  switch state.stage {
237
242
  // An address that holds an account, or is about to, is not registered
@@ -243,7 +248,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
243
248
  }
244
249
  }
245
250
 
246
- | IssueRegistrationChallenge({emailId, proofHash, issuedAt}) =>
251
+ | IssueRegistrationChallenge({emailId, proofHash, issuedAt, ?language, ?messageKey}) =>
247
252
  switch state.stage {
248
253
  | Pending(p) =>
249
254
  switch Guards.onIssueRequested(
@@ -252,7 +257,8 @@ module Make = (App: Reventless.Admission.Declaration) => {
252
257
  ~now=issuedAt,
253
258
  ~policy=policyOf(p),
254
259
  ) {
255
- | Issue => Ok([RegistrationChallengeIssued({emailId, proofHash, issuedAt})])
260
+ | Issue =>
261
+ Ok([RegistrationChallengeIssued({emailId, proofHash, issuedAt, ?language, ?messageKey})])
256
262
  // A redelivered request mints nothing, and because nothing is emitted,
257
263
  // sends nothing either.
258
264
  | AlreadyOpen => Ok([])
@@ -275,6 +281,7 @@ module Make = (App: Reventless.Admission.Declaration) => {
275
281
  email: p.email,
276
282
  reissuedAt: requestedAt,
277
283
  invitedBy: ?p.invitedBy,
284
+ language: ?p.language,
278
285
  }),
279
286
  ])
280
287
  | _ => Ok([])
@@ -55,6 +55,7 @@ function evolve(state, event) {
55
55
  email: event.email,
56
56
  requestedAt: event.requestedAt,
57
57
  roles: event.roles,
58
+ language: event.language,
58
59
  challenge: undefined,
59
60
  proofHash: undefined
60
61
  }
@@ -71,6 +72,7 @@ function evolve(state, event) {
71
72
  requestedAt: event.invitedAt,
72
73
  roles: event.roles,
73
74
  invitedBy: event.invitedBy,
75
+ language: event.language,
74
76
  challenge: undefined,
75
77
  proofHash: undefined
76
78
  }
@@ -223,6 +225,7 @@ function Make(App) {
223
225
  let decide = (state, command) => {
224
226
  switch (command.TAG) {
225
227
  case "Register" :
228
+ let language = command.language;
226
229
  let requestedAt = command.requestedAt;
227
230
  let role = command.role;
228
231
  let email = command.email;
@@ -252,7 +255,8 @@ function Make(App) {
252
255
  _0: email
253
256
  },
254
257
  roles: roles,
255
- requestedAt: requestedAt
258
+ requestedAt: requestedAt,
259
+ language: language
256
260
  }
257
261
  ]
258
262
  };
@@ -275,7 +279,8 @@ function Make(App) {
275
279
  _0: email
276
280
  },
277
281
  roles: roles,
278
- requestedAt: requestedAt
282
+ requestedAt: requestedAt,
283
+ language: language
279
284
  }]
280
285
  };
281
286
  case "Verified" :
@@ -327,7 +332,9 @@ function Make(App) {
327
332
  TAG: "RegistrationChallengeIssued",
328
333
  emailId: emailId$1,
329
334
  proofHash: command.proofHash,
330
- issuedAt: issuedAt
335
+ issuedAt: issuedAt,
336
+ language: command.language,
337
+ messageKey: command.messageKey
331
338
  }]
332
339
  };
333
340
  } else {
@@ -432,13 +439,15 @@ function Make(App) {
432
439
  };
433
440
  let invited_2 = roles$1.map(r => r);
434
441
  let invited_3 = command.invitedBy;
442
+ let invited_5 = command.language;
435
443
  let invited = {
436
444
  TAG: "RegistrationInvited",
437
445
  emailId: emailId$3,
438
446
  email: invited_1,
439
447
  roles: invited_2,
440
448
  invitedBy: invited_3,
441
- invitedAt: requestedAt$1
449
+ invitedAt: requestedAt$1,
450
+ language: invited_5
442
451
  };
443
452
  let p$5 = state.stage;
444
453
  if (typeof p$5 === "object") {
@@ -493,7 +502,8 @@ function Make(App) {
493
502
  emailId: command.emailId,
494
503
  email: p$7.email,
495
504
  reissuedAt: requestedAt$2,
496
- invitedBy: p$7.invitedBy
505
+ invitedBy: p$7.invitedBy,
506
+ language: p$7.language
497
507
  }]
498
508
  };
499
509
  } else {