@@ -119,20 +119,22 @@ export default class LNC {
119119 this . salt = '' ;
120120 this . testCipher = '' ;
121121
122- if ( localStorage . getItem ( `${ this . _namespace } :salt` ) ) {
123- this . salt = localStorage . getItem ( `${ this . _namespace } :salt` ) || '' ;
122+ if ( localStorage . getItem ( `lnc-web:${ this . _namespace } :salt` ) ) {
123+ this . salt =
124+ localStorage . getItem ( `lnc-web:${ this . _namespace } :salt` ) || '' ;
124125 } else if ( ! this . _onLocalPrivCreate && ! this . _onRemoteKeyReceive ) {
125126 this . salt = generateSalt ( ) ;
126- localStorage . setItem ( `${ this . _namespace } :salt` , this . salt ) ;
127+ localStorage . setItem ( `lnc-web: ${ this . _namespace } :salt` , this . salt ) ;
127128 }
128129
129- if ( localStorage . getItem ( `${ this . _namespace } :testCipher` ) ) {
130+ if ( localStorage . getItem ( `lnc-web: ${ this . _namespace } :testCipher` ) ) {
130131 this . testCipher =
131- localStorage . getItem ( `${ this . _namespace } :testCipher` ) || '' ;
132+ localStorage . getItem ( `lnc-web:${ this . _namespace } :testCipher` ) ||
133+ '' ;
132134 } else if ( ! this . _onLocalPrivCreate && ! this . _onRemoteKeyReceive ) {
133135 this . testCipher = createTestCipher ( this . _password , this . salt ) ;
134136 localStorage . setItem (
135- `${ this . _namespace } :testCipher` ,
137+ `lnc-web: ${ this . _namespace } :testCipher` ,
136138 this . testCipher
137139 ) ;
138140 }
@@ -150,15 +152,15 @@ export default class LNC {
150152 onLocalPrivCreate = ( keyHex : string ) => {
151153 log . debug ( 'local private key created: ' + keyHex ) ;
152154 localStorage . setItem (
153- `${ this . _namespace } :localKey` ,
155+ `lnc-web: ${ this . _namespace } :localKey` ,
154156 this . _password ? encrypt ( keyHex , this . _password , this . salt ) : keyHex
155157 ) ;
156158 } ;
157159
158160 onRemoteKeyReceive = ( keyHex : string ) => {
159161 log . debug ( 'remote key received: ' + keyHex ) ;
160162 localStorage . setItem (
161- `${ this . _namespace } :remoteKey` ,
163+ `lnc-web: ${ this . _namespace } :remoteKey` ,
162164 this . _password ? encrypt ( keyHex , this . _password , this . salt ) : keyHex
163165 ) ;
164166 } ;
@@ -183,6 +185,12 @@ export default class LNC {
183185 ) ;
184186 }
185187
188+ clearStorage = ( ) =>
189+ Object . entries ( localStorage )
190+ . map ( ( x ) => x [ 0 ] )
191+ . filter ( ( x ) => x . substring ( 0 , 8 ) == 'lnc-web:' )
192+ . map ( ( x ) => localStorage . removeItem ( x ) ) ;
193+
186194 /**
187195 * Downloads the WASM client binary and run
188196 */
@@ -199,9 +207,11 @@ export default class LNC {
199207
200208 if ( this . _localKey ) {
201209 localKey = this . _localKey ;
202- } else if ( localStorage . getItem ( `${ this . _namespace } :localKey` ) ) {
210+ } else if (
211+ localStorage . getItem ( `lnc-web:${ this . _namespace } :localKey` )
212+ ) {
203213 const data = localStorage . getItem (
204- `${ this . _namespace } :localKey`
214+ `lnc-web: ${ this . _namespace } :localKey`
205215 ) ;
206216 if (
207217 ! verifyTestCipher (
@@ -219,9 +229,11 @@ export default class LNC {
219229
220230 if ( this . _remoteKey ) {
221231 remoteKey = this . _remoteKey ;
222- } else if ( localStorage . getItem ( `${ this . _namespace } :remoteKey` ) ) {
232+ } else if (
233+ localStorage . getItem ( `lnc-web:${ this . _namespace } :remoteKey` )
234+ ) {
223235 const data = localStorage . getItem (
224- `${ this . _namespace } :remoteKey`
236+ `lnc-web: ${ this . _namespace } :remoteKey`
225237 ) ;
226238 if (
227239 ! verifyTestCipher (
0 commit comments