@reventlessdev/reventless-registration 0.0.0-stage → 1.0.0-alpha.10

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 (40) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +50 -2
  3. package/package.json +38 -3
  4. package/rescript.json +28 -0
  5. package/src/ContactVerification.res +106 -0
  6. package/src/ContactVerification.res.mjs +60 -0
  7. package/src/ContactVerification_Guards.res +180 -0
  8. package/src/ContactVerification_Guards.res.mjs +97 -0
  9. package/src/Registration/ContactAddressId.res +30 -0
  10. package/src/Registration/ContactAddressId.res.mjs +53 -0
  11. package/src/Registration/InboundTranslation/CompleteRegistration.res +35 -0
  12. package/src/Registration/InboundTranslation/CompleteRegistration.res.mjs +58 -0
  13. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res +43 -0
  14. package/src/Registration/InboundTranslation/CompleteRegistration_Translation.res.mjs +74 -0
  15. package/src/Registration/InboundTranslation/SignUp.res +36 -0
  16. package/src/Registration/InboundTranslation/SignUp.res.mjs +60 -0
  17. package/src/Registration/InboundTranslation/SignUp_Translation.res +51 -0
  18. package/src/Registration/InboundTranslation/SignUp_Translation.res.mjs +75 -0
  19. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res +40 -0
  20. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal.res.mjs +65 -0
  21. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res +49 -0
  22. package/src/Registration/OutboundTranslation/CreateRegisteredPrincipal_Translation.res.mjs +108 -0
  23. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res +72 -0
  24. package/src/Registration/OutboundTranslation/SendRegistrationChallenge.res.mjs +87 -0
  25. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res +115 -0
  26. package/src/Registration/OutboundTranslation/SendRegistrationChallenge_Translation.res.mjs +200 -0
  27. package/src/Registration/StateChange/RegistrationPolicy.res +58 -0
  28. package/src/Registration/StateChange/RegistrationPolicy.res.mjs +86 -0
  29. package/src/Registration/StateChange/RegistrationPolicy_Decision.res +43 -0
  30. package/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs +88 -0
  31. package/src/Registration/StateChange/Registrations.res +183 -0
  32. package/src/Registration/StateChange/Registrations.res.mjs +238 -0
  33. package/src/Registration/StateChange/Registrations_Decision.res +311 -0
  34. package/src/Registration/StateChange/Registrations_Decision.res.mjs +560 -0
  35. package/src/Registration/StateViewStream/RegistrationWindows.res +30 -0
  36. package/src/Registration/StateViewStream/RegistrationWindows.res.mjs +80 -0
  37. package/src/Registration/StateViewStream/RegistrationWindows_Projection.res +7 -0
  38. package/src/Registration/StateViewStream/RegistrationWindows_Projection.res.mjs +38 -0
  39. package/src/RegistrationChallenge.res +20 -0
  40. package/src/RegistrationChallenge.res.mjs +45 -0
