pkcs11.installModule()

安裝指定的 PKCS #11 模組,使其可供 Firefox 使用。

這是一個非同步函式,返回一個 Promise

語法

js
let installing = browser.pkcs11.installModule(
  name,              // string
  flags              // integer
)

引數

name

string。要安裝的模組名稱。這必須與 PKCS #11 manifest 中該模組的 name 屬性匹配。

flags 可選

integer。要傳遞給模組的標誌。

返回值

一個 Promise,在模組安裝完成後將以無引數的形式解析。

如果找不到模組或發生其他錯誤,承諾將被拒絕並顯示錯誤訊息。

示例

安裝一個模組,然後列出它的槽及其包含的令牌。

js
function onInstalled() {
  return browser.pkcs11.getModuleSlots("my_module");
}

function onGotSlots(slots) {
  for (const slot of slots) {
    console.log(`Slot: ${slot.name}`);
    if (slot.token) {
      console.log(`Contains token: ${slot.token.name}`);
    } else {
      console.log("Is empty");
    }
  }
}

browser.pkcs11.installModule("my_module").then(onInstalled).then(onGotSlots);

瀏覽器相容性