# webcrypto-shim

> Web Cryptography API shim for legacy browsers

Latest version **0.1.7** (published 2021-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install webcrypto-shim
pnpm add webcrypto-shim
yarn add webcrypto-shim
bun add webcrypto-shim
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2021-03-23 |
| First published | 2017-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 426.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 122 |
| Author | Artem S Vybornov |
| Maintainers | vibornoff |
| Keywords | webcrypto, shim, crypto, mscrypto, webkitcrypto, mozcrypto, subtle, webkitsubtle, sha, hmac, pbkdf, aes, cbc, gcm, rsa, oaep, pkcs1 |

## Links

- npm: https://www.npmjs.com/package/webcrypto-shim
- Repository: https://github.com/vibornoff/webcrypto-shim
- Homepage: https://github.com/vibornoff/webcrypto-shim#readme
- Issues: https://github.com/vibornoff/webcrypto-shim/issues
- npm.io page: https://npm.io/package/webcrypto-shim

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2021-03-23
- 0.1.6 — 2020-07-28
- 0.1.5 — 2019-09-23
- 0.1.4 — 2018-05-15
- 0.1.3 — 2018-03-07
- 0.1.2 — 2017-08-21

## README

webcrypto-shim.js
=================

[Web Cryptography API](https://www.w3.org/TR/WebCryptoAPI/) shim for legacy browsers.

Quick start with _Bower_
------------------------

Install the package

```sh
$ bower install webcrypto-shim
```

and link scripts into your html code

```html
<script src="bower_components/promiz/promiz.js"></script>
<script src="bower_components/webcrypto-shim/webcrypto-shim.js"></script>
```

Now you can use webcrypto api through the `window.crypto` and `window.crypto.subtle` objects.

Note that _IE11_ lacks support of `Promise`-s and requires _promiz.js_ to work properly. You can replace _promiz.js_ with any _Promise/A+_-compatible implementation.

Supported browsers
------------------

The library is targeted to fix these browsers having prefixed and buggy webcrypto api implementations:
* _Internet Explorer 11_, _Mobile Internet Explorer 11_,
* _Safari 8 - 10_, _iOS Safari 8 - 10_.

These browsers have unprefixed and conforming webcrypto api implementations, so no need in shim:
* _Chrome 43+_, _Chrome for Android 44+_,
* _Opera 24+_,
* _Firefox 34+_,
* _Edge 12+_.
* _Safari 11+_.

Crossbrowser support of algorithms & operations
-----------------------------------------------

* **SHA-256**, **SHA-384**: `digest`

* **HMAC**: `sign`, `verify`, `generateKey`, `importKey`, `exportKey`
  * with _hash_ **SHA-1**, **SHA-256**, **SHA-384**

* **AES-CBC**: `encrypt`, `decrypt`, `generateKey`, `importKey`, `exportKey`, `wrapKey`, `unwrapKey`
  * _TODO_ tests

* **AES-KW**: `generateKey`, `importKey`, `exportKey`, `wrapKey`, `unwrapKey`
  * _TODO_ tests

* **RSASSA-PKCS1-v1\_5**: `sign`, `verify`, `generateKey`, `importKey`, `exportKey`
  * with _hash_ **SHA-256**, **SHA-384**
  * and _modulusLength_ at least 2048 bits

* **RSA-OAEP**: `encrypt`, `decrypt`, `generateKey`, `importKey`, `exportKey`, `wrapKey`, `unwrapKey`
  * with _hash_ **SHA-1**
  * and _modulusLength_ at least 2048 bits
  * _FIXME_ only `"jwk"` format for wrapped/unwrapped keys

Known limitations
-----------------

`deriveKey`, `deriveBits` are not supported under _IE11_ and _Safari_  since there is no implementation of any algorithm providing key derivation.

Under _IE11_ exception is thrown in case of empty input data since _IE11_ silently discards empty data and leaves returned `Promise` object never resolved nor rejected.

Other browsers support
----------------------

See https://vibornoff.github.io/webcrypto-examples/index.html

Sponsored by
------------

[BrowserStack](https://browserstack.com) — automated & manual crossbrowser testing solution.

---
_Source: https://npm.io/package/webcrypto-shim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
