Socket
Socket
Sign inDemoInstall

@aws-crypto/supports-web-crypto

Package Overview
Dependencies
1
Maintainers
8
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aws-crypto/supports-web-crypto

Provides functions for detecting if the host environment supports the WebCrypto API


Version published
Weekly downloads
12M
increased by2.4%
Maintainers
8
Install size
110 kB
Created
Weekly downloads
 

Package description

What is @aws-crypto/supports-web-crypto?

The @aws-crypto/supports-web-crypto npm package is designed to check if the current runtime environment supports the Web Cryptography API. This is particularly useful for applications that need to perform cryptographic operations in environments where support for Web Crypto might vary, such as in different browsers or Node.js versions. By using this package, developers can ensure that their applications only attempt to use Web Crypto features when they are available, thereby avoiding potential errors in unsupported environments.

What are @aws-crypto/supports-web-crypto's main functionalities?

Checking Web Crypto Support

This feature allows developers to programmatically check if the Web Cryptography API is supported in the current runtime environment. The provided code sample demonstrates how to import the `supportsWebCrypto` function from the package and use it to perform this check. Depending on the result, it logs a message indicating whether or not Web Crypto is supported.

import { supportsWebCrypto } from '@aws-crypto/supports-web-crypto';

if (supportsWebCrypto()) {
  console.log('Web Crypto is supported in this environment.');
} else {
  console.log('Web Crypto is not supported in this environment.');
}

Other packages similar to @aws-crypto/supports-web-crypto

Changelog

Source

5.2.0 (2023-10-16)

Features

  • support ESM artifacts in all packages (#752) (e930ffb)

Readme

Source

@aws-crypto/supports-web-crypto

Functions to check web crypto support for browsers.

Usage

import {supportsWebCrypto} from '@aws-crypto/supports-web-crypto';

if (supportsWebCrypto(window)) {
  // window.crypto.subtle.encrypt will exist
}

supportsWebCrypto

Used to make sure window.crypto.subtle exists and implements crypto functions as well as a cryptographic secure random source exists.

supportsSecureRandom

Used to make sure that a cryptographic secure random source exists. Does not check for window.crypto.subtle.

supportsSubtleCrypto

supportsZeroByteGCM

Test

npm test

FAQs

Last updated on 16 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc