Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# credential-handler-polyfill ChangeLog

## 4.0.2 - 2026-06-dd

### Fixed
- Do not throw during `load()` on browsers (e.g., WebKit/iOS) where
`navigator.credentials` cannot be redefined via `Object.defineProperty`;
fall back to plain assignment or, failing that, skip installing the
proxy that protects against subsequent overwrites.

## 4.0.1 - 2025-12-16

### Fixed
Expand Down
22 changes: 17 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2017-2026 Digital Bazaar, Inc.
*/
/* global navigator, window */
import {WebAppContext} from 'web-request-rpc';
Expand Down Expand Up @@ -104,10 +104,22 @@ export async function load(options = {
}
});

Object.defineProperty(navigator, 'credentials', {
value: navCredentialsProxy,
writable: true
});
try {
Object.defineProperty(navigator, 'credentials', {
value: navCredentialsProxy,
writable: true
});
} catch(e) {
// on WebKit, `navigator.credentials` is a non-configurable property
// that cannot be redefined as a data property; fall back to plain
// assignment and, if that also fails, continue without the proxy --
// `get` and `store` have already been replaced on the existing
// `navigator.credentials` above, so only the protection against
// subsequent overwrites of `navigator.credentials` itself is lost
try {
navigator.credentials = navCredentialsProxy;
} catch(e2) {}
}

window.CredentialManager = CredentialManager;
window.WebCredential = WebCredential;
Expand Down
Loading