@adonisjs/core 7.0.0-next.24 → 7.0.0-next.25

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.
@@ -1,5 +1,5 @@
1
1
  import { t as Ignitor } from "./main-BCUvPhoe.js";
2
- import { t as IgnitorFactory } from "./ignitor-BexUmGra.js";
2
+ import { t as IgnitorFactory } from "./ignitor-DAyIsDqZ.js";
3
3
  import { t as createAceKernel } from "./create_kernel-C5k82J0c.js";
4
4
  var AceFactory = class {
5
5
  async make(ignitorOrAppRoot, options) {
@@ -57,6 +57,16 @@ const drivers = {
57
57
  keys: config.keys.filter((key) => !!key)
58
58
  };
59
59
  });
60
+ },
61
+ legacy: (config) => {
62
+ return configProvider.create(async () => {
63
+ const { Legacy } = await import("./modules/encryption/drivers/legacy.js");
64
+ debug_default("configuring legacy encryption driver");
65
+ return {
66
+ driver: (key) => new Legacy({ key }),
67
+ keys: config.keys.filter((key) => !!key)
68
+ };
69
+ });
60
70
  }
61
71
  };
62
72
  export { drivers as n, defineConfig as t };
@@ -7,10 +7,10 @@ import "../../main-BlJhxJJ2.js";
7
7
  import "../../logger-0KKSqgPG.js";
8
8
  import "../../exceptions-D7t_HaaU.js";
9
9
  import "../../main-B4VF6my1.js";
10
- import "../../define_config-v5L8vFCk.js";
10
+ import "../../define_config-t8DrH2OV.js";
11
11
  import "../../main-BpYXrgM0.js";
12
12
  import "../../main-DixtGykP.js";
13
- import "../../ignitor-BexUmGra.js";
13
+ import "../../ignitor-DAyIsDqZ.js";
14
14
  import "../../create_kernel-C5k82J0c.js";
15
- import { t as AceFactory } from "../../ace-CXo7ewJd.js";
15
+ import { t as AceFactory } from "../../ace-DrvIocZi.js";
16
16
  export { AceFactory };
@@ -6,8 +6,8 @@ import "../../app-DNvbxVWl.js";
6
6
  import "../../logger-0KKSqgPG.js";
7
7
  import "../../exceptions-D7t_HaaU.js";
8
8
  import "../../main-B4VF6my1.js";
9
- import "../../define_config-v5L8vFCk.js";
9
+ import "../../define_config-t8DrH2OV.js";
10
10
  import "../../main-BpYXrgM0.js";
11
11
  import "../../main-DixtGykP.js";
12
- import { t as IgnitorFactory } from "../../ignitor-BexUmGra.js";
12
+ import { t as IgnitorFactory } from "../../ignitor-DAyIsDqZ.js";
13
13
  export { IgnitorFactory };
@@ -12,13 +12,13 @@ import "../../main-BlJhxJJ2.js";
12
12
  import "../../logger-0KKSqgPG.js";
13
13
  import "../../exceptions-D7t_HaaU.js";
14
14
  import "../../main-B4VF6my1.js";
15
- import "../../define_config-v5L8vFCk.js";
16
- import "../../main-Bfnr5tAw.js";
15
+ import "../../define_config-t8DrH2OV.js";
16
+ import "../../main-CoP2zLaT.js";
17
17
  import "../../main-BpYXrgM0.js";
18
18
  import "../../main-DixtGykP.js";
19
- import { t as IgnitorFactory } from "../../ignitor-BexUmGra.js";
19
+ import { t as IgnitorFactory } from "../../ignitor-DAyIsDqZ.js";
20
20
  import "../../create_kernel-C5k82J0c.js";
21
- import { t as AceFactory } from "../../ace-CXo7ewJd.js";
22
- import "../../main-BBYaS2ws.js";
23
- import { t as TestUtilsFactory } from "../../test_utils-m-lvGE5J.js";
21
+ import { t as AceFactory } from "../../ace-DrvIocZi.js";
22
+ import "../../main-BBjkufvA.js";
23
+ import { t as TestUtilsFactory } from "../../test_utils-BUSLSCLy.js";
24
24
  export { AceFactory, IgnitorFactory, TestUtilsFactory };
@@ -11,11 +11,11 @@ import "../../core-BuPP8K6N.js";
11
11
  import "../../logger-0KKSqgPG.js";
12
12
  import "../../exceptions-D7t_HaaU.js";
13
13
  import "../../main-B4VF6my1.js";
14
- import "../../define_config-v5L8vFCk.js";
15
- import "../../main-Bfnr5tAw.js";
14
+ import "../../define_config-t8DrH2OV.js";
15
+ import "../../main-CoP2zLaT.js";
16
16
  import "../../main-BpYXrgM0.js";
