@lindorm/aes 0.6.5 → 0.7.1
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 +126 -231
- package/dist/classes/AesKit.d.ts +4 -4
- package/dist/classes/AesKit.d.ts.map +1 -1
- package/dist/classes/AesKit.js +29 -33
- package/dist/classes/AesKit.js.map +1 -1
- package/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +1 -17
- package/dist/classes/index.js.map +1 -1
- package/dist/errors/AesError.js +2 -6
- package/dist/errors/AesError.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -17
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -22
- package/dist/index.js.map +1 -1
- package/dist/interfaces/AesKit.d.ts +3 -3
- package/dist/interfaces/AesKit.d.ts.map +1 -1
- package/dist/interfaces/AesKit.js +1 -2
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +1 -17
- package/dist/interfaces/index.js.map +1 -1
- package/dist/internal/constants/version.js +3 -6
- package/dist/internal/constants/version.js.map +1 -1
- package/dist/internal/types/aes-data.d.ts +4 -4
- package/dist/internal/types/aes-data.d.ts.map +1 -1
- package/dist/internal/types/aes-data.js +1 -2
- package/dist/internal/types/aes-key-derivation.js +1 -2
- package/dist/internal/types/auth-tag.d.ts +2 -2
- package/dist/internal/types/auth-tag.d.ts.map +1 -1
- package/dist/internal/types/auth-tag.js +1 -2
- package/dist/internal/types/auth-tag.js.map +1 -1
- package/dist/internal/types/content-encryption-key.d.ts +2 -2
- package/dist/internal/types/content-encryption-key.d.ts.map +1 -1
- package/dist/internal/types/content-encryption-key.js +1 -2
- package/dist/internal/types/key-wrap.d.ts +1 -1
- package/dist/internal/types/key-wrap.d.ts.map +1 -1
- package/dist/internal/types/key-wrap.js +1 -2
- package/dist/internal/types/prepared-encryption.d.ts +3 -3
- package/dist/internal/types/prepared-encryption.d.ts.map +1 -1
- package/dist/internal/types/prepared-encryption.js +1 -2
- package/dist/internal/utils/aes-header.d.ts +3 -3
- package/dist/internal/utils/aes-header.d.ts.map +1 -1
- package/dist/internal/utils/aes-header.js +22 -30
- package/dist/internal/utils/aes-header.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-aes-encryption.d.ts +2 -2
- package/dist/internal/utils/calculate/calculate-aes-encryption.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-aes-encryption.js +4 -8
- package/dist/internal/utils/calculate/calculate-aes-encryption.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-content-encryption-key-size.d.ts +2 -2
- package/dist/internal/utils/calculate/calculate-content-encryption-key-size.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-content-encryption-key-size.js +4 -8
- package/dist/internal/utils/calculate/calculate-content-encryption-key-size.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-key-wrap-encryption.d.ts +1 -1
- package/dist/internal/utils/calculate/calculate-key-wrap-encryption.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-key-wrap-encryption.js +3 -7
- package/dist/internal/utils/calculate/calculate-key-wrap-encryption.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-key-wrap-size.d.ts +2 -2
- package/dist/internal/utils/calculate/calculate-key-wrap-size.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-key-wrap-size.js +3 -7
- package/dist/internal/utils/calculate/calculate-key-wrap-size.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-pbkdf-hash.d.ts +2 -2
- package/dist/internal/utils/calculate/calculate-pbkdf-hash.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-pbkdf-hash.js +3 -7
- package/dist/internal/utils/calculate/calculate-pbkdf-hash.js.map +1 -1
- package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.d.ts +2 -2
- package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.d.ts.map +1 -1
- package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.js +3 -7
- package/dist/internal/utils/calculate/calculate-rsa-oaep-hash.js.map +1 -1
- package/dist/internal/utils/content.d.ts +1 -1
- package/dist/internal/utils/content.d.ts.map +1 -1
- package/dist/internal/utils/content.js +11 -17
- package/dist/internal/utils/content.js.map +1 -1
- package/dist/internal/utils/data/auth-tag-hmac.d.ts +1 -1
- package/dist/internal/utils/data/auth-tag-hmac.d.ts.map +1 -1
- package/dist/internal/utils/data/auth-tag-hmac.js +9 -14
- package/dist/internal/utils/data/auth-tag-hmac.js.map +1 -1
- package/dist/internal/utils/data/auth-tag.d.ts +1 -1
- package/dist/internal/utils/data/auth-tag.d.ts.map +1 -1
- package/dist/internal/utils/data/auth-tag.js +9 -14
- package/dist/internal/utils/data/auth-tag.js.map +1 -1
- package/dist/internal/utils/data/get-initialisation-vector.d.ts +1 -1
- package/dist/internal/utils/data/get-initialisation-vector.d.ts.map +1 -1
- package/dist/internal/utils/data/get-initialisation-vector.js +6 -10
- package/dist/internal/utils/data/get-initialisation-vector.js.map +1 -1
- package/dist/internal/utils/data/split-content-encryption-key.d.ts +1 -1
- package/dist/internal/utils/data/split-content-encryption-key.d.ts.map +1 -1
- package/dist/internal/utils/data/split-content-encryption-key.js +4 -8
- package/dist/internal/utils/data/split-content-encryption-key.js.map +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.d.ts +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.d.ts.map +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.js +20 -25
- package/dist/internal/utils/diffie-hellman/diffie-hellman-key-wrap.js.map +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman.d.ts +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman.d.ts.map +1 -1
- package/dist/internal/utils/diffie-hellman/diffie-hellman.js +16 -21
- package/dist/internal/utils/diffie-hellman/diffie-hellman.js.map +1 -1
- package/dist/internal/utils/diffie-hellman/shared-secret.d.ts +3 -3
- package/dist/internal/utils/diffie-hellman/shared-secret.d.ts.map +1 -1
- package/dist/internal/utils/diffie-hellman/shared-secret.js +22 -27
- package/dist/internal/utils/diffie-hellman/shared-secret.js.map +1 -1
- package/dist/internal/utils/encoded-aes.d.ts +2 -2
- package/dist/internal/utils/encoded-aes.d.ts.map +1 -1
- package/dist/internal/utils/encoded-aes.js +18 -23
- package/dist/internal/utils/encoded-aes.js.map +1 -1
- package/dist/internal/utils/encrypt-content.d.ts +1 -1
- package/dist/internal/utils/encrypt-content.d.ts.map +1 -1
- package/dist/internal/utils/encrypt-content.js +14 -18
- package/dist/internal/utils/encrypt-content.js.map +1 -1
- package/dist/internal/utils/encrypt-encoded.d.ts +2 -2
- package/dist/internal/utils/encrypt-encoded.d.ts.map +1 -1
- package/dist/internal/utils/encrypt-encoded.js +15 -19
- package/dist/internal/utils/encrypt-encoded.js.map +1 -1
- package/dist/internal/utils/encrypt-serialised.d.ts +3 -3
- package/dist/internal/utils/encrypt-serialised.d.ts.map +1 -1
- package/dist/internal/utils/encrypt-serialised.js +20 -24
- package/dist/internal/utils/encrypt-serialised.js.map +1 -1
- package/dist/internal/utils/encrypt-tokenised.d.ts +2 -2
- package/dist/internal/utils/encrypt-tokenised.d.ts.map +1 -1
- package/dist/internal/utils/encrypt-tokenised.js +18 -22
- package/dist/internal/utils/encrypt-tokenised.js.map +1 -1
- package/dist/internal/utils/encryption.d.ts +3 -3
- package/dist/internal/utils/encryption.d.ts.map +1 -1
- package/dist/internal/utils/encryption.js +22 -27
- package/dist/internal/utils/encryption.js.map +1 -1
- package/dist/internal/utils/get-key/get-decryption-key.d.ts +1 -1
- package/dist/internal/utils/get-key/get-decryption-key.d.ts.map +1 -1
- package/dist/internal/utils/get-key/get-decryption-key.js +11 -15
- package/dist/internal/utils/get-key/get-decryption-key.js.map +1 -1
- package/dist/internal/utils/get-key/get-encryption-key.d.ts +1 -1
- package/dist/internal/utils/get-key/get-encryption-key.d.ts.map +1 -1
- package/dist/internal/utils/get-key/get-encryption-key.js +11 -15
- package/dist/internal/utils/get-key/get-encryption-key.js.map +1 -1
- package/dist/internal/utils/key-derivation/concat-kdf.d.ts +1 -1
- package/dist/internal/utils/key-derivation/concat-kdf.d.ts.map +1 -1
- package/dist/internal/utils/key-derivation/concat-kdf.js +3 -7
- package/dist/internal/utils/key-derivation/concat-kdf.js.map +1 -1
- package/dist/internal/utils/key-derivation/pbkdf.d.ts +1 -1
- package/dist/internal/utils/key-derivation/pbkdf.d.ts.map +1 -1
- package/dist/internal/utils/key-derivation/pbkdf.js +7 -11
- package/dist/internal/utils/key-derivation/pbkdf.js.map +1 -1
- package/dist/internal/utils/key-types/get-ec-keys.d.ts +1 -1
- package/dist/internal/utils/key-types/get-ec-keys.d.ts.map +1 -1
- package/dist/internal/utils/key-types/get-ec-keys.js +11 -16
- package/dist/internal/utils/key-types/get-ec-keys.js.map +1 -1
- package/dist/internal/utils/key-types/get-oct-keys.d.ts +1 -1
- package/dist/internal/utils/key-types/get-oct-keys.d.ts.map +1 -1
- package/dist/internal/utils/key-types/get-oct-keys.js +14 -19
- package/dist/internal/utils/key-types/get-oct-keys.js.map +1 -1
- package/dist/internal/utils/key-types/get-okp-keys.d.ts +1 -1
- package/dist/internal/utils/key-types/get-okp-keys.d.ts.map +1 -1
- package/dist/internal/utils/key-types/get-okp-keys.js +11 -16
- package/dist/internal/utils/key-types/get-okp-keys.js.map +1 -1
- package/dist/internal/utils/key-types/get-rsa-keys.d.ts +1 -1
- package/dist/internal/utils/key-types/get-rsa-keys.d.ts.map +1 -1
- package/dist/internal/utils/key-types/get-rsa-keys.js +24 -29
- package/dist/internal/utils/key-types/get-rsa-keys.js.map +1 -1
- package/dist/internal/utils/key-wrap/ecb-key-wrap.d.ts +1 -1
- package/dist/internal/utils/key-wrap/ecb-key-wrap.d.ts.map +1 -1
- package/dist/internal/utils/key-wrap/ecb-key-wrap.js +12 -17
- package/dist/internal/utils/key-wrap/ecb-key-wrap.js.map +1 -1
- package/dist/internal/utils/key-wrap/gcm-key-wrap.d.ts +1 -1
- package/dist/internal/utils/key-wrap/gcm-key-wrap.d.ts.map +1 -1
- package/dist/internal/utils/key-wrap/gcm-key-wrap.js +14 -19
- package/dist/internal/utils/key-wrap/gcm-key-wrap.js.map +1 -1
- package/dist/internal/utils/key-wrap/key-wrap.d.ts +1 -1
- package/dist/internal/utils/key-wrap/key-wrap.d.ts.map +1 -1
- package/dist/internal/utils/key-wrap/key-wrap.js +11 -16
- package/dist/internal/utils/key-wrap/key-wrap.js.map +1 -1
- package/dist/internal/utils/oct/get-oct-dir-keys.d.ts +1 -1
- package/dist/internal/utils/oct/get-oct-dir-keys.d.ts.map +1 -1
- package/dist/internal/utils/oct/get-oct-dir-keys.js +13 -18
- package/dist/internal/utils/oct/get-oct-dir-keys.js.map +1 -1
- package/dist/internal/utils/oct/get-oct-key-key-wrap.d.ts +1 -1
- package/dist/internal/utils/oct/get-oct-key-key-wrap.d.ts.map +1 -1
- package/dist/internal/utils/oct/get-oct-key-key-wrap.js +19 -24
- package/dist/internal/utils/oct/get-oct-key-key-wrap.js.map +1 -1
- package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.d.ts +1 -1
- package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.d.ts.map +1 -1
- package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.js +25 -30
- package/dist/internal/utils/oct/get-oct-pbkdf-key-wrap-keys.js.map +1 -1
- package/dist/internal/utils/prepare-encryption.d.ts +1 -1
- package/dist/internal/utils/prepare-encryption.d.ts.map +1 -1
- package/dist/internal/utils/prepare-encryption.js +5 -9
- package/dist/internal/utils/prepare-encryption.js.map +1 -1
- package/dist/internal/utils/serialised-aes.d.ts +2 -2
- package/dist/internal/utils/serialised-aes.d.ts.map +1 -1
- package/dist/internal/utils/serialised-aes.js +19 -24
- package/dist/internal/utils/serialised-aes.js.map +1 -1
- package/dist/internal/utils/tokenised-aes.d.ts +2 -2
- package/dist/internal/utils/tokenised-aes.d.ts.map +1 -1
- package/dist/internal/utils/tokenised-aes.js +22 -27
- package/dist/internal/utils/tokenised-aes.js.map +1 -1
- package/dist/internal/utils/validate-version.js +8 -12
- package/dist/internal/utils/validate-version.js.map +1 -1
- package/dist/mocks/create-mock-aes-kit.d.ts +4 -0
- package/dist/mocks/create-mock-aes-kit.d.ts.map +1 -0
- package/dist/mocks/create-mock-aes-kit.js +81 -0
- package/dist/mocks/create-mock-aes-kit.js.map +1 -0
- package/dist/mocks/jest.d.ts +5 -0
- package/dist/mocks/jest.d.ts.map +1 -0
- package/dist/mocks/jest.js +4 -0
- package/dist/mocks/jest.js.map +1 -0
- package/dist/mocks/vitest.d.ts +6 -0
- package/dist/mocks/vitest.d.ts.map +1 -0
- package/dist/mocks/vitest.js +5 -0
- package/dist/mocks/vitest.js.map +1 -0
- package/dist/types/aes-decryption-data.d.ts +3 -3
- package/dist/types/aes-decryption-data.d.ts.map +1 -1
- package/dist/types/aes-decryption-data.js +1 -2
- package/dist/types/aes-encryption-data.d.ts +3 -3
- package/dist/types/aes-encryption-data.d.ts.map +1 -1
- package/dist/types/aes-encryption-data.js +1 -2
- package/dist/types/aes-kit.d.ts +1 -1
- package/dist/types/aes-kit.d.ts.map +1 -1
- package/dist/types/aes-kit.js +1 -2
- package/dist/types/content.d.ts +1 -1
- package/dist/types/content.d.ts.map +1 -1
- package/dist/types/content.js +1 -2
- package/dist/types/curve.js +1 -2
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -22
- package/dist/types/index.js.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +1 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -18
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-aes.d.ts +1 -1
- package/dist/utils/is-aes.d.ts.map +1 -1
- package/dist/utils/is-aes.js +4 -10
- package/dist/utils/is-aes.js.map +1 -1
- package/dist/utils/parse-aes.d.ts +1 -1
- package/dist/utils/parse-aes.d.ts.map +1 -1
- package/dist/utils/parse-aes.js +15 -19
- package/dist/utils/parse-aes.js.map +1 -1
- package/package.json +22 -23
- package/CHANGELOG.md +0 -165
- package/MERMAID.md +0 -155
- package/__tests__/INTEROP-RESULTS.md +0 -66
- package/__tests__/esm-smoke.test.ts +0 -15
- package/__tests__/fixtures/keys.ts +0 -60
- package/__tests__/helpers/buffer-utils.ts +0 -11
- package/__tests__/helpers/index.ts +0 -2
- package/__tests__/helpers/jwe-adapter.ts +0 -123
- package/__tests__/jose-jwe.test.ts +0 -463
- package/__tests__/noble-ciphers.test.ts +0 -208
- package/dist/mocks/index.d.ts +0 -2
- package/dist/mocks/index.d.ts.map +0 -1
- package/dist/mocks/index.js +0 -6
- package/dist/mocks/index.js.map +0 -1
- package/dist/mocks/mock-aes-kit.d.ts +0 -4
- package/dist/mocks/mock-aes-kit.d.ts.map +0 -1
- package/dist/mocks/mock-aes-kit.js +0 -74
- package/dist/mocks/mock-aes-kit.js.map +0 -1
- package/jest.config.interop.mjs +0 -24
- package/tsconfig.interop.json +0 -9
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const version_1 = require("../constants/version");
|
|
6
|
-
const AesError_1 = require("../../errors/AesError");
|
|
7
|
-
const validate_version_1 = require("./validate-version");
|
|
1
|
+
import { B64 } from "@lindorm/b64";
|
|
2
|
+
import { AES_FORMAT_VERSION } from "../constants/version.js";
|
|
3
|
+
import { AesError } from "../../errors/AesError.js";
|
|
4
|
+
import { validateAesVersion } from "./validate-version.js";
|
|
8
5
|
const sortKeys = (obj) => {
|
|
9
6
|
const sorted = {};
|
|
10
7
|
for (const key of Object.keys(obj).sort()) {
|
|
@@ -14,62 +11,57 @@ const sortKeys = (obj) => {
|
|
|
14
11
|
}
|
|
15
12
|
return sorted;
|
|
16
13
|
};
|
|
17
|
-
const buildAesHeader = (options) => sortKeys({
|
|
14
|
+
export const buildAesHeader = (options) => sortKeys({
|
|
18
15
|
alg: options.algorithm,
|
|
19
16
|
cty: options.contentType,
|
|
20
17
|
enc: options.encryption,
|
|
21
18
|
epk: options.publicEncryptionJwk,
|
|
22
19
|
iv: options.publicEncryptionIv
|
|
23
|
-
?
|
|
20
|
+
? B64.encode(options.publicEncryptionIv, "b64u")
|
|
24
21
|
: undefined,
|
|
25
22
|
kid: options.keyId,
|
|
26
23
|
p2c: options.pbkdfIterations,
|
|
27
|
-
p2s: options.pbkdfSalt ?
|
|
24
|
+
p2s: options.pbkdfSalt ? B64.encode(options.pbkdfSalt, "b64u") : undefined,
|
|
28
25
|
tag: options.publicEncryptionTag
|
|
29
|
-
?
|
|
26
|
+
? B64.encode(options.publicEncryptionTag, "b64u")
|
|
30
27
|
: undefined,
|
|
31
|
-
v:
|
|
28
|
+
v: AES_FORMAT_VERSION,
|
|
32
29
|
});
|
|
33
|
-
|
|
34
|
-
const encodeAesHeader = (header) => {
|
|
30
|
+
export const encodeAesHeader = (header) => {
|
|
35
31
|
const json = JSON.stringify(header);
|
|
36
|
-
return
|
|
32
|
+
return B64.encode(Buffer.from(json, "utf8"), "b64u");
|
|
37
33
|
};
|
|
38
|
-
|
|
39
|
-
const decodeAesHeader = (headerB64) => {
|
|
34
|
+
export const decodeAesHeader = (headerB64) => {
|
|
40
35
|
try {
|
|
41
|
-
const json =
|
|
36
|
+
const json = B64.toBuffer(headerB64, "b64u").toString("utf8");
|
|
42
37
|
const parsed = JSON.parse(json);
|
|
43
38
|
if (!parsed.alg || !parsed.enc || !parsed.v) {
|
|
44
|
-
throw new
|
|
39
|
+
throw new AesError("Invalid AES header: missing required fields", {
|
|
45
40
|
debug: { parsed },
|
|
46
41
|
});
|
|
47
42
|
}
|
|
48
|
-
|
|
43
|
+
validateAesVersion(parsed.v);
|
|
49
44
|
return parsed;
|
|
50
45
|
}
|
|
51
46
|
catch (error) {
|
|
52
|
-
if (error instanceof
|
|
47
|
+
if (error instanceof AesError)
|
|
53
48
|
throw error;
|
|
54
|
-
throw new
|
|
49
|
+
throw new AesError("Failed to decode AES header", {
|
|
55
50
|
error: error,
|
|
56
51
|
});
|
|
57
52
|
}
|
|
58
53
|
};
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
exports.computeAad = computeAad;
|
|
62
|
-
const headerToDecryptionParams = (header) => ({
|
|
54
|
+
export const computeAad = (headerB64) => Buffer.from(headerB64, "ascii");
|
|
55
|
+
export const headerToDecryptionParams = (header) => ({
|
|
63
56
|
algorithm: header.alg,
|
|
64
57
|
contentType: header.cty,
|
|
65
58
|
encryption: header.enc,
|
|
66
59
|
keyId: header.kid,
|
|
67
60
|
pbkdfIterations: header.p2c,
|
|
68
|
-
pbkdfSalt: header.p2s ?
|
|
69
|
-
publicEncryptionIv: header.iv ?
|
|
61
|
+
pbkdfSalt: header.p2s ? B64.toBuffer(header.p2s, "b64u") : undefined,
|
|
62
|
+
publicEncryptionIv: header.iv ? B64.toBuffer(header.iv, "b64u") : undefined,
|
|
70
63
|
publicEncryptionJwk: header.epk,
|
|
71
|
-
publicEncryptionTag: header.tag ?
|
|
64
|
+
publicEncryptionTag: header.tag ? B64.toBuffer(header.tag, "b64u") : undefined,
|
|
72
65
|
version: header.v,
|
|
73
66
|
});
|
|
74
|
-
exports.headerToDecryptionParams = headerToDecryptionParams;
|
|
75
67
|
//# sourceMappingURL=aes-header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aes-header.js","sourceRoot":"","sources":["../../../src/internal/utils/aes-header.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aes-header.js","sourceRoot":"","sources":["../../../src/internal/utils/aes-header.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KryptosEncryption } from "@lindorm/kryptos";
|
|
2
|
-
import { AesInternalEncryption } from "../../../types";
|
|
1
|
+
import type { KryptosEncryption } from "@lindorm/kryptos";
|
|
2
|
+
import type { AesInternalEncryption } from "../../../types/index.js";
|
|
3
3
|
export declare const calculateAesEncryption: (encryption: KryptosEncryption) => AesInternalEncryption;
|
|
4
4
|
//# sourceMappingURL=calculate-aes-encryption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-aes-encryption.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-aes-encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-aes-encryption.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-aes-encryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,eAAO,MAAM,sBAAsB,GACjC,YAAY,iBAAiB,KAC5B,qBA2BF,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateAesEncryption = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculateAesEncryption = (encryption) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculateAesEncryption = (encryption) => {
|
|
6
3
|
if (!encryption) {
|
|
7
|
-
throw new
|
|
4
|
+
throw new AesError("Encryption algorithm is required");
|
|
8
5
|
}
|
|
9
6
|
switch (encryption) {
|
|
10
7
|
case "A128CBC-HS256":
|
|
@@ -20,8 +17,7 @@ const calculateAesEncryption = (encryption) => {
|
|
|
20
17
|
case "A256GCM":
|
|
21
18
|
return "aes-256-gcm";
|
|
22
19
|
default:
|
|
23
|
-
throw new
|
|
20
|
+
throw new AesError("Unsupported encryption algorithm");
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
exports.calculateAesEncryption = calculateAesEncryption;
|
|
27
23
|
//# sourceMappingURL=calculate-aes-encryption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-aes-encryption.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-aes-encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-aes-encryption.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-aes-encryption.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,UAA6B,EACN,EAAE;IACzB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IACzD,CAAC;IAED,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,eAAe;YAClB,OAAO,aAAa,CAAC;QAEvB,KAAK,eAAe;YAClB,OAAO,aAAa,CAAC;QAEvB,KAAK,eAAe;YAClB,OAAO,aAAa,CAAC;QAEvB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QAEvB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QAEvB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QAEvB;YACE,MAAM,IAAI,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KryptosEncryption } from "@lindorm/kryptos";
|
|
2
|
-
import { AesKeyLength } from "@lindorm/types";
|
|
1
|
+
import type { KryptosEncryption } from "@lindorm/kryptos";
|
|
2
|
+
import type { AesKeyLength } from "@lindorm/types";
|
|
3
3
|
export declare const calculateContentEncryptionKeySize: (encryption: KryptosEncryption) => AesKeyLength;
|
|
4
4
|
//# sourceMappingURL=calculate-content-encryption-key-size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-content-encryption-key-size.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-content-encryption-key-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-content-encryption-key-size.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-content-encryption-key-size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,iCAAiC,GAC5C,YAAY,iBAAiB,KAC5B,YA2BF,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateContentEncryptionKeySize = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculateContentEncryptionKeySize = (encryption) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculateContentEncryptionKeySize = (encryption) => {
|
|
6
3
|
if (!encryption) {
|
|
7
|
-
throw new
|
|
4
|
+
throw new AesError("Encryption algorithm is required");
|
|
8
5
|
}
|
|
9
6
|
switch (encryption) {
|
|
10
7
|
case "A128GCM":
|
|
@@ -20,8 +17,7 @@ const calculateContentEncryptionKeySize = (encryption) => {
|
|
|
20
17
|
case "A256CBC-HS512":
|
|
21
18
|
return 64;
|
|
22
19
|
default:
|
|
23
|
-
throw new
|
|
20
|
+
throw new AesError("Unsupported encryption", { debug: { encryption } });
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
exports.calculateContentEncryptionKeySize = calculateContentEncryptionKeySize;
|
|
27
23
|
//# sourceMappingURL=calculate-content-encryption-key-size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-content-encryption-key-size.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-content-encryption-key-size.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-content-encryption-key-size.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-content-encryption-key-size.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,UAA6B,EACf,EAAE;IAChB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IACzD,CAAC;IAED,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QAEZ,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QAEZ,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QAEZ,KAAK,eAAe;YAClB,OAAO,EAAE,CAAC;QAEZ,KAAK,eAAe;YAClB,OAAO,EAAE,CAAC;QAEZ,KAAK,eAAe;YAClB,OAAO,EAAE,CAAC;QAEZ;YACE,MAAM,IAAI,QAAQ,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IKryptos } from "@lindorm/kryptos";
|
|
1
|
+
import type { IKryptos } from "@lindorm/kryptos";
|
|
2
2
|
type KeywrapEncryption = "aes-128-ecb" | "aes-192-ecb" | "aes-256-ecb" | "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
|
|
3
3
|
export declare const calculateKeyWrapEncryption: (kryptos: IKryptos) => KeywrapEncryption;
|
|
4
4
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-key-wrap-encryption.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-key-wrap-encryption.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-encryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,KAAK,iBAAiB,GAClB,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa,CAAC;AAElB,eAAO,MAAM,0BAA0B,GAAI,SAAS,QAAQ,KAAG,iBAgC9D,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateKeyWrapEncryption = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculateKeyWrapEncryption = (kryptos) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculateKeyWrapEncryption = (kryptos) => {
|
|
6
3
|
switch (kryptos.algorithm) {
|
|
7
4
|
case "A128KW":
|
|
8
5
|
case "ECDH-ES+A128KW":
|
|
@@ -26,8 +23,7 @@ const calculateKeyWrapEncryption = (kryptos) => {
|
|
|
26
23
|
case "ECDH-ES+A256GCMKW":
|
|
27
24
|
return "aes-256-gcm";
|
|
28
25
|
default:
|
|
29
|
-
throw new
|
|
26
|
+
throw new AesError("Unsupported keywrap encryption");
|
|
30
27
|
}
|
|
31
28
|
};
|
|
32
|
-
exports.calculateKeyWrapEncryption = calculateKeyWrapEncryption;
|
|
33
29
|
//# sourceMappingURL=calculate-key-wrap-encryption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-key-wrap-encryption.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-encryption.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-key-wrap-encryption.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-encryption.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAUpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,OAAiB,EAAqB,EAAE;IACjF,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,QAAQ,CAAC;QACd,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB;YACvB,OAAO,aAAa,CAAC;QAEvB,KAAK,QAAQ,CAAC;QACd,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB;YACvB,OAAO,aAAa,CAAC;QAEvB,KAAK,QAAQ,CAAC;QACd,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB;YACvB,OAAO,aAAa,CAAC;QAEvB,KAAK,WAAW,CAAC;QACjB,KAAK,mBAAmB;YACtB,OAAO,aAAa,CAAC;QAEvB,KAAK,WAAW,CAAC;QACjB,KAAK,mBAAmB;YACtB,OAAO,aAAa,CAAC;QAEvB,KAAK,WAAW,CAAC;QACjB,KAAK,mBAAmB;YACtB,OAAO,aAAa,CAAC;QAEvB;YACE,MAAM,IAAI,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KryptosAlgorithm } from "@lindorm/kryptos";
|
|
2
|
-
import { AesKeyLength } from "@lindorm/types";
|
|
1
|
+
import type { KryptosAlgorithm } from "@lindorm/kryptos";
|
|
2
|
+
import type { AesKeyLength } from "@lindorm/types";
|
|
3
3
|
export declare const calculateKeyWrapSize: (algorithm: KryptosAlgorithm) => AesKeyLength;
|
|
4
4
|
//# sourceMappingURL=calculate-key-wrap-size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-key-wrap-size.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-key-wrap-size.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,oBAAoB,GAAI,WAAW,gBAAgB,KAAG,YA0BlE,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateKeyWrapSize = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculateKeyWrapSize = (algorithm) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculateKeyWrapSize = (algorithm) => {
|
|
6
3
|
switch (algorithm) {
|
|
7
4
|
case "A128KW":
|
|
8
5
|
case "A128GCMKW":
|
|
@@ -23,8 +20,7 @@ const calculateKeyWrapSize = (algorithm) => {
|
|
|
23
20
|
case "PBES2-HS512+A256KW":
|
|
24
21
|
return 32;
|
|
25
22
|
default:
|
|
26
|
-
throw new
|
|
23
|
+
throw new AesError("Unsupported algorithm", { debug: { algorithm } });
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
exports.calculateKeyWrapSize = calculateKeyWrapSize;
|
|
30
26
|
//# sourceMappingURL=calculate-key-wrap-size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-key-wrap-size.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-size.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-key-wrap-size.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-key-wrap-size.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAA2B,EAAgB,EAAE;IAChF,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,gBAAgB,CAAC;QACtB,KAAK,mBAAmB,CAAC;QACzB,KAAK,oBAAoB;YACvB,OAAO,EAAE,CAAC;QAEZ,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,gBAAgB,CAAC;QACtB,KAAK,mBAAmB,CAAC;QACzB,KAAK,oBAAoB;YACvB,OAAO,EAAE,CAAC;QAEZ,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW,CAAC;QACjB,KAAK,gBAAgB,CAAC;QACtB,KAAK,mBAAmB,CAAC;QACzB,KAAK,oBAAoB;YACvB,OAAO,EAAE,CAAC;QAEZ;YACE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IKryptos } from "@lindorm/kryptos";
|
|
2
|
-
import { ShaAlgorithm } from "@lindorm/types";
|
|
1
|
+
import type { IKryptos } from "@lindorm/kryptos";
|
|
2
|
+
import type { ShaAlgorithm } from "@lindorm/types";
|
|
3
3
|
export declare const calculatePbkdfAlgorithm: (kryptos: IKryptos) => ShaAlgorithm;
|
|
4
4
|
//# sourceMappingURL=calculate-pbkdf-hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-pbkdf-hash.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-pbkdf-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-pbkdf-hash.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-pbkdf-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,uBAAuB,GAAI,SAAS,QAAQ,KAAG,YAc3D,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculatePbkdfAlgorithm = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculatePbkdfAlgorithm = (kryptos) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculatePbkdfAlgorithm = (kryptos) => {
|
|
6
3
|
switch (kryptos.algorithm) {
|
|
7
4
|
case "PBES2-HS256+A128KW":
|
|
8
5
|
return "SHA256";
|
|
@@ -11,8 +8,7 @@ const calculatePbkdfAlgorithm = (kryptos) => {
|
|
|
11
8
|
case "PBES2-HS512+A256KW":
|
|
12
9
|
return "SHA512";
|
|
13
10
|
default:
|
|
14
|
-
throw new
|
|
11
|
+
throw new AesError("Unsupported PBKDF2 algorithm");
|
|
15
12
|
}
|
|
16
13
|
};
|
|
17
|
-
exports.calculatePbkdfAlgorithm = calculatePbkdfAlgorithm;
|
|
18
14
|
//# sourceMappingURL=calculate-pbkdf-hash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-pbkdf-hash.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-pbkdf-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-pbkdf-hash.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-pbkdf-hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAiB,EAAgB,EAAE;IACzE,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,oBAAoB;YACvB,OAAO,QAAQ,CAAC;QAElB,KAAK,oBAAoB;YACvB,OAAO,QAAQ,CAAC;QAElB,KAAK,oBAAoB;YACvB,OAAO,QAAQ,CAAC;QAElB;YACE,MAAM,IAAI,QAAQ,CAAC,8BAA8B,CAAC,CAAC;IACvD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KryptosAlgorithm } from "@lindorm/kryptos";
|
|
2
|
-
import { ShaAlgorithm } from "@lindorm/types";
|
|
1
|
+
import type { KryptosAlgorithm } from "@lindorm/kryptos";
|
|
2
|
+
import type { ShaAlgorithm } from "@lindorm/types";
|
|
3
3
|
export declare const calculateRsaOaepHash: (algorithm: KryptosAlgorithm) => ShaAlgorithm;
|
|
4
4
|
//# sourceMappingURL=calculate-rsa-oaep-hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-rsa-oaep-hash.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-rsa-oaep-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"calculate-rsa-oaep-hash.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-rsa-oaep-hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,oBAAoB,GAAI,WAAW,gBAAgB,KAAG,YAmBlE,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateRsaOaepHash = void 0;
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const calculateRsaOaepHash = (algorithm) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
export const calculateRsaOaepHash = (algorithm) => {
|
|
6
3
|
switch (algorithm) {
|
|
7
4
|
case "RSA-OAEP":
|
|
8
5
|
return "SHA1";
|
|
@@ -13,10 +10,9 @@ const calculateRsaOaepHash = (algorithm) => {
|
|
|
13
10
|
case "RSA-OAEP-512":
|
|
14
11
|
return "SHA512";
|
|
15
12
|
default:
|
|
16
|
-
throw new
|
|
13
|
+
throw new AesError("Unexpected encryption key algorithm", {
|
|
17
14
|
debug: { algorithm },
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
};
|
|
21
|
-
exports.calculateRsaOaepHash = calculateRsaOaepHash;
|
|
22
18
|
//# sourceMappingURL=calculate-rsa-oaep-hash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate-rsa-oaep-hash.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-rsa-oaep-hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculate-rsa-oaep-hash.js","sourceRoot":"","sources":["../../../../src/internal/utils/calculate/calculate-rsa-oaep-hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAA2B,EAAgB,EAAE;IAChF,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QAEhB,KAAK,cAAc;YACjB,OAAO,QAAQ,CAAC;QAElB,KAAK,cAAc;YACjB,OAAO,QAAQ,CAAC;QAElB,KAAK,cAAc;YACjB,OAAO,QAAQ,CAAC;QAElB;YACE,MAAM,IAAI,QAAQ,CAAC,qCAAqC,EAAE;gBACxD,KAAK,EAAE,EAAE,SAAS,EAAE;aACrB,CAAC,CAAC;IACP,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AesContent, AesContentType } from "../../types/content";
|
|
1
|
+
import type { AesContent, AesContentType } from "../../types/content.js";
|
|
2
2
|
export declare const calculateContentType: (content: any) => AesContentType;
|
|
3
3
|
export declare const contentToBuffer: (content: any, contentType: AesContentType) => Buffer;
|
|
4
4
|
export declare const parseContent: <T extends AesContent = string>(content: Buffer, contentType?: AesContentType) => T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/content.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/content.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEzE,eAAO,MAAM,oBAAoB,GAAI,SAAS,GAAG,KAAG,cAgBnD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,GAAG,EAAE,aAAa,cAAc,KAAG,MAgB3E,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,UAAU,GAAG,MAAM,EACxD,SAAS,MAAM,EACf,cAAa,cAA6B,KACzC,CAgBF,CAAC"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const AesError_1 = require("../../errors/AesError");
|
|
6
|
-
const calculateContentType = (content) => {
|
|
7
|
-
if ((0, is_1.isString)(content)) {
|
|
1
|
+
import { isArray, isBoolean, isBuffer, isNumber, isObject, isString } from "@lindorm/is";
|
|
2
|
+
import { AesError } from "../../errors/AesError.js";
|
|
3
|
+
export const calculateContentType = (content) => {
|
|
4
|
+
if (isString(content)) {
|
|
8
5
|
return "text/plain";
|
|
9
6
|
}
|
|
10
|
-
if (
|
|
7
|
+
if (isBuffer(content)) {
|
|
11
8
|
return "application/octet-stream";
|
|
12
9
|
}
|
|
13
|
-
if (
|
|
10
|
+
if (isArray(content) || isBoolean(content) || isNumber(content) || isObject(content)) {
|
|
14
11
|
return "application/json";
|
|
15
12
|
}
|
|
16
|
-
throw new
|
|
13
|
+
throw new AesError("Invalid content type", {
|
|
17
14
|
debug: { content, type: typeof content },
|
|
18
15
|
});
|
|
19
16
|
};
|
|
20
|
-
|
|
21
|
-
const contentToBuffer = (content, contentType) => {
|
|
17
|
+
export const contentToBuffer = (content, contentType) => {
|
|
22
18
|
switch (contentType) {
|
|
23
19
|
case "application/json":
|
|
24
20
|
return Buffer.from(JSON.stringify(content), "utf8");
|
|
@@ -27,13 +23,12 @@ const contentToBuffer = (content, contentType) => {
|
|
|
27
23
|
case "text/plain":
|
|
28
24
|
return Buffer.from(content, "utf8");
|
|
29
25
|
default:
|
|
30
|
-
throw new
|
|
26
|
+
throw new AesError("Invalid content type", {
|
|
31
27
|
debug: { content, type: typeof content },
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
30
|
};
|
|
35
|
-
|
|
36
|
-
const parseContent = (content, contentType = "text/plain") => {
|
|
31
|
+
export const parseContent = (content, contentType = "text/plain") => {
|
|
37
32
|
switch (contentType) {
|
|
38
33
|
case "application/json":
|
|
39
34
|
return JSON.parse(content.toString("utf8"));
|
|
@@ -42,10 +37,9 @@ const parseContent = (content, contentType = "text/plain") => {
|
|
|
42
37
|
case "text/plain":
|
|
43
38
|
return content.toString("utf8");
|
|
44
39
|
default:
|
|
45
|
-
throw new
|
|
40
|
+
throw new AesError("Unexpected content type", {
|
|
46
41
|
debug: { contentType },
|
|
47
42
|
});
|
|
48
43
|
}
|
|
49
44
|
};
|
|
50
|
-
exports.parseContent = parseContent;
|
|
51
45
|
//# sourceMappingURL=content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/internal/utils/content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/internal/utils/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAY,EAAkB,EAAE;IACnE,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtB,OAAO,0BAA0B,CAAC;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACrF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE;QACzC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,OAAO,EAAE;KACzC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAY,EAAE,WAA2B,EAAU,EAAE;IACnF,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;QAEtD,KAAK,0BAA0B;YAC7B,OAAO,OAAO,CAAC;QAEjB,KAAK,YAAY;YACf,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtC;YACE,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EAAE;gBACzC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,OAAO,EAAE;aACzC,CAAC,CAAC;IACP,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAe,EACf,cAA8B,YAAY,EACvC,EAAE;IACL,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,kBAAkB;YACrB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAM,CAAC;QAEnD,KAAK,0BAA0B;YAC7B,OAAO,OAAY,CAAC;QAEtB,KAAK,YAAY;YACf,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM,CAAC;QAEvC;YACE,MAAM,IAAI,QAAQ,CAAC,yBAAyB,EAAE;gBAC5C,KAAK,EAAE,EAAE,WAAW,EAAE;aACvB,CAAC,CAAC;IACP,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateHmacAuthTag, VerifyHmacAuthTag } from "../../types/auth-tag";
|
|
1
|
+
import type { CreateHmacAuthTag, VerifyHmacAuthTag } from "../../types/auth-tag.js";
|
|
2
2
|
export declare const createHmacAuthTag: ({ aad, content, hashKey, initialisationVector, encryption, }: CreateHmacAuthTag) => Buffer;
|
|
3
3
|
export declare const assertHmacAuthTag: ({ aad, authTag, content, encryption, hashKey, initialisationVector, }: VerifyHmacAuthTag) => void;
|
|
4
4
|
//# sourceMappingURL=auth-tag-hmac.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-tag-hmac.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag-hmac.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth-tag-hmac.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag-hmac.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,8DAM/B,iBAAiB,KAAG,MAiBtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,uEAO/B,iBAAiB,KAAG,IAYtB,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.assertHmacAuthTag = exports.createHmacAuthTag = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
const errors_1 = require("../../../errors");
|
|
1
|
+
import { createHmac, timingSafeEqual } from "crypto";
|
|
2
|
+
import { AesError } from "../../../errors/index.js";
|
|
6
3
|
const shaHash = (encryption) => {
|
|
7
4
|
switch (encryption) {
|
|
8
5
|
case "A128CBC-HS256":
|
|
@@ -12,11 +9,11 @@ const shaHash = (encryption) => {
|
|
|
12
9
|
case "A256CBC-HS512":
|
|
13
10
|
return "SHA512";
|
|
14
11
|
default:
|
|
15
|
-
throw new
|
|
12
|
+
throw new AesError("Unexpected algorithm");
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
|
-
const createHmacAuthTag = ({ aad, content, hashKey, initialisationVector, encryption, }) => {
|
|
19
|
-
const hmac =
|
|
15
|
+
export const createHmacAuthTag = ({ aad, content, hashKey, initialisationVector, encryption, }) => {
|
|
16
|
+
const hmac = createHmac(shaHash(encryption), hashKey);
|
|
20
17
|
if (aad) {
|
|
21
18
|
hmac.update(aad);
|
|
22
19
|
}
|
|
@@ -28,18 +25,16 @@ const createHmacAuthTag = ({ aad, content, hashKey, initialisationVector, encryp
|
|
|
28
25
|
const fullTag = hmac.digest();
|
|
29
26
|
return fullTag.subarray(0, fullTag.length / 2);
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const generated = (0, exports.createHmacAuthTag)({
|
|
28
|
+
export const assertHmacAuthTag = ({ aad, authTag, content, encryption, hashKey, initialisationVector, }) => {
|
|
29
|
+
const generated = createHmacAuthTag({
|
|
34
30
|
aad,
|
|
35
31
|
content,
|
|
36
32
|
encryption,
|
|
37
33
|
hashKey,
|
|
38
34
|
initialisationVector,
|
|
39
35
|
});
|
|
40
|
-
if (generated.length === authTag.length &&
|
|
36
|
+
if (generated.length === authTag.length && timingSafeEqual(generated, authTag))
|
|
41
37
|
return;
|
|
42
|
-
throw new
|
|
38
|
+
throw new AesError("Auth tag verification failed");
|
|
43
39
|
};
|
|
44
|
-
exports.assertHmacAuthTag = assertHmacAuthTag;
|
|
45
40
|
//# sourceMappingURL=auth-tag-hmac.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-tag-hmac.js","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag-hmac.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-tag-hmac.js","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag-hmac.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,MAAM,OAAO,GAAG,CAAC,UAA6B,EAAgB,EAAE;IAC9D,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAElB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAElB,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC;QAElB;YACE,MAAM,IAAI,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,GAAG,EACH,OAAO,EACP,OAAO,EACP,oBAAoB,EACpB,UAAU,GACQ,EAAU,EAAE;IAC9B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;IAKtD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,GAAG,EACH,OAAO,EACP,OAAO,EACP,UAAU,EACV,OAAO,EACP,oBAAoB,GACF,EAAQ,EAAE;IAC5B,MAAM,SAAS,GAAG,iBAAiB,CAAC;QAClC,GAAG;QACH,OAAO;QACP,UAAU;QACV,OAAO;QACP,oBAAoB;KACrB,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC;QAAE,OAAO;IAEvF,MAAM,IAAI,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AACrD,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetAuthTagOptions, SetAuthTagOptions } from "../../types/auth-tag";
|
|
1
|
+
import type { GetAuthTagOptions, SetAuthTagOptions } from "../../types/auth-tag.js";
|
|
2
2
|
export declare const createAuthTag: ({ aad, encryption, cipher, content, hashKey, initialisationVector, }: GetAuthTagOptions) => Buffer;
|
|
3
3
|
export declare const assertAuthTag: ({ aad, authTag, content, hashKey, decipher, encryption, initialisationVector, }: SetAuthTagOptions) => void;
|
|
4
4
|
//# sourceMappingURL=auth-tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-tag.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth-tag.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/data/auth-tag.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGpF,eAAO,MAAM,aAAa,GAAI,sEAO3B,iBAAiB,KAAG,MAqBtB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,iFAQ3B,iBAAiB,KAAG,IA4BtB,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const errors_1 = require("../../../errors");
|
|
5
|
-
const auth_tag_hmac_1 = require("./auth-tag-hmac");
|
|
6
|
-
const createAuthTag = ({ aad, encryption, cipher, content, hashKey, initialisationVector, }) => {
|
|
1
|
+
import { AesError } from "../../../errors/index.js";
|
|
2
|
+
import { assertHmacAuthTag, createHmacAuthTag } from "./auth-tag-hmac.js";
|
|
3
|
+
export const createAuthTag = ({ aad, encryption, cipher, content, hashKey, initialisationVector, }) => {
|
|
7
4
|
switch (encryption) {
|
|
8
5
|
case "A128CBC-HS256":
|
|
9
6
|
case "A192CBC-HS384":
|
|
10
7
|
case "A256CBC-HS512":
|
|
11
|
-
return
|
|
8
|
+
return createHmacAuthTag({
|
|
12
9
|
aad,
|
|
13
10
|
content,
|
|
14
11
|
encryption,
|
|
@@ -20,19 +17,18 @@ const createAuthTag = ({ aad, encryption, cipher, content, hashKey, initialisati
|
|
|
20
17
|
case "A256GCM":
|
|
21
18
|
return cipher.getAuthTag();
|
|
22
19
|
default:
|
|
23
|
-
throw new
|
|
20
|
+
throw new AesError("Unexpected algorithm");
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
const assertAuthTag = ({ aad, authTag, content, hashKey, decipher, encryption, initialisationVector, }) => {
|
|
23
|
+
export const assertAuthTag = ({ aad, authTag, content, hashKey, decipher, encryption, initialisationVector, }) => {
|
|
28
24
|
if (!authTag) {
|
|
29
|
-
throw new
|
|
25
|
+
throw new AesError("Auth tag is missing");
|
|
30
26
|
}
|
|
31
27
|
switch (encryption) {
|
|
32
28
|
case "A128CBC-HS256":
|
|
33
29
|
case "A192CBC-HS384":
|
|
34
30
|
case "A256CBC-HS512":
|
|
35
|
-
|
|
31
|
+
assertHmacAuthTag({
|
|
36
32
|
aad,
|
|
37
33
|
authTag,
|
|
38
34
|
content,
|
|
@@ -47,8 +43,7 @@ const assertAuthTag = ({ aad, authTag, content, hashKey, decipher, encryption, i
|
|
|
47
43
|
decipher.setAuthTag(authTag);
|
|
48
44
|
return;
|
|
49
45
|
default:
|
|
50
|
-
throw new
|
|
46
|
+
throw new AesError("Unexpected algorithm");
|
|
51
47
|
}
|
|
52
48
|
};
|
|
53
|
-
exports.assertAuthTag = assertAuthTag;
|
|
54
49
|
//# sourceMappingURL=auth-tag.js.map
|