Skip to content

NotSupportedError: The user agent does not support public key credentials. #48406

@spamshaker

Description

@spamshaker

Preflight Checklist

Electron Version

38.1.2

What operating system(s) are you using?

macOS

Operating System Version

MacOS 26.0 (25A354)

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

  1. Should show the credentials manager that allows to save password
  2. Should show the auth modal that allows to share stored credentials

This works in Chromium Version 142.0.7440.0 (Developer Build) (arm64)

Image

Actual Behavior

The credentials manager not working.

NotSupportedError: The user agent does not support public key credentials.

Image

Testcase Gist URL

No response

Additional Information

minimum code to reproduce:

file name main.ts:

import { app, BrowserWindow } from 'electron/main';

async function storeCredentials() {
  const creds = new PasswordCredential({
    id: 'MyUserName',
    name: 'MyName',
    password: 'MyPassword',
    iconURL: 'https://avatars.githubusercontent.com/u/4864089?v=4&size=256'
  });

  await navigator.credentials.store(creds);
  await navigator.credentials.get({ password: true, mediation: 'optional' });
}

app.whenReady().then(async () => {
  const win = new BrowserWindow({});

  win.webContents.session.protocol.handle('http', (request) => {
    return new Response('OK');
  });
  await win.loadURL('http://localhost/');
  win.webContents.openDevTools();
  await win.webContents.executeJavaScript(`(${storeCredentials.toString()})()`);
});
electron main.ts

If this functionality is disabled for some reason what is the alternative.

It is fully supported since Chrome 60 https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential

Not sure but maybe I can polyfill this functionality using https://www.electronjs.org/docs/latest/api/safe-storage

though this message says
Uncaught (in promise) NotSupportedError: Only exactly one of "password', "federated', and
'publickey' credential types are currently supported.

so I guess it should work

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions