@sebastienrousseau/crypto-lib 0.0.8 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/accel/wasm-bridge.d.ts.map +1 -1
  2. package/dist/accel/wasm-bridge.js +46 -46
  3. package/dist/bin/cryptolib.d.ts +2 -11
  4. package/dist/bin/cryptolib.d.ts.map +1 -1
  5. package/dist/bin/cryptolib.js +3 -10
  6. package/dist/high-level/index.d.ts +1 -1
  7. package/dist/high-level/index.d.ts.map +1 -1
  8. package/dist/high-level/index.js +3 -1
  9. package/dist/high-level/multi-recipient.d.ts +6 -0
  10. package/dist/high-level/multi-recipient.d.ts.map +1 -1
  11. package/dist/high-level/multi-recipient.js +34 -23
  12. package/dist/index.d.ts +1 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +4 -8
  15. package/dist/keys/keygen.d.ts.map +1 -1
  16. package/dist/keys/keygen.js +19 -83
  17. package/dist/modern/hash.d.ts.map +1 -1
  18. package/dist/modern/hash.js +26 -14
  19. package/dist/modern/hpke.d.ts +1 -1
  20. package/dist/modern/hpke.d.ts.map +1 -1
  21. package/dist/modern/hpke.js +74 -11
  22. package/dist/modern/index.d.ts +1 -1
  23. package/dist/modern/index.d.ts.map +1 -1
  24. package/dist/modern/index.js +2 -0
  25. package/dist/modern/kdf.d.ts.map +1 -1
  26. package/dist/modern/kdf.js +25 -19
  27. package/dist/streaming/index.d.ts +6 -2
  28. package/dist/streaming/index.d.ts.map +1 -1
  29. package/dist/streaming/index.js +18 -1
  30. package/dist/streaming/stream-multi-pq-aead.d.ts +35 -0
  31. package/dist/streaming/stream-multi-pq-aead.d.ts.map +1 -0
  32. package/dist/streaming/stream-multi-pq-aead.js +315 -0
  33. package/dist/streaming/stream-pq-aead.d.ts +29 -0
  34. package/dist/streaming/stream-pq-aead.d.ts.map +1 -0
  35. package/dist/streaming/stream-pq-aead.js +175 -0
  36. package/dist/streaming/web-streams.d.ts +25 -0
  37. package/dist/streaming/web-streams.d.ts.map +1 -1
  38. package/dist/streaming/web-streams.js +106 -0
  39. package/dist/tokens/paseto.d.ts +1 -0
  40. package/dist/tokens/paseto.d.ts.map +1 -1
  41. package/dist/tokens/paseto.js +66 -69
  42. package/package.json +88 -13
@@ -4,11 +4,17 @@ exports.WEB_STREAM_HASH_ALGORITHMS = void 0;
4
4
  exports.createEncryptStream = createEncryptStream;
5
5
  exports.createDecryptStream = createDecryptStream;
6
6
  exports.createHashStream = createHashStream;
7
+ exports.createPqEncryptStream = createPqEncryptStream;
8
+ exports.createPqDecryptStream = createPqDecryptStream;
9
+ exports.createMultiPqEncryptStream = createMultiPqEncryptStream;
10
+ exports.createMultiPqDecryptStream = createMultiPqDecryptStream;
7
11
  const chacha_js_1 = require("@noble/ciphers/chacha.js");
8
12
  const utils_js_1 = require("@noble/ciphers/utils.js");
9
13
  const sha2_js_1 = require("@noble/hashes/sha2.js");
10
14
  const sha3_js_1 = require("@noble/hashes/sha3.js");
11
15
  const blake3_js_1 = require("@noble/hashes/blake3.js");
16
+ const stream_pq_aead_1 = require("./stream-pq-aead");
17
+ const stream_multi_pq_aead_1 = require("./stream-multi-pq-aead");
12
18
  const TS = globalThis
13
19
  .TransformStream;
14
20
  const NONCE_LEN = 24;
@@ -111,4 +117,104 @@ function createHashStream(algorithm) {
111
117
  },
112
118
  });
113
119
  }
