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/constants.js
CHANGED
|
@@ -1285,16 +1285,6 @@ __name(toString2, "toString");
|
|
|
1285
1285
|
|
|
1286
1286
|
// src/index.ts
|
|
1287
1287
|
var subtle = globalThis.crypto.subtle;
|
|
1288
|
-
async function create2(recipient, opts) {
|
|
1289
|
-
const { wrapped, key } = await encryptKey(recipient, null, opts);
|
|
1290
|
-
return { enc: wrapped, key };
|
|
1291
|
-
}
|
|
1292
|
-
__name(create2, "create");
|
|
1293
|
-
async function seal(recipient, aesKey, opts) {
|
|
1294
|
-
const { wrapped, key } = await encryptKey(recipient, aesKey, opts);
|
|
1295
|
-
return { enc: wrapped, key };
|
|
1296
|
-
}
|
|
1297
|
-
__name(seal, "seal");
|
|
1298
1288
|
var open = Object.assign(openBytes, {
|
|
1299
1289
|
raw: openRawBytes
|
|
1300
1290
|
});
|
|
@@ -1475,7 +1465,7 @@ async function encryptKey(recipient, aesKey, opts) {
|
|
|
1475
1465
|
const ciphertext = await aeadSeal(key, baseNonce, keyBytes);
|
|
1476
1466
|
const wrapped = concat2(enc, ciphertext);
|
|
1477
1467
|
const aesGcmKey = await importAesKey(keyBytes);
|
|
1478
|
-
return { wrapped, key: aesGcmKey };
|
|
1468
|
+
return { enc: wrapped, key: aesGcmKey };
|
|
1479
1469
|
}
|
|
1480
1470
|
__name(encryptKey, "encryptKey");
|
|
1481
1471
|
|
|
@@ -1515,17 +1505,7 @@ async function aeadOpen(key, nonce, ciphertext) {
|
|
|
1515
1505
|
__name(aeadOpen, "aeadOpen");
|
|
1516
1506
|
async function encryptBytes(recipient, message, aesKey, opts) {
|
|
1517
1507
|
const plaintext = typeof message === "string" ? new TextEncoder().encode(message) : message;
|
|
1518
|
-
|
|
1519
|
-
let key;
|
|
1520
|
-
if (!aesKey) {
|
|
1521
|
-
const keys = await create2(recipient, opts);
|
|
1522
|
-
enc = keys.enc;
|
|
1523
|
-
key = keys.key;
|
|
1524
|
-
} else {
|
|
1525
|
-
const keys = await seal(recipient, aesKey, opts);
|
|
1526
|
-
enc = keys.enc;
|
|
1527
|
-
key = keys.key;
|
|
1528
|
-
}
|
|
1508
|
+
const { enc, key } = await encryptKey(recipient, aesKey, opts);
|
|
1529
1509
|
const iv = globalThis.crypto.getRandomValues(new Uint8Array(NN));
|
|
1530
1510
|
const ct = new Uint8Array(await subtle2.encrypt(
|
|
1531
1511
|
{ name: "AES-GCM", iv },
|