open-vault/ui/app/services/csp-event.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

31 lines
729 B
JavaScript

/*eslint-disable no-constant-condition*/
import { computed } from '@ember/object';
import { filterBy } from '@ember/object/computed';
import Service from '@ember/service';
import { task, waitForEvent } from 'ember-concurrency';
export default Service.extend({
events: computed(function() {
return [];
}),
connectionViolations: filterBy('events', 'violatedDirective', 'connect-src'),
attach() {
this.get('monitor').perform();
},
remove() {
this.get('monitor').cancelAll();
},
monitor: task(function*() {
this.get('events').clear();
while (true) {
let event = yield waitForEvent(window.document, 'securitypolicyviolation');
this.get('events').addObject(event);
}
}),
});