@@ -41,7 +41,7 @@ async function loadUpdateChannelsKeys() {
4141 imported_keys = { } ;
4242 combined_update_channels = [ ] ;
4343
44- for ( let update_channel of combined_update_channels_preflight ) {
44+ for ( let update_channel of combined_update_channels_preflight ) {
4545
4646 try {
4747 imported_keys [ update_channel . name ] = await window . crypto . subtle . importKey (
@@ -88,17 +88,17 @@ async function checkForNewRulesets(update_channel) {
8888 if ( timestamp_result . status == 200 ) {
8989 let rulesets_timestamp = Number ( await timestamp_result . text ( ) ) ;
9090
91- if ( ( await store . local . get_promise ( 'rulesets-timestamp: ' + update_channel . name , 0 ) ) < rulesets_timestamp ) {
91+ if ( ( await store . local . get_promise ( 'rulesets-timestamp: ' + update_channel . name , 0 ) ) < rulesets_timestamp ) {
9292 return rulesets_timestamp ;
9393 }
9494 }
9595 return false ;
9696}
9797
9898// Retrieve the timestamp for when a stored ruleset bundle was published
99- async function getRulesetTimestamps ( ) {
99+ async function getRulesetTimestamps ( ) {
100100 let timestamp_promises = [ ] ;
101- for ( let update_channel of combined_update_channels ) {
101+ for ( let update_channel of combined_update_channels ) {
102102 timestamp_promises . push ( new Promise ( async resolve => {
103103 let timestamp = await store . local . get_promise ( 'rulesets-stored-timestamp: ' + update_channel . name , 0 ) ;
104104 resolve ( [ update_channel . name , timestamp ] ) ;
@@ -135,7 +135,7 @@ async function getNewRulesets(rulesets_timestamp, update_channel) {
135135// Returns a promise which verifies that the rulesets have a valid EFF
136136// signature, and if so, stores them and returns true.
137137// Otherwise, it throws an exception.
138- function verifyAndStoreNewRulesets ( new_rulesets , rulesets_timestamp , update_channel ) {
138+ function verifyAndStoreNewRulesets ( new_rulesets , rulesets_timestamp , update_channel ) {
139139 return new Promise ( ( resolve , reject ) => {
140140 window . crypto . subtle . verify (
141141 {
@@ -154,7 +154,7 @@ function verifyAndStoreNewRulesets(new_rulesets, rulesets_timestamp, update_chan
154154 const rulesets = new TextDecoder ( "utf-8" ) . decode ( rulesets_byte_array ) ;
155155 const rulesets_json = JSON . parse ( rulesets ) ;
156156
157- if ( rulesets_json . timestamp != rulesets_timestamp ) {
157+ if ( rulesets_json . timestamp != rulesets_timestamp ) {
158158 reject ( update_channel . name + ': Downloaded ruleset had an incorrect timestamp. This may be an attempted downgrade attack. Aborting.' ) ;
159159 } else {
160160 await store . local . set_promise ( 'rulesets: ' + update_channel . name , window . btoa ( rulesets_gz ) ) ;
@@ -170,13 +170,13 @@ function verifyAndStoreNewRulesets(new_rulesets, rulesets_timestamp, update_chan
170170}
171171
172172// Unzip and apply the rulesets we have stored.
173- async function applyStoredRulesets ( rulesets_obj ) {
173+ async function applyStoredRulesets ( rulesets_obj ) {
174174 let rulesets_promises = [ ] ;
175- for ( let update_channel of combined_update_channels ) {
175+ for ( let update_channel of combined_update_channels ) {
176176 rulesets_promises . push ( new Promise ( resolve => {
177177 const key = 'rulesets: ' + update_channel . name ;
178178 chrome . storage . local . get ( key , root => {
179- if ( root [ key ] ) {
179+ if ( root [ key ] ) {
180180 util . log ( util . NOTE , update_channel . name + ': Applying stored rulesets.' ) ;
181181
182182 const rulesets_gz = window . atob ( root [ key ] ) ;
@@ -192,14 +192,14 @@ async function applyStoredRulesets(rulesets_obj){
192192 } ) ) ;
193193 }
194194
195- function isNotUndefined ( subject ) {
195+ function isNotUndefined ( subject ) {
196196 return ( typeof subject != 'undefined' ) ;
197197 }
198198
199199 const channel_results = ( await Promise . all ( rulesets_promises ) ) . filter ( isNotUndefined ) ;
200200
201- if ( channel_results . length > 0 ) {
202- for ( let channel_result of channel_results ) {
201+ if ( channel_results . length > 0 ) {
202+ for ( let channel_result of channel_results ) {
203203 rulesets_obj . addFromJson ( channel_result . json . rulesets , channel_result . scope ) ;
204204 }
205205 } else {
@@ -215,9 +215,9 @@ async function performCheck() {
215215 store . local . set_promise ( 'last-checked' , current_timestamp ) ;
216216
217217 let num_updates = 0 ;
218- for ( let update_channel of combined_update_channels ) {
218+ for ( let update_channel of combined_update_channels ) {
219219 let new_rulesets_timestamp = await checkForNewRulesets ( update_channel ) ;
220- if ( new_rulesets_timestamp ) {
220+ if ( new_rulesets_timestamp ) {
221221 util . log ( util . NOTE , update_channel . name + ': A new ruleset bundle has been released. Downloading now.' ) ;
222222 let new_rulesets = await getNewRulesets ( new_rulesets_timestamp , update_channel ) ;
223223 try {
@@ -229,7 +229,7 @@ async function performCheck() {
229229 }
230230 }
231231 }
232- if ( num_updates > 0 ) {
232+ if ( num_updates > 0 ) {
233233 background_callback ( ) ;
234234 }
235235} ;
@@ -253,7 +253,7 @@ chrome.storage.onChanged.addListener(async function(changes, areaName) {
253253let initialCheck ,
254254 subsequentChecks ;
255255
256- async function createTimer ( ) {
256+ async function createTimer ( ) {
257257 const time_to_next_check = await timeToNextCheck ( ) ;
258258
259259 initialCheck = setTimeout ( ( ) => {
@@ -262,7 +262,7 @@ async function createTimer(){
262262 } , time_to_next_check * 1000 ) ;
263263}
264264
265- function destroyTimer ( ) {
265+ function destroyTimer ( ) {
266266 if ( initialCheck ) {
267267 clearTimeout ( initialCheck ) ;
268268 }
@@ -271,7 +271,7 @@ function destroyTimer(){
271271 }
272272}
273273
274- async function initialize ( store_param , cb ) {
274+ async function initialize ( store_param , cb ) {
275275 store = store_param ;
276276 background_callback = cb ;
277277
0 commit comments