pkcs11.installModule()
安装指定的 PKCS #11 模块,使其可用于 Firefox。
这是一个异步函数,返回 Promise
。
语法
js
let installing = browser.pkcs11.installModule(
name, // 字符串
flags // 整型
)
参数
name
-
string
,要安装的模块名称。这需要与模块的 PKCS #11 清单中的name
属性相匹配。 flags
可选-
integer
,传递给模块的标志位。
返回值
当模块安装完成后,会返回一个不以任何参数兑现的 Promise
。
若无法找到模块或发生其他错误,该 Promise 将以一个错误消息拒绝。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
installModule |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
示例
安装一个模块并列出其插槽及其包含的令牌:
js
function onInstalled() {
return browser.pkcs11.getModuleSlots("my_module");
}
function onGotSlots(slots) {
for (const slot of slots) {
console.log(`插槽:${slot.name}`);
if (slot.token) {
console.log(`包含令牌:${slot.token.name}`);
} else {
console.log("为空");
}
}
}
browser.pkcs11.installModule("my_module").then(onInstalled).then(onGotSlots);