@lindorm/aes 0.4.2 → 0.5.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.
Files changed (121) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +285 -0
  3. package/dist/classes/AesKit.d.ts +9 -6
  4. package/dist/classes/AesKit.d.ts.map +1 -1
  5. package/dist/classes/AesKit.js +16 -30
  6. package/dist/classes/AesKit.js.map +1 -1
  7. package/dist/constants/private/format.d.ts.map +1 -1
  8. package/dist/constants/private/version.d.ts +1 -1
  9. package/dist/constants/private/version.d.ts.map +1 -1
  10. package/dist/constants/private/version.js +1 -1
  11. package/dist/constants/private/version.js.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/interfaces/AesKit.d.ts +6 -6
  17. package/dist/interfaces/AesKit.d.ts.map +1 -1
  18. package/dist/types/{aes-data.d.ts → aes-decryption-data.d.ts} +12 -3
  19. package/dist/types/aes-decryption-data.d.ts.map +1 -0
  20. package/dist/types/aes-decryption-data.js +3 -0
  21. package/dist/types/aes-decryption-data.js.map +1 -0
  22. package/dist/types/aes-encryption-data.d.ts +3 -0
  23. package/dist/types/aes-encryption-data.d.ts.map +1 -1
  24. package/dist/types/content.d.ts +4 -0
  25. package/dist/types/content.d.ts.map +1 -0
  26. package/dist/types/{aes-data.js → content.js} +1 -1
  27. package/dist/types/content.js.map +1 -0
  28. package/dist/types/index.d.ts +2 -1
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/dist/types/index.js +2 -1
  31. package/dist/types/index.js.map +1 -1
  32. package/dist/types/private/aes-data.d.ts +1 -1
  33. package/dist/types/private/aes-data.d.ts.map +1 -1
  34. package/dist/types/private/aes-string.d.ts +2 -0
  35. package/dist/types/private/aes-string.d.ts.map +1 -1
  36. package/dist/types/types.d.ts +1 -1
  37. package/dist/types/types.d.ts.map +1 -1
  38. package/dist/utils/index.d.ts +3 -0
  39. package/dist/utils/index.d.ts.map +1 -0
  40. package/dist/utils/index.js +19 -0
  41. package/dist/utils/index.js.map +1 -0
  42. package/dist/utils/{private/is-aes.d.ts → is-aes.d.ts} +1 -1
  43. package/dist/utils/is-aes.d.ts.map +1 -0
  44. package/dist/utils/{private/is-aes.js → is-aes.js} +2 -1
  45. package/dist/utils/is-aes.js.map +1 -0
  46. package/dist/utils/parse-aes.d.ts +3 -0
  47. package/dist/utils/parse-aes.d.ts.map +1 -0
  48. package/dist/utils/parse-aes.js +24 -0
  49. package/dist/utils/parse-aes.js.map +1 -0
  50. package/dist/utils/private/calculate/calculate-aes-encryption.d.ts +2 -2
  51. package/dist/utils/private/calculate/calculate-aes-encryption.d.ts.map +1 -1
  52. package/dist/utils/private/calculate/calculate-aes-encryption.js +3 -0
  53. package/dist/utils/private/calculate/calculate-aes-encryption.js.map +1 -1
  54. package/dist/utils/private/calculate/calculate-content-encryption-key-size.d.ts.map +1 -1
  55. package/dist/utils/private/calculate/calculate-content-encryption-key-size.js +3 -0
  56. package/dist/utils/private/calculate/calculate-content-encryption-key-size.js.map +1 -1
  57. package/dist/utils/private/calculate/calculate-key-wrap-encryption.d.ts.map +1 -1
  58. package/dist/utils/private/calculate/calculate-key-wrap-size.d.ts.map +1 -1
  59. package/dist/utils/private/calculate/calculate-pbkdf-hash.d.ts.map +1 -1
  60. package/dist/utils/private/calculate/calculate-rsa-oaep-hash.d.ts.map +1 -1
  61. package/dist/utils/private/content.d.ts +5 -0
  62. package/dist/utils/private/content.d.ts.map +1 -0
  63. package/dist/utils/private/content.js +51 -0
  64. package/dist/utils/private/content.js.map +1 -0
  65. package/dist/utils/private/data/auth-tag-hmac.d.ts.map +1 -1
  66. package/dist/utils/private/data/auth-tag.d.ts.map +1 -1
  67. package/dist/utils/private/data/get-initialisation-vector.d.ts.map +1 -1
  68. package/dist/utils/private/data/split-content-encryption-key.d.ts.map +1 -1
  69. package/dist/utils/private/diffie-hellman/diffie-hellman-key-wrap.d.ts.map +1 -1
  70. package/dist/utils/private/diffie-hellman/diffie-hellman.d.ts.map +1 -1
  71. package/dist/utils/private/diffie-hellman/diffie-hellman.js +1 -1
  72. package/dist/utils/private/diffie-hellman/diffie-hellman.js.map +1 -1
  73. package/dist/utils/private/diffie-hellman/shared-secret.d.ts.map +1 -1
  74. package/dist/utils/private/diffie-hellman/shared-secret.js +19 -9
  75. package/dist/utils/private/diffie-hellman/shared-secret.js.map +1 -1
  76. package/dist/utils/private/encoded-aes.d.ts.map +1 -1
  77. package/dist/utils/private/encoded-aes.js +9 -5
  78. package/dist/utils/private/encoded-aes.js.map +1 -1
  79. package/dist/utils/private/encryption.d.ts +2 -2
  80. package/dist/utils/private/encryption.d.ts.map +1 -1
  81. package/dist/utils/private/encryption.js +7 -3
  82. package/dist/utils/private/encryption.js.map +1 -1
  83. package/dist/utils/private/get-key/get-decryption-key.d.ts.map +1 -1
  84. package/dist/utils/private/get-key/get-encryption-key.d.ts.map +1 -1
  85. package/dist/utils/private/index.d.ts +0 -1
  86. package/dist/utils/private/index.d.ts.map +1 -1
  87. package/dist/utils/private/index.js +0 -1
  88. package/dist/utils/private/index.js.map +1 -1
  89. package/dist/utils/private/key-derivation/hkdf.d.ts.map +1 -1
  90. package/dist/utils/private/key-derivation/pbkdf.d.ts.map +1 -1
  91. package/dist/utils/private/key-types/get-ec-keys.d.ts.map +1 -1
  92. package/dist/utils/private/key-types/get-oct-keys.d.ts.map +1 -1
  93. package/dist/utils/private/key-types/get-okp-keys.d.ts.map +1 -1
  94. package/dist/utils/private/key-types/get-rsa-keys.d.ts.map +1 -1
  95. package/dist/utils/private/key-types/get-rsa-keys.js +2 -2
  96. package/dist/utils/private/key-types/get-rsa-keys.js.map +1 -1
  97. package/dist/utils/private/key-wrap/ecb-key-wrap.d.ts.map +1 -1
  98. package/dist/utils/private/key-wrap/ecb-key-wrap.js.map +1 -1
  99. package/dist/utils/private/key-wrap/gcm-key-wrap.d.ts.map +1 -1
  100. package/dist/utils/private/key-wrap/key-wrap.d.ts.map +1 -1
  101. package/dist/utils/private/oct/get-oct-dir-keys.d.ts.map +1 -1
  102. package/dist/utils/private/oct/get-oct-dir-keys.js +2 -2
  103. package/dist/utils/private/oct/get-oct-dir-keys.js.map +1 -1
  104. package/dist/utils/private/oct/get-oct-key-key-wrap.d.ts.map +1 -1
  105. package/dist/utils/private/oct/get-oct-key-key-wrap.js +2 -2
  106. package/dist/utils/private/oct/get-oct-key-key-wrap.js.map +1 -1
  107. package/dist/utils/private/oct/get-oct-pbkdf-key-wrap-keys.d.ts.map +1 -1
  108. package/dist/utils/private/oct/get-oct-pbkdf-key-wrap-keys.js +2 -2
  109. package/dist/utils/private/oct/get-oct-pbkdf-key-wrap-keys.js.map +1 -1
  110. package/dist/utils/private/serialised-aes.d.ts.map +1 -1
  111. package/dist/utils/private/serialised-aes.js +5 -0
  112. package/dist/utils/private/serialised-aes.js.map +1 -1
  113. package/dist/utils/private/tokenised-aes.d.ts +1 -1
  114. package/dist/utils/private/tokenised-aes.d.ts.map +1 -1
  115. package/dist/utils/private/tokenised-aes.js +6 -4
  116. package/dist/utils/private/tokenised-aes.js.map +1 -1
  117. package/package.json +10 -8
  118. package/dist/types/aes-data.d.ts.map +0 -1
  119. package/dist/types/aes-data.js.map +0 -1
  120. package/dist/utils/private/is-aes.d.ts.map +0 -1
  121. package/dist/utils/private/is-aes.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.5.1](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.5.0...@lindorm/aes@0.5.1) (2025-07-02)
