@adonisjs/core 7.0.1 → 7.1.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/build/ace-DBm6EcQ-.js +37 -0
- package/build/app-BCcG_oDd.js +7 -0
- package/build/app-CAuSGb2P.js +15 -0
- package/build/bodyparser_middleware-H5FArWkI.js +9 -0
- package/build/{chunk-iKc69rpz.js → chunk-Do49iUES.js} +3 -0
- package/build/commands/add.d.ts +1 -0
- package/build/commands/add.js +64 -10
- package/build/commands/build.js +41 -3
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.js +70 -4
- package/build/commands/eject.js +30 -4
- package/build/commands/env/add.js +62 -4
- package/build/commands/generate_key.js +23 -3
- package/build/commands/inspect_rcfile.js +26 -2
- package/build/commands/list/routes.d.ts +5 -0
- package/build/commands/list/routes.js +242 -3
- package/build/commands/make/command.js +33 -4
- package/build/commands/make/controller.js +46 -4
- package/build/commands/make/event.js +36 -4
- package/build/commands/make/exception.js +36 -4
- package/build/commands/make/listener.js +44 -4
- package/build/commands/make/middleware.js +53 -5
- package/build/commands/make/preload.js +55 -5
- package/build/commands/make/provider.js +54 -5
- package/build/commands/make/service.js +29 -4
- package/build/commands/make/test.js +63 -4
- package/build/commands/make/transformer.js +37 -4
- package/build/commands/make/validator.js +44 -4
- package/build/commands/make/view.js +33 -4
- package/build/commands/repl.js +31 -2
- package/build/commands/serve.js +54 -4
- package/build/commands/test.js +69 -4
- package/build/config-Coti2q6R.js +7 -0
- package/build/config_provider-Do9af1ze.js +35 -0
- package/build/container-CGfEwWof.js +7 -0
- package/build/{core-IpCOCkUL.js → core-aRg0soJX.js} +52 -3
- package/build/create_kernel-BV3swyCg.js +4 -0
- package/build/{create_kernel-B7ILNhuP.js → create_kernel-D38-0Zbt.js} +41 -1
- package/build/debug-DWofTfIX.js +20 -0
- package/build/{decorate-DmrZA614.js → decorate-B9Uz0anB.js} +2 -0
- package/build/{define_config-0oHaj43l.js → define_config--5euEdi8.js} +54 -3
- package/build/dumper-3R77st8F.js +353 -0
- package/build/edge-BG5ZYp6Z.js +57 -0
- package/build/{errors-CrCO-k44.js → errors-BScZTzBu.js} +9 -1
- package/build/events-DlKX1ZdL.js +7 -0
- package/build/exceptions-B2MzIlHY.js +2 -0
- package/build/factories/app.js +1 -0
- package/build/factories/bodyparser.js +1 -0
- package/build/factories/core/ace.js +16 -22
- package/build/factories/core/ignitor.js +13 -73
- package/build/factories/core/main.js +25 -17
- package/build/factories/core/test_utils.js +22 -19
- package/build/factories/encryption.js +1 -0
- package/build/factories/events.js +1 -0
- package/build/factories/hash.js +1 -0
- package/build/factories/http.js +1 -0
- package/build/factories/logger.js +1 -0
- package/build/factories/stubs.js +75 -7
- package/build/ignitor-Kym3gR-I.js +169 -0
- package/build/index.js +11 -8
- package/build/logger-DIdZPHCe.js +43 -0
- package/build/main-B50zECAi.js +121 -0
- package/build/main-CRnMnrH7.js +184 -0
- package/build/{main-kn40V-hF.js → main-CfTiGsiS.js} +2 -0
- package/build/main-Ck0GqLx4.js +117 -0
- package/build/main-CoZI4Ezs.js +2 -0
- package/build/main-D1MSq4Uu.js +435 -0
- package/build/{main--nXd7T-C.js → main-bRYXIHgD.js} +75 -3
- package/build/main-zxNP7iRl.js +7 -0
- package/build/modules/ace/codemods.js +301 -2
- package/build/modules/ace/commands.d.ts +5 -0
- package/build/modules/ace/main.js +2 -1
- package/build/modules/app.js +3 -5
- package/build/modules/bodyparser/bodyparser_middleware.js +2 -2
- package/build/modules/bodyparser/main.js +3 -5
- package/build/modules/config.js +3 -5
- package/build/modules/container.js +3 -5
- package/build/modules/dumper/main.js +29 -2
- package/build/modules/dumper/plugins/edge.js +2 -46
- package/build/modules/encryption/drivers/aes_256_cbc.js +1 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +1 -0
- package/build/modules/encryption/drivers/aes_siv.js +1 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +1 -0
- package/build/modules/encryption/drivers/legacy.js +46 -1
- package/build/modules/encryption/main.js +7 -5
- package/build/modules/env/editor.js +1 -0
- package/build/modules/env/main.js +1 -0
- package/build/modules/events.js +3 -5
- package/build/modules/hash/drivers/argon.js +1 -0
- package/build/modules/hash/drivers/bcrypt.js +1 -0
- package/build/modules/hash/drivers/scrypt.js +1 -0
- package/build/modules/hash/main.js +4 -4
- package/build/modules/hash/phc_formatter.js +1 -0
- package/build/modules/health.js +1 -0
- package/build/modules/http/helpers.js +1 -0
- package/build/modules/http/main.js +2 -2
- package/build/modules/http/url_builder_client.js +1 -0
- package/build/modules/logger.js +3 -13
- package/build/modules/repl.js +3 -5
- package/build/modules/transformers/main.js +1 -0
- package/build/providers/app_provider.js +214 -15
- package/build/providers/edge_provider.js +90 -3
- package/build/providers/hash_provider.js +59 -4
- package/build/providers/repl_provider.js +64 -2
- package/build/providers/vinejs_provider.js +44 -3
- package/build/repl-C02Re0Yd.js +7 -0
- package/build/services/ace.js +11 -1
- package/build/services/app.js +2 -4
- package/build/services/config.js +7 -1
- package/build/services/dumper.js +13 -1
- package/build/services/emitter.js +8 -1
- package/build/services/encryption.js +8 -1
- package/build/services/hash.js +8 -1
- package/build/services/logger.js +8 -1
- package/build/services/repl.js +8 -1
- package/build/services/router.js +8 -1
- package/build/services/server.js +8 -1
- package/build/services/test_utils.js +11 -1
- package/build/services/url_builder.js +8 -1
- package/build/src/cli_formatters/routes_list.d.ts +7 -0
- package/build/src/exceptions.js +2 -1
- package/build/src/helpers/assert.js +1 -0
- package/build/src/helpers/http.js +1 -0
- package/build/src/helpers/is.js +24 -0
- package/build/src/helpers/main.js +2 -1
- package/build/src/helpers/string.js +2 -27
- package/build/src/helpers/types.js +18 -0
- package/build/src/helpers/verification_token.js +2 -45
- package/build/src/test_utils/main.js +9 -7
- package/build/src/types.js +1 -0
- package/build/src/vine.js +2 -32
- package/build/string-8_8He-HH.js +46 -0
- package/build/test_utils-DbJS_uEu.js +32 -0
- package/build/toolkit/main.js +13 -1
- package/build/types/ace.js +1 -0
- package/build/types/app.js +1 -0
- package/build/types/bodyparser.js +1 -0
- package/build/types/common.js +1 -0
- package/build/types/container.js +1 -0
- package/build/types/encryption.js +1 -0
- package/build/types/events.js +1 -0
- package/build/types/hash.js +1 -0
- package/build/types/health.js +1 -0
- package/build/types/helpers.js +1 -0
- package/build/types/http.js +1 -0
- package/build/types/logger.js +1 -0
- package/build/types/repl.js +1 -0
- package/build/types/transformers.js +1 -0
- package/build/utils-CKwka7OL.js +105 -0
- package/build/verification_token-WCrZtUgZ.js +108 -0
- package/build/vine-DkIupA3Z.js +97 -0
- package/package.json +12 -12
- package/build/config_provider-FIAUgvae.js +0 -13
- package/build/create_kernel-BD0Iqi8e.js +0 -3
- package/build/debug-CGQmxzGt.js +0 -3
- package/build/dumper-BBgqFX5a.js +0 -147
- package/build/main-Cxz0TyIw.js +0 -173
- package/build/main-DN2qEEg5.js +0 -41
- package/build/main-DkNgvceD.js +0 -52
- package/build/main-MBAMnmJb.js +0 -81
- package/build/utils-rRkbAPnP.js +0 -42
package/build/src/vine.js
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function isBodyParserFile(file) {
|
|
4
|
-
return !!(file && typeof file === "object" && "isMultipartFile" in file);
|
|
5
|
-
}
|
|
6
|
-
const isMultipartFile = vine.createRule((file, options, field) => {
|
|
7
|
-
if (!field.isDefined) return false;
|
|
8
|
-
if (!isBodyParserFile(file)) {
|
|
9
|
-
field.report("The {{ field }} must be a file", "file", field);
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
const validationOptions = typeof options === "function" ? options(field) : options;
|
|
13
|
-
if (file.sizeLimit === void 0 && validationOptions.size) file.sizeLimit = validationOptions.size;
|
|
14
|
-
if (file.allowedExtensions === void 0 && validationOptions.extnames) file.allowedExtensions = validationOptions.extnames;
|
|
15
|
-
file.validate();
|
|
16
|
-
file.errors.forEach((error) => {
|
|
17
|
-
field.report(error.message, `file.${error.type}`, field, validationOptions);
|
|
18
|
-
});
|
|
19
|
-
return file.isValid;
|
|
20
|
-
});
|
|
21
|
-
var VineMultipartFile = class VineMultipartFile extends BaseLiteralType {
|
|
22
|
-
#validationOptions;
|
|
23
|
-
[MULTIPART_FILE] = "multipartFile";
|
|
24
|
-
constructor(validationOptions, options, validations) {
|
|
25
|
-
super(options, validations || []);
|
|
26
|
-
this.#validationOptions = validationOptions;
|
|
27
|
-
this.dataTypeValidator = isMultipartFile(validationOptions || {});
|
|
28
|
-
}
|
|
29
|
-
clone() {
|
|
30
|
-
return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
|
|
31
|
-
}
|
|
32
|
-
};
|
|
1
|
+
import "../chunk-Do49iUES.js";
|
|
2
|
+
import { t as VineMultipartFile } from "../vine-DkIupA3Z.js";
|
|
33
3
|
export { VineMultipartFile };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import prettyHrTime from "pretty-hrtime";
|
|
2
|
+
import string from "@poppinss/utils/string";
|
|
3
|
+
import he from "he";
|
|
4
|
+
import StringBuilder from "@poppinss/utils/string_builder";
|
|
5
|
+
//#region src/helpers/string.ts
|
|
6
|
+
/**
|
|
7
|
+
* Collection of string helpers to transform a string value. This object extends
|
|
8
|
+
* the base string utilities from @poppinss/utils with additional AdonisJS-specific
|
|
9
|
+
* string manipulation methods.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Basic string transformations
|
|
13
|
+
* stringHelpers.camelCase('hello_world') // 'helloWorld'
|
|
14
|
+
* stringHelpers.snakeCase('HelloWorld') // 'hello_world'
|
|
15
|
+
* stringHelpers.pascalCase('hello world') // 'HelloWorld'
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // HTML escaping and encoding
|
|
19
|
+
* stringHelpers.escapeHTML('<script>alert("xss")<\/script>')
|
|
20
|
+
* stringHelpers.encodeSymbols('© 2023 AdonisJS')
|
|
21
|
+
*/
|
|
22
|
+
const stringHelpers = {
|
|
23
|
+
...string,
|
|
24
|
+
toSentence: string.sentence,
|
|
25
|
+
ordinalize: string.ordinal,
|
|
26
|
+
generateRandom: string.random,
|
|
27
|
+
create(value) {
|
|
28
|
+
return new StringBuilder(value);
|
|
29
|
+
},
|
|
30
|
+
prettyHrTime(time, options) {
|
|
31
|
+
return prettyHrTime(time, options);
|
|
32
|
+
},
|
|
33
|
+
isEmpty(value) {
|
|
34
|
+
return value.trim().length === 0;
|
|
35
|
+
},
|
|
36
|
+
escapeHTML(value, options) {
|
|
37
|
+
value = he.escape(value);
|
|
38
|
+
if (options && options.encodeSymbols) value = this.encodeSymbols(value, { allowUnsafeSymbols: true });
|
|
39
|
+
return value;
|
|
40
|
+
},
|
|
41
|
+
encodeSymbols(value, options) {
|
|
42
|
+
return he.encode(value, options);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { stringHelpers as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { t as Ignitor } from "./main-D1MSq4Uu.js";
|
|
2
|
+
import { t as IgnitorFactory } from "./ignitor-Kym3gR-I.js";
|
|
3
|
+
import { t as TestUtils } from "./main-bRYXIHgD.js";
|
|
4
|
+
//#region factories/core/test_utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Factory for creating TestUtils instances used in AdonisJS testing scenarios.
|
|
7
|
+
* This factory provides convenient methods to set up test utilities either from
|
|
8
|
+
* an existing Ignitor instance or by creating a new configured one.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Create from URL for testing
|
|
13
|
+
* const factory = new TestUtilsFactory()
|
|
14
|
+
* const testUtils = factory.create(new URL('../', import.meta.url))
|
|
15
|
+
*
|
|
16
|
+
* // Use in tests
|
|
17
|
+
* const app = testUtils.app()
|
|
18
|
+
* await app.boot()
|
|
19
|
+
*
|
|
20
|
+
* // Create HTTP client
|
|
21
|
+
* const client = testUtils.httpClient()
|
|
22
|
+
* const response = await client.get('/users')
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
var TestUtilsFactory = class {
|
|
26
|
+
create(ignitorOrAppRoot, options) {
|
|
27
|
+
if (ignitorOrAppRoot instanceof Ignitor) return new TestUtils(ignitorOrAppRoot.createApp("test"));
|
|
28
|
+
return new TestUtils(new IgnitorFactory().withCoreConfig().withCoreProviders().create(ignitorOrAppRoot, options).createApp("console"));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { TestUtilsFactory as t };
|
package/build/toolkit/main.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import "../chunk-Do49iUES.js";
|
|
3
|
+
import { t as __decorate } from "../decorate-B9Uz0anB.js";
|
|
3
4
|
import { BaseCommand, HelpCommand, IndexGenerator, Kernel, ListLoader, args } from "@adonisjs/ace";
|
|
4
5
|
import { join } from "node:path";
|
|
6
|
+
//#region toolkit/commands/index_commands.ts
|
|
7
|
+
/**
|
|
8
|
+
* Generates index of commands with a loader. Must be called against
|
|
9
|
+
* the TypeScript compiled output.
|
|
10
|
+
*/
|
|
5
11
|
var IndexCommand = class extends BaseCommand {
|
|
6
12
|
static commandName = "index";
|
|
7
13
|
static description = "Create an index of commands along with a lazy loader";
|
|
@@ -10,16 +16,22 @@ var IndexCommand = class extends BaseCommand {
|
|
|
10
16
|
}
|
|
11
17
|
};
|
|
12
18
|
__decorate([args.string({ description: "Relative path from cwd to the commands directory" })], IndexCommand.prototype, "commandsDir", void 0);
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region toolkit/main.ts
|
|
13
21
|
const kernel = Kernel.create();
|
|
14
22
|
kernel.addLoader(new ListLoader([IndexCommand]));
|
|
15
23
|
kernel.defineFlag("help", {
|
|
16
24
|
type: "boolean",
|
|
17
25
|
description: HelpCommand.description
|
|
18
26
|
});
|
|
27
|
+
/**
|
|
28
|
+
* Flag listener to display the help
|
|
29
|
+
*/
|
|
19
30
|
kernel.on("help", async (command, $kernel, parsed) => {
|
|
20
31
|
parsed.args.unshift(command.commandName);
|
|
21
32
|
await new HelpCommand($kernel, parsed, kernel.ui, kernel.prompt).exec();
|
|
22
33
|
return $kernel.shortcircuit();
|
|
23
34
|
});
|
|
24
35
|
await kernel.handle(process.argv.splice(2));
|
|
36
|
+
//#endregion
|
|
25
37
|
export {};
|
package/build/types/ace.js
CHANGED
package/build/types/app.js
CHANGED
package/build/types/common.js
CHANGED
package/build/types/container.js
CHANGED
package/build/types/events.js
CHANGED
package/build/types/hash.js
CHANGED
package/build/types/health.js
CHANGED
package/build/types/helpers.js
CHANGED
package/build/types/http.js
CHANGED
package/build/types/logger.js
CHANGED
package/build/types/repl.js
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region src/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Imports the AdonisJS assembler package optionally. This function attempts
|
|
4
|
+
* to import the assembler and returns undefined if it's not available,
|
|
5
|
+
* making it safe to use in environments where the assembler might not be installed.
|
|
6
|
+
*
|
|
7
|
+
* @param app - The application service instance used for importing the assembler
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const assembler = await importAssembler(app)
|
|
11
|
+
* if (assembler) {
|
|
12
|
+
* // Use assembler functionality
|
|
13
|
+
* const generator = new assembler.IndexGenerator()
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
async function importAssembler(app) {
|
|
17
|
+
try {
|
|
18
|
+
return await app.import("@adonisjs/assembler");
|
|
19
|
+
} catch {}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Imports the TypeScript compiler package optionally. This function attempts
|
|
23
|
+
* to import TypeScript and returns undefined if it's not available,
|
|
24
|
+
* making it safe to use in environments where TypeScript might not be installed.
|
|
25
|
+
*
|
|
26
|
+
* @param app - The application service instance used for importing TypeScript
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const ts = await importTypeScript(app)
|
|
30
|
+
* if (ts) {
|
|
31
|
+
* // Use TypeScript compiler API
|
|
32
|
+
* const program = ts.createProgram(['file.ts'], {})
|
|
33
|
+
* const sourceFile = program.getSourceFile('file.ts')
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
async function importTypeScript(app) {
|
|
37
|
+
try {
|
|
38
|
+
return await app.importDefault("typescript");
|
|
39
|
+
} catch {}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Outputs transformer data objects by generating TypeScript type definitions
|
|
43
|
+
* for all transformers in the provided file tree. This function creates
|
|
44
|
+
* InferData types for each transformer and organizes them in namespaces.
|
|
45
|
+
*
|
|
46
|
+
* @param transformersList - A recursive file tree containing transformer file paths
|
|
47
|
+
* @param buffer - The file buffer to write the generated types to
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const transformersList = {
|
|
51
|
+
* User: '#app/transformers/user_transformer',
|
|
52
|
+
* Auth: {
|
|
53
|
+
* Login: '#app/transformers/auth/login_transformer'
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* await outputTransformerDataObjects(transformersList, buffer)
|
|
57
|
+
* // Generates:
|
|
58
|
+
* // export namespace Data {
|
|
59
|
+
* // export type User = InferData<UserTransformer>
|
|
60
|
+
* // export namespace Auth {
|
|
61
|
+
* // export type Login = InferData<AuthLoginTransformer>
|
|
62
|
+
* // }
|
|
63
|
+
* // }
|
|
64
|
+
*/
|
|
65
|
+
async function outputTransformerDataObjects(transformersList, buffer, withSharedProps, inertiaMiddlewareImportPath = "#middleware/inertia_middleware") {
|
|
66
|
+
const importsBuffer = buffer.create();
|
|
67
|
+
importsBuffer.write(`/// <reference path="./manifest.d.ts" />`);
|
|
68
|
+
importsBuffer.write(`import type { InferData, InferVariants } from '@adonisjs/core/types/transformers'`);
|
|
69
|
+
if (withSharedProps) importsBuffer.write(`import type { InferSharedProps } from '@adonisjs/inertia/types'`);
|
|
70
|
+
buffer.writeLine(importsBuffer);
|
|
71
|
+
buffer.write("export namespace Data {").indent();
|
|
72
|
+
/**
|
|
73
|
+
* Recursively generates namespace tree structure for transformers.
|
|
74
|
+
* Creates nested namespaces for directory structures and type exports
|
|
75
|
+
* for individual transformer files.
|
|
76
|
+
*
|
|
77
|
+
* @param input - The current level of the file tree to process
|
|
78
|
+
* @param parents - Array of parent namespace names for import naming
|
|
79
|
+
*/
|
|
80
|
+
function generateNamespaceTree(input, parents) {
|
|
81
|
+
Object.keys(input).forEach((key) => {
|
|
82
|
+
const value = input[key];
|
|
83
|
+
if (typeof value === "string") {
|
|
84
|
+
const importName = `${parents.join("")}${key}Transformer`;
|
|
85
|
+
importsBuffer.write(`import type ${importName} from '${value}'`);
|
|
86
|
+
buffer.write(`export type ${key} = InferData<${importName}>`);
|
|
87
|
+
buffer.write(`export namespace ${key} {`).indent();
|
|
88
|
+
buffer.write(`export type Variants = InferVariants<${importName}>`);
|
|
89
|
+
buffer.dedent().write("}");
|
|
90
|
+
} else {
|
|
91
|
+
buffer.write(`export namespace ${key} {`).indent();
|
|
92
|
+
generateNamespaceTree(value, [...parents, key]);
|
|
93
|
+
buffer.dedent().write(`}`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
generateNamespaceTree(transformersList, []);
|
|
98
|
+
if (withSharedProps) {
|
|
99
|
+
importsBuffer.write(`import type InertiaMiddleware from '${inertiaMiddlewareImportPath}'`);
|
|
100
|
+
buffer.write("export type SharedProps = InferSharedProps<InertiaMiddleware>");
|
|
101
|
+
}
|
|
102
|
+
buffer.dedent().write("}");
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { importTypeScript as n, outputTransformerDataObjects as r, importAssembler as t };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import string from "@poppinss/utils/string";
|
|
2
|
+
import base64 from "@poppinss/utils/base64";
|
|
3
|
+
import { Secret, safeEqual } from "@poppinss/utils";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
//#region src/helpers/verification_token.ts
|
|
6
|
+
/**
|
|
7
|
+
* Verification token class can be used to create tokens publicly
|
|
8
|
+
* shareable tokens while storing the token hash within the database.
|
|
9
|
+
*
|
|
10
|
+
* This class is used by the Auth and the Persona packages to manage
|
|
11
|
+
* tokens for authentication and authorization purposes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* class UserToken extends VerificationToken {
|
|
15
|
+
* constructor(user: User, secret: Secret<string>) {
|
|
16
|
+
* super()
|
|
17
|
+
* this.tokenableId = user.id
|
|
18
|
+
* this.computeValue(secret)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
var VerificationToken = class {
|
|
23
|
+
/**
|
|
24
|
+
* Decodes a publicly shared token and return the series
|
|
25
|
+
* and the token value from it.
|
|
26
|
+
*
|
|
27
|
+
* Returns null when unable to decode the token because of
|
|
28
|
+
* invalid format or encoding.
|
|
29
|
+
*
|
|
30
|
+
* @param value - The token string to decode
|
|
31
|
+
*/
|
|
32
|
+
static decode(value) {
|
|
33
|
+
/**
|
|
34
|
+
* Ensure value is a string and starts with the prefix.
|
|
35
|
+
*/
|
|
36
|
+
if (typeof value !== "string") return null;
|
|
37
|
+
/**
|
|
38
|
+
* Remove prefix from the rest of the token.
|
|
39
|
+
*/
|
|
40
|
+
if (!value) return null;
|
|
41
|
+
const [identifier, ...tokenValue] = value.split(".");
|
|
42
|
+
if (!identifier || tokenValue.length === 0) return null;
|
|
43
|
+
const decodedIdentifier = base64.urlDecode(identifier);
|
|
44
|
+
const decodedSecret = base64.urlDecode(tokenValue.join("."));
|
|
45
|
+
if (!decodedIdentifier || !decodedSecret) return null;
|
|
46
|
+
return {
|
|
47
|
+
identifier: decodedIdentifier,
|
|
48
|
+
secret: new Secret(decodedSecret)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a transient token that can be shared with the persistence
|
|
53
|
+
* layer.
|
|
54
|
+
*
|
|
55
|
+
* @param userId - The user ID for whom the token is being created
|
|
56
|
+
* @param size - The size of the random token seed
|
|
57
|
+
* @param expiresIn - Token expiration time (string like '2h' or number in seconds)
|
|
58
|
+
*/
|
|
59
|
+
static createTransientToken(userId, size, expiresIn) {
|
|
60
|
+
const expiresAt = /* @__PURE__ */ new Date();
|
|
61
|
+
expiresAt.setSeconds(expiresAt.getSeconds() + string.seconds.parse(expiresIn));
|
|
62
|
+
return {
|
|
63
|
+
userId,
|
|
64
|
+
expiresAt,
|
|
65
|
+
...this.seed(size)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a secret opaque token and its hash.
|
|
70
|
+
*
|
|
71
|
+
* @param size - The length of the random token to generate
|
|
72
|
+
*/
|
|
73
|
+
static seed(size) {
|
|
74
|
+
const secret = new Secret(string.random(size));
|
|
75
|
+
return {
|
|
76
|
+
secret,
|
|
77
|
+
hash: createHash("sha256").update(secret.release()).digest("hex")
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compute the value property using the given secret. You can
|
|
82
|
+
* get secret via the static "createTransientToken" method.
|
|
83
|
+
*
|
|
84
|
+
* @param secret - The secret value to compute the public token value from
|
|
85
|
+
*/
|
|
86
|
+
computeValue(secret) {
|
|
87
|
+
this.value = new Secret(`${base64.urlEncode(String(this.identifier))}.${base64.urlEncode(secret.release())}`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if the token has been expired. Verifies
|
|
91
|
+
* the "expiresAt" timestamp with the current
|
|
92
|
+
* date.
|
|
93
|
+
*/
|
|
94
|
+
isExpired() {
|
|
95
|
+
return this.expiresAt < /* @__PURE__ */ new Date();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Verifies the value of a token against the pre-defined hash
|
|
99
|
+
*
|
|
100
|
+
* @param secret - The secret to verify against the stored hash
|
|
101
|
+
*/
|
|
102
|
+
verify(secret) {
|
|
103
|
+
const newHash = createHash("sha256").update(secret.release()).digest("hex");
|
|
104
|
+
return safeEqual(this.hash, newHash);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
export { VerificationToken as t };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import vine, { BaseLiteralType, symbols } from "@vinejs/vine";
|
|
2
|
+
//#region src/vine.ts
|
|
3
|
+
const MULTIPART_FILE = symbols.SUBTYPE ?? Symbol.for("subtype");
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the value is an instance of multipart file from bodyparser.
|
|
6
|
+
* Used internally for type guarding in file validation.
|
|
7
|
+
*
|
|
8
|
+
* @param file - The value to check for MultipartFile instance
|
|
9
|
+
*/
|
|
10
|
+
function isBodyParserFile(file) {
|
|
11
|
+
return !!(file && typeof file === "object" && "isMultipartFile" in file);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* VineJS validation rule that validates the file to be an instance of BodyParser
|
|
15
|
+
* MultipartFile class and applies size/extension validation if configured.
|
|
16
|
+
*
|
|
17
|
+
* @param file - The file value to validate
|
|
18
|
+
* @param options - Validation options for file size and extensions
|
|
19
|
+
* @param field - The field context from VineJS validation
|
|
20
|
+
*/
|
|
21
|
+
const isMultipartFile = vine.createRule((file, options, field) => {
|
|
22
|
+
if (!field.isDefined) return false;
|
|
23
|
+
/**
|
|
24
|
+
* Report error when value is not a field multipart
|
|
25
|
+
* file object
|
|
26
|
+
*/
|
|
27
|
+
if (!isBodyParserFile(file)) {
|
|
28
|
+
field.report("The {{ field }} must be a file", "file", field);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const validationOptions = typeof options === "function" ? options(field) : options;
|
|
32
|
+
/**
|
|
33
|
+
* Set size when it's defined in the options and missing
|
|
34
|
+
* on the file instance
|
|
35
|
+
*/
|
|
36
|
+
if (file.sizeLimit === void 0 && validationOptions.size) file.sizeLimit = validationOptions.size;
|
|
37
|
+
/**
|
|
38
|
+
* Set extensions when it's defined in the options and missing
|
|
39
|
+
* on the file instance
|
|
40
|
+
*/
|
|
41
|
+
if (file.allowedExtensions === void 0 && validationOptions.extnames) file.allowedExtensions = validationOptions.extnames;
|
|
42
|
+
/**
|
|
43
|
+
* Validate file
|
|
44
|
+
*/
|
|
45
|
+
file.validate();
|
|
46
|
+
/**
|
|
47
|
+
* Report errors
|
|
48
|
+
*/
|
|
49
|
+
file.errors.forEach((error) => {
|
|
50
|
+
field.report(error.message, `file.${error.type}`, field, validationOptions);
|
|
51
|
+
});
|
|
52
|
+
return file.isValid;
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Represents a multipart file uploaded via multipart/form-data HTTP
|
|
56
|
+
* request. This class extends VineJS's BaseLiteralType to provide
|
|
57
|
+
* specialized validation for uploaded files.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const fileSchema = vine.object({
|
|
61
|
+
* avatar: vine.file({
|
|
62
|
+
* size: '2mb',
|
|
63
|
+
* extnames: ['jpg', 'png']
|
|
64
|
+
* })
|
|
65
|
+
* })
|
|
66
|
+
*/
|
|
67
|
+
var VineMultipartFile = class VineMultipartFile extends BaseLiteralType {
|
|
68
|
+
/**
|
|
69
|
+
* Private validation options for file validation
|
|
70
|
+
*/
|
|
71
|
+
#validationOptions;
|
|
72
|
+
/**
|
|
73
|
+
* Symbol identifier for multipart file subtype
|
|
74
|
+
*/
|
|
75
|
+
[MULTIPART_FILE] = "multipartFile";
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new VineMultipartFile instance
|
|
78
|
+
*
|
|
79
|
+
* @param validationOptions - File validation options like size limits and allowed extensions
|
|
80
|
+
* @param options - Field options from VineJS
|
|
81
|
+
* @param validations - Array of validation functions to apply
|
|
82
|
+
*/
|
|
83
|
+
constructor(validationOptions, options, validations) {
|
|
84
|
+
super(options, validations || []);
|
|
85
|
+
this.#validationOptions = validationOptions;
|
|
86
|
+
this.dataTypeValidator = isMultipartFile(validationOptions || {});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates a clone of the current VineMultipartFile instance
|
|
90
|
+
* with the same validation options and configurations
|
|
91
|
+
*/
|
|
92
|
+
clone() {
|
|
93
|
+
return new VineMultipartFile(this.#validationOptions, this.cloneOptions(), this.cloneValidations());
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { VineMultipartFile as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/core",
|
|
3
3
|
"description": "Core of AdonisJS",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.1.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"index:commands": "node --import=@poppinss/ts-exec toolkit/main.js index build/commands"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@adonisjs/assembler": "^8.0.
|
|
85
|
+
"@adonisjs/assembler": "^8.0.1",
|
|
86
86
|
"@adonisjs/eslint-config": "^3.0.0",
|
|
87
87
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
88
88
|
"@adonisjs/tsconfig": "^2.0.0",
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
"@japa/runner": "^5.3.0",
|
|
93
93
|
"@japa/snapshot": "^2.0.10",
|
|
94
94
|
"@poppinss/ts-exec": "^1.4.4",
|
|
95
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
96
|
-
"@types/node": "~25.
|
|
95
|
+
"@release-it/conventional-changelog": "^10.0.6",
|
|
96
|
+
"@types/node": "~25.5.0",
|
|
97
97
|
"@types/pretty-hrtime": "^1.0.3",
|
|
98
98
|
"@types/sinon": "^21.0.0",
|
|
99
|
-
"@types/supertest": "^
|
|
99
|
+
"@types/supertest": "^7.2.0",
|
|
100
100
|
"@types/test-console": "^2.0.3",
|
|
101
101
|
"@vinejs/vine": "^4.3.0",
|
|
102
102
|
"argon2": "^0.44.0",
|
|
@@ -106,17 +106,17 @@
|
|
|
106
106
|
"cross-env": "^10.1.0",
|
|
107
107
|
"del-cli": "^7.0.0",
|
|
108
108
|
"edge.js": "^6.5.0",
|
|
109
|
-
"eslint": "^10.0.
|
|
109
|
+
"eslint": "^10.0.3",
|
|
110
110
|
"execa": "^9.6.1",
|
|
111
111
|
"get-port": "^7.1.0",
|
|
112
112
|
"pino-pretty": "^13.1.3",
|
|
113
113
|
"prettier": "^3.8.1",
|
|
114
114
|
"release-it": "^19.2.4",
|
|
115
|
-
"sinon": "^21.0.
|
|
115
|
+
"sinon": "^21.0.3",
|
|
116
116
|
"supertest": "^7.2.2",
|
|
117
117
|
"test-console": "^2.0.0",
|
|
118
118
|
"timekeeper": "^2.3.1",
|
|
119
|
-
"tsdown": "^0.
|
|
119
|
+
"tsdown": "^0.21.4",
|
|
120
120
|
"typedoc": "^0.28.17",
|
|
121
121
|
"typescript": "^5.9.3",
|
|
122
122
|
"youch": "^4.1.0"
|
|
@@ -132,14 +132,14 @@
|
|
|
132
132
|
"@adonisjs/hash": "^10.0.0",
|
|
133
133
|
"@adonisjs/health": "^3.1.0",
|
|
134
134
|
"@adonisjs/http-server": "^8.0.0",
|
|
135
|
-
"@adonisjs/http-transformers": "^2.3.
|
|
136
|
-
"@adonisjs/logger": "^7.1.
|
|
135
|
+
"@adonisjs/http-transformers": "^2.3.1",
|
|
136
|
+
"@adonisjs/logger": "^7.1.1",
|
|
137
137
|
"@adonisjs/repl": "^5.0.0",
|
|
138
138
|
"@boringnode/encryption": "^1.0.0",
|
|
139
139
|
"@poppinss/colors": "^4.1.6",
|
|
140
140
|
"@poppinss/dumper": "^0.7.0",
|
|
141
|
-
"@poppinss/macroable": "^1.1.
|
|
142
|
-
"@poppinss/utils": "^7.0.
|
|
141
|
+
"@poppinss/macroable": "^1.1.1",
|
|
142
|
+
"@poppinss/utils": "^7.0.1",
|
|
143
143
|
"@sindresorhus/is": "^7.2.0",
|
|
144
144
|
"@types/he": "^1.2.3",
|
|
145
145
|
"error-stack-parser-es": "^1.0.5",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const configProvider = {
|
|
2
|
-
create(resolver) {
|
|
3
|
-
return {
|
|
4
|
-
type: "provider",
|
|
5
|
-
resolver
|
|
6
|
-
};
|
|
7
|
-
},
|
|
8
|
-
async resolve(app, provider) {
|
|
9
|
-
if (provider && typeof provider === "object" && "type" in provider) return provider.resolver(app);
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export { configProvider as t };
|
package/build/debug-CGQmxzGt.js
DELETED