17
17
  import "../../main-DixtGykP.js";
18
- import "../../ignitor-BexUmGra.js";
19
- import "../../main-BBYaS2ws.js";
20
- import { t as TestUtilsFactory } from "../../test_utils-m-lvGE5J.js";
18
+ import "../../ignitor-DAyIsDqZ.js";
19
+ import "../../main-BBjkufvA.js";
20
+ import { t as TestUtilsFactory } from "../../test_utils-BUSLSCLy.js";
21
21
  export { TestUtilsFactory };
@@ -1,7 +1,7 @@
1
1
  import { t as Ignitor } from "./main-BCUvPhoe.js";
2
2
  import { t as logger_exports } from "./logger-0KKSqgPG.js";
3
3
  import { t as main_exports } from "./main-B4VF6my1.js";
4
- import { n as drivers, t as defineConfig } from "./define_config-v5L8vFCk.js";
4
+ import { n as drivers, t as defineConfig } from "./define_config-t8DrH2OV.js";
5
5
  import { n as defineConfig$1, r as drivers$1 } from "./main-BpYXrgM0.js";
6
6
  import { t as main_exports$1 } from "./main-DixtGykP.js";
7
7
  var IgnitorFactory = class {
@@ -1,6 +1,6 @@
1
1
  import { n as debug_default } from "./config_provider-DWVFHOQX.js";
2
2
  import { t as main_exports } from "./main-B4VF6my1.js";
3
- import { n as Encryption } from "./main-Bfnr5tAw.js";
3
+ import { n as Encryption } from "./main-CoP2zLaT.js";
4
4
  import { IncomingMessage, ServerResponse, createServer } from "node:http";
5
5
  import { Socket } from "node:net";
6
6
  import Macroable from "@poppinss/macroable";
@@ -0,0 +1,2 @@
1
+ import { BaseDriver as BaseDriver$1, Encryption, EncryptionManager, Hmac as Hmac$1 } from "@boringnode/encryption";
2
+ export { Hmac$1 as i, Encryption as n, EncryptionManager as r, BaseDriver$1 as t };
@@ -1,5 +1,5 @@
1
1
  import { type ConfigProvider } from '../../src/types.ts';
2
- import { type AES256CBCDriverConfig, type AES256GCMDriverConfig, type ChaCha20Poly1305DriverConfig } from '../../types/encryption.ts';
2
+ import { type AES256CBCDriverConfig, type AES256GCMDriverConfig, type ChaCha20Poly1305DriverConfig, type LegacyDriverConfig } from '../../types/encryption.ts';
3
3
  import { type EncryptionConfig } from '../../types/encryption.ts';
4
4
  /**
5
5
  * Resolved configuration from the config provider that will be
@@ -124,5 +124,24 @@ export declare const drivers: {
124
124
  * ```
125
125
  */
126
126
  aes256gcm: (config: AES256GCMDriverConfig) => ConfigProvider<EncryptionConfig>;
127
+ /**
128
+ * Creates a Legacy encryption driver configuration.
129
+ *
130
+ * The Legacy driver maintains compatibility with the old AdonisJS v6
131
+ * encryption format. It uses AES-256-CBC with HMAC SHA-256.
132
+ *
133
+ * Use this driver to decrypt values encrypted with older versions
134
+ * of AdonisJS or when migrating to newer encryption drivers.
135
+ *
136
+ * @param config - The Legacy driver configuration
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * drivers.legacy({
141
+ * keys: [env.get('APP_KEY')]
142
+ * })
143
+ * ```
144
+ */
145
+ legacy: (config: LegacyDriverConfig) => ConfigProvider<EncryptionConfig>;
127
146
  };
128
147
  export {};