7
+
8
+ ### Bug Fixes
9
+
10
+ - amend bug in aes utility ([7437e8e](https://github.com/lindorm-io/monorepo/commit/7437e8e0f047bb0995b8a8c0e6929c9cc368d592))
11
+
12
+ # [0.5.0](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.4.2...@lindorm/aes@0.5.0) (2025-06-17)
13
+
14
+ ### Bug Fixes
15
+
16
+ - align with kryptos changes ([3f934a4](https://github.com/lindorm-io/monorepo/commit/3f934a4ec55eee3d4ebc6f0be55886d8f095af8b))
17
+ - align with kryptos changes ([206eb38](https://github.com/lindorm-io/monorepo/commit/206eb38ae2a03b14973e706035c87a953cc753af))
18
+ - improve and expose aes parsing ([ec6f271](https://github.com/lindorm-io/monorepo/commit/ec6f27179ec3d67146a50257cbff98fe253c3380))
19
+ - improve types ([f6ce002](https://github.com/lindorm-io/monorepo/commit/f6ce002e8555c54ba4f12bd67222457fa2bcf90a))
20
+ - update try catch ([7ebebe8](https://github.com/lindorm-io/monorepo/commit/7ebebe81f40851b0d1fcb05e6e6cc60b1c754a91))
21
+
22
+ ### Features
23
+
24
+ - add content type to aes data ([dfb3285](https://github.com/lindorm-io/monorepo/commit/dfb3285ddf20bc77cf8f3d2531e26032853b98a9))
25
+
6
26
  ## [0.4.2](https://github.com/lindorm-io/monorepo/compare/@lindorm/aes@0.4.1...@lindorm/aes@0.4.2) (2025-01-28)
7
27
 
8
28
  **Note:** Version bump only for package @lindorm/aes
package/README.md CHANGED
@@ -1 +1,286 @@
1
1
  # @lindorm/aes
2
+
3
+ A comprehensive TypeScript library for AES encryption and decryption with support for multiple key algorithms, encryption modes, and flexible output formats.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @lindorm/aes
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **Multiple Key Algorithms**: Support for EC, OKP, RSA, and symmetric keys
14
+ - **Key Derivation**: HKDF, PBKDF2, and direct key usage
15
+ - **Key Wrapping**: ECB and GCM key wrapping modes
16
+ - **Multiple Encryption Modes**: CBC-HMAC and GCM authenticated encryption
17
+ - **Flexible Output Formats**: Encoded strings, structured records, serialized objects, and tokenized strings
18
+ - **Type Safety**: Full TypeScript support with comprehensive type definitions
19
+ - **Content Type Detection**: Automatic detection and handling of different data types
20
+ - **Verification Methods**: Built-in verification and assertion utilities
21
+
22
+ ## Supported Algorithms
23
+
24
+ ### Key Algorithms
25
+ - **ECDH-ES**: Elliptic Curve Diffie-Hellman Ephemeral Static
26
+ - **ECDH-ES+A128KW**: ECDH-ES with AES-128 Key Wrap
27
+ - **ECDH-ES+A128GCMKW**: ECDH-ES with AES-128 GCM Key Wrap
28
+ - **A128KW**: AES-128 Key Wrap
29
+ - **A128GCMKW**: AES-128 GCM Key Wrap
30
+ - **PBES2-HS256+A128KW**: PBKDF2 with HMAC SHA-256 and AES-128 Key Wrap
31
+ - **RSA-OAEP-256**: RSA OAEP with SHA-256
32
+
33
+ ### Encryption Modes
34
+ - **A128CBC-HS256**: AES-128 CBC with HMAC SHA-256
35
+ - **A128GCM**: AES-128 GCM (default)
36
+ - **A192GCM**: AES-192 GCM
37
+ - **A256GCM**: AES-256 GCM
38
+
39
+ ## Basic Usage
40
+
41
+ ### Setup
42
+
43
+ ```typescript
44
+ import { AesKit } from '@lindorm/aes';
45
+ import { KryptosKit } from '@lindorm/kryptos';
46
+
47
+ // Generate or load a cryptographic key
48
+ const kryptos = KryptosKit.generate.auto({ algorithm: 'ECDH-ES' });
49
+
50
+ // Create AES kit instance
51
+ const aesKit = new AesKit({
52
+ kryptos,
53
+ encryption: 'A256GCM' // Optional: defaults to A256GCM or kryptos.encryption
54
+ });
55
+ ```
56
+
57
+ ### Encryption Modes
58
+
59
+ The AES kit supports four different output formats:
60
+
61
+ #### 1. Encoded (Default)
62
+ Returns a base64-encoded string - simplest format for storage/transmission:
63
+
64
+ ```typescript
65
+ const encrypted = aesKit.encrypt('Hello World'); // Returns base64 string
66
+ const decrypted = aesKit.decrypt(encrypted); // 'Hello World'
67
+ ```
68
+
69
+ #### 2. Record
70
+ Returns a structured object with Buffer values - useful for direct manipulation:
71
+
72
+ ```typescript
73
+ const encrypted = aesKit.encrypt('Hello World', 'record');
74
+ // Returns: AesEncryptionRecord with Buffer properties
75
+
76
+ console.log(encrypted.keyId); // Key identifier
77
+ console.log(encrypted.algorithm); // 'ECDH-ES'
78
+ console.log(encrypted.encryption); // 'A256GCM'
79
+ console.log(encrypted.content); // Buffer containing encrypted data
80
+
81
+ const decrypted = aesKit.decrypt(encrypted); // 'Hello World'
82
+ ```
83
+
84
+ #### 3. Serialised
85
+ Returns a structured object with string values - JSON-serializable:
86
+
87
+ ```typescript
88
+ const encrypted = aesKit.encrypt('Hello World', 'serialised');
89
+ // Returns: SerialisedAesEncryption with base64 string properties
90
+
91
+ const json = JSON.stringify(encrypted); // Can be serialized
92
+ const parsed = JSON.parse(json);
93
+ const decrypted = aesKit.decrypt(parsed); // 'Hello World'
94
+ ```
95
+
96
+ #### 4. Tokenised
97
+ Returns a compact token format with embedded metadata:
98
+
99
+ ```typescript
100
+ const encrypted = aesKit.encrypt('Hello World', 'tokenised');
101
+ // Returns: '$A256GCM$v=1&alg=ECDH-ES&...$base64content$'
102
+
103
+ const decrypted = aesKit.decrypt(encrypted); // 'Hello World'
104
+ ```
105
+
106
+ ### Content Types
107
+
108
+ The library automatically handles different content types:
109
+
110
+ ```typescript
111
+ // String content
112
+ const text = aesKit.encrypt('Hello World');
113
+
114
+ // JSON objects
115
+ const obj = aesKit.encrypt({ message: 'Hello', count: 42 });
116
+
117
+ // Arrays
118
+ const arr = aesKit.encrypt([1, 2, 3]);
119
+
120
+ // Buffers
121
+ const buf = aesKit.encrypt(Buffer.from('binary data'));
122
+
123
+ // Numbers
124
+ const num = aesKit.encrypt(42);
125
+ ```
126
+
127
+ ### Verification and Assertion
128
+
129
+ ```typescript
130
+ const encrypted = aesKit.encrypt('Hello World');
131
+
132
+ // Verify without throwing
133
+ const isValid = aesKit.verify('Hello World', encrypted); // true
134
+ const isInvalid = aesKit.verify('Wrong data', encrypted); // false
135
+
136
+ // Assert with exception on failure
137
+ aesKit.assert('Hello World', encrypted); // Passes
138
+ aesKit.assert('Wrong data', encrypted); // Throws AesError
139
+ ```
140
+
141
+ ## Advanced Usage
142
+
143
+ ### Custom Encryption Configuration
144
+
145
+ ```typescript
146
+ import { AesKit } from '@lindorm/aes';
147
+ import { KryptosKit } from '@lindorm/kryptos';
148
+
149
+ // RSA with OAEP padding
150
+ const rsaKey = KryptosKit.generate.rsa({
151
+ algorithm: 'RSA-OAEP-256',
152
+ modulusLength: 2048
153
+ });
154
+
155
+ const aesKit = new AesKit({
156
+ kryptos: rsaKey,
157
+ encryption: 'A256GCM'
158
+ });
159
+
160
+ // PBKDF2-based key derivation
161
+ const pbkdfKey = KryptosKit.generate.oct({
162
+ algorithm: 'PBES2-HS256+A128KW',
163
+ length: 256
164
+ });
165
+
166
+ const pbkdfAes = new AesKit({
167
+ kryptos: pbkdfKey,
168
+ encryption: 'A128CBC-HS256'
169
+ });
170
+ ```
171
+
172
+ ### Working with Different Key Types
173
+
174
+ ```typescript
175
+ // Elliptic Curve keys
176
+ const ecKey = KryptosKit.generate.ec({
177
+ algorithm: 'ECDH-ES+A128GCMKW',
178
+ curve: 'P-256'
179
+ });
180
+
181
+ // Edwards Curve keys (OKP)
182
+ const okpKey = KryptosKit.generate.okp({
183
+ algorithm: 'ECDH-ES',
184
+ curve: 'X25519'
185
+ });
186
+
187
+ // Symmetric keys
188
+ const symmetricKey = KryptosKit.generate.oct({
189
+ algorithm: 'A128GCMKW',
190
+ length: 256
191
+ });
192
+ ```
193
+
194
+ ### Utility Functions
195
+
196
+ ```typescript
197
+ import { parseAes, isAesTokenised } from '@lindorm/aes';
198
+
199
+ // Parse any AES format to standard record
200
+ const record = parseAes(encryptedData); // Works with any format
201
+
202
+ // Check if string is tokenised format
203
+ const isToken = isAesTokenised('$A256GCM$v=1&alg=ECDH-ES$...$'); // true
204
+ const isNotToken = isAesTokenised('base64string'); // false
205
+ ```
206
+
207
+ ## Type Definitions
208
+
209
+ ### Core Types
210
+
211
+ ```typescript
212
+ interface AesKitOptions {
213
+ kryptos: IKryptos; // Cryptographic key instance
214
+ encryption?: KryptosEncryption; // Encryption mode (defaults to A256GCM)
215
+ }
216
+
217
+ type AesContent = Array<any> | Buffer | Dict | number | string;
218
+
219
+ type AesEncryptionMode = 'encoded' | 'record' | 'serialised' | 'tokenised';
220
+ ```
221
+
222
+ ### Record Types
223
+
224
+ ```typescript
225
+ interface AesEncryptionRecord {
226
+ algorithm: KryptosAlgorithm; // Key algorithm used
227
+ authTag: Buffer; // Authentication tag
228
+ content: Buffer; // Encrypted content
229
+ contentType: AesContentType; // Original content type
230
+ encryption: KryptosEncryption; // Encryption mode
231
+ hkdfSalt?: Buffer; // HKDF salt (if applicable)
232
+ initialisationVector: Buffer; // IV for encryption
233
+ keyId: string; // Key identifier
234
+ pbkdfIterations?: number; // PBKDF2 iterations (if applicable)
235
+ pbkdfSalt?: Buffer; // PBKDF2 salt (if applicable)
236
+ publicEncryptionJwk?: PublicEncryptionJwk; // Public key (for ECDH)
237
+ version: number; // Format version
238
+ }
239
+
240
+ interface SerialisedAesEncryption {
241
+ // Same as AesEncryptionRecord but with base64 strings instead of Buffers
242
+ }
243
+ ```
244
+
245
+ ## Error Handling
246
+
247
+ ```typescript
248
+ import { AesError } from '@lindorm/aes';
249
+
250
+ try {
251
+ const decrypted = aesKit.decrypt(invalidData);
252
+ } catch (error) {
253
+ if (error instanceof AesError) {
254
+ console.log('AES operation failed:', error.message);
255
+ }
256
+ }
257
+ ```
258
+
259
+ ## Integration with Kryptos
260
+
261
+ The AES library integrates seamlessly with `@lindorm/kryptos` for key management:
262
+
263
+ ```typescript
264
+ import { AesKit } from '@lindorm/aes';
265
+ import { Amphora } from '@lindorm/amphora';
266
+
267
+ // Use with key storage
268
+ const amphora = new Amphora({ domain: 'https://example.com', logger });
269
+ await amphora.setup();
270
+
271
+ // Find encryption key
272
+ const kryptos = await amphora.find({ use: 'enc', algorithm: 'ECDH-ES' });
273
+
274
+ const aesKit = new AesKit({ kryptos });
275
+ ```
276
+
277
+ ## Performance Considerations
278
+
279
+ - **Encoded mode**: Fastest for simple use cases
280
+ - **Record mode**: Best for direct Buffer manipulation
281
+ - **Serialised mode**: Optimal for JSON storage/transmission
282
+ - **Tokenised mode**: Most compact for URL-safe tokens
283
+
284
+ ## License
285
+
286
+ AGPL-3.0-or-later
@@ -1,16 +1,19 @@
1
1
  import { IKryptos } from "@lindorm/kryptos";
2
2
  import { IAesKit } from "../interfaces";
3
- import { AesDecryptionRecord, AesEncryptionRecord, AesKitOptions, SerialisedAesDecryption, SerialisedAesEncryption } from "../types";
3
+ import { AesContent, AesContentType, AesDecryptionRecord, AesEncryptionRecord, AesKitOptions, SerialisedAesDecryption, SerialisedAesEncryption } from "../types";
4
4
  export declare class AesKit implements IAesKit {
5
5
  private readonly encryption;
6
6
  readonly kryptos: IKryptos;
7
7
  constructor(options: AesKitOptions);
8
- encrypt(data: string, mode?: "encoded"): string;
9
- encrypt(data: string, mode: "record"): AesEncryptionRecord;
10
- encrypt(data: string, mode: "serialised"): SerialisedAesEncryption;
11
- encrypt(data: string, mode: "tokenised"): string;
12
- decrypt(data: AesDecryptionRecord | SerialisedAesDecryption | string): string;
8
+ encrypt(data: AesContent, mode?: "encoded"): string;
9
+ encrypt(data: AesContent, mode: "record"): AesEncryptionRecord;
10
+ encrypt(data: AesContent, mode: "serialised"): SerialisedAesEncryption;
11
+ encrypt(data: AesContent, mode: "tokenised"): string;
12
+ decrypt<T extends AesContent = string>(data: AesDecryptionRecord | SerialisedAesDecryption | string): T;
13
13
  verify(input: string, data: AesDecryptionRecord | SerialisedAesDecryption | string): boolean;
14
14
  assert(input: string, data: AesDecryptionRecord | SerialisedAesDecryption | string): void;
15
+ static contentType(input: any): AesContentType;
16
+ static isAesTokenised(input: any): input is string;
17
+ static parse(data: AesDecryptionRecord | SerialisedAesDecryption | string): AesDecryptionRecord;
15
18
  }
16
19
  //# sourceMappingURL=AesKit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AesKit.d.ts","sourceRoot":"","sources":["../../src/classes/AesKit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAqB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AAO,YAAW,OAAO;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,SAAgB,OAAO,EAAE,QAAQ,CAAC;gBAEf,OAAO,EAAE,aAAa;IAKlC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IACnD,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,mBAAmB;IAC9D,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,uBAAuB;IACtE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;IA6CpD,OAAO,CAAC,CAAC,SAAS,UAAU,GAAG,MAAM,EAC1C,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,CAAC;IAIG,MAAM,CACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,OAAO;IAIH,MAAM,CACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,IAAI;WAOO,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,cAAc;WAIvC,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM;WAI3C,KAAK,CACjB,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,mBAAmB;CAGvB"}
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AesKit = void 0;
4
- const is_1 = require("@lindorm/is");
5
4
  const errors_1 = require("../errors");
5
+ const utils_1 = require("../utils");
6
6
  const private_1 = require("../utils/private");
7
+ const content_1 = require("../utils/private/content");
7
8
  class AesKit {
8
9
  encryption;
9
10
  kryptos;
@@ -15,25 +16,25 @@ class AesKit {
15
16
  switch (mode) {
16
17
  case "encoded":
17
18
  return (0, private_1.createEncodedAesString)((0, private_1.encryptAes)({
18
- data: data,
19
+ data,
19
20
  encryption: this.encryption,
20
21
  kryptos: this.kryptos,
21
22
  }));
22
23
  case "record":
23
24
  return (0, private_1.encryptAes)({
24
- data: data,
25
+ data,
25
26
  encryption: this.encryption,
26
27
  kryptos: this.kryptos,
27
28
  });
28
29
  case "serialised":
29
30
  return (0, private_1.createSerialisedAesRecord)((0, private_1.encryptAes)({
30
- data: data,
31
+ data,
31
32
  encryption: this.encryption,
32
33
  kryptos: this.kryptos,
33
34
  }));
34
35
  case "tokenised":
35
36
  return (0, private_1.createTokenisedAesString)((0, private_1.encryptAes)({
36
- data: data,
37
+ data,
37
38
  encryption: this.encryption,
38
39
  kryptos: this.kryptos,
39
40
  }));
@@ -42,31 +43,7 @@ class AesKit {
42
43
  }
43
44
  }
44
45
  decrypt(data) {
45
- if ((0, is_1.isString)(data) && !(0, private_1.isAesTokenised)(data)) {
46
- return (0, private_1.decryptAes)({
47
- ...(0, private_1.parseEncodedAesString)(data),
48
- kryptos: this.kryptos,
49
- });
50
- }
51
- if ((0, is_1.isString)(data) && (0, private_1.isAesTokenised)(data)) {
52
- return (0, private_1.decryptAes)({
53
- ...(0, private_1.parseTokenisedAesString)(data),
54
- kryptos: this.kryptos,
55
- });
56
- }
57
- if ((0, is_1.isObject)(data) && (0, private_1.isAesBufferData)(data)) {
58
- return (0, private_1.decryptAes)({
59
- ...data,
60
- kryptos: this.kryptos,
61
- });
62
- }
63
- if ((0, is_1.isObject)(data) && (0, private_1.isAesSerialisedData)(data)) {
64
- return (0, private_1.decryptAes)({
65
- ...(0, private_1.parseSerialisedAesRecord)(data),
66
- kryptos: this.kryptos,
67
- });
68
- }
69
- throw new errors_1.AesError("Invalid decryption type");
46
+ return (0, private_1.decryptAes)({ ...(0, utils_1.parseAes)(data), kryptos: this.kryptos });
70
47
  }
71
48
  verify(input, data) {
72
49
  return this.decrypt(data) === input;
@@ -76,6 +53,15 @@ class AesKit {
76
53
  return;
77
54
  throw new errors_1.AesError("Invalid AES cipher");
78
55
  }
56
+ static contentType(input) {
57
+ return (0, content_1.calculateContentType)(input);
58
+ }
59
+ static isAesTokenised(input) {
60
+ return (0, utils_1.isAesTokenised)(input);
61
+ }
62
+ static parse(data) {
63
+ return (0, utils_1.parseAes)(data);
64
+ }
79
65
  }
80
66
  exports.AesKit = AesKit;
81
67
  //# sourceMappingURL=AesKit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AesKit.js","sourceRoot":"","sources":["../../src/classes/AesKit.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAEjD,sCAAqC;AAUrC,8CAY0B;AAE1B,MAAa,MAAM;IACA,UAAU,CAAoB;IAC/B,OAAO,CAAW;IAElC,YAAmB,OAAsB;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,SAAS,CAAC;IAClF,CAAC;IAMM,OAAO,CACZ,IAAY,EACZ,OAA0B,SAAS;QAEnC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,SAAS;gBACZ,OAAO,IAAA,gCAAsB,EAC3B,IAAA,oBAAU,EAAC;oBACT,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CACH,CAAC;YAEJ,KAAK,QAAQ;gBACX,OAAO,IAAA,oBAAU,EAAC;oBAChB,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CAAC;YAEL,KAAK,YAAY;gBACf,OAAO,IAAA,mCAAyB,EAC9B,IAAA,oBAAU,EAAC;oBACT,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,IAAI,CA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A6FC"}
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/constants/private/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,aAAuB,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/constants/private/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAG,WAAoB,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const LATEST_AES_VERSION = 9;
1
+ export declare const LATEST_AES_VERSION = 10;
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/constants/private/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,IAAI,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/constants/private/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,KAAK,CAAC"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LATEST_AES_VERSION = void 0;
4
- exports.LATEST_AES_VERSION = 9;
4
+ exports.LATEST_AES_VERSION = 10;
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/constants/private/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/constants/private/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from "./errors";
3
3
  export * from "./interfaces";
4
4
  export * from "./mocks";
5
5
  export * from "./types";
6
+ export * from "./utils";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -19,4 +19,5 @@ __exportStar(require("./errors"), exports);
19
19
  __exportStar(require("./interfaces"), exports);
20
20
  __exportStar(require("./mocks"), exports);
21
21
  __exportStar(require("./types"), exports);
22
+ __exportStar(require("./utils"), exports);
22
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB"}
@@ -1,12 +1,12 @@
1
1
  import { IKryptos } from "@lindorm/kryptos";
2
- import { AesDecryptionRecord, AesEncryptionRecord, SerialisedAesDecryption, SerialisedAesEncryption } from "../types";
2
+ import { AesContent, AesDecryptionRecord, AesEncryptionRecord, SerialisedAesDecryption, SerialisedAesEncryption } from "../types";
3
3
  export interface IAesKit {
4
4
  kryptos: IKryptos;
5
- encrypt(data: string, mode?: "encoded"): string;
6
- encrypt(data: string, mode: "record"): AesEncryptionRecord;
7
- encrypt(data: string, mode: "serialised"): SerialisedAesEncryption;
8
- encrypt(data: string, mode: "tokenised"): string;
9
- decrypt(data: AesDecryptionRecord | SerialisedAesDecryption | string): string;
5
+ encrypt(content: AesContent, mode?: "encoded"): string;
6
+ encrypt(content: AesContent, mode: "record"): AesEncryptionRecord;
7
+ encrypt(content: AesContent, mode: "serialised"): SerialisedAesEncryption;
8
+ encrypt(content: AesContent, mode: "tokenised"): string;
9
+ decrypt<T extends AesContent = string>(data: AesDecryptionRecord | SerialisedAesDecryption | string): T;
10
10
  verify(input: string, data: AesDecryptionRecord | SerialisedAesDecryption | string): boolean;
11
11
  assert(input: string, data: AesDecryptionRecord | SerialisedAesDecryption | string): void;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AesKit.d.ts","sourceRoot":"","sources":["../../src/interfaces/AesKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,QAAQ,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,mBAAmB,CAAC;IAC3D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,uBAAuB,CAAC;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAEjD,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAAG,MAAM,CAAC;IAC9E,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,OAAO,CAAC;IACX,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,IAAI,CAAC;CACT"}
1
+ {"version":3,"file":"AesKit.d.ts","sourceRoot":"","sources":["../../src/interfaces/AesKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,QAAQ,CAAC;IAElB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACvD,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,mBAAmB,CAAC;IAClE,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,uBAAuB,CAAC;IAC1E,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IAExD,OAAO,CAAC,CAAC,SAAS,UAAU,GAAG,MAAM,EACnC,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,CAAC,CAAC;IACL,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,OAAO,CAAC;IACX,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAC3D,IAAI,CAAC;CACT"}
@@ -1,34 +1,43 @@
1
- import { KryptosEncryption } from "@lindorm/kryptos";
1
+ import { KryptosAlgorithm, KryptosEncryption } from "@lindorm/kryptos";
2
+ import { AesContent, AesContentType } from "./content";
2
3
  import { PublicEncryptionJwk } from "./types";
3
4
  export type AesEncryptionMode = "encoded" | "record" | "serialised" | "tokenised";
4
5
  export type AesEncryptionOptions = {
5
- data: Buffer | string;
6
+ data: AesContent;
6
7
  encryption?: KryptosEncryption;
7
8
  };
8
9
  export type AesDecryptionRecord = {
10
+ algorithm?: KryptosAlgorithm;
9
11
  authTag?: Buffer;
10
12
  content: Buffer;
13
+ contentType?: AesContentType;
11
14
  encryption: KryptosEncryption;
12
15
  hkdfSalt?: Buffer;
13
16
  initialisationVector: Buffer;
17
+ keyId?: string;
14
18
  pbkdfIterations?: number;
15
19
  pbkdfSalt?: Buffer;
16
20
  publicEncryptionIv?: Buffer;
17
21
  publicEncryptionJwk?: PublicEncryptionJwk;
18
22
  publicEncryptionKey?: Buffer;
19
23
  publicEncryptionTag?: Buffer;
24
+ version?: number;
20
25
  };
21
26
  export type SerialisedAesDecryption = {
27
+ algorithm?: KryptosAlgorithm;
22
28
  authTag?: string;
23
29
  content: string;
30
+ contentType?: AesContentType;
24
31
  encryption: KryptosEncryption;
25
32
  hkdfSalt?: string;
26
33
  initialisationVector: string;
34
+ keyId?: string;
27
35
  pbkdfIterations?: number;
28
36
  pbkdfSalt?: string;
29
37
  publicEncryptionIv?: string;
30
38
  publicEncryptionJwk?: PublicEncryptionJwk;
31
39
  publicEncryptionKey?: string;
32
40
  publicEncryptionTag?: string;
41
+ version?: number;
33
42
  };
34
- //# sourceMappingURL=aes-data.d.ts.map
43
+ //# sourceMappingURL=aes-decryption-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-decryption-data.d.ts","sourceRoot":"","sources":["../../src/types/aes-decryption-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG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1C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=aes-decryption-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-decryption-data.js","sourceRoot":"","sources":["../../src/types/aes-decryption-data.ts"],"names":[],"mappings":""}
@@ -1,9 +1,11 @@
1
1
  import { KryptosAlgorithm, KryptosEncryption } from "@lindorm/kryptos";
2
+ import { AesContentType } from "./content";
2
3
  import { PublicEncryptionJwk } from "./types";
3
4
  export type AesEncryptionRecord = {
4
5
  algorithm: KryptosAlgorithm;
5
6
  authTag: Buffer;
6
7
  content: Buffer;
8
+ contentType: AesContentType;
7
9
  encryption: KryptosEncryption;
8
10
  hkdfSalt: Buffer | undefined;
9
11
  initialisationVector: Buffer;
@@ -20,6 +22,7 @@ export type SerialisedAesEncryption = {
20
22
  algorithm: KryptosAlgorithm;
21
23
  authTag: string;
22
24
  content: string;
25
+ contentType: AesContentType;
23
26
  encryption: KryptosEncryption;
24
27
  hkdfSalt: string | undefined;
25
28
  initialisationVector: string;
@@ -1 +1 @@
1
- {"version":3,"file":"aes-encryption-data.d.ts","sourceRoot":"","sources":["../../src/types/aes-encryption-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,oBAAoB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<any> | Buffer | Dict | number | string;
3
+ export type AesContentType = "application/json" | "application/octet-stream" | "text/plain";
4
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/types/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtE,MAAM,MAAM,cAAc,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,YAAY,CAAC"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=aes-data.js.map
3
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/types/content.ts"],"names":[],"mappings":""}