feat: Implement password delegate for NSS (#41205)
* feat: Implement password delegate for NSS (#41188) Introduce an app event client-certificate-request-password. It allows the user to display a UI to prompt for the password. An alternative would have been to implement a class similar to CryptoModulePasswordDialogView, to provide the UI. This might have been simpler for the user, comparing to letting them implement the UI. But it seems like electron does not have an i18n framework, so it's not possible to provide a locale aware UI. * fix lint:markdown error * address review comments * use a trampoline handler in JS. The api exposed is now app.setClientCertRequestPasswordHandler * use properties on the Event object instead of positional parameters * remove ChromeNSSCryptoModuleDelegate::OnPassword in favor of args->GetNext(&password_) * address review comments second round - backslash escape parametrized TypeScript - rename hostName param to hostname - use base::ScopedAllowBaseSyncPrimitivesForTesting - and then, rename ChromeNSSCryptoModuleDelegate to ElectronNSSCryptoModuleDelegate * Update docs/api/app.md Co-authored-by: Sam Maddock <samuel.maddock@gmail.com> * Update docs/api/app.md Co-authored-by: Erick Zhao <erick@hotmail.ca> --------- Co-authored-by: Arno Renevier <arnaud@switchboard.app> Co-authored-by: Sam Maddock <samuel.maddock@gmail.com> Co-authored-by: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
parent
c210ae9b33
commit
81bdba67ec
7 changed files with 173 additions and 1 deletions
|
@ -1489,6 +1489,38 @@ This method can only be called after app is ready.
|
|||
|
||||
Returns `Promise<string>` - Resolves with the proxy information for `url` that will be used when attempting to make requests using [Net](net.md) in the [utility process](../glossary.md#utility-process).
|
||||
|
||||
### `app.setClientCertRequestPasswordHandler(handler)` _Linux_
|
||||
|
||||
* `handler` Function\<Promise\<string\>\>
|
||||
* `clientCertRequestParams` Object
|
||||
* `hostname` string - the hostname of the site requiring a client certificate
|
||||
* `tokenName` string - the token (or slot) name of the cryptographic device
|
||||
* `isRetry` boolean - whether there have been previous failed attempts at prompting the password
|
||||
|
||||
Returns `Promise<string>` - Resolves with the password
|
||||
|
||||
The handler is called when a password is needed to unlock a client certificate for
|
||||
`hostname`.
|
||||
|
||||
```js
|
||||
const { app } = require('electron')
|
||||
|
||||
async function passwordPromptUI (text) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// display UI to prompt user for password
|
||||
// ...
|
||||
// ...
|
||||
resolve('the password')
|
||||
})
|
||||
}
|
||||
|
||||
app.setClientCertRequestPasswordHandler(async ({ hostname, tokenName, isRetry }) => {
|
||||
const text = `Please sign in to ${tokenName} to authenticate to ${hostname} with your certificate`
|
||||
const password = await passwordPromptUI(text)
|
||||
return password
|
||||
})
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
### `app.accessibilitySupportEnabled` _macOS_ _Windows_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue