Commit graph

20 commits

Author SHA1 Message Date
codedust
ed32b0d46e fix: workaround for RangeError in browser runtime base64url
Fixes RangeError in base64url.ts when encrypting large Uint8Arrays

String.fromCharCode.apply causes a RangeError for large Uint8Arrays
(> ~500kB). This happens, e.g., when encrypting larger files.

See this gist to reproduce the bug (select a large file and see the
browser console):
https://gist.github.com/codedust/88c8af3b2acd782e72ffbe0c3c8bf5af

Error message in Firefox:
```
Uncaught (in promise) RangeError: too many arguments provided for a
function call (in base64url.js:8:62)
    encode http://localhost:8000/jose/runtime/base64url.js:8
    encrypt http://localhost:8000/jose/jwe/flattened/encrypt.js:143
```

Error message in Chromium:
```
Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at encode (base64url.js:8)
    at FlattenedEncrypt.encrypt (encrypt.js:143)
    at async CompactEncrypt.encrypt (encrypt.js:23)
    at async jwe_test ((index):55)
```

Solution: Apply String.fromCharCode.apply in chunks of 32768 bytes,
see https://stackoverflow.com/a/12713326
2021-01-10 14:33:30 +01:00
Filip Skokan
c886f77c6a refactor: catch and rethrow atob invalid inputs as TypeError
resolves #134
2020-12-22 19:24:16 +01:00
Filip Skokan
626d91f201 refactor: iv and cek generators are not async 2020-12-17 19:02:07 +01:00
Filip Skokan
6abd2ef962 lint: lint with upgraded deps 2020-12-17 13:42:02 +01:00
Filip Skokan
0e9e6e79cf refactor: remove workaround for a bugged v15.2.x webcrypto 2020-12-16 18:43:35 +01:00
Filip Skokan
cfd2d261ca lint: prettier over the type casting syntax 2020-12-16 11:36:18 +01:00
Filip Skokan
55e8bfed32 style: use <> type casting syntax 2020-12-16 11:11:34 +01:00
Filip Skokan
175f273819 fix(typescript): ref dom lib via triple-slash to fix some compile issues
closes #126
2020-12-14 16:41:59 +01:00
Filip Skokan
e72af2742e test: add coverage for generate key pair options 2020-12-01 12:12:24 +01:00
Filip Skokan
5f7a0e9055 feat: allow specifying modulusLength when generating RSA Key Pairs
resolves #121
2020-12-01 12:12:24 +01:00
Filip Skokan
29373633bc fix(typescript): refactored how types are published
resolves #119
2020-11-26 18:53:01 +01:00
Filip Skokan
b83c59bb43 fix: handle globalThis undefined in legacy browsers 2020-11-24 14:53:08 +01:00
Filip Skokan
56ff8fa65a fix: global detection in a browser worker runtime 2020-11-24 14:40:38 +01:00
Filip Skokan
38494a8882 feat: allow http.Agent and https.Agent passed in remote JWK Set 2020-11-22 14:53:25 +01:00
Filip Skokan
ce521d567b refactor: less for in, added type checks, error messages 2020-11-22 12:44:27 +01:00
Filip Skokan
7a8418eadd feat: added "KeyLike to JWK" module
resolves #109
2020-11-22 12:44:27 +01:00
Filip Skokan
8bc4c67fd0 src: runtime declarations 2020-11-15 13:17:21 +01:00
Filip Skokan
e6e789c8dd style: lint .d.ts files 2020-11-15 12:40:47 +01:00
Filip Skokan
d9cb5734d7 fix(typescript): fix compiling by adding .d.ts files for runtime modules 2020-11-15 12:33:42 +01:00
Filip Skokan
357fe0b964 feat: Revised API, No dependencies, Browser Support, Promises
BREAKING CHANGE: Revised, Promise-based API
BREAKING CHANGE: No dependencies
BREAKING CHANGE: Browser support (using [Web Cryptography API](https://www.w3.org/TR/WebCryptoAPI/))
BREAKING CHANGE: Support for verification using a remote JWKS endpoint
BREAKING CHANGE: Experimental Node.js libuv thread pool based runtime (non-blocking 🎉)
2020-11-14 18:26:46 +01:00