simple-hpke 0.1.5 → 0.2.0
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.
- package/README.md +10 -8
- package/dist/constants.cjs +2 -22
- package/dist/constants.cjs.map +3 -3
- package/dist/constants.js +2 -22
- package/dist/constants.js.map +3 -3
- package/dist/constants.min.cjs +1 -1
- package/dist/constants.min.cjs.map +3 -3
- package/dist/constants.min.js +1 -1
- package/dist/constants.min.js.map +3 -3
- package/dist/index.cjs +6 -21
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +33 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -21
- package/dist/index.js.map +3 -3
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +16 -16
- package/dist/util.cjs +2 -22
- package/dist/util.cjs.map +3 -3
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +2 -22
- package/dist/util.js.map +3 -3
- package/dist/util.min.cjs +1 -1
- package/dist/util.min.cjs.map +3 -3
- package/dist/util.min.js +1 -1
- package/dist/util.min.js.map +3 -3
- package/package.json +1 -1
package/dist/util.js
CHANGED
|
@@ -1308,16 +1308,6 @@ var HPKE_SUITE_ID = concat2(
|
|
|
1308
1308
|
|
|
1309
1309
|
// src/index.ts
|
|
1310
1310
|
var subtle = globalThis.crypto.subtle;
|
|
1311
|
-
async function create2(recipient, opts) {
|
|
1312
|
-
const { wrapped, key } = await encryptKey(recipient, null, opts);
|
|
1313
|
-
return { enc: wrapped, key };
|
|
1314
|
-
}
|
|
1315
|
-
__name(create2, "create");
|
|
1316
|
-
async function seal(recipient, aesKey, opts) {
|
|
1317
|
-
const { wrapped, key } = await encryptKey(recipient, aesKey, opts);
|
|
1318
|
-
return { enc: wrapped, key };
|
|
1319
|
-
}
|
|
1320
|
-
__name(seal, "seal");
|
|
1321
1311
|
var open = Object.assign(openBytes, {
|
|
1322
1312
|
raw: openRawBytes
|
|
1323
1313
|
});
|
|
@@ -1498,7 +1488,7 @@ async function encryptKey(recipient, aesKey, opts) {
|
|
|
1498
1488
|
const ciphertext = await aeadSeal(key, baseNonce, keyBytes);
|
|
1499
1489
|
const wrapped = concat2(enc, ciphertext);
|
|
1500
1490
|
const aesGcmKey = await importAesKey(keyBytes);
|
|
1501
|
-
return { wrapped, key: aesGcmKey };
|
|
1491
|
+
return { enc: wrapped, key: aesGcmKey };
|
|
1502
1492
|
}
|
|
1503
1493
|
__name(encryptKey, "encryptKey");
|
|
1504
1494
|
|
|
@@ -1538,17 +1528,7 @@ async function aeadOpen(key, nonce, ciphertext) {
|
|
|
1538
1528
|
__name(aeadOpen, "aeadOpen");
|
|
1539
1529
|
async function encryptBytes(recipient, message, aesKey, opts) {
|
|
1540
1530
|
const plaintext = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
1541
|
-
|
|
1542
|
-
let key;
|
|
1543
|
-
if (!aesKey) {
|
|
1544
|
-
const keys = await create2(recipient, opts);
|
|
1545
|
-
enc = keys.enc;
|
|
1546
|
-
key = keys.key;
|
|
1547
|
-
} else {
|
|
1548
|
-
const keys = await seal(recipient, aesKey, opts);
|
|
1549
|
-
enc = keys.enc;
|
|
1550
|
-
key = keys.key;
|
|
1551
|
-
}
|
|
1531
|
+
const { enc, key } = await encryptKey(recipient, aesKey, opts);
|
|
1552
1532
|
const iv = globalThis.crypto.getRandomValues(new Uint8Array(NN));
|
|
1553
1533
|
const ct = new Uint8Array(await subtle2.encrypt(
|
|
1554
1534
|
{ name: "AES-GCM", iv },
|