120
+ function createPqEncryptStream(options) {
121
+ const chunks = [];
122
+ let totalLen = 0;
123
+ return new TS({
124
+ transform(chunk) {
125
+ chunks.push(chunk);
126
+ totalLen += chunk.length;
127
+ },
128
+ flush(controller) {
129
+ const plaintext = new Uint8Array(totalLen);
130
+ let offset = 0;
131
+ for (const c of chunks) {
132
+ plaintext.set(c, offset);
133
+ offset += c.length;
134
+ }
135
+ const encrypted = (0, stream_pq_aead_1.streamPqEncrypt)({
136
+ recipientX25519Public: options.recipientX25519Public,
137
+ recipientMlKemPublic: options.recipientMlKemPublic,
138
+ plaintext,
139
+ chunkSize: options.chunkSize,
140
+ });
141
+ controller.enqueue(encrypted.ciphertext);
142
+ },
143
+ });
144
+ }
145
+ function createPqDecryptStream(options) {
146
+ const chunks = [];
147
+ let totalLen = 0;
148
+ return new TS({
149
+ transform(chunk) {
150
+ chunks.push(chunk);
151
+ totalLen += chunk.length;
152
+ },
153
+ flush(controller) {
154
+ const ciphertext = new Uint8Array(totalLen);
155
+ let offset = 0;
156
+ for (const c of chunks) {
157
+ ciphertext.set(c, offset);
158
+ offset += c.length;
159
+ }
160
+ const decrypted = (0, stream_pq_aead_1.streamPqDecrypt)({
161
+ recipientX25519Secret: options.recipientX25519Secret,
162
+ recipientMlKemSecret: options.recipientMlKemSecret,
163
+ ciphertext,
164
+ chunkSize: options.chunkSize,
165
+ });
166
+ controller.enqueue(decrypted);
167
+ },
168
+ });
169
+ }
170
+ function createMultiPqEncryptStream(options) {
171
+ const chunks = [];
172
+ let totalLen = 0;
173
+ return new TS({
174
+ transform(chunk) {
175
+ chunks.push(chunk);
176
+ totalLen += chunk.length;
177
+ },
178
+ flush(controller) {
179
+ const plaintext = new Uint8Array(totalLen);
180
+ let offset = 0;
181
+ for (const c of chunks) {
182
+ plaintext.set(c, offset);
183
+ offset += c.length;
184
+ }
185
+ const encrypted = (0, stream_multi_pq_aead_1.streamMultiPqEncrypt)({
186
+ recipients: options.recipients,
187
+ plaintext,
188
+ chunkSize: options.chunkSize,
189
+ });
190
+ controller.enqueue(encrypted.ciphertext);
191
+ },
192
+ });
193
+ }
194
+ function createMultiPqDecryptStream(options) {
195
+ const chunks = [];
196
+ let totalLen = 0;
197
+ return new TS({
198
+ transform(chunk) {
199
+ chunks.push(chunk);
200
+ totalLen += chunk.length;
201
+ },
202
+ flush(controller) {
203
+ const ciphertext = new Uint8Array(totalLen);
204
+ let offset = 0;
205
+ for (const c of chunks) {
206
+ ciphertext.set(c, offset);
207
+ offset += c.length;
208
+ }
209
+ const decrypted = (0, stream_multi_pq_aead_1.streamMultiPqDecrypt)({
210
+ recipientId: options.recipientId,
211
+ recipientX25519Secret: options.recipientX25519Secret,
212
+ recipientMlKemSecret: options.recipientMlKemSecret,
213
+ ciphertext,
214
+ chunkSize: options.chunkSize,
215
+ });
216
+ controller.enqueue(decrypted.plaintext);
217
+ },
218
+ });
219
+ }
114
220
  //# sourceMappingURL=web-streams.js.map
@@ -30,6 +30,7 @@ export interface PasetoPayload {
30
30
  footer?: string;
31
31
  }
32
32
  export declare function pae(...pieces: Uint8Array[]): Uint8Array;
33
+ export declare function localEncryptWithNonce(opts: PasetoLocalEncryptOptions, nonce: Uint8Array): PasetoToken;
33
34
  declare function localEncrypt(opts: PasetoLocalEncryptOptions): PasetoToken;
34
35
  declare function localDecrypt(opts: PasetoLocalDecryptOptions): PasetoPayload;
35
36
  declare function publicSign(opts: PasetoPublicSignOptions): PasetoToken;
