@mrxsys/mrx-core 2.6.0 → 2.8.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/CHANGELOG.md +84 -19
- package/dist/chunk-4mt568fz.js +26 -0
- package/dist/chunk-7g8k2epn.js +104 -0
- package/dist/chunk-kv9hms2z.js +28 -0
- package/dist/{chunk-7m70tmz2.js → chunk-m18th1g5.js} +1 -1
- package/dist/chunk-ncc0m208.js +8 -0
- package/dist/chunk-r1kcf1q6.js +62 -0
- package/dist/chunk-sepwfqdh.js +6 -0
- package/dist/chunk-snqdnkk7.js +10 -0
- package/dist/{chunk-9wk2pajt.js → chunk-syhskygx.js} +9 -8
- package/dist/{chunk-64d6w5kt.js → chunk-y78xrx17.js} +2 -2
- package/dist/chunk-yd82hdxv.js +6 -0
- package/dist/chunk-z1skzn1j.js +8 -0
- package/dist/modules/data/data.d.ts +1 -1
- package/dist/modules/database/index.js +2 -2
- package/dist/modules/elysia/cache/cache.d.ts +306 -0
- package/dist/modules/elysia/cache/index.d.ts +1 -0
- package/dist/modules/elysia/cache/index.js +68 -0
- package/dist/modules/elysia/cache/types/cacheItem.d.ts +7 -0
- package/dist/modules/elysia/cache/types/cacheOptions.d.ts +21 -0
- package/dist/modules/elysia/cache/types/index.d.ts +1 -0
- package/dist/modules/elysia/cache/utils/generateCacheKey.d.ts +5 -0
- package/dist/modules/elysia/cache/utils/index.d.ts +1 -0
- package/dist/modules/elysia/cache/utils/index.js +7 -0
- package/dist/modules/elysia/crud/crud.d.ts +1 -1
- package/dist/modules/elysia/crud/index.js +13 -10
- package/dist/modules/elysia/crud/types/crudOptions.d.ts +2 -0
- package/dist/modules/elysia/dbResolver/dbResolver.d.ts +1 -1
- package/dist/modules/elysia/dbResolver/index.js +3 -3
- package/dist/modules/elysia/error/index.js +11 -2
- package/dist/modules/elysia/rateLimit/enums/index.d.ts +1 -0
- package/dist/modules/elysia/rateLimit/enums/index.js +7 -0
- package/dist/modules/elysia/rateLimit/enums/rateLimitErrorKeys.d.ts +3 -0
- package/dist/modules/elysia/rateLimit/index.d.ts +1 -0
- package/dist/modules/elysia/rateLimit/index.js +59 -0
- package/dist/modules/elysia/{ratelimit/ratelimit.d.ts → rateLimit/rateLimit.d.ts} +32 -15
- package/dist/modules/elysia/{ratelimit → rateLimit}/types/rateLimitOptions.d.ts +7 -16
- package/dist/modules/jwt/enums/index.d.ts +2 -0
- package/dist/modules/jwt/enums/index.js +11 -0
- package/dist/modules/jwt/enums/jwtErrorKeys.d.ts +5 -0
- package/dist/modules/jwt/enums/parseHumanTimeToSecondsErrorKeys.d.ts +3 -0
- package/dist/modules/jwt/index.d.ts +1 -0
- package/dist/modules/jwt/index.js +58 -0
- package/dist/modules/jwt/jwt.d.ts +3 -0
- package/dist/modules/jwt/utils/index.d.ts +1 -0
- package/dist/modules/jwt/utils/index.js +9 -0
- package/dist/modules/jwt/utils/parseHumanTimeToSeconds.d.ts +17 -0
- package/dist/modules/kvStore/enums/index.d.ts +1 -0
- package/dist/modules/kvStore/enums/index.js +7 -0
- package/dist/modules/kvStore/enums/kvStoreErrorKeys.d.ts +5 -0
- package/dist/modules/kvStore/ioredis/index.d.ts +1 -0
- package/dist/modules/kvStore/ioredis/index.js +102 -0
- package/dist/modules/kvStore/ioredis/ioredisStore.d.ts +107 -0
- package/dist/modules/kvStore/memory/index.d.ts +1 -0
- package/dist/modules/kvStore/memory/index.js +9 -0
- package/dist/modules/kvStore/memory/memoryStore.d.ts +119 -0
- package/dist/modules/kvStore/memory/types/memoryStoreEntry.d.ts +11 -0
- package/dist/modules/kvStore/types/index.d.ts +1 -0
- package/dist/modules/kvStore/types/index.js +1 -0
- package/dist/modules/kvStore/types/kvStore.d.ts +81 -0
- package/dist/modules/repository/index.js +1 -1
- package/dist/modules/repository/types/queryOptions.d.ts +5 -1
- package/dist/modules/totp/enums/index.d.ts +1 -0
- package/dist/modules/totp/enums/index.js +7 -0
- package/dist/modules/totp/enums/totpErrorKeys.d.ts +7 -0
- package/dist/modules/totp/hotp.d.ts +11 -0
- package/dist/modules/totp/index.d.ts +3 -0
- package/dist/modules/totp/index.js +110 -0
- package/dist/modules/totp/otpAuthUri.d.ts +21 -0
- package/dist/modules/totp/totp.d.ts +23 -0
- package/dist/modules/totp/types/index.d.ts +3 -0
- package/dist/modules/totp/types/index.js +1 -0
- package/dist/modules/totp/types/otpAuthUri.d.ts +35 -0
- package/dist/modules/totp/types/totpOptions.d.ts +23 -0
- package/dist/modules/totp/types/verifyOptions.d.ts +18 -0
- package/dist/modules/totp/utils/base32.d.ts +19 -0
- package/dist/modules/totp/utils/createCounterBuffer.d.ts +8 -0
- package/dist/modules/totp/utils/dynamicTruncation.d.ts +9 -0
- package/dist/modules/totp/utils/generateHmac.d.ts +9 -0
- package/dist/modules/totp/utils/generateSecretBytes.d.ts +10 -0
- package/dist/modules/totp/utils/index.d.ts +6 -0
- package/dist/modules/totp/utils/index.js +81 -0
- package/dist/modules/totp/utils/timeRemaining.d.ts +9 -0
- package/dist/utils/types/index.d.ts +1 -0
- package/dist/utils/types/renameKey.d.ts +10 -0
- package/package.json +86 -75
- package/dist/chunk-cqw9xq4y.js +0 -7
- package/dist/chunk-twaga0fp.js +0 -6
- package/dist/modules/elysia/jwt/enums/index.d.ts +0 -1
- package/dist/modules/elysia/jwt/enums/index.js +0 -7
- package/dist/modules/elysia/jwt/enums/jwtErrorKeys.d.ts +0 -4
- package/dist/modules/elysia/jwt/index.d.ts +0 -1
- package/dist/modules/elysia/jwt/index.js +0 -77
- package/dist/modules/elysia/jwt/jwt.d.ts +0 -119
- package/dist/modules/elysia/jwt/types/index.d.ts +0 -1
- package/dist/modules/elysia/jwt/types/jwtOptions.d.ts +0 -98
- package/dist/modules/elysia/ratelimit/enums/index.d.ts +0 -1
- package/dist/modules/elysia/ratelimit/enums/index.js +0 -7
- package/dist/modules/elysia/ratelimit/enums/ratelimitErrorKeys.d.ts +0 -3
- package/dist/modules/elysia/ratelimit/index.d.ts +0 -1
- package/dist/modules/elysia/ratelimit/index.js +0 -52
- /package/dist/modules/elysia/{jwt → cache}/types/index.js +0 -0
- /package/dist/modules/elysia/{ratelimit → rateLimit}/types/index.d.ts +0 -0
- /package/dist/modules/elysia/{ratelimit → rateLimit}/types/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,96 @@
|
|
|
1
1
|
|
|
2
|
-
## v2.
|
|
2
|
+
## v2.8.0
|
|
3
3
|
|
|
4
|
-
[compare changes](https://github.com/MRX-Systems/MRX-Core/compare/v2.
|
|
4
|
+
[compare changes](https://github.com/MRX-Systems/MRX-Core/compare/v2.7.0...v2.8.0)
|
|
5
5
|
|
|
6
|
-
###
|
|
7
|
-
|
|
8
|
-
- **🌊:** [fix TOperations with default CrudOperationsOptions] ([b8b6169d](https://github.com/MRX-Systems/MRX-Core/commit/b8b6169d))
|
|
9
|
-
|
|
10
|
-
### 🤖 CI
|
|
11
|
-
|
|
12
|
-
- **🤖:** [Add CI workflows for build, test, and deployment] ([7d98d68b](https://github.com/MRX-Systems/MRX-Core/commit/7d98d68b))
|
|
13
|
-
|
|
14
|
-
### ❤️ Contributors
|
|
15
|
-
|
|
16
|
-
- Ruby <necrelox@proton.me>
|
|
17
|
-
|
|
18
|
-
## v2.6.0-canary-20250805-40e4647
|
|
6
|
+
### 🚀 Enhancements
|
|
19
7
|
|
|
20
|
-
[
|
|
8
|
+
- **🚀:** [Add tags support to CRUD options] ([f38ec111](https://github.com/MRX-Systems/MRX-Core/commit/f38ec111))
|
|
9
|
+
- **🚀:** [Add prefix option to CRUD options] ([6305bcf3](https://github.com/MRX-Systems/MRX-Core/commit/6305bcf3))
|
|
10
|
+
- **🚀:** [Add JWT error keys enumeration] ([5fce607d](https://github.com/MRX-Systems/MRX-Core/commit/5fce607d))
|
|
11
|
+
- **🚀:** [Add parseHumanTimeToSeconds utility function] ([829511bc](https://github.com/MRX-Systems/MRX-Core/commit/829511bc))
|
|
12
|
+
- **🚀:** [Add JWT signing and verification functions] ([82fe48c3](https://github.com/MRX-Systems/MRX-Core/commit/82fe48c3))
|
|
13
|
+
- **🚀:** [Add error keys for human time parsing] ([d566df3e](https://github.com/MRX-Systems/MRX-Core/commit/d566df3e))
|
|
14
|
+
- **🚀:** [Enhance query returning with trigger modifications] ([c5b62b91](https://github.com/MRX-Systems/MRX-Core/commit/c5b62b91))
|
|
15
|
+
- **🚀:** [Add KV_STORE_ERROR_KEYS enum for error handling] ## Features - Introduced `KV_STORE_ERROR_KEYS` enum to standardize error messages. ([45fc7119](https://github.com/MRX-Systems/MRX-Core/commit/45fc7119))
|
|
16
|
+
- **🚀:** [Add IoRedisStore class for Redis-based key-value store] ([0181be2b](https://github.com/MRX-Systems/MRX-Core/commit/0181be2b))
|
|
17
|
+
- **🚀:** [Add MemoryStore class for in-memory key-value storage] ([4342e1f7](https://github.com/MRX-Systems/MRX-Core/commit/4342e1f7))
|
|
18
|
+
- **🚀:** [Add RATE_LIMIT_ERROR_KEYS export] ([1b819bea](https://github.com/MRX-Systems/MRX-Core/commit/1b819bea))
|
|
19
|
+
- **🚀:** [Add generateCacheKey utility for caching requests] ## Features - Introduced `generateCacheKey` function to create a unique cache key based on request properties. ([b80bd5e2](https://github.com/MRX-Systems/MRX-Core/commit/b80bd5e2))
|
|
20
|
+
- **🚀:** [Add caching functionality with cache utility] ([a54cd86f](https://github.com/MRX-Systems/MRX-Core/commit/a54cd86f))
|
|
21
|
+
- **🚀:** [Enhance caching mechanism with route tracking and metadata] ## Features - Implemented route tracking to cache responses based on request method and URL. - Enhanced cache storage to include metadata alongside the response. - Updated cache control headers to reflect cache hits and misses. ([1e77647f](https://github.com/MRX-Systems/MRX-Core/commit/1e77647f))
|
|
22
|
+
|
|
23
|
+
### 🔧 Fixes
|
|
24
|
+
|
|
25
|
+
- **🔧:** [Improve error handling in Repository class] ([af8b8ef2](https://github.com/MRX-Systems/MRX-Core/commit/af8b8ef2))
|
|
26
|
+
- **🔧:** [fix add x-cache MISS to the first request] - Added a check to ensure 'x-cache' header is set to 'MISS' if not already defined. - This change enhances the clarity of cache status in responses. ([26eb7929](https://github.com/MRX-Systems/MRX-Core/commit/26eb7929))
|
|
27
|
+
- **🔧:** [Update cache control headers to use metadata TTL] ([d70ce44a](https://github.com/MRX-Systems/MRX-Core/commit/d70ce44a))
|
|
28
|
+
|
|
29
|
+
### 🧹 Refactors
|
|
30
|
+
|
|
31
|
+
- **🧹:** [Totp module little clean] ([701c9a3b](https://github.com/MRX-Systems/MRX-Core/commit/701c9a3b))
|
|
32
|
+
- **🧹:** [Enhance error handling structure in error plugin] ## Refactoring - Improved the structure of the error handling in the error plugin. - Updated the validation error response to include detailed error information. ([883a17d2](https://github.com/MRX-Systems/MRX-Core/commit/883a17d2))
|
|
33
|
+
- **🧹:** [Remove JWT plugin and related files for cleanup] ([4805d0d0](https://github.com/MRX-Systems/MRX-Core/commit/4805d0d0))
|
|
34
|
+
- **🧹:** [Rename ResolveDbHeader to dbResolverHeader for consistency] ([239b7898](https://github.com/MRX-Systems/MRX-Core/commit/239b7898))
|
|
35
|
+
- **🧹:** [Refactor like operator to use where clause] ## Refactoring - Changed the implementation of the `$like` operator to use `where` instead of `whereLike`. (for non case sensitive) ([a2cf66d2](https://github.com/MRX-Systems/MRX-Core/commit/a2cf66d2))
|
|
36
|
+
- **🧹:** [Change 'like' operator to use uppercase syntax] ## Refactoring - Updated the 'like' operator in the query builder to use uppercase 'LIKE'. ([19057d82](https://github.com/MRX-Systems/MRX-Core/commit/19057d82))
|
|
37
|
+
- **🧹:** [Remove return await in ioredisStore] ([2019a41c](https://github.com/MRX-Systems/MRX-Core/commit/2019a41c))
|
|
38
|
+
- **🧹:** [Remove rate limiting store implementation] ([aec26501](https://github.com/MRX-Systems/MRX-Core/commit/aec26501))
|
|
39
|
+
- **🧹:** [Refactor rate limiting to use kvStore] ([1d42fb97](https://github.com/MRX-Systems/MRX-Core/commit/1d42fb97))
|
|
40
|
+
|
|
41
|
+
### 📖 Documentation
|
|
42
|
+
|
|
43
|
+
- **📖:** [fix tsdoc CoreError to BaseError] ([8db68847](https://github.com/MRX-Systems/MRX-Core/commit/8db68847))
|
|
44
|
+
|
|
45
|
+
### 📦 Build
|
|
46
|
+
|
|
47
|
+
- **📦:** [update dependencies in package.json] ([2c69bbb5](https://github.com/MRX-Systems/MRX-Core/commit/2c69bbb5))
|
|
48
|
+
- **📦:** [Update nodemailer type definitions to version 7.0.1] ([387ac697](https://github.com/MRX-Systems/MRX-Core/commit/387ac697))
|
|
49
|
+
- **📦:** [Refactor JWT module paths for better organization] ([9f504873](https://github.com/MRX-Systems/MRX-Core/commit/9f504873))
|
|
50
|
+
- **📦:** [Update JWT module paths and dependencies] ([71eaca98](https://github.com/MRX-Systems/MRX-Core/commit/71eaca98))
|
|
51
|
+
- **📦:** [Update package.json for improved dependency management] ([f48a7fa6](https://github.com/MRX-Systems/MRX-Core/commit/f48a7fa6))
|
|
52
|
+
- **📦:** [Add kvStore module paths to builder] ([3020bf8a](https://github.com/MRX-Systems/MRX-Core/commit/3020bf8a))
|
|
53
|
+
- **📦:** [Update dependencies and add kvStore module paths] ([056c4b2b](https://github.com/MRX-Systems/MRX-Core/commit/056c4b2b))
|
|
54
|
+
- **📦:** [Remove kvStore module from build process] ## Build Changes - Removed './source/modules/kvStore/index.ts' from the build configuration. ([502e25a2](https://github.com/MRX-Systems/MRX-Core/commit/502e25a2))
|
|
55
|
+
- **📦:** [Remove kvStore module from exports] ([b2a02bc6](https://github.com/MRX-Systems/MRX-Core/commit/b2a02bc6))
|
|
56
|
+
- **📦:** [Add cache module to builder configuration] ## Build - Included cache module paths in the builder configuration. ([63681c8b](https://github.com/MRX-Systems/MRX-Core/commit/63681c8b))
|
|
57
|
+
- **📦:** [Add cache module exports to package.json] ([ef662af9](https://github.com/MRX-Systems/MRX-Core/commit/ef662af9))
|
|
21
58
|
|
|
22
|
-
###
|
|
59
|
+
### 🌊 Types
|
|
23
60
|
|
|
24
|
-
-
|
|
61
|
+
- **🌊:** [Update throwIfNoResult type in QueryOptions interface] Updated the `throwIfNoResult` property in the `QueryOptions` interface to accept an object with optional `message` and `code` properties, enhancing error handling capabilities. ([644ff8be](https://github.com/MRX-Systems/MRX-Core/commit/644ff8be))
|
|
62
|
+
- **🌊:** [Add KvStore interface for key-value store operations] ([ec2c8dea](https://github.com/MRX-Systems/MRX-Core/commit/ec2c8dea))
|
|
63
|
+
- **🌊:** [Add CacheOptions type definition and index export] ([7f17d79b](https://github.com/MRX-Systems/MRX-Core/commit/7f17d79b))
|
|
64
|
+
- **🌊:** [Add CacheItem type definition for caching mechanism] ([a10a15f7](https://github.com/MRX-Systems/MRX-Core/commit/a10a15f7))
|
|
25
65
|
|
|
26
66
|
### 🦉 Chore
|
|
27
67
|
|
|
28
|
-
- **🦉:** [Clean CHANGELOG] ([
|
|
68
|
+
- **🦉:** [Clean up CHANGELOG.md for better readability] ([d66fac36](https://github.com/MRX-Systems/MRX-Core/commit/d66fac36))
|
|
69
|
+
|
|
70
|
+
### 🧪 Tests
|
|
71
|
+
|
|
72
|
+
- **🧪:** [totp tests little clean] ([238ac25b](https://github.com/MRX-Systems/MRX-Core/commit/238ac25b))
|
|
73
|
+
- **🧪:** [Add test to hande custom code and refacto custom message] ([c7737572](https://github.com/MRX-Systems/MRX-Core/commit/c7737572))
|
|
74
|
+
- **🧪:** [Update validation error handling tests for new structure] ([42184d86](https://github.com/MRX-Systems/MRX-Core/commit/42184d86))
|
|
75
|
+
- **🧪:** [Remove JWT tests for cleanup] ([08ca9a71](https://github.com/MRX-Systems/MRX-Core/commit/08ca9a71))
|
|
76
|
+
- **🧪:** [[Add comprehensive tests for parseHumanTimeToSeconds function] ([8d2c37c1](https://github.com/MRX-Systems/MRX-Core/commit/8d2c37c1))
|
|
77
|
+
- **🧪:** [Add comprehensive tests for JWT signing and verification] ([6c281486](https://github.com/MRX-Systems/MRX-Core/commit/6c281486))
|
|
78
|
+
- **🧪:** [Add tests for parseHumanTimeToSeconds utility function] ([6bf5dbca](https://github.com/MRX-Systems/MRX-Core/commit/6bf5dbca))
|
|
79
|
+
- **🧪:** [Rename ResolveDbHeader to dbResolverHeader for consistency] ([8a5a4dd2](https://github.com/MRX-Systems/MRX-Core/commit/8a5a4dd2))
|
|
80
|
+
- **🧪:** [Add case insensitive Q operator filter test] ## Tests - Introduced a new test case for the Q operator to ensure it is case insensitive. ([fccfb182](https://github.com/MRX-Systems/MRX-Core/commit/fccfb182))
|
|
81
|
+
- **🧪:** [Refactor MSSQL test setup and enhance findByNamePattern] ([e1dcea34](https://github.com/MRX-Systems/MRX-Core/commit/e1dcea34))
|
|
82
|
+
- **🧪:** [Add comprehensive tests for MemoryStore functionality] ([25c165ec](https://github.com/MRX-Systems/MRX-Core/commit/25c165ec))
|
|
83
|
+
- **🧪:** [Refactor rate limit tests to use MemoryStore] ([1311cd07](https://github.com/MRX-Systems/MRX-Core/commit/1311cd07))
|
|
84
|
+
- **🧪:** [Remove MemoryStore test suite] ([e0fe6f39](https://github.com/MRX-Systems/MRX-Core/commit/e0fe6f39))
|
|
85
|
+
- **🧪:** [Add tests for generateCacheKey utility function] ## Tests - Implement unit tests for the `generateCacheKey` function. - Cover scenarios for requests with and without bodies. - Validate that identical requests produce the same cache key. - Ensure different bodies generate different cache keys. ([90562c7a](https://github.com/MRX-Systems/MRX-Core/commit/90562c7a))
|
|
86
|
+
- **🧪:** [Add comprehensive tests for cache module functionality] ([28d28d3d](https://github.com/MRX-Systems/MRX-Core/commit/28d28d3d))
|
|
87
|
+
- **🧪:** [Add test for specific TTL handling in cache logic] - Implemented a test to verify that the cache correctly handles specific TTL values in the `isCached` option. - The test checks that the cache returns a MISS header on the first request and verifies the cache-control header. - It also ensures that after the TTL expires, the cache still returns a MISS header on subsequent requests. ([9ca8a99c](https://github.com/MRX-Systems/MRX-Core/commit/9ca8a99c))
|
|
88
|
+
- **🧪:** [fix test name CoreError to BaseError] ([c02afec2](https://github.com/MRX-Systems/MRX-Core/commit/c02afec2))
|
|
89
|
+
|
|
90
|
+
### 🎨 Styles
|
|
91
|
+
|
|
92
|
+
- **🎨:** [fix import order in HOTP tests] Rearranged the import statements in the HOTP test file for consistency and improved readability. ([a66d34d6](https://github.com/MRX-Systems/MRX-Core/commit/a66d34d6))
|
|
93
|
+
- **🎨:** [Remove unnecessary blank line in signJWT function] Removed an extra blank line in the signJWT function for improved code readability and consistency. ([8ea44aef](https://github.com/MRX-Systems/MRX-Core/commit/8ea44aef))
|
|
29
94
|
|
|
30
95
|
### ❤️ Contributors
|
|
31
96
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// source/modules/totp/utils/createCounterBuffer.ts
|
|
2
|
+
var createCounterBuffer = (counter) => {
|
|
3
|
+
const counterBuffer = new ArrayBuffer(8);
|
|
4
|
+
const counterView = new DataView(counterBuffer);
|
|
5
|
+
if (typeof counter === "bigint")
|
|
6
|
+
counterView.setBigUint64(0, counter, false);
|
|
7
|
+
else
|
|
8
|
+
counterView.setUint32(4, counter, false);
|
|
9
|
+
return counterBuffer;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// source/modules/totp/utils/dynamicTruncation.ts
|
|
13
|
+
var dynamicTruncation = (hmacArray, digits) => {
|
|
14
|
+
const offset = hmacArray[hmacArray.length - 1] & 15;
|
|
15
|
+
const code = ((hmacArray[offset] & 127) << 24 | (hmacArray[offset + 1] & 255) << 16 | (hmacArray[offset + 2] & 255) << 8 | hmacArray[offset + 3] & 255) % 10 ** digits;
|
|
16
|
+
return code.toString().padStart(digits, "0");
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// source/modules/totp/utils/generateHmac.ts
|
|
20
|
+
import { webcrypto } from "crypto";
|
|
21
|
+
var generateHmac = async (key, data) => {
|
|
22
|
+
const hmac = await webcrypto.subtle.sign("HMAC", key, data);
|
|
23
|
+
return new Uint8Array(hmac);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { createCounterBuffer, dynamicTruncation, generateHmac };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KV_STORE_ERROR_KEYS
|
|
3
|
+
} from "./chunk-z1skzn1j.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseError
|
|
6
|
+
} from "./chunk-vknq69e0.js";
|
|
7
|
+
|
|
8
|
+
// source/modules/kvStore/memory/memoryStore.ts
|
|
9
|
+
class MemoryStore {
|
|
10
|
+
_store = new Map;
|
|
11
|
+
_cleanupInterval;
|
|
12
|
+
_cleanupTimer = null;
|
|
13
|
+
constructor(cleanupIntervalMs) {
|
|
14
|
+
this._cleanupInterval = cleanupIntervalMs ?? 300000;
|
|
15
|
+
this._startCleanup();
|
|
16
|
+
}
|
|
17
|
+
get(key) {
|
|
18
|
+
const entry = this._store.get(key);
|
|
19
|
+
if (!entry)
|
|
20
|
+
return null;
|
|
21
|
+
const now = Date.now();
|
|
22
|
+
if (now > entry.expiresAt && entry.expiresAt !== -1) {
|
|
23
|
+
this._store.delete(key);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return entry.value;
|
|
27
|
+
}
|
|
28
|
+
set(key, value, ttlSec) {
|
|
29
|
+
const expiresAt = ttlSec ? Date.now() + ttlSec * 1000 : -1;
|
|
30
|
+
this._store.set(key, { value, expiresAt });
|
|
31
|
+
}
|
|
32
|
+
increment(key, amount = 1) {
|
|
33
|
+
const current = this.get(key);
|
|
34
|
+
const entry = this._store.get(key);
|
|
35
|
+
if (current !== null && typeof current !== "number")
|
|
36
|
+
throw new BaseError({
|
|
37
|
+
message: KV_STORE_ERROR_KEYS.NOT_INTEGER
|
|
38
|
+
});
|
|
39
|
+
const currentValue = current ?? 0;
|
|
40
|
+
const newValue = currentValue + amount;
|
|
41
|
+
const expiresAt = entry ? entry.expiresAt : -1;
|
|
42
|
+
this._store.set(key, { value: newValue, expiresAt });
|
|
43
|
+
return newValue;
|
|
44
|
+
}
|
|
45
|
+
decrement(key, amount = 1) {
|
|
46
|
+
const current = this.get(key);
|
|
47
|
+
const entry = this._store.get(key);
|
|
48
|
+
if (current !== null && typeof current !== "number")
|
|
49
|
+
throw new BaseError({
|
|
50
|
+
message: KV_STORE_ERROR_KEYS.NOT_INTEGER
|
|
51
|
+
});
|
|
52
|
+
const currentValue = current ?? 0;
|
|
53
|
+
const newValue = currentValue - amount;
|
|
54
|
+
const expiresAt = entry ? entry.expiresAt : -1;
|
|
55
|
+
this._store.set(key, { value: newValue, expiresAt });
|
|
56
|
+
return newValue;
|
|
57
|
+
}
|
|
58
|
+
del(key) {
|
|
59
|
+
return this._store.delete(key);
|
|
60
|
+
}
|
|
61
|
+
expire(key, ttlSec) {
|
|
62
|
+
const entry = this._store.get(key);
|
|
63
|
+
if (!entry)
|
|
64
|
+
return false;
|
|
65
|
+
entry.expiresAt = Date.now() + ttlSec * 1000;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
ttl(key) {
|
|
69
|
+
const entry = this._store.get(key);
|
|
70
|
+
if (!entry)
|
|
71
|
+
return -1;
|
|
72
|
+
if (entry.expiresAt === -1)
|
|
73
|
+
return -1;
|
|
74
|
+
const remaining = entry.expiresAt - Date.now();
|
|
75
|
+
return remaining > 0 ? Math.ceil(remaining / 1000) : -1;
|
|
76
|
+
}
|
|
77
|
+
clean() {
|
|
78
|
+
const sizeBefore = this._store.size;
|
|
79
|
+
this._store.clear();
|
|
80
|
+
return sizeBefore;
|
|
81
|
+
}
|
|
82
|
+
_startCleanup() {
|
|
83
|
+
if (this._cleanupTimer)
|
|
84
|
+
return;
|
|
85
|
+
this._cleanupTimer = setInterval(() => {
|
|
86
|
+
this._removeExpiredEntries();
|
|
87
|
+
}, this._cleanupInterval);
|
|
88
|
+
}
|
|
89
|
+
_removeExpiredEntries() {
|
|
90
|
+
const now = Date.now();
|
|
91
|
+
for (const [key, entry] of this._store.entries())
|
|
92
|
+
if (entry.expiresAt !== -1 && now > entry.expiresAt)
|
|
93
|
+
this._store.delete(key);
|
|
94
|
+
}
|
|
95
|
+
destroy() {
|
|
96
|
+
if (this._cleanupTimer) {
|
|
97
|
+
clearInterval(this._cleanupTimer);
|
|
98
|
+
this._cleanupTimer = null;
|
|
99
|
+
}
|
|
100
|
+
this._store.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { MemoryStore };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// source/modules/elysia/cache/utils/generateCacheKey.ts
|
|
2
|
+
var _calculateBodyHash = async (body, hasher) => {
|
|
3
|
+
if (!body)
|
|
4
|
+
return;
|
|
5
|
+
const reader = body.getReader();
|
|
6
|
+
try {
|
|
7
|
+
while (true) {
|
|
8
|
+
const { done, value } = await reader.read();
|
|
9
|
+
if (done)
|
|
10
|
+
break;
|
|
11
|
+
if (value)
|
|
12
|
+
hasher.update(new Uint8Array(value));
|
|
13
|
+
}
|
|
14
|
+
} finally {
|
|
15
|
+
reader.releaseLock();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var generateCacheKey = async (request) => {
|
|
19
|
+
const { method, url, headers } = request;
|
|
20
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
21
|
+
hasher.update(method);
|
|
22
|
+
hasher.update(url);
|
|
23
|
+
hasher.update(JSON.stringify(headers));
|
|
24
|
+
await _calculateBodyHash(request.body, hasher);
|
|
25
|
+
return hasher.digest("hex");
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { generateCacheKey };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS
|
|
3
|
+
} from "./chunk-sepwfqdh.js";
|
|
4
|
+
import {
|
|
5
|
+
BaseError
|
|
6
|
+
} from "./chunk-vknq69e0.js";
|
|
7
|
+
|
|
8
|
+
// source/modules/jwt/utils/parseHumanTimeToSeconds.ts
|
|
9
|
+
var TIME_UNITS = {
|
|
10
|
+
SECOND: 1,
|
|
11
|
+
MINUTE: 60,
|
|
12
|
+
HOUR: 60 * 60,
|
|
13
|
+
DAY: 60 * 60 * 24,
|
|
14
|
+
WEEK: 60 * 60 * 24 * 7,
|
|
15
|
+
YEAR: 60 * 60 * 24 * 365.25
|
|
16
|
+
};
|
|
17
|
+
var TIME_EXPRESSION_REGEX = /^(\+|-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
18
|
+
var UNIT_MAPPINGS = {
|
|
19
|
+
s: TIME_UNITS.SECOND,
|
|
20
|
+
sec: TIME_UNITS.SECOND,
|
|
21
|
+
secs: TIME_UNITS.SECOND,
|
|
22
|
+
second: TIME_UNITS.SECOND,
|
|
23
|
+
seconds: TIME_UNITS.SECOND,
|
|
24
|
+
m: TIME_UNITS.MINUTE,
|
|
25
|
+
min: TIME_UNITS.MINUTE,
|
|
26
|
+
mins: TIME_UNITS.MINUTE,
|
|
27
|
+
minute: TIME_UNITS.MINUTE,
|
|
28
|
+
minutes: TIME_UNITS.MINUTE,
|
|
29
|
+
h: TIME_UNITS.HOUR,
|
|
30
|
+
hr: TIME_UNITS.HOUR,
|
|
31
|
+
hrs: TIME_UNITS.HOUR,
|
|
32
|
+
hour: TIME_UNITS.HOUR,
|
|
33
|
+
hours: TIME_UNITS.HOUR,
|
|
34
|
+
d: TIME_UNITS.DAY,
|
|
35
|
+
day: TIME_UNITS.DAY,
|
|
36
|
+
days: TIME_UNITS.DAY,
|
|
37
|
+
w: TIME_UNITS.WEEK,
|
|
38
|
+
week: TIME_UNITS.WEEK,
|
|
39
|
+
weeks: TIME_UNITS.WEEK,
|
|
40
|
+
y: TIME_UNITS.YEAR,
|
|
41
|
+
yr: TIME_UNITS.YEAR,
|
|
42
|
+
yrs: TIME_UNITS.YEAR,
|
|
43
|
+
year: TIME_UNITS.YEAR,
|
|
44
|
+
years: TIME_UNITS.YEAR
|
|
45
|
+
};
|
|
46
|
+
var parseHumanTimeToSeconds = (timeExpression) => {
|
|
47
|
+
const match = TIME_EXPRESSION_REGEX.exec(timeExpression);
|
|
48
|
+
if (!match || match[4] && match[1])
|
|
49
|
+
throw new BaseError({
|
|
50
|
+
message: PARSE_HUMAN_TIME_TO_SECONDS_ERROR_KEYS.INVALID_TIME_EXPRESSION
|
|
51
|
+
});
|
|
52
|
+
const [, sign, valueStr, unitStr, direction] = match;
|
|
53
|
+
const value = parseFloat(valueStr);
|
|
54
|
+
const unit = unitStr.toLowerCase();
|
|
55
|
+
const multiplier = UNIT_MAPPINGS[unit];
|
|
56
|
+
const seconds = Math.round(value * multiplier);
|
|
57
|
+
if (sign === "-" || direction === "ago")
|
|
58
|
+
return -seconds;
|
|
59
|
+
return seconds;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { parseHumanTimeToSeconds };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// source/modules/totp/enums/totpErrorKeys.ts
|
|
2
|
+
var TOTP_ERROR_KEYS = {
|
|
3
|
+
INVALID_BASE32_CHARACTER: "totp.error.invalid_base32_character",
|
|
4
|
+
INVALID_SECRET_LENGTH: "totp.error.invalid_secret_length",
|
|
5
|
+
INVALID_ALGORITHM: "totp.error.invalid_algorithm",
|
|
6
|
+
INVALID_OTP_AUTH_URI: "totp.error.invalid_otp_auth_uri",
|
|
7
|
+
MISSING_SECRET: "totp.error.missing_secret"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { TOTP_ERROR_KEYS };
|
|
@@ -27,7 +27,7 @@ var _operators = {
|
|
|
27
27
|
const likeValue = `%${v}%`;
|
|
28
28
|
if (isDateString(v))
|
|
29
29
|
return q.whereRaw(`CONVERT(VARCHAR, ${c}, 23) LIKE ?`, [likeValue]);
|
|
30
|
-
return q.
|
|
30
|
+
return q.where(c, "LIKE", likeValue);
|
|
31
31
|
},
|
|
32
32
|
$nlike: (q, c, v) => {
|
|
33
33
|
const likeValue = `%${v}%`;
|
|
@@ -124,10 +124,11 @@ class Repository {
|
|
|
124
124
|
}
|
|
125
125
|
_applySelectedFields(query, selectedFields) {
|
|
126
126
|
const qMethod = query._method;
|
|
127
|
+
const sanitizedFields = selectedFields ? Array.isArray(selectedFields) ? selectedFields.map((selectedField) => `${selectedField} as ${selectedField}`) : `${selectedFields} as ${selectedFields}` : "*";
|
|
127
128
|
if (qMethod === "del" || qMethod === "update" || qMethod === "insert")
|
|
128
|
-
query.returning(
|
|
129
|
+
query.returning(sanitizedFields, { includeTriggerModifications: true });
|
|
129
130
|
else
|
|
130
|
-
query.select(
|
|
131
|
+
query.select(sanitizedFields);
|
|
131
132
|
}
|
|
132
133
|
_applyFilter(query, search) {
|
|
133
134
|
const processing = (query2, search2) => {
|
|
@@ -166,13 +167,13 @@ class Repository {
|
|
|
166
167
|
if (!(qMethod === "select"))
|
|
167
168
|
return;
|
|
168
169
|
if (!orderBy)
|
|
169
|
-
query.orderBy(this._table.primaryKey[0]
|
|
170
|
+
query.orderBy(`[${this._table.name}].${this._table.primaryKey[0]}`, "asc");
|
|
170
171
|
else if (Array.isArray(orderBy))
|
|
171
172
|
orderBy.forEach((item) => {
|
|
172
|
-
query.orderBy(item.selectedField
|
|
173
|
+
query.orderBy(`[${this._table.name}].${item.selectedField}`, item.direction);
|
|
173
174
|
});
|
|
174
175
|
else
|
|
175
|
-
query.orderBy(orderBy.selectedField
|
|
176
|
+
query.orderBy(`[${this._table.name}].${orderBy.selectedField}`, orderBy.direction);
|
|
176
177
|
}
|
|
177
178
|
_applyQueryOptions(query, options) {
|
|
178
179
|
this._applyFilter(query, options?.filters);
|
|
@@ -201,11 +202,11 @@ class Repository {
|
|
|
201
202
|
const result = await query;
|
|
202
203
|
if (throwIfNoResult && result.length === 0)
|
|
203
204
|
throw new HttpError({
|
|
204
|
-
message: DATABASE_ERROR_KEYS.MSSQL_NO_RESULT,
|
|
205
|
+
message: typeof throwIfNoResult === "object" && throwIfNoResult.message ? throwIfNoResult.message : DATABASE_ERROR_KEYS.MSSQL_NO_RESULT,
|
|
205
206
|
cause: {
|
|
206
207
|
query: query.toSQL().sql
|
|
207
208
|
},
|
|
208
|
-
httpStatusCode: 404
|
|
209
|
+
httpStatusCode: typeof throwIfNoResult === "object" && throwIfNoResult.code ? throwIfNoResult.code : 404
|
|
209
210
|
});
|
|
210
211
|
return result;
|
|
211
212
|
} catch (error) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-dwfyt1m6.js";
|
|
7
7
|
import {
|
|
8
8
|
MSSQL
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-m18th1g5.js";
|
|
10
10
|
import {
|
|
11
11
|
HttpError
|
|
12
12
|
} from "./chunk-683sda6e.js";
|
|
@@ -42,7 +42,7 @@ var dbResolver = (database) => {
|
|
|
42
42
|
}).resolve({ as: "global" }, async ({ headers }) => _resolveDatabaseConnection(database, headers));
|
|
43
43
|
if (typeof database === "object")
|
|
44
44
|
app.model({
|
|
45
|
-
|
|
45
|
+
dbResolverHeader: t.Object({
|
|
46
46
|
"database-using": t.String({
|
|
47
47
|
description: "The name of the database to be used for the request"
|
|
48
48
|
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// source/modules/kvStore/enums/kvStoreErrorKeys.ts
|
|
2
|
+
var KV_STORE_ERROR_KEYS = {
|
|
3
|
+
NOT_INTEGER: "kv-store.error.not_integer",
|
|
4
|
+
CONNECTION_FAILED: "kv-store.error.connection_failed",
|
|
5
|
+
CLOSING_CONNECTION_FAILED: "kv-store.error.closing_connection_failed"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { KV_STORE_ERROR_KEYS };
|
|
@@ -103,7 +103,7 @@ export declare const filterByValue: <TObject extends Readonly<object>>(data: Rea
|
|
|
103
103
|
* @param data - The object whose keys are to be transformed.
|
|
104
104
|
* @param transformer - The key transformation strategy to use.
|
|
105
105
|
*
|
|
106
|
-
* @throws ({@link
|
|
106
|
+
* @throws ({@link BaseError}) - If the provided data object is null or undefined.
|
|
107
107
|
*
|
|
108
108
|
* @returns A new object with transformed keys.
|
|
109
109
|
*
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
MSSQL,
|
|
4
4
|
Table
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import"../../chunk-
|
|
5
|
+
} from "../../chunk-m18th1g5.js";
|
|
6
|
+
import"../../chunk-syhskygx.js";
|
|
7
7
|
import"../../chunk-5qtpggzv.js";
|
|
8
8
|
import"../../chunk-yvyahr2h.js";
|
|
9
9
|
import"../../chunk-zaje5tv4.js";
|