Recommended Free Tools
JavaScript permissions are not one system. The browser and user control access to features such as location, camera, microphone, and notifications; your application’s trusted server must decide what an authenticated user may do. Query browser permission state to guide the interface, call the feature API when the user needs it, and enforce every application access rule on the server.
First, identify which kind of permission you mean
A permission check is useful only when it checks the right authority. Browser feature permission, embedded-document policy, application authorization, and Node.js process permissions have different decision-makers and failure signals.
| Permission scope | Who decides | Typical state or failure | What can change it |
|---|---|---|---|
| Browser feature access | The browser, considering user choice and browser requirements | granted, prompt, or denied; the feature API may also fail |
The user can change browser settings; the page requests access through the feature API |
| Permissions Policy for a page or iframe | The site’s HTTP response policy and the embedding page’s iframe configuration | A feature may be blocked, often without a user prompt; a permission query may report denied |
A policy or embedding configuration deployment |
| Application authorization | Your trusted application service, using the authenticated user and requested resource | Usually an HTTP authorization failure such as 403 |
A role, entitlement, ownership, or policy change in the application |
| Node.js process resource access | The runtime configuration used to launch the process | ERR_ACCESS_DENIED when a restricted operation is attempted |
A process restart with different permissions or configuration |
A browser’s granted state does not give a user an application role. Likewise, hiding an application button does not secure its API.
Check browser feature state without mistaking it for a request
The Permissions API can report a feature’s current state through navigator.permissions.query(). It does not itself display a prompt or grant access. The API’s availability is broad, but support for individual permission names varies, so feature-detect both the API and the name by handling a rejected query.
#1 Best Overall
Example: observe geolocation permission
This example checks geolocation state and updates the page if that state changes. Define showLocationState to render a concise status for the user.
async function watchLocationPermission() {
if (!navigator.permissions?.query) {
showLocationState("Permission status is not available in this browser.");
return;
}
try {
const status = await navigator.permissions.query({ name: "geolocation" });
showLocationState(status.state);
status.addEventListener("change", () => {
showLocationState(status.state);
});
} catch {
// The browser may not support querying this permission name.
showLocationState("Permission status cannot be queried here.");
}
}
The returned state is one of granted, prompt, or denied. Treat a failed query or unsupported permission name as “unknown,” not as “denied.” The change listener is useful for refreshing the interface while the page is open; it does not replace handling errors when the feature is actually used.
Request access through the feature the user needs
Explain the benefit before triggering a request, and call the relevant feature API in response to an understandable user action. For example, a location button can call navigator.geolocation.getCurrentPosition(success, error). A camera or microphone flow uses navigator.mediaDevices.getUserMedia(); a notification flow uses the Notifications API’s permission request mechanism. The browser may prompt, refuse, or require a secure context or user interaction, depending on the feature and browser.
Rank #2
After the call, handle its success and error outcomes. A prior granted query is only a snapshot: settings, policy, or other browser conditions can still prevent the operation. If a user has denied access, explain how to enable it in browser settings when appropriate rather than repeatedly prompting.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsDiagnose why a permission query says denied
denied means the browser will not currently allow the feature in this context. It is not proof that the user refused a prompt, and it says nothing about the user’s application role. The Permissions API reflects multiple conditions, including secure-context requirements, Permissions Policy restrictions, user-interaction requirements, and user choices.
- Check the browser context: confirm that the page meets the feature’s secure-context requirements.
- Check the policy: a site response header or an embedding page can block a feature before the browser asks the user.
- Check user settings: the user may have previously blocked the feature or revoked access in browser settings.
- Check the actual API result: handle errors from geolocation, media capture, or another feature API; a permission query alone does not establish that the operation will succeed.
- Check support for the permission name: query names are not uniformly supported. Catch query failures and keep an “unknown or unavailable” UI state.
When browser access is blocked, offer a useful explanation or fallback. Do not interpret this state as an application authorization decision.
Control feature access in embedded pages
Use the HTTP Permissions-Policy response header to set the page’s feature policy, and an iframe’s allow attribute when an embedded document needs a feature. The parent document and iframe allowlists combine restrictively: a child cannot re-enable a feature that its parent disallows. A policy block usually prevents a user prompt and can make a permission query report denied.
Choose a restrictive policy appropriate to the application, then explicitly allow only the features and embedded origins that need them. Test the final behavior in the top-level page and in each relevant iframe; an iframe’s own settings cannot override a restriction imposed higher in the embedding chain.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWebAuthn in cross-origin iframes
Cross-origin iframes that use WebAuthn need the Permissions Policy features publickey-credentials-create and publickey-credentials-get to be allowed. The documented top-level defaults are self, so an embedded cross-origin flow must be configured deliberately rather than assumed to inherit access.
Rank #4
Enforce application authorization on the server
Client-side JavaScript runs in an environment the user can inspect and manipulate. It may hide a button or disable a form to improve usability, but it cannot securely decide whether a user may read data or perform an action. A user can call an endpoint without using the interface, alter client-side state, or submit a crafted request.
OWASP ASVS 5.0 control 8.3.1 says: “Verify that the application enforces authorization rules at a trusted service layer and doesn’t rely on controls that an untrusted consumer could manipulate, such as client-side JavaScript.” The OWASP Authorization Cheat Sheet similarly says: “Permission should be validated correctly on every request, regardless of whether the request was initiated by an AJAX script, server-side, or any other source.”
Apply the rule to every request and resource
- Authenticate the request, then make the authorization decision on a trusted service using the authenticated subject and the requested action and resource.
- Check every request, including AJAX calls; do not rely on a prior page-load check or on whether a control was visible.
- Enforce function-level rules (whether the user may perform the operation), object-level rules (whether they may access this particular record), and field-level rules (which properties they may read or change).
- Deny by default unless a route or operation is explicitly public. Do not treat a missing client-supplied role or permission as a trusted decision.
- Log relevant authorization decisions and test business rules with unit and integration tests, including object- and field-level cases.
A UI check can still be worthwhile: it keeps people from attempting actions that the server will reject and can make the interface clearer. Keep that check as a convenience, with the trusted service as the security boundary.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Best Value
Know what Node.js permissions restrict
Node.js has a separate permission model for restricting process access to resources. The Node.js v26.7.0 documentation describes node --permission controls for areas including the filesystem, network, child processes, workers, native addons, WASI, FFI, and the inspector. This is a runtime launch configuration, not a browser permission prompt or a way to assign application roles.
Node.js describes the model as a “seat belt” for trusted code: it can reduce unintended access to resources that were not explicitly granted. The documentation warns that it does not protect against malicious code. Audit the resources your application requires before enabling it, and treat a runtime denial such as ERR_ACCESS_DENIED as a process configuration issue to investigate. It is not a substitute for application authorization.
Quick Recap
Implementation checklist
- Feature-detect
navigator.permissionsand handle unsupported permission names or rejected queries. - Use permission state to guide the UI; call the feature API when the user’s action needs that capability.
- Explain why access is useful before prompting, request only what the action needs, and handle denial or feature API failure.
- Configure restrictive Permissions Policy defaults and explicit iframe allowlists for required features.
- Authorize every server request using the authenticated subject and resource attributes; never trust hidden buttons, disabled controls, or client-supplied roles.
- Log and test authorization decisions, including object- and field-level access.
- If using Node.js
--permission, audit required resources and remember its documented boundary: it is not protection from malicious code.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

