@hkdigital/lib-core 0.4.12 → 0.4.13
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 +4 -1
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/errors.js +1 -1
- package/dist/auth/jwt/constants.d.ts +6 -0
- package/dist/auth/jwt/constants.js +13 -0
- package/dist/auth/jwt/core.d.ts +38 -0
- package/dist/auth/jwt/core.js +114 -0
- package/dist/auth/jwt/errors.d.ts +39 -0
- package/dist/auth/jwt/errors.js +74 -0
- package/dist/auth/jwt/generators.d.ts +29 -0
- package/dist/auth/jwt/generators.js +53 -0
- package/dist/auth/jwt/typedef.d.ts +159 -0
- package/dist/auth/jwt/typedef.js +72 -0
- package/dist/auth/jwt/util.d.ts +6 -0
- package/dist/auth/jwt/util.js +43 -0
- package/dist/auth/jwt.d.ts +4 -0
- package/dist/auth/jwt.js +12 -0
- package/dist/generic/data/classes/IterableTree.js +1 -1
- package/dist/generic/data/classes/Selector.js +1 -1
- package/dist/generic/promises/classes/HkPromise.js +1 -1
- package/dist/generic/streaming/classes/ServerEventsStore.js +1 -1
- package/dist/generic/typedef.d.ts +2 -0
- package/dist/generic/typedef.js +2 -0
- package/dist/logging/internal/adapters/console.js +3 -3
- package/dist/logging/internal/adapters/pino.js +17 -3
- package/dist/logging/internal/adapters/pino.js__ +260 -0
- package/dist/logging/internal/test-errors.js +3 -2
- package/dist/network/http/errors.js +10 -4
- package/dist/network/http/headers.js +1 -1
- package/dist/network/http/http-request.js +1 -1
- package/dist/network/http/json-request.js +1 -1
- package/dist/network/http/response.js +1 -1
- package/dist/network/loaders/audio/AudioScene.svelte.js +1 -1
- package/dist/network/loaders/image/ImageScene.svelte.js +1 -1
- package/dist/network/loaders/image/utils/index.js +1 -1
- package/dist/network/states/NetworkLoader.svelte.js +1 -1
- package/dist/network/typedef.d.ts +2 -0
- package/dist/network/typedef.js +3 -1
- package/dist/services/service-base/ServiceBase.js +1 -3
- package/dist/services/typedef.d.ts +2 -0
- package/dist/services/typedef.js +2 -0
- package/dist/state/typedef.d.ts +3 -0
- package/dist/state/typedef.js +3 -0
- package/dist/ui/components/drag-drop/drag-state.svelte.d.ts +3 -3
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/ui/components/presenter/util.js +1 -1
- package/dist/ui/components/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +3 -3
- package/dist/util/array/index.d.ts +0 -4
- package/dist/util/array/index.js +1 -5
- package/dist/util/array.d.ts +1 -0
- package/dist/util/array.js +9 -0
- package/dist/util/bases/base64.d.ts +8 -0
- package/dist/util/bases/base64.js +23 -0
- package/dist/util/bases/index.d.ts +0 -1
- package/dist/util/bases/index.js +0 -1
- package/dist/util/bases.d.ts +2 -0
- package/dist/util/bases.js +10 -0
- package/dist/util/compare.d.ts +1 -0
- package/dist/util/compare.js +9 -0
- package/dist/util/css/index.d.ts +0 -1
- package/dist/util/css/index.js +0 -1
- package/dist/util/css.d.ts +1 -0
- package/dist/util/css.js +8 -0
- package/dist/util/env.d.ts +1 -0
- package/dist/util/env.js +8 -0
- package/dist/util/exceptions.d.ts +1 -0
- package/dist/util/exceptions.js +8 -0
- package/dist/util/expect/arrays.js +2 -0
- package/dist/util/expect/compounds.d.ts +20 -0
- package/dist/util/expect/compounds.js +48 -0
- package/dist/util/expect/objects.d.ts +28 -0
- package/dist/util/expect/objects.js +70 -0
- package/dist/util/expect/primitives.d.ts +31 -1
- package/dist/util/expect/primitives.js +56 -0
- package/dist/util/expect/values.d.ts +26 -0
- package/dist/util/expect/values.js +48 -0
- package/dist/util/expect.d.ts +6 -0
- package/dist/util/expect.js +31 -0
- package/dist/util/function/index.js +1 -1
- package/dist/util/function.d.ts +1 -0
- package/dist/util/function.js +8 -0
- package/dist/util/geometry.d.ts +1 -0
- package/dist/util/geometry.js +9 -0
- package/dist/util/is.d.ts +1 -0
- package/dist/util/is.js +8 -0
- package/dist/util/iterate/index.js +1 -1
- package/dist/util/iterate.d.ts +1 -0
- package/dist/util/iterate.js +8 -0
- package/dist/util/object/index.js +2 -2
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +8 -0
- package/dist/util/random/bytes.d.ts +28 -0
- package/dist/util/random/bytes.js +72 -0
- package/dist/util/random.d.ts +1 -0
- package/dist/util/random.js +9 -0
- package/dist/util/singleton/index.js +1 -1
- package/dist/util/singleton.d.ts +1 -0
- package/dist/util/singleton.js +8 -0
- package/dist/util/ssr.d.ts +1 -0
- package/dist/util/ssr.js +8 -0
- package/dist/util/string/convert.js +1 -1
- package/dist/util/string/index.d.ts +0 -5
- package/dist/util/string/index.js +0 -5
- package/dist/util/string/interpolate.js +1 -1
- package/dist/util/string.d.ts +5 -0
- package/dist/util/string.js +12 -0
- package/dist/util/svelte/index.d.ts +0 -3
- package/dist/util/svelte/index.js +0 -4
- package/dist/util/svelte.d.ts +3 -0
- package/dist/util/svelte.js +11 -0
- package/dist/util/sveltekit/index.d.ts +0 -1
- package/dist/util/sveltekit/index.js +0 -1
- package/dist/util/sveltekit/route-folders/index.js +1 -1
- package/dist/util/sveltekit.d.ts +1 -0
- package/dist/util/sveltekit.js +8 -0
- package/dist/util/time/index.d.ts +7 -0
- package/dist/util/time/index.js +12 -1
- package/dist/util/time.d.ts +1 -0
- package/dist/util/time.js +1 -0
- package/dist/util/unique.d.ts +1 -0
- package/dist/util/unique.js +8 -0
- package/dist/valibot/{index.d.ts → valibot.d.ts} +1 -2
- package/dist/valibot/{index.js → valibot.js} +1 -6
- package/package.json +3 -1
- package/dist/auth/errors/jwt.d.ts +0 -8
- package/dist/auth/errors/jwt.js +0 -5
- package/dist/util/expect/index.d.ts +0 -103
- package/dist/util/expect/index.js +0 -259
- package/dist/util/index.d.ts +0 -10
- /package/dist/util/{geo → geometry}/index.d.ts +0 -0
- /package/dist/util/{geo → geometry}/index.js +0 -0
- /package/dist/util/{index.js → index.js__} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bytes.js
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Cross-platform random byte generation utilities using Web Crypto API
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as expect from '../expect.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate cryptographically secure random bytes
|
|
12
|
+
* - Uses Web Crypto API (works in Node.js 16+ and all modern browsers)
|
|
13
|
+
* - Returns Uint8Array for maximum compatibility
|
|
14
|
+
*
|
|
15
|
+
* @param {number} length - Number of bytes to generate
|
|
16
|
+
*
|
|
17
|
+
* @returns {Uint8Array} Random bytes
|
|
18
|
+
*/
|
|
19
|
+
export function randomBytes(length) {
|
|
20
|
+
expect.positiveNumber(length);
|
|
21
|
+
|
|
22
|
+
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
23
|
+
// Modern browsers + Node.js 16+
|
|
24
|
+
return crypto.getRandomValues(new Uint8Array(length));
|
|
25
|
+
} else if (typeof require !== 'undefined') {
|
|
26
|
+
// Fallback for older Node.js environments
|
|
27
|
+
try {
|
|
28
|
+
const { randomBytes: nodeRandomBytes } = require('crypto');
|
|
29
|
+
return new Uint8Array(nodeRandomBytes(length));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error('No secure random generator available');
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
throw new Error('No secure random generator available');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generate random bytes and return as base64 string
|
|
40
|
+
* - Cross-platform base64 encoding
|
|
41
|
+
*
|
|
42
|
+
* @param {number} length - Number of bytes to generate
|
|
43
|
+
*
|
|
44
|
+
* @returns {string} Base64 encoded random bytes
|
|
45
|
+
*/
|
|
46
|
+
export function randomBytesBase64(length) {
|
|
47
|
+
const bytes = randomBytes(length);
|
|
48
|
+
|
|
49
|
+
// Convert to base64 using available method
|
|
50
|
+
if (typeof Buffer !== 'undefined') {
|
|
51
|
+
// Node.js - most efficient
|
|
52
|
+
return Buffer.from(bytes).toString('base64');
|
|
53
|
+
} else {
|
|
54
|
+
// Browser - use btoa
|
|
55
|
+
return btoa(String.fromCharCode(...bytes));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generate random bytes and return as hex string
|
|
61
|
+
* - Cross-platform hex encoding
|
|
62
|
+
*
|
|
63
|
+
* @param {number} length - Number of bytes to generate
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} Hex encoded random bytes
|
|
66
|
+
*/
|
|
67
|
+
export function randomBytesHex(length) {
|
|
68
|
+
const bytes = randomBytes(length);
|
|
69
|
+
|
|
70
|
+
// Convert to hex string
|
|
71
|
+
return Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./random/bytes.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./singleton/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ssr/index.js";
|
package/dist/util/ssr.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String utilities main export
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This module provides string manipulation and processing utilities.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './string/array-path.js';
|
|
9
|
+
export * from './string/convert.js';
|
|
10
|
+
export * from './string/fs.js';
|
|
11
|
+
export * from './string/interpolate.js';
|
|
12
|
+
export * from './string/pad.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte utilities main export
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This module provides Svelte-specific utilities including loading trackers,
|
|
6
|
+
* observers, and waiting utilities.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './svelte/loading/loading-tracker.svelte.js';
|
|
10
|
+
export * from './svelte/observe/index.js';
|
|
11
|
+
export * from './svelte/wait/index.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./route-folders/index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './route-folders/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdir } from 'node:fs/promises';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { kebabToTitleCase, basename } from '../../string
|
|
4
|
+
import { kebabToTitleCase, basename } from '../../string.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Validates if a path is within the project's src/routes directory
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./sveltekit/route-folders/index.js";
|
|
@@ -13,6 +13,13 @@
|
|
|
13
13
|
* @returns {HkPromise} promise that resolves after a specified timeout
|
|
14
14
|
*/
|
|
15
15
|
export function delay(delayOrMinDelayMs: number, maxDelayMs?: number): HkPromise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns Date.now(), later this method may be extended with time
|
|
18
|
+
* synchronisaiton
|
|
19
|
+
*
|
|
20
|
+
* @return {number} date timestamp
|
|
21
|
+
*/
|
|
22
|
+
export function now(): number;
|
|
16
23
|
/**
|
|
17
24
|
* Get the number of milliseconds since the specified time stamp of the default
|
|
18
25
|
* reference time stamp TIME_2025_01_01
|
package/dist/util/time/index.js
CHANGED
|
@@ -85,6 +85,17 @@ export function delay(delayOrMinDelayMs, maxDelayMs) {
|
|
|
85
85
|
return promise;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Returns Date.now(), later this method may be extended with time
|
|
90
|
+
* synchronisaiton
|
|
91
|
+
*
|
|
92
|
+
* @return {number} date timestamp
|
|
93
|
+
*/
|
|
94
|
+
export function now()
|
|
95
|
+
{
|
|
96
|
+
return Date.now();
|
|
97
|
+
}
|
|
98
|
+
|
|
88
99
|
/**
|
|
89
100
|
* Get the number of milliseconds since the specified time stamp of the default
|
|
90
101
|
* reference time stamp TIME_2025_01_01
|
|
@@ -94,7 +105,7 @@ export function delay(delayOrMinDelayMs, maxDelayMs) {
|
|
|
94
105
|
* @returns {number} number of milliseconds since the specified time
|
|
95
106
|
*/
|
|
96
107
|
export function sinceMs(sinceMs = TIME_2025_01_01) {
|
|
97
|
-
return
|
|
108
|
+
return now() - sinceMs;
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./time/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './time/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./unique/index.js";
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as valibot from 'valibot';
|
|
2
2
|
|
|
3
|
-
// export * from './date.js';
|
|
4
|
-
|
|
5
|
-
export * from './parsers.js';
|
|
6
|
-
|
|
7
3
|
/**
|
|
8
4
|
* Custom parse function that wraps valibot's original parse
|
|
9
5
|
* for better stack trace detection in error logging
|
|
@@ -30,5 +26,4 @@ Object.defineProperty(v, 'parse', {
|
|
|
30
26
|
configurable: true
|
|
31
27
|
});
|
|
32
28
|
|
|
33
|
-
export { v };
|
|
34
|
-
export default valibot;
|
|
29
|
+
export { v, valibot };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hkdigital/lib-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "HKdigital",
|
|
6
6
|
"url": "https://hkdigital.nl"
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@steeze-ui/heroicons": "^2.4.2",
|
|
78
78
|
"@sveltejs/kit": "^2.28.0",
|
|
79
79
|
"eslint-plugin-import": "^2.32.0",
|
|
80
|
+
"jsonwebtoken": "^9.0.0",
|
|
80
81
|
"pino": "^9.8.0",
|
|
81
82
|
"pino-pretty": "^13.1.1",
|
|
82
83
|
"runed": "^0.31.1",
|
|
@@ -107,6 +108,7 @@
|
|
|
107
108
|
"fake-indexeddb": "^6.1.0",
|
|
108
109
|
"globals": "^16.3.0",
|
|
109
110
|
"jsdom": "^26.1.0",
|
|
111
|
+
"jsonwebtoken": "^9.0.0",
|
|
110
112
|
"npm-check-updates": "^18.0.2",
|
|
111
113
|
"npm-run-all": "^4.1.5",
|
|
112
114
|
"pino": "^9.8.0",
|
package/dist/auth/errors/jwt.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throws a validation error if value is not an Error instance
|
|
3
|
-
*
|
|
4
|
-
* @param {any} value
|
|
5
|
-
*/
|
|
6
|
-
export function error_(value: any): void;
|
|
7
|
-
/**
|
|
8
|
-
* Expect a value not to be null
|
|
9
|
-
*
|
|
10
|
-
* @param {any} value
|
|
11
|
-
*/
|
|
12
|
-
export function notNull(value: any): void;
|
|
13
|
-
/**
|
|
14
|
-
* Expect a value to be a boolean and true
|
|
15
|
-
*
|
|
16
|
-
* @param {any} value
|
|
17
|
-
*/
|
|
18
|
-
export function _true(value: any): void;
|
|
19
|
-
/**
|
|
20
|
-
* Expect a positive number
|
|
21
|
-
*
|
|
22
|
-
* @param {any} value
|
|
23
|
-
*/
|
|
24
|
-
export function positiveNumber(value: any): void;
|
|
25
|
-
/**
|
|
26
|
-
* Throws a validation error if value is not a string
|
|
27
|
-
*
|
|
28
|
-
* @param {any} value
|
|
29
|
-
*/
|
|
30
|
-
export function notEmptyString(value: any): void;
|
|
31
|
-
/**
|
|
32
|
-
* Throws a validation error if value is not iterable
|
|
33
|
-
*
|
|
34
|
-
* @param {any} value
|
|
35
|
-
*/
|
|
36
|
-
export function iterable(value: any): void;
|
|
37
|
-
/**
|
|
38
|
-
* Throws a validation error if value is not a a store (has not subscribe
|
|
39
|
-
* method)
|
|
40
|
-
*
|
|
41
|
-
* @param {any} value
|
|
42
|
-
*/
|
|
43
|
-
export function store(value: any): void;
|
|
44
|
-
/**
|
|
45
|
-
* Throws a validation error if value is not an object or the value
|
|
46
|
-
* is an array
|
|
47
|
-
*
|
|
48
|
-
* @param {any} value
|
|
49
|
-
*/
|
|
50
|
-
export function objectNoArray(value: any): void;
|
|
51
|
-
/**
|
|
52
|
-
* Throws a validation error if value is not an object or the value
|
|
53
|
-
* is a function
|
|
54
|
-
*
|
|
55
|
-
* @param {any} value
|
|
56
|
-
*/
|
|
57
|
-
export function objectNoFunction(value: any): void;
|
|
58
|
-
/**
|
|
59
|
-
* Throws a validation error if value is not an object or null
|
|
60
|
-
*
|
|
61
|
-
* @param {any} value
|
|
62
|
-
*/
|
|
63
|
-
export function objectOrNull(value: any): void;
|
|
64
|
-
/**
|
|
65
|
-
* Throws a validation error if value is not an array or Set
|
|
66
|
-
*
|
|
67
|
-
* @param {any} value
|
|
68
|
-
*/
|
|
69
|
-
export function arrayOrSet(value: any): void;
|
|
70
|
-
export * from "./arrays.js";
|
|
71
|
-
export * from "./primitives.js";
|
|
72
|
-
export * from "./url.js";
|
|
73
|
-
/**
|
|
74
|
-
* Throws a validation error if value is not an object
|
|
75
|
-
*
|
|
76
|
-
* @param {any} value
|
|
77
|
-
*/
|
|
78
|
-
declare function object_(value: any): void;
|
|
79
|
-
/**
|
|
80
|
-
* Throws a validation error if value is not a function
|
|
81
|
-
*
|
|
82
|
-
* @param {any} value
|
|
83
|
-
*/
|
|
84
|
-
declare function function_(value: any): void;
|
|
85
|
-
/**
|
|
86
|
-
* Throws a validation error if value is not a Promise
|
|
87
|
-
*
|
|
88
|
-
* @param {any} value
|
|
89
|
-
*/
|
|
90
|
-
declare function promise_(value: any): void;
|
|
91
|
-
/**
|
|
92
|
-
* Throws a validation error if value is not a Map
|
|
93
|
-
*
|
|
94
|
-
* @param {any} value
|
|
95
|
-
*/
|
|
96
|
-
declare function map_(value: any): void;
|
|
97
|
-
/**
|
|
98
|
-
* Throws a validation error if value is not a Set
|
|
99
|
-
*
|
|
100
|
-
* @param {any} value
|
|
101
|
-
*/
|
|
102
|
-
declare function set_(value: any): void;
|
|
103
|
-
export { object_ as object, function_ as function, _function as function, function_ as class, _class as class, promise_ as promise, map_ as map, set_ as set, error_ as error, _true as true, _true as true };
|