toolbox-x 2.2.5 → 2.3.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 +10 -0
- package/dist/{guards-Dc9MB9on.mjs → basics-B7Sqf33u.mjs} +233 -233
- package/dist/{guards-BSwFQX1M.cjs → basics-Cif013VV.cjs} +233 -233
- package/dist/{colors.cjs → colors/index.cjs} +6 -6
- package/dist/{colors.d.mts → colors/index.d.cts} +2 -2
- package/dist/{colors.d.cts → colors/index.d.mts} +2 -2
- package/dist/{colors.mjs → colors/index.mjs} +6 -6
- package/dist/constants.cjs +13 -13
- package/dist/constants.mjs +3 -3
- package/dist/{converter.cjs → converter/index.cjs} +1 -1
- package/dist/{converter.d.cts → converter/index.d.cts} +2 -2
- package/dist/{converter.d.mts → converter/index.d.mts} +2 -2
- package/dist/{converter.mjs → converter/index.mjs} +1 -1
- package/dist/{date.cjs → date/index.cjs} +7 -7
- package/dist/{date.d.cts → date/index.d.cts} +1 -1
- package/dist/{date.d.mts → date/index.d.mts} +1 -1
- package/dist/{date.mjs → date/index.mjs} +7 -7
- package/dist/{dom.cjs → dom/index.cjs} +8 -8
- package/dist/{dom.d.cts → dom/index.d.cts} +3 -3
- package/dist/{dom.d.mts → dom/index.d.mts} +3 -3
- package/dist/{dom.mjs → dom/index.mjs} +5 -5
- package/dist/{guards.cjs → guards/index.cjs} +38 -38
- package/dist/{guards.d.mts → guards/index.d.cts} +4 -4
- package/dist/{guards.d.cts → guards/index.d.mts} +4 -4
- package/dist/{guards.mjs → guards/index.mjs} +6 -6
- package/dist/{guards-CqbVT4L5.cjs → guards-BD2Fkugj.cjs} +2 -2
- package/dist/{guards-DKGBsd6x.mjs → guards-DBunDnng.mjs} +2 -2
- package/dist/{hash.cjs → hash/index.cjs} +69 -66
- package/dist/{hash.d.cts → hash/index.d.cts} +77 -5
- package/dist/{hash.d.mts → hash/index.d.mts} +77 -5
- package/dist/{hash.mjs → hash/index.mjs} +5 -5
- package/dist/{http-status.cjs → http-status/index.cjs} +1 -1
- package/dist/{http-status.d.mts → http-status/index.d.cts} +2 -2
- package/dist/{http-status.d.cts → http-status/index.d.mts} +2 -2
- package/dist/{http-status.mjs → http-status/index.mjs} +1 -1
- package/dist/index.cjs +84 -84
- package/dist/index.mjs +5 -5
- package/dist/{parse-TuFyLeVH.mjs → parse-CILDG7TG.mjs} +3 -3
- package/dist/{parse-jh637S25.cjs → parse-CffWYCuy.cjs} +3 -3
- package/dist/{query-sWSi-d7u.cjs → query-Blm7AiEZ.cjs} +9 -9
- package/dist/{query-BomnyWh3.mjs → query-PGFEup3p.mjs} +2 -2
- package/dist/{stylog.cjs → stylog/index.cjs} +5 -5
- package/dist/{stylog.d.cts → stylog/index.d.cts} +2 -2
- package/dist/{stylog.d.mts → stylog/index.d.mts} +2 -2
- package/dist/{stylog.mjs → stylog/index.mjs} +5 -5
- package/dist/types/pluralizer.d.cts +25 -1
- package/dist/types/pluralizer.d.mts +25 -1
- package/dist/{utilities-BSv8VbnM.mjs → utilities-CmPwOkdy.mjs} +1 -1
- package/dist/{utilities-BVpk3LKy.cjs → utilities-_COSGq1U.cjs} +1 -1
- package/dist/{basics-20lm69yy.mjs → utils-BO5CcsjK.mjs} +631 -548
- package/dist/{basics-byj0VH1c.cjs → utils-DR9g0Sef.cjs} +580 -479
- package/dist/{verbalizer.cjs → verbalizer/index.cjs} +1 -1
- package/dist/{verbalizer.mjs → verbalizer/index.mjs} +1 -1
- package/package.json +19 -23
- package/dist/pluralizer-DXMuPUAK.d.mts +0 -42
- package/dist/pluralizer-DYsDqq9c.d.cts +0 -42
- package/dist/pluralizer.cjs +0 -678
- package/dist/pluralizer.d.cts +0 -152
- package/dist/pluralizer.d.mts +0 -152
- package/dist/pluralizer.mjs +0 -676
- /package/dist/{verbalizer.d.cts → verbalizer/index.d.cts} +0 -0
- /package/dist/{verbalizer.d.mts → verbalizer/index.d.mts} +0 -0
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
18
|
-
const require_primitives = require('
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
18
|
+
const require_primitives = require('../primitives-CBGICrDR.cjs');
|
|
19
|
+
const require_utils = require('../utils-DR9g0Sef.cjs');
|
|
20
|
+
const require_specials = require('../specials-DU8u108m.cjs');
|
|
21
|
+
const require_parse = require('../parse-CffWYCuy.cjs');
|
|
22
22
|
|
|
23
23
|
//#region src/hash/Cipher.ts
|
|
24
24
|
/**
|
|
@@ -45,9 +45,9 @@ var Cipher = class {
|
|
|
45
45
|
*/
|
|
46
46
|
constructor(secret) {
|
|
47
47
|
if (!require_primitives.isNonEmptyString(secret)) throw new Error("Secret must be non-empty string!");
|
|
48
|
-
this.#secretBytes =
|
|
49
|
-
this.#encKey =
|
|
50
|
-
this.#macKey =
|
|
48
|
+
this.#secretBytes = require_utils.utf8ToBytes(secret);
|
|
49
|
+
this.#encKey = require_utils.hmacSha256(this.#secretBytes, require_utils.utf8ToBytes("enc"));
|
|
50
|
+
this.#macKey = require_utils.hmacSha256(this.#secretBytes, require_utils.utf8ToBytes("mac"));
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Generates a keystream of the same length as the provided data using a `HMAC`-based counter mode.
|
|
@@ -60,8 +60,8 @@ var Cipher = class {
|
|
|
60
60
|
#genKeystream(target, iv) {
|
|
61
61
|
const blocks = Math.ceil(target.length / 32);
|
|
62
62
|
const keystreamParts = [];
|
|
63
|
-
for (let counter = 0; counter < blocks; counter++) keystreamParts.push(
|
|
64
|
-
return
|
|
63
|
+
for (let counter = 0; counter < blocks; counter++) keystreamParts.push(require_utils.hmacSha256(this.#encKey, require_utils.concatBytes(iv, require_utils.intTo4BytesBE(counter))));
|
|
64
|
+
return require_utils.concatBytes(...keystreamParts).subarray(0, target.length);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* * Encrypts a UTF-8 string.
|
|
@@ -71,12 +71,12 @@ var Cipher = class {
|
|
|
71
71
|
* @returns A base64-encoded encrypted token.
|
|
72
72
|
*/
|
|
73
73
|
encrypt(text) {
|
|
74
|
-
const plain =
|
|
75
|
-
const iv =
|
|
74
|
+
const plain = require_utils.utf8ToBytes(text);
|
|
75
|
+
const iv = require_utils.sha256Bytes(require_utils.utf8ToBytes(String(Date.now()) + "-" + String(Math.random()))).subarray(0, 16);
|
|
76
76
|
const keystream = this.#genKeystream(plain, iv);
|
|
77
77
|
const ct = new Uint8Array(plain.length);
|
|
78
78
|
for (let i = 0; i < plain.length; i++) ct[i] = plain[i] ^ keystream[i];
|
|
79
|
-
return
|
|
79
|
+
return require_utils.bytesToBase64(require_utils.concatBytes(iv, ct, require_utils.hmacSha256(this.#macKey, require_utils.concatBytes(iv, ct))));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* * Checks if a token is structurally valid and contains a matching MAC using the same secret.
|
|
@@ -86,12 +86,12 @@ var Cipher = class {
|
|
|
86
86
|
*/
|
|
87
87
|
isValid(token) {
|
|
88
88
|
if (!require_specials.isBase64(token)) return false;
|
|
89
|
-
const blob =
|
|
89
|
+
const blob = require_utils.base64ToBytes(token);
|
|
90
90
|
if (blob.length < 48) return false;
|
|
91
91
|
const iv = blob.subarray(0, 16);
|
|
92
92
|
const tag = blob.subarray(blob.length - 32);
|
|
93
93
|
const ct = blob.subarray(16, blob.length - 32);
|
|
94
|
-
return
|
|
94
|
+
return require_utils._constantTimeEquals(require_utils.hmacSha256(this.#macKey, require_utils.concatBytes(iv, ct)), tag);
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* * Decrypts a previously encrypted token.
|
|
@@ -102,16 +102,16 @@ var Cipher = class {
|
|
|
102
102
|
*/
|
|
103
103
|
decrypt(token) {
|
|
104
104
|
if (!require_specials.isBase64(token)) throw new Error("Token must be a base64 string!");
|
|
105
|
-
const blob =
|
|
105
|
+
const blob = require_utils.base64ToBytes(token);
|
|
106
106
|
if (blob.length < 48) throw new Error("Malformed or tampered token!");
|
|
107
107
|
const iv = blob.subarray(0, 16);
|
|
108
108
|
const tag = blob.subarray(blob.length - 32);
|
|
109
109
|
const ct = blob.subarray(16, blob.length - 32);
|
|
110
|
-
if (!
|
|
110
|
+
if (!require_utils._constantTimeEquals(require_utils.hmacSha256(this.#macKey, require_utils.concatBytes(iv, ct)), tag)) throw new Error("Key in the token is tampered or invalid!)");
|
|
111
111
|
const keystream = this.#genKeystream(ct, iv);
|
|
112
112
|
const pt = new Uint8Array(ct.length);
|
|
113
113
|
for (let i = 0; i < ct.length; i++) pt[i] = ct[i] ^ keystream[i];
|
|
114
|
-
return
|
|
114
|
+
return require_utils.bytesToUtf8(pt);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
|
|
@@ -195,7 +195,7 @@ var Signet = class {
|
|
|
195
195
|
*/
|
|
196
196
|
constructor(secret) {
|
|
197
197
|
if (!require_primitives.isNonEmptyString(secret)) throw new Error("Secret must be a non-empty string!");
|
|
198
|
-
this.#secretBytes =
|
|
198
|
+
this.#secretBytes = require_utils.utf8ToBytes(secret);
|
|
199
199
|
}
|
|
200
200
|
/** Decodes a token without verifying its signature. */
|
|
201
201
|
#decode(token) {
|
|
@@ -203,10 +203,10 @@ var Signet = class {
|
|
|
203
203
|
const parts = token.split(".");
|
|
204
204
|
if (parts.length !== 3) throw new Error("Token is tampered or malformed!");
|
|
205
205
|
const [hdr, pld, signature] = parts;
|
|
206
|
-
const headerBytes =
|
|
207
|
-
const payloadBytes =
|
|
208
|
-
const headerStr =
|
|
209
|
-
const payloadStr =
|
|
206
|
+
const headerBytes = require_utils.base64ToBytes(hdr);
|
|
207
|
+
const payloadBytes = require_utils.base64ToBytes(pld);
|
|
208
|
+
const headerStr = require_utils.stripJsonEdgeGarbage(require_utils.bytesToUtf8(headerBytes));
|
|
209
|
+
const payloadStr = require_utils.stripJsonEdgeGarbage(require_utils.bytesToUtf8(payloadBytes));
|
|
210
210
|
let header;
|
|
211
211
|
try {
|
|
212
212
|
header = JSON.parse(headerStr);
|
|
@@ -301,15 +301,15 @@ var Signet = class {
|
|
|
301
301
|
...issuer && { iss: issuer },
|
|
302
302
|
...payload
|
|
303
303
|
};
|
|
304
|
-
const headerJson =
|
|
304
|
+
const headerJson = require_utils.stableStringify({
|
|
305
305
|
alg: "HS256",
|
|
306
306
|
typ: "SIGNET+JWT"
|
|
307
307
|
});
|
|
308
|
-
const payloadJson =
|
|
309
|
-
const headerB =
|
|
310
|
-
const payloadB =
|
|
311
|
-
const signingInput = `${
|
|
312
|
-
return `${signingInput}.${
|
|
308
|
+
const payloadJson = require_utils.stableStringify($payload);
|
|
309
|
+
const headerB = require_utils.utf8ToBytes(headerJson);
|
|
310
|
+
const payloadB = require_utils.utf8ToBytes(payloadJson);
|
|
311
|
+
const signingInput = `${require_utils.bytesToBase64(headerB)}.${require_utils.bytesToBase64(payloadB)}`;
|
|
312
|
+
return `${signingInput}.${require_utils.bytesToBase64(require_utils.hmacSha256(this.#secretBytes, require_utils.utf8ToBytes(signingInput)))}`;
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
315
|
* * Decodes a token without verifying its signature.
|
|
@@ -573,7 +573,7 @@ var Signet = class {
|
|
|
573
573
|
try {
|
|
574
574
|
const { signature, signingInput, payload } = this.#decode(token);
|
|
575
575
|
const { audience, issuer, subject } = options || {};
|
|
576
|
-
if (!
|
|
576
|
+
if (!require_utils._constantTimeEquals(signature, require_utils.bytesToBase64(require_utils.hmacSha256(this.#secretBytes, require_utils.utf8ToBytes(signingInput))))) throw new Error("Invalid or tampered signature!");
|
|
577
577
|
if (this.hasExpired(token)) throw new Error("Token has expired!");
|
|
578
578
|
if (this.isTooEarly(token)) throw new Error("Token is not active yet!");
|
|
579
579
|
if (this.isInvalidIssuer(token, issuer)) throw new Error("Invalid token issuer!");
|
|
@@ -740,7 +740,7 @@ var TextCodec = class TextCodec {
|
|
|
740
740
|
* TextCodec.utf8ToHex('Hi');
|
|
741
741
|
*/
|
|
742
742
|
static utf8ToHex(text, spaced = true) {
|
|
743
|
-
return [...
|
|
743
|
+
return [...require_utils.utf8ToBytes(text)].map((b) => require_utils._padStartWith0(b, "hex")).join(spaced ? " " : "");
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
746
|
* @static Converts UTF-8 text into binary byte representation.
|
|
@@ -753,7 +753,7 @@ var TextCodec = class TextCodec {
|
|
|
753
753
|
* TextCodec.utf8ToBinary('A');
|
|
754
754
|
*/
|
|
755
755
|
static utf8ToBinary(text, spaced = true) {
|
|
756
|
-
return [...
|
|
756
|
+
return [...require_utils.utf8ToBytes(text)].map((b) => require_utils._padStartWith0(b, "binary")).join(spaced ? " " : "");
|
|
757
757
|
}
|
|
758
758
|
/**
|
|
759
759
|
* @static Converts hexadecimal byte string into UTF-8 text.
|
|
@@ -765,7 +765,7 @@ var TextCodec = class TextCodec {
|
|
|
765
765
|
* TextCodec.hexToUtf8('48 69');
|
|
766
766
|
*/
|
|
767
767
|
static hexToUtf8(hex) {
|
|
768
|
-
return
|
|
768
|
+
return require_utils.bytesToUtf8(require_utils.hexToBytes(hex));
|
|
769
769
|
}
|
|
770
770
|
/**
|
|
771
771
|
* @static Converts binary byte string into UTF-8 text.
|
|
@@ -778,8 +778,8 @@ var TextCodec = class TextCodec {
|
|
|
778
778
|
*/
|
|
779
779
|
static binaryToUtf8(binary) {
|
|
780
780
|
if (!require_specials.isBinaryString(binary)) return "";
|
|
781
|
-
const bytes =
|
|
782
|
-
return
|
|
781
|
+
const bytes = require_utils._splitByCharLength(binary, 8).map((b) => parseInt(b, 2));
|
|
782
|
+
return require_utils.bytesToUtf8(new Uint8Array(bytes));
|
|
783
783
|
}
|
|
784
784
|
/**
|
|
785
785
|
* @static Converts hexadecimal byte string into binary byte string.
|
|
@@ -793,7 +793,7 @@ var TextCodec = class TextCodec {
|
|
|
793
793
|
*/
|
|
794
794
|
static hexToBinary(hex, spaced = true) {
|
|
795
795
|
if (!require_specials.isHexString(hex)) return "";
|
|
796
|
-
return
|
|
796
|
+
return require_utils._splitByCharLength(hex, 2).map((h) => require_utils._padStartWith0(parseInt(h, 16), "binary")).join(spaced ? " " : "");
|
|
797
797
|
}
|
|
798
798
|
/**
|
|
799
799
|
* @static Converts binary byte string into hexadecimal byte string.
|
|
@@ -807,7 +807,7 @@ var TextCodec = class TextCodec {
|
|
|
807
807
|
*/
|
|
808
808
|
static binaryToHex(binary, spaced = true) {
|
|
809
809
|
if (!require_specials.isBinaryString(binary)) return "";
|
|
810
|
-
return
|
|
810
|
+
return require_utils._splitByCharLength(binary, 8).map((b) => require_utils._padStartWith0(parseInt(b, 2), "hex")).join(spaced ? " " : "");
|
|
811
811
|
}
|
|
812
812
|
/**
|
|
813
813
|
* @static Converts a Base64-encoded string into UTF-8 text.
|
|
@@ -820,7 +820,7 @@ var TextCodec = class TextCodec {
|
|
|
820
820
|
*/
|
|
821
821
|
static base64ToUtf8(b64) {
|
|
822
822
|
if (!require_specials.isBase64(b64)) return "";
|
|
823
|
-
return
|
|
823
|
+
return require_utils.bytesToUtf8(require_utils.base64ToBytes(b64));
|
|
824
824
|
}
|
|
825
825
|
/**
|
|
826
826
|
* @static Converts UTF-8 text into a Base64-encoded string.
|
|
@@ -833,7 +833,7 @@ var TextCodec = class TextCodec {
|
|
|
833
833
|
*/
|
|
834
834
|
static utf8ToBase64(text) {
|
|
835
835
|
if (!require_primitives.isNonEmptyString(text)) return "";
|
|
836
|
-
return
|
|
836
|
+
return require_utils.bytesToBase64(require_utils.utf8ToBytes(text));
|
|
837
837
|
}
|
|
838
838
|
/**
|
|
839
839
|
* @static Converts Base64 directly into hexadecimal byte string.
|
|
@@ -891,32 +891,35 @@ var TextCodec = class TextCodec {
|
|
|
891
891
|
exports.Cipher = Cipher;
|
|
892
892
|
exports.Signet = Signet;
|
|
893
893
|
exports.TextCodec = TextCodec;
|
|
894
|
-
exports.base64ToBytes =
|
|
895
|
-
exports.bytesToBase64 =
|
|
896
|
-
exports.bytesToHex =
|
|
897
|
-
exports.bytesToUtf8 =
|
|
898
|
-
exports.concatBytes =
|
|
899
|
-
exports.decodeUUID =
|
|
900
|
-
exports.generateRandomID =
|
|
901
|
-
exports.getRandomID =
|
|
902
|
-
exports.hexToBytes =
|
|
903
|
-
exports.hmacSha256 =
|
|
904
|
-
exports.intTo4BytesBE =
|
|
894
|
+
exports.base64ToBytes = require_utils.base64ToBytes;
|
|
895
|
+
exports.bytesToBase64 = require_utils.bytesToBase64;
|
|
896
|
+
exports.bytesToHex = require_utils.bytesToHex;
|
|
897
|
+
exports.bytesToUtf8 = require_utils.bytesToUtf8;
|
|
898
|
+
exports.concatBytes = require_utils.concatBytes;
|
|
899
|
+
exports.decodeUUID = require_utils.decodeUUID;
|
|
900
|
+
exports.generateRandomID = require_utils.generateRandomID;
|
|
901
|
+
exports.getRandomID = require_utils.generateRandomID;
|
|
902
|
+
exports.hexToBytes = require_utils.hexToBytes;
|
|
903
|
+
exports.hmacSha256 = require_utils.hmacSha256;
|
|
904
|
+
exports.intTo4BytesBE = require_utils.intTo4BytesBE;
|
|
905
905
|
exports.isUUID = require_specials.isUUID;
|
|
906
|
-
exports.isUUIDv1 =
|
|
907
|
-
exports.isUUIDv2 =
|
|
908
|
-
exports.isUUIDv3 =
|
|
909
|
-
exports.isUUIDv4 =
|
|
910
|
-
exports.isUUIDv5 =
|
|
911
|
-
exports.isUUIDv6 =
|
|
912
|
-
exports.isUUIDv7 =
|
|
913
|
-
exports.isUUIDv8 =
|
|
914
|
-
exports.md5 =
|
|
915
|
-
exports.
|
|
916
|
-
exports.
|
|
917
|
-
exports.
|
|
918
|
-
exports.
|
|
919
|
-
exports.
|
|
920
|
-
exports.
|
|
921
|
-
exports.
|
|
922
|
-
exports.
|
|
906
|
+
exports.isUUIDv1 = require_utils.isUUIDv1;
|
|
907
|
+
exports.isUUIDv2 = require_utils.isUUIDv2;
|
|
908
|
+
exports.isUUIDv3 = require_utils.isUUIDv3;
|
|
909
|
+
exports.isUUIDv4 = require_utils.isUUIDv4;
|
|
910
|
+
exports.isUUIDv5 = require_utils.isUUIDv5;
|
|
911
|
+
exports.isUUIDv6 = require_utils.isUUIDv6;
|
|
912
|
+
exports.isUUIDv7 = require_utils.isUUIDv7;
|
|
913
|
+
exports.isUUIDv8 = require_utils.isUUIDv8;
|
|
914
|
+
exports.md5 = require_utils.md5;
|
|
915
|
+
exports.randomAlphaNumeric = require_utils.randomAlphaNumeric;
|
|
916
|
+
exports.randomBytes = require_utils.randomBytes;
|
|
917
|
+
exports.randomHex = require_utils.randomHex;
|
|
918
|
+
exports.randomID = require_utils.generateRandomID;
|
|
919
|
+
exports.randomNumeric = require_utils.randomNumeric;
|
|
920
|
+
exports.sha1 = require_utils.sha1;
|
|
921
|
+
exports.sha256 = require_utils.sha256;
|
|
922
|
+
exports.sha256Bytes = require_utils.sha256Bytes;
|
|
923
|
+
exports.uint8To32ArrayBE = require_utils.uint8To32ArrayBE;
|
|
924
|
+
exports.utf8ToBytes = require_utils.utf8ToBytes;
|
|
925
|
+
exports.uuid = require_utils.uuid;
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { nt as Maybe, y as GenericObject } from "
|
|
18
|
-
import { _ as VerifiedToken, d as SignetPayload, l as SignOptions, p as TokenString, s as DecodedToken, v as VerifyOptions } from "
|
|
19
|
-
import { a as isUUIDv4, c as isUUIDv7, i as isUUIDv3, l as isUUIDv8, n as isUUIDv1, o as isUUIDv5, r as isUUIDv2, s as isUUIDv6, t as decodeUUID, u as uuid, w as isUUID } from "
|
|
20
|
-
import { t as generateRandomID } from "
|
|
17
|
+
import { nt as Maybe, y as GenericObject } from "../object-DyVg8BFt.cjs";
|
|
18
|
+
import { _ as VerifiedToken, d as SignetPayload, l as SignOptions, p as TokenString, s as DecodedToken, v as VerifyOptions } from "../hash-DHawpylk.cjs";
|
|
19
|
+
import { a as isUUIDv4, c as isUUIDv7, i as isUUIDv3, l as isUUIDv8, n as isUUIDv1, o as isUUIDv5, r as isUUIDv2, s as isUUIDv6, t as decodeUUID, u as uuid, w as isUUID } from "../uuid-CMNRM9NO.cjs";
|
|
20
|
+
import { t as generateRandomID } from "../basics-DlwGpXu-.cjs";
|
|
21
21
|
|
|
22
22
|
//#region src/hash/Cipher.d.ts
|
|
23
23
|
/**
|
|
@@ -751,6 +751,35 @@ declare class TextCodec {
|
|
|
751
751
|
}
|
|
752
752
|
//#endregion
|
|
753
753
|
//#region src/hash/utils.d.ts
|
|
754
|
+
/**
|
|
755
|
+
* * Generates random bytes in the {@link Uint8Array} format.
|
|
756
|
+
*
|
|
757
|
+
* @param size - The length of the byte array to generate. Defaults to `8`.
|
|
758
|
+
* @returns A random array of bytes.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```typescript
|
|
762
|
+
* const bytes = randomBytes(16);
|
|
763
|
+
* // Returns something like: Uint8Array(16) [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 224, 166, 170, 224, 167, 131]
|
|
764
|
+
*
|
|
765
|
+
* // Empty array
|
|
766
|
+
* const empty = randomBytes(0);
|
|
767
|
+
* // Returns: Uint8Array(0) []
|
|
768
|
+
*
|
|
769
|
+
* // Zero or negative values are treated as 0
|
|
770
|
+
* const zero = randomBytes(-5);
|
|
771
|
+
* // Returns: Uint8Array(0) []
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* @remarks
|
|
775
|
+
* - It uses {@link crypto.getRandomValues} when available for secure randomness, and falls back to {@link Math.random} if not.
|
|
776
|
+
* - If {@link crypto.getRandomValues} is available (supported environments include browser and Node.js), it is used for cryptographically secure random number generation.
|
|
777
|
+
* - In environments where {@link crypto.getRandomValues} is not available, the function falls back to {@link Math.random}, which is **not** cryptographically secure.
|
|
778
|
+
* - {@link crypto.getRandomValues} fills the array with random values in the range [0, 255] (inclusive).
|
|
779
|
+
* - {@link Math.random} returns values in the range [0, 1) (exclusive of 1), so the values are scaled to [0, 255].
|
|
780
|
+
* - If `size` is 0 or negative, an empty `Uint8Array` is returned.
|
|
781
|
+
*/
|
|
782
|
+
declare function randomBytes(size?: number): Uint8Array;
|
|
754
783
|
/**
|
|
755
784
|
* * Generates a random hexadecimal string of the specified length.
|
|
756
785
|
*
|
|
@@ -774,6 +803,49 @@ declare class TextCodec {
|
|
|
774
803
|
* const token = randomHex(8, true);
|
|
775
804
|
*/
|
|
776
805
|
declare function randomHex(length: number, uppercase?: boolean): string;
|
|
806
|
+
/**
|
|
807
|
+
* * Generates a random numeric string of the specified length.
|
|
808
|
+
*
|
|
809
|
+
* @param length - Length of the numeric string. Defaults to `6`.
|
|
810
|
+
* @returns A randomly generated numeric string.
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const otp = randomNumeric(6);
|
|
815
|
+
* // Returns something like: '123456'
|
|
816
|
+
* ```
|
|
817
|
+
*
|
|
818
|
+
* @remarks
|
|
819
|
+
* - If `length` is `0` or negative, an empty string is returned.
|
|
820
|
+
*/
|
|
821
|
+
declare function randomNumeric(length?: number): `${number}`;
|
|
822
|
+
/**
|
|
823
|
+
* * Generates a random alphanumeric string (letters and numbers) of the specified length.
|
|
824
|
+
*
|
|
825
|
+
* @param length - The desired length of the random string. Defaults to `8`.
|
|
826
|
+
* @param uppercase - If `true`, the string will contain uppercase letters (A-Z). Defaults to `false` (lowercase).
|
|
827
|
+
*
|
|
828
|
+
* @returns A random string composed of alphanumeric characters.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* // Generate a random 8-character alphanumeric string (default: lowercase)
|
|
833
|
+
* const randomStr = randomAlphaNumeric(8);
|
|
834
|
+
* // Example output: "a7b2f9d1"
|
|
835
|
+
*
|
|
836
|
+
* // Generate a 12-character uppercase alphanumeric string
|
|
837
|
+
* const randomUpper = randomAlphaNumeric(12, true);
|
|
838
|
+
* // Example output: "X5K9P2M7H4L3"
|
|
839
|
+
*
|
|
840
|
+
* // Generate a 6-character string
|
|
841
|
+
* const shortStr = randomAlphaNumeric(6);
|
|
842
|
+
* ```
|
|
843
|
+
*
|
|
844
|
+
* @remarks
|
|
845
|
+
* - The function generates random bytes and converts them to base-36 (0-9, a-z) characters.
|
|
846
|
+
* - If `length` is `0` or negative, an empty string is returned.
|
|
847
|
+
*/
|
|
848
|
+
declare function randomAlphaNumeric(length?: number, uppercase?: boolean): string;
|
|
777
849
|
/**
|
|
778
850
|
* * Converts a UTF-8 string to a byte array (`Uint8Array`).
|
|
779
851
|
*
|
|
@@ -1143,4 +1215,4 @@ declare function bytesToHex(bytes: Uint8Array): string;
|
|
|
1143
1215
|
*/
|
|
1144
1216
|
declare function hexToBytes(hex: string): Uint8Array;
|
|
1145
1217
|
//#endregion
|
|
1146
|
-
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomHex, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
1218
|
+
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomAlphaNumeric, randomBytes, randomHex, randomNumeric, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { nt as Maybe, y as GenericObject } from "
|
|
18
|
-
import { _ as VerifiedToken, d as SignetPayload, l as SignOptions, p as TokenString, s as DecodedToken, v as VerifyOptions } from "
|
|
19
|
-
import { a as isUUIDv4, c as isUUIDv7, i as isUUIDv3, l as isUUIDv8, n as isUUIDv1, o as isUUIDv5, r as isUUIDv2, s as isUUIDv6, t as decodeUUID, u as uuid, w as isUUID } from "
|
|
20
|
-
import { t as generateRandomID } from "
|
|
17
|
+
import { nt as Maybe, y as GenericObject } from "../object-DyVg8BFt.mjs";
|
|
18
|
+
import { _ as VerifiedToken, d as SignetPayload, l as SignOptions, p as TokenString, s as DecodedToken, v as VerifyOptions } from "../hash-2mygGWLk.mjs";
|
|
19
|
+
import { a as isUUIDv4, c as isUUIDv7, i as isUUIDv3, l as isUUIDv8, n as isUUIDv1, o as isUUIDv5, r as isUUIDv2, s as isUUIDv6, t as decodeUUID, u as uuid, w as isUUID } from "../uuid-DvQsIl9p.mjs";
|
|
20
|
+
import { t as generateRandomID } from "../basics-DY7AX7D4.mjs";
|
|
21
21
|
|
|
22
22
|
//#region src/hash/Cipher.d.ts
|
|
23
23
|
/**
|
|
@@ -751,6 +751,35 @@ declare class TextCodec {
|
|
|
751
751
|
}
|
|
752
752
|
//#endregion
|
|
753
753
|
//#region src/hash/utils.d.ts
|
|
754
|
+
/**
|
|
755
|
+
* * Generates random bytes in the {@link Uint8Array} format.
|
|
756
|
+
*
|
|
757
|
+
* @param size - The length of the byte array to generate. Defaults to `8`.
|
|
758
|
+
* @returns A random array of bytes.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```typescript
|
|
762
|
+
* const bytes = randomBytes(16);
|
|
763
|
+
* // Returns something like: Uint8Array(16) [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 224, 166, 170, 224, 167, 131]
|
|
764
|
+
*
|
|
765
|
+
* // Empty array
|
|
766
|
+
* const empty = randomBytes(0);
|
|
767
|
+
* // Returns: Uint8Array(0) []
|
|
768
|
+
*
|
|
769
|
+
* // Zero or negative values are treated as 0
|
|
770
|
+
* const zero = randomBytes(-5);
|
|
771
|
+
* // Returns: Uint8Array(0) []
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* @remarks
|
|
775
|
+
* - It uses {@link crypto.getRandomValues} when available for secure randomness, and falls back to {@link Math.random} if not.
|
|
776
|
+
* - If {@link crypto.getRandomValues} is available (supported environments include browser and Node.js), it is used for cryptographically secure random number generation.
|
|
777
|
+
* - In environments where {@link crypto.getRandomValues} is not available, the function falls back to {@link Math.random}, which is **not** cryptographically secure.
|
|
778
|
+
* - {@link crypto.getRandomValues} fills the array with random values in the range [0, 255] (inclusive).
|
|
779
|
+
* - {@link Math.random} returns values in the range [0, 1) (exclusive of 1), so the values are scaled to [0, 255].
|
|
780
|
+
* - If `size` is 0 or negative, an empty `Uint8Array` is returned.
|
|
781
|
+
*/
|
|
782
|
+
declare function randomBytes(size?: number): Uint8Array;
|
|
754
783
|
/**
|
|
755
784
|
* * Generates a random hexadecimal string of the specified length.
|
|
756
785
|
*
|
|
@@ -774,6 +803,49 @@ declare class TextCodec {
|
|
|
774
803
|
* const token = randomHex(8, true);
|
|
775
804
|
*/
|
|
776
805
|
declare function randomHex(length: number, uppercase?: boolean): string;
|
|
806
|
+
/**
|
|
807
|
+
* * Generates a random numeric string of the specified length.
|
|
808
|
+
*
|
|
809
|
+
* @param length - Length of the numeric string. Defaults to `6`.
|
|
810
|
+
* @returns A randomly generated numeric string.
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const otp = randomNumeric(6);
|
|
815
|
+
* // Returns something like: '123456'
|
|
816
|
+
* ```
|
|
817
|
+
*
|
|
818
|
+
* @remarks
|
|
819
|
+
* - If `length` is `0` or negative, an empty string is returned.
|
|
820
|
+
*/
|
|
821
|
+
declare function randomNumeric(length?: number): `${number}`;
|
|
822
|
+
/**
|
|
823
|
+
* * Generates a random alphanumeric string (letters and numbers) of the specified length.
|
|
824
|
+
*
|
|
825
|
+
* @param length - The desired length of the random string. Defaults to `8`.
|
|
826
|
+
* @param uppercase - If `true`, the string will contain uppercase letters (A-Z). Defaults to `false` (lowercase).
|
|
827
|
+
*
|
|
828
|
+
* @returns A random string composed of alphanumeric characters.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* // Generate a random 8-character alphanumeric string (default: lowercase)
|
|
833
|
+
* const randomStr = randomAlphaNumeric(8);
|
|
834
|
+
* // Example output: "a7b2f9d1"
|
|
835
|
+
*
|
|
836
|
+
* // Generate a 12-character uppercase alphanumeric string
|
|
837
|
+
* const randomUpper = randomAlphaNumeric(12, true);
|
|
838
|
+
* // Example output: "X5K9P2M7H4L3"
|
|
839
|
+
*
|
|
840
|
+
* // Generate a 6-character string
|
|
841
|
+
* const shortStr = randomAlphaNumeric(6);
|
|
842
|
+
* ```
|
|
843
|
+
*
|
|
844
|
+
* @remarks
|
|
845
|
+
* - The function generates random bytes and converts them to base-36 (0-9, a-z) characters.
|
|
846
|
+
* - If `length` is `0` or negative, an empty string is returned.
|
|
847
|
+
*/
|
|
848
|
+
declare function randomAlphaNumeric(length?: number, uppercase?: boolean): string;
|
|
777
849
|
/**
|
|
778
850
|
* * Converts a UTF-8 string to a byte array (`Uint8Array`).
|
|
779
851
|
*
|
|
@@ -1143,4 +1215,4 @@ declare function bytesToHex(bytes: Uint8Array): string;
|
|
|
1143
1215
|
*/
|
|
1144
1216
|
declare function hexToBytes(hex: string): Uint8Array;
|
|
1145
1217
|
//#endregion
|
|
1146
|
-
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomHex, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
1218
|
+
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomAlphaNumeric, randomBytes, randomHex, randomNumeric, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { a as isNonEmptyString } from "
|
|
18
|
-
import {
|
|
19
|
-
import { c as
|
|
20
|
-
import {
|
|
17
|
+
import { a as isNonEmptyString } from "../primitives-Djsevc69.mjs";
|
|
18
|
+
import { A as uuid, B as bytesToUtf8, C as isUUIDv2, D as isUUIDv6, E as isUUIDv5, F as _padStartWith0, G as randomAlphaNumeric, H as hexToBytes, I as _splitByCharLength, J as randomNumeric, K as randomBytes, L as base64ToBytes, M as sha1, N as sha256, O as isUUIDv7, P as _constantTimeEquals, Q as generateRandomID, R as bytesToBase64, S as isUUIDv1, T as isUUIDv4, U as hmacSha256, V as concatBytes, W as intTo4BytesBE, X as uint8To32ArrayBE, Y as sha256Bytes, Z as utf8ToBytes, h as stripJsonEdgeGarbage, j as md5, k as isUUIDv8, m as stableStringify, q as randomHex, w as isUUIDv3, x as decodeUUID, z as bytesToHex } from "../utils-BO5CcsjK.mjs";
|
|
19
|
+
import { c as isHexString, m as isUUID, n as isBinaryString, t as isBase64, w as isNotEmptyObject } from "../specials-krf7zsqI.mjs";
|
|
20
|
+
import { c as _toSeconds, s as _secToDate, t as parseMSec } from "../parse-CILDG7TG.mjs";
|
|
21
21
|
|
|
22
22
|
//#region src/hash/Cipher.ts
|
|
23
23
|
/**
|
|
@@ -887,4 +887,4 @@ var TextCodec = class TextCodec {
|
|
|
887
887
|
};
|
|
888
888
|
|
|
889
889
|
//#endregion
|
|
890
|
-
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomHex, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
890
|
+
export { Cipher, Signet, TextCodec, base64ToBytes, bytesToBase64, bytesToHex, bytesToUtf8, concatBytes, decodeUUID, generateRandomID, generateRandomID as getRandomID, generateRandomID as randomID, hexToBytes, hmacSha256, intTo4BytesBE, isUUID, isUUIDv1, isUUIDv2, isUUIDv3, isUUIDv4, isUUIDv5, isUUIDv6, isUUIDv7, isUUIDv8, md5, randomAlphaNumeric, randomBytes, randomHex, randomNumeric, sha1, sha256, sha256Bytes, uint8To32ArrayBE, utf8ToBytes, uuid };
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
18
|
-
const require_constants = require('
|
|
18
|
+
const require_constants = require('../constants-ZnFGKd7G.cjs');
|
|
19
19
|
|
|
20
20
|
//#region src/http-status/HttpStatus.ts
|
|
21
21
|
/**
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { nt as Maybe } from "
|
|
18
|
-
import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "
|
|
17
|
+
import { nt as Maybe } from "../object-DyVg8BFt.cjs";
|
|
18
|
+
import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "../http-status-CpYDj2wq.cjs";
|
|
19
19
|
|
|
20
20
|
//#region src/http-status/HttpStatus.d.ts
|
|
21
21
|
/**
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { nt as Maybe } from "
|
|
18
|
-
import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "
|
|
17
|
+
import { nt as Maybe } from "../object-DyVg8BFt.mjs";
|
|
18
|
+
import { a as HttpStatusCode, c as StatusCode, l as StatusEntry, o as HttpStatusName, s as StatusCategory, u as StatusName } from "../http-status-BXNuC-33.mjs";
|
|
19
19
|
|
|
20
20
|
//#region src/http-status/HttpStatus.d.ts
|
|
21
21
|
/**
|