I'd like to call window.crypto.subtle.generateKey
in my Firefox AddOn. Since I can not access window
in main.js I create a page-worker with a content script :
var self = require('sdk/self');
var cryptoScript = require('sdk/page-worker').Page({
contentURL: self.data.url('empty.html'),
contentScriptFile: self.data.url('call-web-crypto.js')
});
I can call window.crypto.subtle.generateKey
in call-web-crypto.js , but I can not access the key properties of the generated key pair:
XrayWrapper denied access to property publicKey (reason: value not same-origin with target). See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. Note that only the first denied property access from a given global object will be reported.
How can I generate a key pair and access its keys in my Firefox Addon?
in main.js you can ...
const { Cu } = require("chrome");
Cu.importGlobalProperties(["crypto"]);
then you'll have access to crypto.subtle.generateKey
as well as all the other crypto
goodness ... note no window
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.