ssi.askConsent()

Ask the user whether to give a permission to the requsting web app. Depending on the internal state, a dialog will be presented to the user, and the content of that dialog can be optionally customized.

This is an asynchronous function that returns a Promise.

Syntax

const booleanValue = await browser.ssi.askConsent(
	tabId, // integer
	protocolName, // string
	credentialName, // string
	dialogOptions, // optional object
)

Parameters

tabId

integer. This is tabs.Tab.id. See also MDN Reference.

protocolName

string. The protocol name targeted.

credentialName

string. The credential name targeted.

dialogOptions (optional)

DialogInfo. Parameters to build Auth dialog.

Return value

A Promise that will be fulfilled with a boolean value to indicate the authorization result.

Examples

// Authorization will be performed using the secret currently set as primary
// within the specified protocol name and credential name.
const permitted = await browser.ssi.askConsent(
  tabId,
  "nostr", // protocol name
  "nsec", // credential name
  {
    // A text description displayed on Auth dialog. Base title (kind such as sign/encrypt
    // and site URL) is generated by the system, so add additional information as needed.
    caption: "Offer from ABC Company"
  }
)
if (permitted) {
  // Go to next
}

Case for mandatory

Even when a authorization is still valid, you can require re-authorization to the user. It would be useful at critical times.

const isAuthorized = await browser.ssi.askConsent(
  tabId,
  "nostr",
  "nsec",
  {
    enforce: true
  }
)
if (!isAuthorized) {
  throw new Error("Rejected.")
}

Note

This documentation is derived from ssi.json in gecko-dev-for-ssi.