@@ -0,0 +1,58 @@
1
+ // RegistrationPolicy StateChangeSlice.
2
+ //
3
+ // Whether visitors may sign themselves up for a role right now, as domain state
4
+ // an administrator changes with a command rather than a deploy. Kept per role:
5
+ // only a role the app declares self-service has a policy at all, and
6
+ // such a role is open until an administrator closes it — the declaration is the
7
+ // deployer's opt-in, so needing a second command to make it do anything would be
8
+ // a trap.
9
+ //
10
+ // An open window may carry an end, checked against the time the registration
11
+ // arrived, so a test window someone forgets to close closes itself.
12
+
13
+ @@reventless.spec
14
+ @@reventless.authorize(AllowRoles([Admin]))
15
+
16
+ // The one role this slice's rule names: the framework's administrator, whose
17
+ // group the deployment provides. Declared here rather than in a `Roles.res`, so
18
+ // the package has no `Roles` of its own beside the app's.
19
+ module Roles = {
20
+ type t = Admin
21
+ }
22
+
23
+ // The role is this slice's partition, tagged by its type: a role is an identity
24
+ // the framework declares, not an id the plugin names.
25
+ @schema
26
+ type consumedEvent =
27
+ | RegistrationOpened({
28
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
29
+ until?: Reventless.DateTime.t,
30
+ })
31
+ | RegistrationClosed({
32
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
33
+ })
34
+
35
+ @schema
36
+ type command =
37
+ | OpenRegistration({
38
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
39
+ until?: Reventless.DateTime.t,
40
+ })
41
+ | CloseRegistration({
42
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
43
+ })
44
+
45
+ // Told to an administrator, never to a visitor: this slice's commands are an
46
+ // administrator's.
47
+ @schema
48
+ type error = NotSelfService({role: Reventless.Role.name})
49
+
50
+ @schema
51
+ type event =
52
+ | RegistrationOpened({
53
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
54
+ until?: Reventless.DateTime.t,
55
+ })
56
+ | RegistrationClosed({
57
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
58
+ })
@@ -0,0 +1,86 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Sury from "sury";
4
+ import * as Role$Reventless from "@reventlessdev/reventless-spec/src/types/Role.res.mjs";
5
+ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
+ import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
7
+
8
+ let Roles = {};
9
+
10
+ let consumedEventSchema = Sury.union([
11
+ Sury.$schema(s => ({
12
+ TAG: "RegistrationOpened",
13
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
14
+ until: s.m(Sury.$option(DateTime$Reventless.schema))
15
+ })),
16
+ Sury.$schema(s => ({
17
+ TAG: "RegistrationClosed",
18
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema))
19
+ }))
20
+ ]);
21
+
22
+ let commandSchema = Sury.union([
23
+ Sury.$schema(s => ({
24
+ TAG: "OpenRegistration",
25
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
26
+ until: s.m(Sury.$option(DateTime$Reventless.schema))
27
+ })),
28
+ Sury.$schema(s => ({
29
+ TAG: "CloseRegistration",
30
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema))
31
+ }))
32
+ ]);
33
+
34
+ let errorSchema = Sury.$schema(s => ({
35
+ TAG: "NotSelfService",
36
+ role: s.m(Role$Reventless.nameSchema)
37
+ }));
38
+
39
+ let eventSchema = Sury.union([
40
+ Sury.$schema(s => ({
41
+ TAG: "RegistrationOpened",
42
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
43
+ until: s.m(Sury.$option(DateTime$Reventless.schema))
44
+ })),
45
+ Sury.$schema(s => ({
46
+ TAG: "RegistrationClosed",
47
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema))
48
+ }))
49
+ ]);
50
+
51
+ function authorizationOf(param) {
52
+ return {
53
+ TAG: "AllowRoles",
54
+ _0: ["Admin"]
55
+ };
56
+ }
57
+
58
+ function commandTransition(param) {
59
+ return "Undeclared";
60
+ }
61
+
62
+ let traits = [];
63
+
64
+ let name = "RegistrationPolicy";
65
+
66
+ let Id;
67
+
68
+ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateChange/RegistrationPolicy.res.mjs";
69
+
70
+ let readConsistency = "EscalateOnRetry";
71
+
72
+ export {
73
+ name,
74
+ Id,
75
+ Roles,
76
+ consumedEventSchema,
77
+ commandSchema,
78
+ errorSchema,
79
+ eventSchema,
80
+ moduleUrl,
81
+ authorizationOf,
82
+ readConsistency,
83
+ commandTransition,
84
+ traits,
85
+ }
86
+ /* consumedEventSchema Not a pure module */
@@ -0,0 +1,43 @@
1
+ @@reventless.decision
2
+
3
+ // Nothing recorded is open: a role reaches this slice only if the app declares
4
+ // it self-service. Opening an open role with the same end, or closing a closed
5
+ // one, changes nothing and records nothing.
6
+
7
+ type state =
8
+ | Closed
9
+ | Open(option<Reventless.DateTime.t>)
10
+
11
+ let initialState = Open(None)
12
+
13
+ let evolve = (_state, event) =>
14
+ switch event {
15
+ | RegistrationOpened({?until}) => Open(until)
16
+ | RegistrationClosed(_) => Closed
17
+ }
18
+
19
+ /** The decision over the app's table, which says which roles are self-service. */
20
+ module Make = (App: Reventless.Admission.Declaration) => {
21
+ module Spec = Spec
22
+ let moduleUrl = moduleUrl
23
+
24
+ type state = state
25
+ let initialState = initialState
26
+ let evolve = evolve
27
+
28
+ let decide = (state, command) => {
29
+ let role = switch command {
30
+ | OpenRegistration({role}) | CloseRegistration({role}) => role
31
+ }
32
+ if !(App.table->Reventless.Admission.isSelfService(role)) {
33
+ Error(NotSelfService({role: role}))
34
+ } else {
35
+ switch (state, command) {
36
+ | (Open(current), OpenRegistration({?until})) if current == until => Ok([])
37
+ | (_, OpenRegistration({role, ?until})) => Ok([RegistrationOpened({role, ?until})])
38
+ | (Closed, CloseRegistration(_)) => Ok([])
39
+ | (Open(_), CloseRegistration({role})) => Ok([RegistrationClosed({role: role})])
40
+ }
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,88 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
4
+ import * as Admission$Reventless from "@reventlessdev/reventless-spec/src/types/Admission.res.mjs";
5
+ import * as RegistrationPolicy$ReventlessRegistration from "./RegistrationPolicy.res.mjs";
6
+
7
+ let initialState = {
8
+ TAG: "Open",
9
+ _0: undefined
10
+ };
11
+
12
+ function evolve(_state, event) {
13
+ if (event.TAG === "RegistrationOpened") {
14
+ return {
15
+ TAG: "Open",
16
+ _0: event.until
17
+ };
18
+ } else {
19
+ return "Closed";
20
+ }
21
+ }
22
+
23
+ function Make(App) {
24
+ let decide = (state, command) => {
25
+ let role = command.role;
26
+ if (!Admission$Reventless.isSelfService(App.table, role)) {
27
+ return {
28
+ TAG: "Error",
29
+ _0: {
30
+ TAG: "NotSelfService",
31
+ role: role
32
+ }
33
+ };
34
+ }
35
+ if (typeof state !== "object") {
36
+ if (command.TAG !== "OpenRegistration") {
37
+ return {
38
+ TAG: "Ok",
39
+ _0: []
40
+ };
41
+ }
42
+ } else {
43
+ if (command.TAG !== "OpenRegistration") {
44
+ return {
45
+ TAG: "Ok",
46
+ _0: [{
47
+ TAG: "RegistrationClosed",
48
+ role: command.role
49
+ }]
50
+ };
51
+ }
52
+ if (Primitive_object.equal(state._0, command.until)) {
53
+ return {
54
+ TAG: "Ok",
55
+ _0: []
56
+ };
57
+ }
58
+ }
59
+ return {
60
+ TAG: "Ok",
61
+ _0: [{
62
+ TAG: "RegistrationOpened",
63
+ role: command.role,
64
+ until: command.until
65
+ }]
66
+ };
67
+ };
68
+ return {
69
+ Spec: undefined,
70
+ moduleUrl: RegistrationPolicy$ReventlessRegistration.moduleUrl,
71
+ initialState: initialState,
72
+ evolve: evolve,
73
+ decide: decide
74
+ };
75
+ }
76
+
77
+ let Spec;
78
+
79
+ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateChange/RegistrationPolicy_Decision.res.mjs";
80
+
81
+ export {
82
+ Spec,
83
+ initialState,
84
+ evolve,
85
+ Make,
86
+ moduleUrl,
87
+ }
88
+ /* Admission-Reventless Not a pure module */
@@ -0,0 +1,183 @@
1
+ // Registrations StateChangeSlice.
2
+ //
3
+ // One registration per address: the address claimed, the challenge sent to it,
4
+ // the proof that answers the challenge, and the account that follows. The claim
5
+ // is a DCB tag on the address — `contactAddress` — so "this address is taken" is
6
+ // decided here, identically on every platform, rather than by whichever identity
7
+ // provider happens to be behind the deployment.
8
+ //
9
+ // **Verify, then create.** Nothing here creates an account. A registration is
10
+ // recorded against the address, the proof settles it, and only then does a
11
+ // translation reach the identity provider. An address nobody proved holds no
12
+ // account, so there is no unconfirmed account to clean up.
13
+ //
14
+ // **Every command is relayed, never a client's.** The doors are the inbound
15
+ // translations in this chapter: they stamp the time a request arrived, and they
16
+ // hash a presented proof so its plaintext never reaches this slice or the log.
17
+ //
18
+ // **The address is not the key.** `email` is the address's keyed fingerprint
19
+ // (`ContactAddressId`), which is what tags and partitions the ledger; an index key
20
+ // cannot be erased. The address itself rides in `address`, on the events that must
21
+ // reach the person and on the commands that start a claim, so it lives only where
22
+ // a payload field can be encrypted or erased.
23
+ //
24
+ // **Its answers do not tell an anonymous caller anything.** A closed policy, a
25
+ // pending registration and an address already registered all leave the door
26
+ // answering the same way; only what is sent to the address differs.
27
+
28
+ @@reventless.spec
29
+
30
+ // The policy's two events are read by role, a reference to another entity: the
31
+ // role is an identity the framework declares, so the inference reads it across
32
+ // partitions as it reads any id another slice is partitioned by.
33
+ @schema
34
+ type consumedEvent =
35
+ | RegistrationOpened({
36
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
37
+ until?: Reventless.DateTime.t,
38
+ })
39
+ | RegistrationClosed({
40
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
41
+ })
42
+ | RegistrationRequested({
43
+ email: ContactAddressId.t,
44
+ @pii({subject: "email"}) address: Reventless.Email.t,
45
+ roles: array<string>,
46
+ requestedAt: Reventless.DateTime.t,
47
+ })
48
+ | RegistrationExpired({email: ContactAddressId.t})
49
+ | RegistrationInvited({
50
+ email: ContactAddressId.t,
51
+ @pii({subject: "email"}) address: Reventless.Email.t,
52
+ roles: array<string>,
53
+ invitedBy: string,
54
+ invitedAt: Reventless.DateTime.t,
55
+ })
56
+ | RegistrationChallengeReissued({
57
+ email: ContactAddressId.t,
58
+ @pii({subject: "email"}) address: Reventless.Email.t,
59
+ reissuedAt: Reventless.DateTime.t,
60
+ invitedBy?: string,
61
+ })
62
+ | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
63
+ | RegistrationAttemptedOnTakenAddress({
64
+ email: ContactAddressId.t,
65
+ @pii({subject: "email"}) address: Reventless.Email.t,
66
+ attemptedAt: Reventless.DateTime.t,
67
+ })
68
+ | RegistrationChallengeIssued({
69
+ email: ContactAddressId.t,
70
+ proofHash: string,
71
+ issuedAt: Reventless.DateTime.t,
72
+ })
73
+ | RegistrationProofAccepted({
74
+ email: ContactAddressId.t,
75
+ @pii({subject: "email"}) address: Reventless.Email.t,
76
+ roles: array<string>,
77
+ proofHash: string,
78
+ })
79
+ | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
80
+ | RegistrationCompleted({email: ContactAddressId.t})
81
+
82
+ // `Register` names the role asked for, and the policy is read by it. The
83
+ // registration records the roles it grants as
84
+ // data, never as a tag: keeping the tag off this slice's own events is what
85
+ // makes the role a read of another entity rather than one of this slice's keys,
86
+ // so a policy changing while a registration is decided is caught by the append
87
+ // condition. A set rather than one role, so a door granting several at once
88
+ // records them all; a sign-up records a set of one. Plain names on the events,
89
+ // since what they carry is what a settled proof grants, not a key the ledger is
90
+ // read by.
91
+ @schema
92
+ type command =
93
+ | @noApi
94
+ Register({
95
+ email: ContactAddressId.t,
96
+ @pii({subject: "email"}) address: Reventless.Email.t,
97
+ role: @s.matches(Reventless.DcbTag.mark(Reventless.Role.nameSchema)) Reventless.Role.name,
98
+ requestedAt: Reventless.DateTime.t,
99
+ })
100
+ | @noApi
101
+ IssueRegistrationChallenge({
102
+ email: ContactAddressId.t,
103
+ proofHash: string,
104
+ issuedAt: Reventless.DateTime.t,
105
+ })
106
+ | @noApi
107
+ SubmitRegistrationProof({
108
+ email: ContactAddressId.t,
109
+ proofHash: string,
110
+ presentedAt: Reventless.DateTime.t,
111
+ })
112
+ | @noApi RecordRegistrationCompleted({email: ContactAddressId.t})
113
+ // A signed-in inviter claims the address for someone else, as the roles the
114
+ // app declares by invitation. No door here reaches it: a plugin that provides
115
+ // invitations marks its door `Invite` and checks the inviter before relaying.
116
+ | @noApi
117
+ Invite({
118
+ email: ContactAddressId.t,
119
+ @pii({subject: "email"}) address: Reventless.Email.t,
120
+ roles: array<Reventless.Role.name>,
121
+ invitedBy: string,
122
+ requestedAt: Reventless.DateTime.t,
123
+ })
124
+ // Voids the code a pending registration holds, so a new one is sent: a code
125
+ // lost, or its attempts spent. Held to one per resend cooldown.
126
+ | @noApi
127
+ ReissueRegistrationChallenge({
128
+ email: ContactAddressId.t,
129
+ requestedAt: Reventless.DateTime.t,
130
+ })
131
+ // Releases an address a registration holds and nobody has proved yet.
132
+ | @noApi WithdrawRegistration({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
133
+
134
+ // Every outcome of a command relayed for an anonymous caller is a recorded fact
135
+ // or a quiet no-op, never an error: an error is the one answer a caller could
136
+ // tell apart. `Invite` is the exception, because its caller is a signed-in
137
+ // inviter, who is owed the reason an invitation was not recorded.
138
+ @schema
139
+ type error =
140
+ | NotByInvitation({role: string})
141
+ | NoRoleToGrant
142
+
143
+ @schema
144
+ type event =
145
+ | RegistrationRequested({
146
+ email: ContactAddressId.t,
147
+ @pii({subject: "email"}) address: Reventless.Email.t,
148
+ roles: array<string>,
149
+ requestedAt: Reventless.DateTime.t,
150
+ })
151
+ | RegistrationExpired({email: ContactAddressId.t})
152
+ | RegistrationInvited({
153
+ email: ContactAddressId.t,
154
+ @pii({subject: "email"}) address: Reventless.Email.t,
155
+ roles: array<string>,
156
+ invitedBy: string,
157
+ invitedAt: Reventless.DateTime.t,
158
+ })
159
+ | RegistrationChallengeReissued({
160
+ email: ContactAddressId.t,
161
+ @pii({subject: "email"}) address: Reventless.Email.t,
162
+ reissuedAt: Reventless.DateTime.t,
163
+ invitedBy?: string,
164
+ })
165
+ | RegistrationWithdrawn({email: ContactAddressId.t, withdrawnAt: Reventless.DateTime.t})
166
+ | RegistrationAttemptedOnTakenAddress({
167
+ email: ContactAddressId.t,
168
+ @pii({subject: "email"}) address: Reventless.Email.t,
169
+ attemptedAt: Reventless.DateTime.t,
170
+ })
171
+ | RegistrationChallengeIssued({
172
+ email: ContactAddressId.t,
173
+ proofHash: string,
174
+ issuedAt: Reventless.DateTime.t,
175
+ })
176
+ | RegistrationProofAccepted({
177
+ email: ContactAddressId.t,
178
+ @pii({subject: "email"}) address: Reventless.Email.t,
179
+ roles: array<string>,
180
+ proofHash: string,
181
+ })
182
+ | RegistrationProofRefused({email: ContactAddressId.t, reason: string})
183
+ | RegistrationCompleted({email: ContactAddressId.t})
@@ -0,0 +1,238 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Sury from "sury";
4
+ import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
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";
7
+ import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
8
+ import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
9
+ import * as DateTime$Reventless from "@reventlessdev/reventless-spec/src/semantic/DateTime.res.mjs";
10
+ import * as ContactAddressId$ReventlessRegistration from "../ContactAddressId.res.mjs";
11
+
12
+ let consumedEventSchema = Sury.union([
13
+ Sury.$schema(s => ({
14
+ TAG: "RegistrationOpened",
15
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
16
+ until: s.m(Sury.$option(DateTime$Reventless.schema))
17
+ })),
18
+ Sury.$schema(s => ({
19
+ TAG: "RegistrationClosed",
20
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema))
21
+ })),
22
+ Sury.$schema(s => ({
23
+ TAG: "RegistrationRequested",
24
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
25
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
26
+ roles: s.m(Sury.array(Sury.string)),
27
+ requestedAt: s.m(DateTime$Reventless.schema)
28
+ })),
29
+ Sury.$schema(s => ({
30
+ TAG: "RegistrationExpired",
31
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
32
+ })),
33
+ Sury.$schema(s => ({
34
+ TAG: "RegistrationInvited",
35
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
36
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
37
+ roles: s.m(Sury.array(Sury.string)),
38
+ invitedBy: s.m(Sury.string),
39
+ invitedAt: s.m(DateTime$Reventless.schema)
40
+ })),
41
+ Sury.$schema(s => ({
42
+ TAG: "RegistrationChallengeReissued",
43
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
44
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
45
+ reissuedAt: s.m(DateTime$Reventless.schema),
46
+ invitedBy: s.m(Sury.$option(Sury.string))
47
+ })),
48
+ Sury.$schema(s => ({
49
+ TAG: "RegistrationWithdrawn",
50
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
51
+ withdrawnAt: s.m(DateTime$Reventless.schema)
52
+ })),
53
+ Sury.$schema(s => ({
54
+ TAG: "RegistrationAttemptedOnTakenAddress",
55
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
56
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
57
+ attemptedAt: s.m(DateTime$Reventless.schema)
58
+ })),
59
+ Sury.$schema(s => ({
60
+ TAG: "RegistrationChallengeIssued",
61
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
62
+ proofHash: s.m(Sury.string),
63
+ issuedAt: s.m(DateTime$Reventless.schema)
64
+ })),
65
+ Sury.$schema(s => ({
66
+ TAG: "RegistrationProofAccepted",
67
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
68
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
69
+ roles: s.m(Sury.array(Sury.string)),
70
+ proofHash: s.m(Sury.string)
71
+ })),
72
+ Sury.$schema(s => ({
73
+ TAG: "RegistrationProofRefused",
74
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
75
+ reason: s.m(Sury.string)
76
+ })),
77
+ Sury.$schema(s => ({
78
+ TAG: "RegistrationCompleted",
79
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
80
+ }))
81
+ ]);
82
+
83
+ let commandSchema = Sury.union([
84
+ Sury.$schema(s => ({
85
+ TAG: "Register",
86
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
87
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
88
+ role: s.m(DcbTag$Reventless.mark(Role$Reventless.nameSchema)),
89
+ requestedAt: s.m(DateTime$Reventless.schema)
90
+ })),
91
+ Sury.$schema(s => ({
92
+ TAG: "IssueRegistrationChallenge",
93
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
94
+ proofHash: s.m(Sury.string),
95
+ issuedAt: s.m(DateTime$Reventless.schema)
96
+ })),
97
+ Sury.$schema(s => ({
98
+ TAG: "SubmitRegistrationProof",
99
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
100
+ proofHash: s.m(Sury.string),
101
+ presentedAt: s.m(DateTime$Reventless.schema)
102
+ })),
103
+ Sury.$schema(s => ({
104
+ TAG: "RecordRegistrationCompleted",
105
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
106
+ })),
107
+ Sury.$schema(s => ({
108
+ TAG: "Invite",
109
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
110
+ address: s.m(Pii$Reventless.mark("email", undefined, Email$Reventless.schema)),
111
+ roles: s.m(Sury.array(Role$Reventless.nameSchema)),
112
+ invitedBy: s.m(Sury.string),
113
+ requestedAt: s.m(DateTime$Reventless.schema)
114
+ })),
115
+ Sury.$schema(s => ({
116
+ TAG: "ReissueRegistrationChallenge",
117
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
118
+ requestedAt: s.m(DateTime$Reventless.schema)
119
+ })),
120
+ Sury.$schema(s => ({
121
+ TAG: "WithdrawRegistration",
122
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
123
+ withdrawnAt: s.m(DateTime$Reventless.schema)
124
+ }))
125
+ ]);
126
+
127
+ let errorSchema = Sury.union([
128
+ Sury.$schema(s => ({
129
+ TAG: "NotByInvitation",
130
+ role: s.m(Sury.string)
131
+ })),
132
+ Sury.literal("NoRoleToGrant")
133
+ ]);
134
+
135
+ let eventSchema = Sury.union([
136
+ Sury.$schema(s => ({
137
+ TAG: "RegistrationRequested",
138
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
139
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
140
+ roles: s.m(Sury.array(Sury.string)),
141
+ requestedAt: s.m(DateTime$Reventless.schema)
142
+ })),
143
+ Sury.$schema(s => ({
144
+ TAG: "RegistrationExpired",
145
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
146
+ })),
147
+ Sury.$schema(s => ({
148
+ TAG: "RegistrationInvited",
149
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
150
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
151
+ roles: s.m(Sury.array(Sury.string)),
152
+ invitedBy: s.m(Sury.string),
153
+ invitedAt: s.m(DateTime$Reventless.schema)
154
+ })),
155
+ Sury.$schema(s => ({
156
+ TAG: "RegistrationChallengeReissued",
157
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
158
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
159
+ reissuedAt: s.m(DateTime$Reventless.schema),
160
+ invitedBy: s.m(Sury.$option(Sury.string))
161
+ })),
162
+ Sury.$schema(s => ({
163
+ TAG: "RegistrationWithdrawn",
164
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
165
+ withdrawnAt: s.m(DateTime$Reventless.schema)
166
+ })),
167
+ Sury.$schema(s => ({
168
+ TAG: "RegistrationAttemptedOnTakenAddress",
169
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
170
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
171
+ attemptedAt: s.m(DateTime$Reventless.schema)
172
+ })),
173
+ Sury.$schema(s => ({
174
+ TAG: "RegistrationChallengeIssued",
175
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
176
+ proofHash: s.m(Sury.string),
177
+ issuedAt: s.m(DateTime$Reventless.schema)
178
+ })),
179
+ Sury.$schema(s => ({
180
+ TAG: "RegistrationProofAccepted",
181
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
182
+ address: s.m(Pii$Reventless.marked("email", undefined, Email$Reventless.schema)),
183
+ roles: s.m(Sury.array(Sury.string)),
184
+ proofHash: s.m(Sury.string)
185
+ })),
186
+ Sury.$schema(s => ({
187
+ TAG: "RegistrationProofRefused",
188
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema)),
189
+ reason: s.m(Sury.string)
190
+ })),
191
+ Sury.$schema(s => ({
192
+ TAG: "RegistrationCompleted",
193
+ email: s.m(DcbTag$Reventless.mark(ContactAddressId$ReventlessRegistration.schema))
194
+ }))
195
+ ]);
196
+
197
+ let commandSchema$1 = Api$ReventlessInfra.markNoApiVariants(commandSchema, [
198
+ "Register",
199
+ "IssueRegistrationChallenge",
200
+ "SubmitRegistrationProof",
201
+ "RecordRegistrationCompleted",
202
+ "Invite",
203
+ "ReissueRegistrationChallenge",
204
+ "WithdrawRegistration"
205
+ ]);
206
+
207
+ function authorizationOf(param) {
208
+ return "AllowAuthenticated";
209
+ }
210
+
211
+ function commandTransition(param) {
212
+ return "Undeclared";
213
+ }
214
+
215
+ let traits = [];
216
+
217
+ let name = "Registrations";
218
+
219
+ let Id;
220
+
221
+ let moduleUrl = "@reventlessdev/reventless-registration/src/Registration/StateChange/Registrations.res.mjs";
222
+
223
+ let readConsistency = "EscalateOnRetry";
224
+
225
+ export {
226
+ name,
227
+ Id,
228
+ consumedEventSchema,
229
+ errorSchema,
230
+ eventSchema,
231
+ commandSchema$1 as commandSchema,
232
+ moduleUrl,
233
+ authorizationOf,
234
+ readConsistency,
235
+ commandTransition,
236
+ traits,
237
+ }
238
+ /* consumedEventSchema Not a pure module */