@@ -0,0 +1,76 @@
1
+ import { type Secret } from '@poppinss/utils';
2
+ import { BaseDriver } from '@boringnode/encryption';
3
+ import type { EncryptionDriverContract, CypherText, EncryptOptions } from '@boringnode/encryption/types';
4
+ /**
5
+ * Configuration for the Legacy encryption driver.
6
+ *
7
+ * The Legacy driver maintains compatibility with the old AdonisJS v6
8
+ * encryption format using AES-256-CBC with HMAC SHA-256.
9
+ */
10
+ export interface LegacyConfig {
11
+ key: string | Secret<string>;
12
+ }
13
+ /**
14
+ * Configuration for the Legacy encryption driver factory.
15
+ *
16
+ * Used when configuring the driver through the defineConfig function.
17
+ */
18
+ export interface LegacyDriverConfig {
19
+ keys: (string | Secret<string>)[];
20
+ }
21
+ /**
22
+ * Factory function to create a Legacy encryption configuration.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * drivers.legacy({
27
+ * keys: [env.get('APP_KEY')]
28
+ * })
29
+ * ```
30
+ */
31
+ export declare function legacy(config: LegacyDriverConfig): {
32
+ driver: (key: string | Secret<string>) => Legacy;
33
+ keys: (string | Secret<string>)[];
34
+ };
35
+ /**
36
+ * Legacy encryption driver for AdonisJS.
37
+ *
38
+ * This driver maintains compatibility with the old AdonisJS v6 encryption
39
+ * format. It uses:
40
+ * - AES-256-CBC for encryption
41
+ * - HMAC SHA-256 for integrity verification
42
+ * - MessageBuilder from @poppinss/utils for encoding values
43
+ *
44
+ * Encrypted format: `[encrypted_base64url].[iv_base64url].[hmac]`
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const driver = new Legacy({ key: 'your-32-character-secret-key!!' })
49
+ *
50
+ * const encrypted = driver.encrypt('sensitive data')
51
+ * const decrypted = driver.decrypt(encrypted)
52
+ * ```
53
+ */
54
+ export declare class Legacy extends BaseDriver implements EncryptionDriverContract {
55
+ constructor(config: LegacyConfig);
56
+ /**
57
+ * Encrypt a given piece of value using the app secret. A wide range of
58
+ * data types are supported.
59
+ *
60
+ * - String
61
+ * - Arrays
62
+ * - Objects
63
+ * - Booleans
64
+ * - Numbers
65
+ * - Dates
66
+ *
67
+ * You can optionally define a purpose for which the value was encrypted and
68
+ * mentioning a different purpose/no purpose during decrypt will fail.
69
+ */
70
+ encrypt(payload: any, options?: EncryptOptions): CypherText;
71
+ encrypt(payload: any, expiresIn?: string | number, purpose?: string): CypherText;
72
+ /**
73
+ * Decrypt value and verify it against a purpose
74
+ */
75
+ decrypt<T extends any>(value: string, purpose?: string): T | null;
76
+ }
@@ -0,0 +1,50 @@
1
+ import { BaseDriver, Hmac, base64UrlDecode, base64UrlEncode, errors } from "@boringnode/encryption";
2
+ import { MessageBuilder } from "@poppinss/utils";
3
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
4
+ function legacy(config) {
5
+ return {
6
+ driver: (key) => new Legacy({ key }),
7
+ keys: config.keys
8
+ };
9
+ }
10
+ var Legacy = class extends BaseDriver {
11
+ constructor(config) {
12
+ super(config);
13
+ if (this.cryptoKey.length < 16) throw new errors.E_INSECURE_ENCRYPTER_KEY();
14
+ }
15
+ encrypt(payload, expiresInOrOptions, purpose) {
16
+ let expiresIn;
17
+ let actualPurpose;
18
+ if (typeof expiresInOrOptions === "object" && expiresInOrOptions !== null) {
19
+ expiresIn = expiresInOrOptions.expiresIn;
20
+ actualPurpose = expiresInOrOptions.purpose;
21
+ } else {
22
+ expiresIn = expiresInOrOptions;
23
+ actualPurpose = purpose;
24
+ }
25
+ const iv = randomBytes(16);
26
+ const cipher = createCipheriv("aes-256-cbc", this.cryptoKey.subarray(0, 32), iv);
27
+ const plainText = new MessageBuilder().build(payload, expiresIn, actualPurpose);
28
+ const macPayload = `${base64UrlEncode(Buffer.concat([cipher.update(plainText), cipher.final()]))}${this.separator}${base64UrlEncode(iv)}`;
29
+ const hmac = new Hmac(this.cryptoKey).generate(macPayload);
30
+ return this.computeReturns([macPayload, hmac]);
31
+ }
32
+ decrypt(value, purpose) {
33
+ if (typeof value !== "string") return null;
34
+ const [cipherEncoded, ivEncoded, macEncoded] = value.split(this.separator);
35
+ if (!cipherEncoded || !ivEncoded || !macEncoded) return null;
36
+ const cipherText = base64UrlDecode(cipherEncoded);
37
+ if (!cipherText) return null;
38
+ const iv = base64UrlDecode(ivEncoded);
39
+ if (!iv) return null;
40
+ if (!new Hmac(this.cryptoKey).compare(`${cipherEncoded}${this.separator}${ivEncoded}`, macEncoded)) return null;
41
+ try {
42
+ const decipher = createDecipheriv("aes-256-cbc", this.cryptoKey.subarray(0, 32), iv);
43
+ const plainTextBuffer = Buffer.concat([decipher.update(cipherText), decipher.final()]);
44
+ return new MessageBuilder().verify(plainTextBuffer, purpose);
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+ };
50
+ export { Legacy, legacy };
@@ -1,5 +1,5 @@
1
1
  import "../../config_provider-DWVFHOQX.js";
2
2
  import "../../exceptions-D7t_HaaU.js";
3
- import { n as drivers, t as defineConfig } from "../../define_config-v5L8vFCk.js";
4
- import { i as Hmac, n as Encryption, r as EncryptionManager, t as BaseDriver } from "../../main-Bfnr5tAw.js";
3
+ import { n as drivers, t as defineConfig } from "../../define_config-t8DrH2OV.js";
4
+ import { i as Hmac, n as Encryption, r as EncryptionManager, t as BaseDriver } from "../../main-CoP2zLaT.js";
5
5
  export { BaseDriver, Encryption, EncryptionManager, Hmac, defineConfig, drivers };
@@ -7,8 +7,8 @@ import { t as logger_exports } from "../logger-0KKSqgPG.js";
7
7
  import { t as Dumper } from "../dumper-BTjb8j4y.js";
8
8
  import { r as RuntimeException } from "../exceptions-D7t_HaaU.js";
9
9
  import { t as main_exports } from "../main-B4VF6my1.js";
10
- import "../define_config-v5L8vFCk.js";
11
- import { n as Encryption } from "../main-Bfnr5tAw.js";
10
+ import "../define_config-t8DrH2OV.js";
11
+ import { n as Encryption } from "../main-CoP2zLaT.js";
12
12
  import { t as bodyparser_middleware_default } from "../bodyparser_middleware-DTW0epKM.js";
13
13
  import { dirname } from "node:path";
14
14
  import { mkdir, writeFile } from "node:fs/promises";
@@ -2,7 +2,7 @@ import "../../chunk-B88MteZI.js";
2
2
  import "../../config_provider-DWVFHOQX.js";
3
3
  import "../../exceptions-D7t_HaaU.js";
4
4
  import "../../main-B4VF6my1.js";
5
- import "../../define_config-v5L8vFCk.js";
6
- import "../../main-Bfnr5tAw.js";
7
- import { t as TestUtils } from "../../main-BBYaS2ws.js";
5
+ import "../../define_config-t8DrH2OV.js";
6
+ import "../../main-CoP2zLaT.js";
7
+ import { t as TestUtils } from "../../main-BBjkufvA.js";
8
8
  export { TestUtils };
@@ -1,6 +1,6 @@
1
1
  import { t as Ignitor } from "./main-BCUvPhoe.js";
2
- import { t as IgnitorFactory } from "./ignitor-BexUmGra.js";
3
- import { t as TestUtils } from "./main-BBYaS2ws.js";
2
+ import { t as IgnitorFactory } from "./ignitor-DAyIsDqZ.js";
3
+ import { t as TestUtils } from "./main-BBjkufvA.js";
4
4
  var TestUtilsFactory = class {
5
5
  create(ignitorOrAppRoot, options) {
6
6
  if (ignitorOrAppRoot instanceof Ignitor) return new TestUtils(ignitorOrAppRoot.createApp("test"));
@@ -37,3 +37,11 @@ export type { AES256GCMDriverConfig } from '@boringnode/encryption/drivers/aes_2
37
37
  * for decryption (allowing for key rotation).
38
38
  */
39
39
  export type { ChaCha20Poly1305DriverConfig } from '@boringnode/encryption/drivers/chacha20_poly1305';
40
+ /**
41
+ * Configuration options for the Legacy encryption driver.
42
+ *
43
+ * The Legacy driver maintains compatibility with the old AdonisJS v6
44
+ * encryption format. It does not require a driver identifier since
45
+ * the legacy format doesn't include one.
46
+ */
47
+ export type { LegacyDriverConfig } from '../modules/encryption/drivers/legacy.ts';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/core",
3
3
  "description": "Core of AdonisJS",
4
- "version": "7.0.0-next.24",
4
+ "version": "7.0.0-next.25",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -133,7 +133,7 @@
133
133
  "@adonisjs/http-transformers": "^2.1.0",
134
134
  "@adonisjs/logger": "^7.1.0-next.3",
135
135
  "@adonisjs/repl": "^5.0.0-next.1",
136
- "@boringnode/encryption": "^0.2.4",
136
+ "@boringnode/encryption": "^0.2.5",
137
137
  "@poppinss/colors": "^4.1.6",
138
138
  "@poppinss/dumper": "^0.7.0",
139
139
  "@poppinss/macroable": "^1.1.0",
@@ -1,2 +0,0 @@
1
- import { BaseDriver, Encryption, EncryptionManager, Hmac } from "@boringnode/encryption";
2
- export { Hmac as i, Encryption as n, EncryptionManager as r, BaseDriver as t };