@adonisjs/core 7.0.0-next.9 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -1
- package/build/chunk-iKc69rpz.js +26 -0
- package/build/commands/add.d.ts +4 -3
- package/build/commands/add.js +73 -110
- package/build/commands/build.js +51 -107
- package/build/commands/commands.json +1 -1
- package/build/commands/configure.js +81 -177
- package/build/commands/eject.js +17 -60
- package/build/commands/env/add.js +55 -134
- package/build/commands/generate_key.js +22 -66
- package/build/commands/inspect_rcfile.js +27 -55
- package/build/commands/list/routes.js +246 -116
- package/build/commands/make/command.d.ts +5 -0
- package/build/commands/make/command.js +16 -57
- package/build/commands/make/controller.d.ts +5 -0
- package/build/commands/make/controller.js +44 -120
- package/build/commands/make/event.d.ts +5 -0
- package/build/commands/make/event.js +17 -62
- package/build/commands/make/exception.d.ts +5 -0
- package/build/commands/make/exception.js +17 -62
- package/build/commands/make/listener.d.ts +5 -0
- package/build/commands/make/listener.js +37 -93
- package/build/commands/make/middleware.d.ts +5 -0
- package/build/commands/make/middleware.js +42 -101
- package/build/commands/make/preload.d.ts +5 -0
- package/build/commands/make/preload.js +48 -113
- package/build/commands/make/provider.d.ts +5 -0
- package/build/commands/make/provider.js +48 -112
- package/build/commands/make/service.d.ts +5 -0
- package/build/commands/make/service.js +17 -55
- package/build/commands/make/test.d.ts +5 -0
- package/build/commands/make/test.js +48 -132
- package/build/commands/make/transformer.d.ts +5 -0
- package/build/commands/make/transformer.js +18 -64
- package/build/commands/make/validator.d.ts +5 -0
- package/build/commands/make/validator.js +21 -80
- package/build/commands/make/view.d.ts +5 -0
- package/build/commands/make/view.js +16 -56
- package/build/commands/repl.js +17 -50
- package/build/commands/serve.js +80 -150
- package/build/commands/test.js +92 -202
- package/build/config_provider-FIAUgvae.js +13 -0
- package/build/core-IpCOCkUL.js +146 -0
- package/build/create_kernel-B7ILNhuP.js +38 -0
- package/build/create_kernel-BD0Iqi8e.js +3 -0
- package/build/debug-CGQmxzGt.js +3 -0
- package/build/decorate-DmrZA614.js +7 -0
- package/build/define_config-0oHaj43l.js +86 -0
- package/build/dumper-BBgqFX5a.js +147 -0
- package/build/errors-CrCO-k44.js +8 -0
- package/build/factories/app.js +2 -9
- package/build/factories/bodyparser.js +2 -9
- package/build/factories/core/ace.js +22 -45
- package/build/factories/core/ignitor.js +74 -180
- package/build/factories/core/main.js +18 -11
- package/build/factories/core/test_utils.js +19 -42
- package/build/factories/encryption.d.ts +1 -1
- package/build/factories/encryption.js +2 -9
- package/build/factories/events.js +2 -9
- package/build/factories/hash.js +2 -9
- package/build/factories/http.js +2 -9
- package/build/factories/logger.js +2 -9
- package/build/factories/stubs.d.ts +1 -6
- package/build/factories/stubs.js +24 -91
- package/build/index.d.ts +1 -1
- package/build/index.js +10 -46
- package/build/main--nXd7T-C.js +73 -0
- package/build/main-Cxz0TyIw.js +173 -0
- package/build/main-DN2qEEg5.js +41 -0
- package/build/main-DkNgvceD.js +52 -0
- package/build/main-MBAMnmJb.js +81 -0
- package/build/main-kn40V-hF.js +2 -0
- package/build/{stubs/make → make}/health/controller.stub +5 -2
- package/build/modules/ace/codemods.d.ts +74 -22
- package/build/modules/ace/codemods.js +295 -476
- package/build/modules/ace/main.js +2 -41
- package/build/modules/app.js +6 -26
- package/build/modules/bodyparser/bodyparser_middleware.js +3 -14
- package/build/modules/bodyparser/main.js +6 -9
- package/build/modules/config.js +6 -26
- package/build/modules/container.js +6 -9
- package/build/modules/dumper/main.js +6 -32
- package/build/modules/dumper/plugins/edge.js +46 -61
- package/build/modules/encryption/define_config.d.ts +161 -0
- package/build/modules/encryption/drivers/aes_256_cbc.d.ts +20 -0
- package/build/modules/encryption/drivers/aes_256_cbc.js +2 -0
- package/build/modules/encryption/drivers/aes_256_gcm.d.ts +21 -0
- package/build/modules/encryption/drivers/aes_256_gcm.js +2 -0
- package/build/modules/encryption/drivers/aes_siv.d.ts +19 -0
- package/build/modules/encryption/drivers/aes_siv.js +2 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.d.ts +21 -0
- package/build/modules/encryption/drivers/chacha20_poly1305.js +2 -0
- package/build/modules/encryption/drivers/legacy.d.ts +84 -0
- package/build/modules/encryption/drivers/legacy.js +57 -0
- package/build/modules/encryption/errors.d.ts +16 -0
- package/build/modules/encryption/main.d.ts +89 -0
- package/build/modules/encryption/main.js +6 -0
- package/build/modules/env/editor.js +2 -9
- package/build/modules/env/main.js +2 -28
- package/build/modules/events.js +6 -9
- package/build/modules/hash/drivers/argon.js +2 -9
- package/build/modules/hash/drivers/bcrypt.js +2 -20
- package/build/modules/hash/drivers/scrypt.js +2 -9
- package/build/modules/hash/main.js +6 -28
- package/build/modules/hash/phc_formatter.js +2 -9
- package/build/modules/health.js +2 -9
- package/build/modules/http/helpers.d.ts +1 -0
- package/build/modules/http/helpers.js +2 -0
- package/build/modules/http/main.js +4 -15
- package/build/modules/http/request_validator.d.ts +3 -4
- package/build/modules/http/url_builder_client.js +2 -9
- package/build/modules/logger.d.ts +30 -0
- package/build/modules/logger.js +14 -9
- package/build/modules/repl.js +6 -9
- package/build/modules/transformers/main.js +2 -9
- package/build/providers/app_provider.d.ts +5 -13
- package/build/providers/app_provider.js +153 -359
- package/build/providers/edge_provider.js +98 -164
- package/build/providers/hash_provider.js +29 -91
- package/build/providers/repl_provider.js +66 -152
- package/build/providers/vinejs_provider.d.ts +1 -1
- package/build/providers/vinejs_provider.js +21 -65
- package/build/services/ace.js +1 -16
- package/build/services/app.js +3 -19
- package/build/services/config.js +1 -12
- package/build/services/dumper.js +4 -20
- package/build/services/emitter.js +1 -13
- package/build/services/encryption.js +1 -13
- package/build/services/hash.js +1 -13
- package/build/services/logger.js +1 -13
- package/build/services/repl.js +1 -13
- package/build/services/router.js +1 -13
- package/build/services/server.js +1 -13
- package/build/services/test_utils.js +1 -16
- package/build/services/url_builder.d.ts +3 -3
- package/build/services/url_builder.js +4 -16
- package/build/src/assembler_hooks/index_entities.d.ts +34 -1
- package/build/src/debug.d.ts +1 -1
- package/build/src/exceptions.js +2 -49
- package/build/src/helpers/assert.js +2 -55
- package/build/src/helpers/http.js +2 -28
- package/build/src/helpers/is.js +3 -31
- package/build/src/helpers/main.js +5 -52
- package/build/src/helpers/string.js +26 -76
- package/build/src/helpers/types.js +25 -134
- package/build/src/helpers/verification_token.js +46 -120
- package/build/src/test_utils/main.js +8 -77
- package/build/src/types.d.ts +53 -99
- package/build/src/types.js +0 -8
- package/build/src/utils.d.ts +1 -1
- package/build/src/vine.js +29 -101
- package/build/toolkit/main.js +19 -21
- package/build/types/ace.js +2 -9
- package/build/types/app.js +2 -9
- package/build/types/bodyparser.js +2 -9
- package/build/types/common.js +2 -9
- package/build/types/container.js +2 -9
- package/build/types/encryption.d.ts +53 -1
- package/build/types/encryption.js +1 -9
- package/build/types/events.js +2 -9
- package/build/types/hash.js +2 -9
- package/build/types/health.js +2 -9
- package/build/types/helpers.js +0 -8
- package/build/types/http.js +2 -9
- package/build/types/logger.js +2 -9
- package/build/types/repl.js +2 -9
- package/build/types/transformers.js +2 -9
- package/build/utils-rRkbAPnP.js +42 -0
- package/package.json +117 -62
- package/build/modules/ace/commands.js +0 -157
- package/build/modules/ace/create_kernel.js +0 -91
- package/build/modules/ace/kernel.js +0 -40
- package/build/modules/dumper/define_config.js +0 -36
- package/build/modules/dumper/dumper.js +0 -266
- package/build/modules/dumper/errors.js +0 -119
- package/build/modules/encryption.d.ts +0 -18
- package/build/modules/encryption.js +0 -26
- package/build/modules/hash/define_config.js +0 -125
- package/build/modules/http/request_validator.js +0 -100
- package/build/src/assembler_hooks/index_entities.js +0 -112
- package/build/src/cli_formatters/routes_list.js +0 -397
- package/build/src/config_provider.js +0 -71
- package/build/src/debug.js +0 -25
- package/build/src/ignitor/ace.js +0 -102
- package/build/src/ignitor/http.js +0 -159
- package/build/src/ignitor/main.js +0 -124
- package/build/src/ignitor/test.js +0 -66
- package/build/src/test_utils/http.js +0 -82
- package/build/src/utils.js +0 -114
- package/build/stubs/main.js +0 -9
- package/build/toolkit/commands/index_commands.js +0 -30
- /package/build/{stubs/make → make}/command/main.stub +0 -0
- /package/build/{stubs/make → make}/controller/actions.stub +0 -0
- /package/build/{stubs/make → make}/controller/api.stub +0 -0
- /package/build/{stubs/make → make}/controller/main.stub +0 -0
- /package/build/{stubs/make → make}/controller/resource.stub +0 -0
- /package/build/{stubs/make → make}/event/main.stub +0 -0
- /package/build/{stubs/make → make}/exception/main.stub +0 -0
- /package/build/{stubs/make → make}/health/main.stub +0 -0
- /package/build/{stubs/make → make}/listener/for_event.stub +0 -0
- /package/build/{stubs/make → make}/listener/main.stub +0 -0
- /package/build/{stubs/make → make}/middleware/main.stub +0 -0
- /package/build/{stubs/make → make}/preload/main.stub +0 -0
- /package/build/{stubs/make → make}/provider/main.stub +0 -0
- /package/build/{stubs/make → make}/service/main.stub +0 -0
- /package/build/{stubs/make → make}/test/main.stub +0 -0
- /package/build/{stubs/make → make}/transformer/main.stub +0 -0
- /package/build/{stubs/make → make}/validator/main.stub +0 -0
- /package/build/{stubs/make → make}/validator/resource.stub +0 -0
- /package/build/{stubs/make → make}/view/main.stub +0 -0
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Core helper utilities for AdonisJS applications. This module provides
|
|
11
|
-
* a collection of commonly used utilities including file system operations,
|
|
12
|
-
* cryptographic functions, composition utilities, and HTTP server helpers.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // File system utilities
|
|
16
|
-
* import { fsReadAll, fsImportAll } from '@adonisjs/core/helpers'
|
|
17
|
-
*
|
|
18
|
-
* const files = await fsReadAll(url('app/controllers'))
|
|
19
|
-
* const modules = await fsImportAll(url('app/events'))
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // Cryptographic utilities
|
|
23
|
-
* import { base64, safeEqual, Secret } from '@adonisjs/core/helpers'
|
|
24
|
-
*
|
|
25
|
-
* const encoded = base64.encode('sensitive data')
|
|
26
|
-
* const isEqual = safeEqual(hash1, hash2)
|
|
27
|
-
* const secret = new Secret('my-secret-key')
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // HTTP server helpers
|
|
31
|
-
* import { middlewareInfo, routeInfo } from '@adonisjs/core/helpers'
|
|
32
|
-
*
|
|
33
|
-
* const middleware = middlewareInfo('cors', () => {})
|
|
34
|
-
* const route = routeInfo('users.show', '/users/:id')
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* File system utilities for reading and importing files recursively.
|
|
38
|
-
*/
|
|
39
|
-
export { fsReadAll, fsImportAll } from '@poppinss/utils/fs';
|
|
40
|
-
/**
|
|
41
|
-
* Base64 encoding and decoding utilities.
|
|
42
|
-
*/
|
|
43
|
-
export { default as base64 } from '@poppinss/utils/base64';
|
|
44
|
-
/**
|
|
45
|
-
* Core utilities including function composition, secret management,
|
|
46
|
-
* safe equality comparison, and message building.
|
|
47
|
-
*/
|
|
48
|
-
export { compose, Secret, safeEqual, MessageBuilder, defineStaticProperty } from '@poppinss/utils';
|
|
49
|
-
/**
|
|
50
|
-
* Verification token utility for creating secure tokens.
|
|
51
|
-
*/
|
|
52
|
-
export { VerificationToken } from "./verification_token.js";
|
|
1
|
+
import { VerificationToken } from "./verification_token.js";
|
|
2
|
+
import { fsImportAll, fsReadAll } from "@poppinss/utils/fs";
|
|
3
|
+
import base64 from "@poppinss/utils/base64";
|
|
4
|
+
import { MessageBuilder, Secret, compose, defineStaticProperty, safeEqual } from "@poppinss/utils";
|
|
5
|
+
export { MessageBuilder, Secret, VerificationToken, base64, compose, defineStaticProperty, fsImportAll, fsReadAll, safeEqual };
|
|
@@ -1,78 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import prettyHrTime from 'pretty-hrtime';
|
|
10
|
-
import string from '@poppinss/utils/string';
|
|
11
|
-
import he from 'he';
|
|
12
|
-
import StringBuilder from '@poppinss/utils/string_builder';
|
|
13
|
-
/**
|
|
14
|
-
* Collection of string helpers to transform a string value. This object extends
|
|
15
|
-
* the base string utilities from @poppinss/utils with additional AdonisJS-specific
|
|
16
|
-
* string manipulation methods.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Basic string transformations
|
|
20
|
-
* stringHelpers.camelCase('hello_world') // 'helloWorld'
|
|
21
|
-
* stringHelpers.snakeCase('HelloWorld') // 'hello_world'
|
|
22
|
-
* stringHelpers.pascalCase('hello world') // 'HelloWorld'
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* // HTML escaping and encoding
|
|
26
|
-
* stringHelpers.escapeHTML('<script>alert("xss")</script>')
|
|
27
|
-
* stringHelpers.encodeSymbols('© 2023 AdonisJS')
|
|
28
|
-
*/
|
|
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";
|
|
29
5
|
const stringHelpers = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
isEmpty(value) {
|
|
52
|
-
return value.trim().length === 0;
|
|
53
|
-
},
|
|
54
|
-
/**
|
|
55
|
-
* Escape HTML entities to prevent XSS attacks and display HTML safely.
|
|
56
|
-
*
|
|
57
|
-
* @param value - The string containing HTML to escape
|
|
58
|
-
* @param options - Optional configuration for escaping behavior
|
|
59
|
-
* @param options.encodeSymbols - Whether to also encode Unicode symbols as HTML entities
|
|
60
|
-
*/
|
|
61
|
-
escapeHTML(value, options) {
|
|
62
|
-
value = he.escape(value);
|
|
63
|
-
if (options && options.encodeSymbols) {
|
|
64
|
-
value = this.encodeSymbols(value, { allowUnsafeSymbols: true });
|
|
65
|
-
}
|
|
66
|
-
return value;
|
|
67
|
-
},
|
|
68
|
-
/**
|
|
69
|
-
* Encode Unicode symbols and special characters as HTML entities.
|
|
70
|
-
*
|
|
71
|
-
* @param value - The string containing symbols to encode
|
|
72
|
-
* @param options - Encoding options from the 'he' library
|
|
73
|
-
*/
|
|
74
|
-
encodeSymbols(value, options) {
|
|
75
|
-
return he.encode(value, options);
|
|
76
|
-
},
|
|
6
|
+
...string,
|
|
7
|
+
toSentence: string.sentence,
|
|
8
|
+
ordinalize: string.ordinal,
|
|
9
|
+
generateRandom: string.random,
|
|
10
|
+
create(value) {
|
|
11
|
+
return new StringBuilder(value);
|
|
12
|
+
},
|
|
13
|
+
prettyHrTime(time, options) {
|
|
14
|
+
return prettyHrTime(time, options);
|
|
15
|
+
},
|
|
16
|
+
isEmpty(value) {
|
|
17
|
+
return value.trim().length === 0;
|
|
18
|
+
},
|
|
19
|
+
escapeHTML(value, options) {
|
|
20
|
+
value = he.escape(value);
|
|
21
|
+
if (options && options.encodeSymbols) value = this.encodeSymbols(value, { allowUnsafeSymbols: true });
|
|
22
|
+
return value;
|
|
23
|
+
},
|
|
24
|
+
encodeSymbols(value, options) {
|
|
25
|
+
return he.encode(value, options);
|
|
26
|
+
}
|
|
77
27
|
};
|
|
78
|
-
export default
|
|
28
|
+
export { stringHelpers as default };
|
|
@@ -1,136 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
* @adonisjs/core
|
|
3
|
-
*
|
|
4
|
-
* (c) AdonisJS
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
import is from '@sindresorhus/is';
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated
|
|
12
|
-
* Use "is" helpers instead. The types helpers exist for backward compatibility.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // Instead of using types helpers (deprecated)
|
|
16
|
-
* types.isString('hello')
|
|
17
|
-
* types.isNumber(42)
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Use the new "is" helpers
|
|
21
|
-
* import { is } from '@adonisjs/core/helpers'
|
|
22
|
-
* is.string('hello')
|
|
23
|
-
* is.number(42)
|
|
24
|
-
*/
|
|
1
|
+
import is from "@sindresorhus/is";
|
|
25
2
|
const types = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
isNumber: is.number,
|
|
51
|
-
/**
|
|
52
|
-
* Check if value is a string.
|
|
53
|
-
* @deprecated Use is.string instead
|
|
54
|
-
*/
|
|
55
|
-
isString: is.string,
|
|
56
|
-
/**
|
|
57
|
-
* Check if value is an arguments object.
|
|
58
|
-
* @deprecated Use is.arguments instead
|
|
59
|
-
*/
|
|
60
|
-
isArguments: is.arguments,
|
|
61
|
-
/**
|
|
62
|
-
* Check if value is an object.
|
|
63
|
-
* @deprecated Use is.object instead
|
|
64
|
-
*/
|
|
65
|
-
isObject: is.object,
|
|
66
|
-
/**
|
|
67
|
-
* Check if value is a Date.
|
|
68
|
-
* @deprecated Use is.date instead
|
|
69
|
-
*/
|
|
70
|
-
isDate: is.date,
|
|
71
|
-
/**
|
|
72
|
-
* Check if value is an array.
|
|
73
|
-
* @deprecated Use is.array instead
|
|
74
|
-
*/
|
|
75
|
-
isArray: is.array,
|
|
76
|
-
/**
|
|
77
|
-
* Check if value is a regular expression.
|
|
78
|
-
* @deprecated Use is.regExp instead
|
|
79
|
-
*/
|
|
80
|
-
isRegexp: is.regExp,
|
|
81
|
-
/**
|
|
82
|
-
* Check if value is an error object.
|
|
83
|
-
* @deprecated Use is.error instead
|
|
84
|
-
*/
|
|
85
|
-
isError: is.error,
|
|
86
|
-
/**
|
|
87
|
-
* Check if value is a function.
|
|
88
|
-
* @deprecated Use is.function instead
|
|
89
|
-
*/
|
|
90
|
-
isFunction: is.function,
|
|
91
|
-
/**
|
|
92
|
-
* Check if value is a class.
|
|
93
|
-
* @deprecated Use is.class instead
|
|
94
|
-
*/
|
|
95
|
-
isClass: is.class,
|
|
96
|
-
/**
|
|
97
|
-
* Check if value is an integer.
|
|
98
|
-
* @deprecated Use is.integer instead
|
|
99
|
-
*/
|
|
100
|
-
isInteger: is.integer,
|
|
101
|
-
/**
|
|
102
|
-
* Check if a number is a float (has decimal places).
|
|
103
|
-
*
|
|
104
|
-
* @param value - The number to check
|
|
105
|
-
* @deprecated Use is.decimal or custom logic instead
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* types.isFloat(3.14) // true
|
|
109
|
-
* types.isFloat(42) // false
|
|
110
|
-
*/
|
|
111
|
-
isFloat(value) {
|
|
112
|
-
return value !== (value | 0);
|
|
113
|
-
},
|
|
114
|
-
/**
|
|
115
|
-
* Check if a value represents a decimal number with specific decimal places.
|
|
116
|
-
*
|
|
117
|
-
* @param value - The value to check (string or number)
|
|
118
|
-
* @param options - Options for decimal validation
|
|
119
|
-
* @param options.decimalPlaces - Regex pattern for allowed decimal places (default: '1,')
|
|
120
|
-
* @deprecated Use a validation library like Vine or custom logic instead
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* types.isDecimal('3.14') // true
|
|
124
|
-
* types.isDecimal('42.0') // true
|
|
125
|
-
* types.isDecimal('42') // false
|
|
126
|
-
* types.isDecimal('3.141', { decimalPlaces: '1,3' }) // true
|
|
127
|
-
*/
|
|
128
|
-
isDecimal(value, options) {
|
|
129
|
-
if (typeof value === 'number') {
|
|
130
|
-
value = value.toString();
|
|
131
|
-
}
|
|
132
|
-
const decimalPlaces = (options && options.decimalPlaces) || '1,';
|
|
133
|
-
return new RegExp(`^[-+]?([0-9]+)?(\\.[0-9]{${decimalPlaces}})$`).test(value);
|
|
134
|
-
},
|
|
3
|
+
lookup: is,
|
|
4
|
+
isNull: is.null,
|
|
5
|
+
isBoolean: is.boolean,
|
|
6
|
+
isBuffer: is.buffer,
|
|
7
|
+
isNumber: is.number,
|
|
8
|
+
isString: is.string,
|
|
9
|
+
isArguments: is.arguments,
|
|
10
|
+
isObject: is.object,
|
|
11
|
+
isDate: is.date,
|
|
12
|
+
isArray: is.array,
|
|
13
|
+
isRegexp: is.regExp,
|
|
14
|
+
isError: is.error,
|
|
15
|
+
isFunction: is.function,
|
|
16
|
+
isClass: is.class,
|
|
17
|
+
isInteger: is.integer,
|
|
18
|
+
isFloat(value) {
|
|
19
|
+
return value !== (value | 0);
|
|
20
|
+
},
|
|
21
|
+
isDecimal(value, options) {
|
|
22
|
+
if (typeof value === "number") value = value.toString();
|
|
23
|
+
const decimalPlaces = options && options.decimalPlaces || "1,";
|
|
24
|
+
return new RegExp(`^[-+]?([0-9]+)?(\\.[0-9]{${decimalPlaces}})$`).test(value);
|
|
25
|
+
}
|
|
135
26
|
};
|
|
136
|
-
export default
|
|
27
|
+
export { types as default };
|
|
@@ -1,120 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* Remove prefix from the rest of the token.
|
|
48
|
-
*/
|
|
49
|
-
if (!value) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
const [identifier, ...tokenValue] = value.split('.');
|
|
53
|
-
if (!identifier || tokenValue.length === 0) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const decodedIdentifier = base64.urlDecode(identifier);
|
|
57
|
-
const decodedSecret = base64.urlDecode(tokenValue.join('.'));
|
|
58
|
-
if (!decodedIdentifier || !decodedSecret) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
identifier: decodedIdentifier,
|
|
63
|
-
secret: new Secret(decodedSecret),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Creates a transient token that can be shared with the persistence
|
|
68
|
-
* layer.
|
|
69
|
-
*
|
|
70
|
-
* @param userId - The user ID for whom the token is being created
|
|
71
|
-
* @param size - The size of the random token seed
|
|
72
|
-
* @param expiresIn - Token expiration time (string like '2h' or number in seconds)
|
|
73
|
-
*/
|
|
74
|
-
static createTransientToken(userId, size, expiresIn) {
|
|
75
|
-
const expiresAt = new Date();
|
|
76
|
-
expiresAt.setSeconds(expiresAt.getSeconds() + string.seconds.parse(expiresIn));
|
|
77
|
-
return {
|
|
78
|
-
userId,
|
|
79
|
-
expiresAt,
|
|
80
|
-
...this.seed(size),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates a secret opaque token and its hash.
|
|
85
|
-
*
|
|
86
|
-
* @param size - The length of the random token to generate
|
|
87
|
-
*/
|
|
88
|
-
static seed(size) {
|
|
89
|
-
const seed = string.random(size);
|
|
90
|
-
const secret = new Secret(seed);
|
|
91
|
-
const hash = createHash('sha256').update(secret.release()).digest('hex');
|
|
92
|
-
return { secret, hash };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Compute the value property using the given secret. You can
|
|
96
|
-
* get secret via the static "createTransientToken" method.
|
|
97
|
-
*
|
|
98
|
-
* @param secret - The secret value to compute the public token value from
|
|
99
|
-
*/
|
|
100
|
-
computeValue(secret) {
|
|
101
|
-
this.value = new Secret(`${base64.urlEncode(String(this.identifier))}.${base64.urlEncode(secret.release())}`);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Check if the token has been expired. Verifies
|
|
105
|
-
* the "expiresAt" timestamp with the current
|
|
106
|
-
* date.
|
|
107
|
-
*/
|
|
108
|
-
isExpired() {
|
|
109
|
-
return this.expiresAt < new Date();
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Verifies the value of a token against the pre-defined hash
|
|
113
|
-
*
|
|
114
|
-
* @param secret - The secret to verify against the stored hash
|
|
115
|
-
*/
|
|
116
|
-
verify(secret) {
|
|
117
|
-
const newHash = createHash('sha256').update(secret.release()).digest('hex');
|
|
118
|
-
return safeEqual(this.hash, newHash);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
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
|
+
var VerificationToken = class {
|
|
6
|
+
static decode(value) {
|
|
7
|
+
if (typeof value !== "string") return null;
|
|
8
|
+
if (!value) return null;
|
|
9
|
+
const [identifier, ...tokenValue] = value.split(".");
|
|
10
|
+
if (!identifier || tokenValue.length === 0) return null;
|
|
11
|
+
const decodedIdentifier = base64.urlDecode(identifier);
|
|
12
|
+
const decodedSecret = base64.urlDecode(tokenValue.join("."));
|
|
13
|
+
if (!decodedIdentifier || !decodedSecret) return null;
|
|
14
|
+
return {
|
|
15
|
+
identifier: decodedIdentifier,
|
|
16
|
+
secret: new Secret(decodedSecret)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static createTransientToken(userId, size, expiresIn) {
|
|
20
|
+
const expiresAt = /* @__PURE__ */ new Date();
|
|
21
|
+
expiresAt.setSeconds(expiresAt.getSeconds() + string.seconds.parse(expiresIn));
|
|
22
|
+
return {
|
|
23
|
+
userId,
|
|
24
|
+
expiresAt,
|
|
25
|
+
...this.seed(size)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static seed(size) {
|
|
29
|
+
const secret = new Secret(string.random(size));
|
|
30
|
+
return {
|
|
31
|
+
secret,
|
|
32
|
+
hash: createHash("sha256").update(secret.release()).digest("hex")
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
computeValue(secret) {
|
|
36
|
+
this.value = new Secret(`${base64.urlEncode(String(this.identifier))}.${base64.urlEncode(secret.release())}`);
|
|
37
|
+
}
|
|
38
|
+
isExpired() {
|
|
39
|
+
return this.expiresAt < /* @__PURE__ */ new Date();
|
|
40
|
+
}
|
|
41
|
+
verify(secret) {
|
|
42
|
+
const newHash = createHash("sha256").update(secret.release()).digest("hex");
|
|
43
|
+
return safeEqual(this.hash, newHash);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export { VerificationToken };
|
|
@@ -1,77 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { Socket } from 'node:net';
|
|
10
|
-
import Macroable from '@poppinss/macroable';
|
|
11
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
|
-
import { HttpServerUtils } from "./http.js";
|
|
13
|
-
import { CookieClient } from "../../modules/http/main.js";
|
|
14
|
-
/**
|
|
15
|
-
* Test utils has a collection of helper methods to make testing
|
|
16
|
-
* experience great for AdonisJS applications. It provides utilities
|
|
17
|
-
* for HTTP testing, context creation, and cookie handling.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const testUtils = new TestUtils(app)
|
|
21
|
-
* await testUtils.boot()
|
|
22
|
-
*
|
|
23
|
-
* const ctx = await testUtils.createHttpContext()
|
|
24
|
-
* const httpUtils = testUtils.httpServer()
|
|
25
|
-
*/
|
|
26
|
-
export class TestUtils extends Macroable {
|
|
27
|
-
app;
|
|
28
|
-
/**
|
|
29
|
-
* Flag to track if test utils have been booted
|
|
30
|
-
*/
|
|
31
|
-
#booted = false;
|
|
32
|
-
/**
|
|
33
|
-
* Check if utils have been booted
|
|
34
|
-
*/
|
|
35
|
-
get isBooted() {
|
|
36
|
-
return this.#booted;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new TestUtils instance
|
|
40
|
-
*
|
|
41
|
-
* @param app - The application service instance
|
|
42
|
-
*/
|
|
43
|
-
constructor(app) {
|
|
44
|
-
super();
|
|
45
|
-
this.app = app;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Boot test utils. It requires the app to be booted
|
|
49
|
-
* and container to have all the bindings
|
|
50
|
-
*/
|
|
51
|
-
async boot() {
|
|
52
|
-
if (!this.isBooted) {
|
|
53
|
-
this.#booted = true;
|
|
54
|
-
this.cookies = new CookieClient(await this.app.container.make('encryption'));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Returns an instance of the HTTP server testing
|
|
59
|
-
* utils
|
|
60
|
-
*/
|
|
61
|
-
httpServer() {
|
|
62
|
-
return new HttpServerUtils(this);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Create an instance of HTTP context for testing
|
|
66
|
-
*
|
|
67
|
-
* @param options - Options for creating HTTP context with custom req/res objects
|
|
68
|
-
*/
|
|
69
|
-
async createHttpContext(options = {}) {
|
|
70
|
-
const req = options.req || new IncomingMessage(new Socket());
|
|
71
|
-
const res = options.res || new ServerResponse(req);
|
|
72
|
-
const server = await this.app.container.make('server');
|
|
73
|
-
const request = server.createRequest(req, res);
|
|
74
|
-
const response = server.createResponse(req, res);
|
|
75
|
-
return server.createHttpContext(request, response, this.app.container.createResolver());
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
import "../../chunk-iKc69rpz.js";
|
|
2
|
+
import "../../debug-CGQmxzGt.js";
|
|
3
|
+
import "../../config_provider-FIAUgvae.js";
|
|
4
|
+
import "../../main-DN2qEEg5.js";
|
|
5
|
+
import "../../errors-CrCO-k44.js";
|
|
6
|
+
import "../../define_config-0oHaj43l.js";
|
|
7
|
+
import { t as TestUtils } from "../../main--nXd7T-C.js";
|
|
8
|
+
export { TestUtils };
|