@@ -1 +1 @@
1
- {"version":3,"file":"paseto.d.ts","sourceRoot":"","sources":["../../src/tokens/paseto.ts"],"names":[],"mappings":"AAqDA,MAAM,WAAW,yBAAyB;IAExC,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,yBAAyB;IAExC,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,uBAAuB;IAEtC,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,yBAAyB;IAExC,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,WAAW;IAE1B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,aAAa;IAE5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkBD,wBAAgB,GAAG,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAoBvD;AAoCD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,WAAW,CA+ClE;AAeD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,aAAa,CA4DpE;AAiBD,iBAAS,UAAU,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CA8B9D;AAcD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,aAAa,CAkDpE;AAaD,eAAO,MAAM,OAAO;;;CAKV,CAAC;AAWX,eAAO,MAAM,QAAQ;;;CAKX,CAAC"}
1
+ {"version":3,"file":"paseto.d.ts","sourceRoot":"","sources":["../../src/tokens/paseto.ts"],"names":[],"mappings":"AAyDA,MAAM,WAAW,yBAAyB;IAExC,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,yBAAyB;IAExC,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,uBAAuB;IAEtC,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,yBAAyB;IAExC,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,WAAW;IAE1B,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,aAAa;IAE5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAkBD,wBAAgB,GAAG,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAoBvD;AA+FD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,yBAAyB,EAC/B,KAAK,EAAE,UAAU,GAChB,WAAW,CA2Bb;AAiBD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,WAAW,CAElE;AAyBD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,aAAa,CAqCpE;AAiBD,iBAAS,UAAU,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CA8B9D;AAcD,iBAAS,YAAY,CAAC,IAAI,EAAE,yBAAyB,GAAG,aAAa,CA0CpE;AAaD,eAAO,MAAM,OAAO;;;CAKV,CAAC;AAWX,eAAO,MAAM,QAAQ;;;CAKX,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.v4public = exports.v4local = void 0;
4
4
  exports.pae = pae;
5
+ exports.localEncryptWithNonce = localEncryptWithNonce;
5
6
  const chacha_js_1 = require("@noble/ciphers/chacha.js");
6
7
  const utils_js_1 = require("@noble/ciphers/utils.js");
7
8
  const ed25519_js_1 = require("@noble/curves/ed25519.js");
@@ -10,8 +11,10 @@ const V4_LOCAL_HEADER = "v4.local.";
10
11
  const V4_PUBLIC_HEADER = "v4.public.";
11
12
  const NONCE_LEN = 32;
12
13
  const EK_LEN = 32;
13
- const N3_LEN = 24;
14
+ const N2_LEN = 24;
15
+ const TAG_LEN = 32;
14
16
  const SIG_LEN = 64;
17
+ const BASE64URL_RE = /^[A-Za-z0-9_-]*$/;
15
18
  const HEX_RE = /^[0-9a-fA-F]*$/;
16
19
  function pae(...pieces) {
17
20
  const le64 = (n) => {
@@ -43,88 +46,90 @@ function toBase64url(buf) {
43
46
  return Buffer.from(buf).toString("base64url");
44
47
  }
45
48
  function fromBase64url(s) {
46
- const padded = s.replace(/-/g, "+").replace(/_/g, "/");
47
- return Buffer.from(padded, "base64");
49
+ const bytes = Buffer.from(s, "base64url");
50
+ if (!BASE64URL_RE.test(s) || bytes.toString("base64url") !== s) {
51
+ throw new Error("Invalid base64url encoding");
52
+ }
53
+ return bytes;
48
54
  }
49
55
  const encoder = new TextEncoder();
50
- function localEncrypt(opts) {
51
- const { key, payload, footer = "", implicit = "" } = opts;
56
+ function localKey(key) {
52
57
  const keyBytes = hexToBytes(key);
53
58
  if (keyBytes.length !== 32) {
54
59
  throw new Error(`Key must be 32 bytes, got ${keyBytes.length}`);
55
60
  }
56
- const header = encoder.encode(V4_LOCAL_HEADER);
57
- const message = encoder.encode(JSON.stringify(payload));
61
+ return keyBytes;
62
+ }
63
+ function deriveFromNonce(key, info, nonce, dkLen) {
64
+ const label = encoder.encode(info);
65
+ const msg = new Uint8Array(label.length + nonce.length);
66
+ msg.set(label);
67
+ msg.set(nonce, label.length);
68
+ return (0, blake2_js_1.blake2b)(msg, { key, dkLen });
69
+ }
70
+ function localSubkeys(key, nonce) {
71
+ const tmp = deriveFromNonce(key, "paseto-encryption-key", nonce, EK_LEN + N2_LEN);
72
+ return {
73
+ ek: tmp.subarray(0, EK_LEN),
74
+ n2: tmp.subarray(EK_LEN),
75
+ ak: deriveFromNonce(key, "paseto-auth-key-for-aead", nonce, TAG_LEN),
76
+ };
77
+ }
78
+ function localTag(ak, nonce, ciphertext, footer, implicit) {
79
+ const preAuth = pae(encoder.encode(V4_LOCAL_HEADER), nonce, ciphertext, footer, implicit);
80
+ return (0, blake2_js_1.blake2b)(preAuth, { key: ak, dkLen: TAG_LEN });
81
+ }
82
+ function localEncryptWithNonce(opts, nonce) {
83
+ const { key, payload, footer = "", implicit = "" } = opts;
84
+ const keyBytes = localKey(key);
85
+ if (nonce.length !== NONCE_LEN) {
86
+ throw new Error(`Nonce must be ${NONCE_LEN} bytes, got ${nonce.length}`);
87
+ }
58
88
  const footerBytes = encoder.encode(footer);
59
- const implicitBytes = encoder.encode(implicit);
60
- const randomN = (0, utils_js_1.randomBytes)(NONCE_LEN);
61
- const nonce = (0, blake2_js_1.blake2b)(message, { key: randomN, dkLen: NONCE_LEN });
62
- const ekInput = new Uint8Array(keyBytes.length + 16);
63
- ekInput.set(keyBytes);
64
- ekInput.set(nonce.subarray(0, 16), keyBytes.length);
65
- const derived = (0, blake2_js_1.blake2b)(encoder.encode("paseto-encryption-key"), {
66
- key: ekInput,
67
- dkLen: EK_LEN + N3_LEN,
68
- });
69
- const ek = derived.subarray(0, EK_LEN);
70
- const n3 = derived.subarray(EK_LEN, EK_LEN + N3_LEN);
71
- const aad = pae(header, nonce, footerBytes, implicitBytes);
72
- const cipher = (0, chacha_js_1.xchacha20poly1305)(ek, n3, aad);
73
- const ciphertext = cipher.encrypt(message);
74
- const body = new Uint8Array(NONCE_LEN + ciphertext.length);
89
+ const { ek, n2, ak } = localSubkeys(keyBytes, nonce);
90
+ const ciphertext = (0, chacha_js_1.xchacha20)(ek, n2, encoder.encode(JSON.stringify(payload)));
91
+ const tag = localTag(ak, nonce, ciphertext, footerBytes, encoder.encode(implicit));
92
+ const body = new Uint8Array(NONCE_LEN + ciphertext.length + TAG_LEN);
75
93
  body.set(nonce);
76
94
  body.set(ciphertext, NONCE_LEN);
95
+ body.set(tag, NONCE_LEN + ciphertext.length);
77
96
  let token = V4_LOCAL_HEADER + toBase64url(body);
78
97
  if (footer) {
79
98
  token += "." + toBase64url(footerBytes);
80
99
  }
81
100
  return { token };
82
101
  }
102
+ function localEncrypt(opts) {
103
+ return localEncryptWithNonce(opts, (0, utils_js_1.randomBytes)(NONCE_LEN));
104
+ }
105
+ function assertFooter(footerB64, footer) {
106
+ const expected = encoder.encode(footer);
107
+ if (!(0, utils_js_1.equalBytes)(fromBase64url(footerB64), expected)) {
108
+ throw new Error("Footer mismatch");
109
+ }
110
+ }
83
111
  function localDecrypt(opts) {
84
112
  const { key, token, footer = "", implicit = "" } = opts;
85
- const keyBytes = hexToBytes(key);
86
- if (keyBytes.length !== 32) {
87
- throw new Error(`Key must be 32 bytes, got ${keyBytes.length}`);
88
- }
113
+ const keyBytes = localKey(key);
89
114
  if (!token.startsWith(V4_LOCAL_HEADER)) {
90
115
  throw new Error(`Invalid token header: expected "${V4_LOCAL_HEADER}"`);
91
116
  }
92
- const withoutHeader = token.slice(V4_LOCAL_HEADER.length);
93
- const parts = withoutHeader.split(".");
94
- const bodyB64 = parts[0];
95
- const footerB64 = parts[1] ?? "";
96
- const footerBytes = encoder.encode(footer);
97
- if (footerB64) {
98
- const tokenFooter = fromBase64url(footerB64);
99
- if (Buffer.from(tokenFooter).toString("utf8") !== footer) {
100
- throw new Error("Footer mismatch");
101
- }
102
- }
103
- else if (footer) {
104
- throw new Error("Footer mismatch");
105
- }
106
- const body = fromBase64url(bodyB64);
107
- if (body.length < NONCE_LEN + 16) {
117
+ const parts = token.slice(V4_LOCAL_HEADER.length).split(".");
118
+ assertFooter(parts[1] ?? "", footer);
119
+ const body = fromBase64url(parts[0]);
120
+ if (body.length < NONCE_LEN + TAG_LEN) {
108
121
  throw new Error("Token body too short");
109
122
  }
110
- const header = encoder.encode(V4_LOCAL_HEADER);
111
- const implicitBytes = encoder.encode(implicit);
112
123
  const nonce = body.subarray(0, NONCE_LEN);
113
- const ciphertext = body.subarray(NONCE_LEN);
114
- const ekInput = new Uint8Array(keyBytes.length + 16);
115
- ekInput.set(keyBytes);
116
- ekInput.set(nonce.subarray(0, 16), keyBytes.length);
117
- const derived = (0, blake2_js_1.blake2b)(encoder.encode("paseto-encryption-key"), {
118
- key: ekInput,
119
- dkLen: EK_LEN + N3_LEN,
120
- });
121
- const ek = derived.subarray(0, EK_LEN);
122
- const n3 = derived.subarray(EK_LEN, EK_LEN + N3_LEN);
123
- const aad = pae(header, nonce, footerBytes, implicitBytes);
124
- const cipher = (0, chacha_js_1.xchacha20poly1305)(ek, n3, aad);
125
- const plaintext = cipher.decrypt(ciphertext);
126
- const payloadStr = Buffer.from(plaintext).toString("utf8");
127
- const payload = JSON.parse(payloadStr);
124
+ const ciphertext = body.subarray(NONCE_LEN, body.length - TAG_LEN);
125
+ const tag = body.subarray(body.length - TAG_LEN);
126
+ const { ek, n2, ak } = localSubkeys(keyBytes, nonce);
127
+ const expected = localTag(ak, nonce, ciphertext, encoder.encode(footer), encoder.encode(implicit));
128
+ if (!(0, utils_js_1.equalBytes)(tag, expected)) {
129
+ throw new Error("Invalid token: authentication failed");
130
+ }
131
+ const plaintext = (0, chacha_js_1.xchacha20)(ek, n2, ciphertext);
132
+ const payload = JSON.parse(Buffer.from(plaintext).toString("utf8"));
128
133
  return { payload, ...(footer ? { footer } : {}) };
129
134
  }
130
135
  function publicSign(opts) {
@@ -162,16 +167,8 @@ function publicVerify(opts) {
162
167
  const parts = withoutHeader.split(".");
163
168
  const bodyB64 = parts[0];
164
169
  const footerB64 = parts[1] ?? "";
170
+ assertFooter(footerB64, footer);
165
171
  const footerBytes = encoder.encode(footer);
166
- if (footerB64) {
167
- const tokenFooter = fromBase64url(footerB64);
168
- if (Buffer.from(tokenFooter).toString("utf8") !== footer) {
169
- throw new Error("Footer mismatch");
170
- }
171
- }
172
- else if (footer) {
173
- throw new Error("Footer mismatch");
174
- }
175
172
  const body = fromBase64url(bodyB64);
176
173
  if (body.length < SIG_LEN) {
177
174
  throw new Error("Token body too short");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebastienrousseau/crypto-lib",
3
- "version": "0.0.8",
3
+ "version": "0.0.24",
4
4
  "description": "Crypto Lib is a powerful intuitive cryptographic JavaScript library that encapsulates common algorithms, functions and provides an interface for low-level cryptographic operations.",
5
5
  "author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
6
6
  "license": "MIT OR Apache-2.0",
@@ -16,12 +16,86 @@
16
16
  "engines": {
17
17
  "node": ">=22.0.0"
18
18
  },
19
+ "type": "commonjs",
19
20
  "main": "./dist/index.js",
20
21
  "types": "./dist/index.d.ts",
21
- "sideEffects": false,
22
- "bin": {
23
- "cryptolib": "./dist/index.js"
22
+ "typesVersions": {
23
+ "*": {
24
+ "modern": [
25
+ "./dist/modern/index.d.ts"
26
+ ],
27
+ "high-level": [
28
+ "./dist/high-level/index.d.ts"
29
+ ],
30
+ "keys": [
31
+ "./dist/keys/index.d.ts"
32
+ ],
33
+ "streaming": [
34
+ "./dist/streaming/index.d.ts"
35
+ ],
36
+ "protocols": [
37
+ "./dist/protocols/index.d.ts"
38
+ ],
39
+ "tokens": [
40
+ "./dist/tokens/index.d.ts"
41
+ ],
42
+ "accel": [
43
+ "./dist/accel/index.d.ts"
44
+ ],
45
+ "pgp": [
46
+ "./dist/bin/cryptolib.d.ts"
47
+ ]
48
+ }
49
+ },
50
+ "exports": {
51
+ ".": {
52
+ "types": "./dist/index.d.ts",
53
+ "require": "./dist/index.js",
54
+ "default": "./dist/index.js"
55
+ },
56
+ "./modern": {
57
+ "types": "./dist/modern/index.d.ts",
58
+ "require": "./dist/modern/index.js",
59
+ "default": "./dist/modern/index.js"
60
+ },
61
+ "./high-level": {
62
+ "types": "./dist/high-level/index.d.ts",
63
+ "require": "./dist/high-level/index.js",
64
+ "default": "./dist/high-level/index.js"
65
+ },
66
+ "./keys": {
67
+ "types": "./dist/keys/index.d.ts",
68
+ "require": "./dist/keys/index.js",
69
+ "default": "./dist/keys/index.js"
70
+ },
71
+ "./streaming": {
72
+ "types": "./dist/streaming/index.d.ts",
73
+ "require": "./dist/streaming/index.js",
74
+ "default": "./dist/streaming/index.js"
75
+ },
76
+ "./protocols": {
77
+ "types": "./dist/protocols/index.d.ts",
78
+ "require": "./dist/protocols/index.js",
79
+ "default": "./dist/protocols/index.js"
80
+ },
81
+ "./tokens": {
82
+ "types": "./dist/tokens/index.d.ts",
83
+ "require": "./dist/tokens/index.js",
84
+ "default": "./dist/tokens/index.js"
85
+ },
86
+ "./accel": {
87
+ "types": "./dist/accel/index.d.ts",
88
+ "require": "./dist/accel/index.js",
89
+ "default": "./dist/accel/index.js"
90
+ },
91
+ "./pgp": {
92
+ "types": "./dist/bin/cryptolib.d.ts",
93
+ "require": "./dist/bin/cryptolib.js",
94
+ "default": "./dist/bin/cryptolib.js"
95
+ },
96
+ "./package.json": "./package.json"
24
97
  },
98
+ "sideEffects": false,
25
99
  "files": [
26
100
  "dist/**/*.js",
27
101
  "dist/**/*.d.ts",
@@ -33,18 +107,19 @@
33
107
  "@noble/hashes": "^2.4.0",
34
108
  "@noble/post-quantum": "^0.7.1",
35
109
  "@openpgp/web-stream-tools": "^0.3.1",
36
- "openpgp": "^6.3.1"
110
+ "openpgp": "^6.3.2"
37
111
  },
38
112
  "devDependencies": {
39
- "@types/chai": "^4.3.7",
113
+ "@types/chai": "^5.2.3",
40
114
  "@types/chai-as-promised": "^8.0.2",
41
- "@types/mocha": "^10.0.2",
115
+ "@types/mocha": "^10.0.10",
42
116
  "@types/node": "^26.6.3",
43
117
  "c8": "^12.0.0",
44
- "chai": "^4.5.0",
45
- "chai-as-promised": "^7.1.2",
46
- "mocha": "^10.8.2",
47
- "prettier": "^3.9.8",
118
+ "chai": "^6.3.0",
119
+ "chai-as-promised": "^8.0.2",
120
+ "fast-check": "^4.10.2",
121
+ "mocha": "^12.0.3",
122
+ "prettier": "^3.9.9",
48
123
  "rimraf": "^6.1.3",
49
124
  "ts-node": "^10.9.2",
50
125
  "typedoc": "^0.28.20",
@@ -66,8 +141,8 @@
66
141
  "scripts": {
67
142
  "build": "tsc --build tsconfig.json",
68
143
  "clean": "rimraf ./coverage ./dist ./docs",
69
- "lint": "eslint --ext .ts src __tests__",
70
- "lint:fix": "eslint --cache --fix --ext .ts src __tests__",
144
+ "lint": "eslint src __tests__",
145
+ "lint:fix": "eslint --cache --fix src __tests__",
71
146
  "format": "prettier --write src/**/*.ts",
72
147
  "format:check": "prettier --check \"src/**/*.ts\"",
73
148
  "start": "node dist/index.js",