Commit graph

52 commits

Author SHA1 Message Date
Filip Skokan
484e04ca8e refactor: use nullish coalescing instead of logical OR 2021-03-03 10:55:22 +01:00
Filip Skokan
433f020246 fix(electron): properly ASN.1 encode [0x00] when converting RSA JWKs 2021-03-03 00:00:39 +01:00
Filip Skokan
a5a6c4dc9f fix(electron): only call (de)cipher.setAAD() when aad is not empty 2021-03-02 23:58:48 +01:00
Filip Skokan
2c358e0ea5 fix(typescript): update maxTokenAge type and examples 2021-02-16 11:38:21 +01:00
Filip Skokan
fc584b2efd fix: node runtime json fetch handles connection errors properly 2021-02-10 13:36:29 +01:00
Filip Skokan
e8d41a9335 feat: allow CryptoKey instances in a regular non-webcrypto node runtime 2021-02-04 17:39:28 +01:00
Filip Skokan
eef442cb54 refactor: use long form web crypto algorithm values 2021-02-04 16:53:37 +01:00
Filip Skokan
0b3561181c chore: remove unused interfaces 2021-02-02 09:58:39 +01:00
Filip Skokan
bd1b7c4812 refactor(typescript): dont mess with the node types 2021-01-28 16:25:08 +01:00
Filip Skokan
69a7edea0a refactor: explicit new uint8array arg 2021-01-28 16:16:12 +01:00
Filip Skokan
d2a574818a refactor: remove checking for secure context 2021-01-28 16:13:53 +01:00
Filip Skokan
9998cb389a refactor: generate_key_pair type returns KeyLike 2021-01-22 14:31:08 +01:00
Filip Skokan
c068e46c68 refactor: src/runtime/node/fetch.ts 2021-01-21 18:16:14 +01:00
Filip Skokan
2e5800535a fix: workaround downstream dependency issues messing with http
ref #154
2021-01-20 17:07:03 +01:00
Filip Skokan
ad88ee2cd5 perf: use KeyObject.prototype asymmetricKeyDetails when available 2021-01-18 13:50:42 +01:00
Filip Skokan
808f06cd08 perf: use 'base64url' encoding when available in Node.js runtime 2021-01-18 13:50:37 +01:00
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
3ebe3756fe style: use <> type casting syntax in embedded.ts 2021-01-10 14:32:36 +01:00
Filip Skokan
f362f6fde1 refactor: rename combinedHeader in embedded.ts 2021-01-10 14:32:27 +01:00
Filip Skokan
71d35a7d0e docs: update unsecured jwt docs 2020-12-29 10:27:29 +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
5745a6af42 docs: reword decodeProtectedHeader 2020-12-17 23:40:20 +01:00
Filip Skokan
2d58cbcf12 refactor: check general jws sign recipients length 2020-12-17 19:02:07 +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
16dea9ec7d feat: added JWE General JSON Serialization decryption 2020-12-17 12:18:13 +01:00
Filip Skokan
f511889936 refactor: form flattened jws explicitly in general verify 2020-12-17 12:08:35 +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
6fb862cf12 feat: added JWS General JSON Serialization signing
resolves #129
2020-12-16 18:43:35 +01:00
Filip Skokan
60bcd51e75 docs: update docs for GetKeyFunction 2020-12-16 18:29:30 +01:00
Filip Skokan
fa29d68cfd feat: added utility function for decoding token's protected header 2020-12-16 18:29:30 +01:00
Filip Skokan
55b77810d0 feat: added JWS General JSON Serialization verification
resolves #129
2020-12-16 18:29:05 +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
5163116ca1 feat: support recognizing proprietary crit header parameters
closes #123
2020-12-06 17:54:38 +01:00
Filip Skokan
691b44ad47 fix: reject JWTs with b64: false
As per https://tools.ietf.org/html/rfc7797 abstract

This specification updates RFC 7519 by stating that JSON Web Tokens
(JWTs) MUST NOT use the unencoded payload option defined by this
specification.
2020-12-06 17:54:32 +01:00
Filip Skokan
205529fc54 style: upgrade typescript-eslint and resolve lint issues 2020-12-01 14:57:43 +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
3bda5796f5 refactor: import agent types differently 2020-11-24 14:27:22 +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
e39c3dba75 feat: allow compact verify/decrypt tokens to be uint8array encoded
This means that when Nested JWT is used the decrypted plaintext can
be piped directly to verify.
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