@@ -3,11 +3,21 @@ import { Store } from 'store';
33import * as LIT from 'types/generated/lit-sessions_pb' ;
44import { MAX_DATE , PermissionUriMap } from 'util/constants' ;
55
6+ export enum PermissionTypeValues {
7+ Admin = 'admin' ,
8+ ReadOnly = 'read-only' ,
9+ Liquidity = 'liquidity' ,
10+ Payments = 'payments' ,
11+ Messenger = 'messenger' ,
12+ Custodial = 'custodial' ,
13+ Custom = 'custom' ,
14+ }
15+
616export default class AddSessionView {
717 private _store : Store ;
818
919 label = '' ;
10- permissionType = 'admin' ; // Expected values: admin | read-only | custodial | custom | liquidity | payments
20+ permissionType : PermissionTypeValues = PermissionTypeValues . Admin ;
1121 editing = false ;
1222 permissions : { [ key : string ] : boolean } = {
1323 openChannel : false ,
@@ -17,6 +27,7 @@ export default class AddSessionView {
1727 pool : false ,
1828 send : false ,
1929 receive : false ,
30+ sign : false ,
2031 } ;
2132 expiration = 'never' ; // Expected values: 7 | 30 | 60 | 90 | never | custom
2233 expirationOptions = [
@@ -49,11 +60,11 @@ export default class AddSessionView {
4960 //
5061
5162 get sessionType ( ) {
52- if ( this . permissionType === 'admin' ) {
63+ if ( this . permissionType === PermissionTypeValues . Admin ) {
5364 return LIT . SessionType . TYPE_MACAROON_ADMIN ;
54- } else if ( this . permissionType === 'read-only' ) {
65+ } else if ( this . permissionType === PermissionTypeValues . ReadOnly ) {
5566 return LIT . SessionType . TYPE_MACAROON_READONLY ;
56- } else if ( this . permissionType === 'custodial' ) {
67+ } else if ( this . permissionType === PermissionTypeValues . Custodial ) {
5768 return LIT . SessionType . TYPE_MACAROON_ACCOUNT ;
5869 }
5970
@@ -132,45 +143,52 @@ export default class AddSessionView {
132143 this . custodialBalance = balance ;
133144 }
134145
135- setPermissionType ( permissionType : string ) {
146+ setPermissionType ( permissionType : PermissionTypeValues ) {
136147 this . permissionType = permissionType ;
137148
138149 switch ( permissionType ) {
139- case 'admin' :
150+ case PermissionTypeValues . Admin :
140151 this . setAllPermissions ( true ) ;
141152 break ;
142153
143- case 'read-only' :
154+ case PermissionTypeValues . ReadOnly :
144155 this . setAllPermissions ( false ) ;
145156 break ;
146157
147- case 'liquidity' :
158+ case PermissionTypeValues . Liquidity :
148159 this . setAllPermissions ( false ) ;
149160 this . permissions . setFees = true ;
150161 this . permissions . loop = true ;
151162 this . permissions . pool = true ;
152163 break ;
153164
154- case 'payments' :
165+ case PermissionTypeValues . Payments :
166+ this . setAllPermissions ( false ) ;
167+ this . permissions . send = true ;
168+ this . permissions . receive = true ;
169+ break ;
170+
171+ case PermissionTypeValues . Messenger :
155172 this . setAllPermissions ( false ) ;
156173 this . permissions . send = true ;
157174 this . permissions . receive = true ;
175+ this . permissions . sign = true ;
158176 break ;
159177
160- case 'custodial' :
178+ case PermissionTypeValues . Custodial :
161179 this . setAllPermissions ( false ) ;
162180 this . permissions . send = true ;
163181 this . permissions . receive = true ;
164182 break ;
165183
166- case 'custom' :
184+ case PermissionTypeValues . Custom :
167185 // We don't need to change anything, let the user customize permissions how they want
168186 break ;
169187 }
170188 }
171189
172190 togglePermission ( permission : string ) {
173- this . setPermissionType ( 'custom' ) ;
191+ this . setPermissionType ( PermissionTypeValues . Custom ) ;
174192 this . permissions [ permission ] = ! this . permissions [ permission ] ;
175193 }
176194
@@ -184,7 +202,7 @@ export default class AddSessionView {
184202
185203 cancel ( ) {
186204 this . label = '' ;
187- this . permissionType = 'admin' ;
205+ this . permissionType = PermissionTypeValues . Admin ;
188206 this . editing = false ;
189207 this . setAllPermissions ( false ) ;
190208 this . expiration = 'never' ;
@@ -197,7 +215,7 @@ export default class AddSessionView {
197215 //
198216
199217 async handleSubmit ( ) {
200- if ( this . permissionType === 'custom' ) {
218+ if ( this . permissionType === PermissionTypeValues . Custom ) {
201219 this . _store . settingsStore . sidebarVisible = false ;
202220 this . _store . router . push ( '/connect/custom' ) ;
203221 } else {
@@ -223,7 +241,7 @@ export default class AddSessionView {
223241 label = `My ${ this . permissionType } session` ;
224242 }
225243
226- if ( this . permissionType === 'custodial' ) {
244+ if ( this . permissionType === PermissionTypeValues . Custodial ) {
227245 const custodialAccountId = await this . registerCustodialAccount ( ) ;
228246
229247 // Return immediately to prevent a session being created when there is an error creating the custodial account
0 commit comments