11import * as Schema from 'effect/Schema' ;
22
3+ export const EventAuthor = Schema . Struct ( {
4+ accountId : Schema . String ,
5+ // must be validated if it belongs to the accountId before being used
6+ // Note: could be removed, but also might be useful to keep around in case accounts rotate their keys
7+ publicKey : Schema . String ,
8+ signature : Schema . String ,
9+ } ) ;
10+
11+ export type EventAuthor = Schema . Schema . Type < typeof Author > ;
12+
313export const SpaceMember = Schema . Struct ( {
414 accountId : Schema . String ,
5- signaturePublicKey : Schema . String ,
6- encryptionPublicKey : Schema . String ,
715 role : Schema . Union ( Schema . Literal ( 'admin' ) , Schema . Literal ( 'member' ) ) ,
816} ) ;
917
1018export type SpaceMember = Schema . Schema . Type < typeof SpaceMember > ;
1119
1220export const SpaceInvitation = Schema . Struct ( {
1321 inviteeAccountId : Schema . String ,
14- signaturePublicKey : Schema . String ,
15- encryptionPublicKey : Schema . String ,
1622} ) ;
1723
1824export type SpaceInvitation = Schema . Schema . Type < typeof SpaceInvitation > ;
@@ -32,14 +38,8 @@ export const CreateSpaceEvent = Schema.Struct({
3238 type : Schema . Literal ( 'create-space' ) ,
3339 id : Schema . String ,
3440 creatorAccountId : Schema . String ,
35- creatorSignaturePublicKey : Schema . String ,
36- creatorEncryptionPublicKey : Schema . String ,
37- } ) ,
38- author : Schema . Struct ( {
39- accountId : Schema . String ,
40- publicKey : Schema . String ,
41- signature : Schema . String ,
4241 } ) ,
42+ author : EventAuthor ,
4343} ) ;
4444
4545export type CreateSpaceEvent = Schema . Schema . Type < typeof CreateSpaceEvent > ;
@@ -50,11 +50,7 @@ export const DeleteSpaceEvent = Schema.Struct({
5050 id : Schema . String ,
5151 previousEventHash : Schema . String ,
5252 } ) ,
53- author : Schema . Struct ( {
54- accountId : Schema . String ,
55- publicKey : Schema . String ,
56- signature : Schema . String ,
57- } ) ,
53+ author : EventAuthor ,
5854} ) ;
5955
6056export type DeleteSpaceEvent = Schema . Schema . Type < typeof DeleteSpaceEvent > ;
@@ -63,18 +59,10 @@ export const CreateInvitationEvent = Schema.Struct({
6359 transaction : Schema . Struct ( {
6460 type : Schema . Literal ( 'create-invitation' ) ,
6561 id : Schema . String ,
66- ciphertext : Schema . String ,
67- nonce : Schema . String ,
6862 inviteeAccountId : Schema . String ,
69- signaturePublicKey : Schema . String ,
70- encryptionPublicKey : Schema . String ,
7163 previousEventHash : Schema . String ,
7264 } ) ,
73- author : Schema . Struct ( {
74- accountId : Schema . String ,
75- publicKey : Schema . String ,
76- signature : Schema . String ,
77- } ) ,
65+ author : EventAuthor ,
7866} ) ;
7967
8068export type CreateInvitationEvent = Schema . Schema . Type < typeof CreateInvitationEvent > ;
@@ -85,11 +73,7 @@ export const AcceptInvitationEvent = Schema.Struct({
8573 type : Schema . Literal ( 'accept-invitation' ) ,
8674 previousEventHash : Schema . String ,
8775 } ) ,
88- author : Schema . Struct ( {
89- accountId : Schema . String ,
90- publicKey : Schema . String ,
91- signature : Schema . String ,
92- } ) ,
76+ author : EventAuthor ,
9377} ) ;
9478
9579export type AcceptInvitationEvent = Schema . Schema . Type < typeof AcceptInvitationEvent > ;
0 commit comments