@burdenoff/be-sdk 2026.510.79
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 +173 -0
- package/configs/eslint/index.js +492 -0
- package/configs/tsconfig/tsconfig.json +53 -0
- package/dist/EventQueueFactory-6NMSGECR.js +8 -0
- package/dist/EventQueueFactory-6NMSGECR.js.map +1 -0
- package/dist/auth/index.d.ts +66 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/captcha/index.d.ts +1 -0
- package/dist/captcha/index.js +4 -0
- package/dist/captcha/index.js.map +1 -0
- package/dist/chunk-2HANKZZM.js +245 -0
- package/dist/chunk-2HANKZZM.js.map +1 -0
- package/dist/chunk-2SD5L2F2.js +816 -0
- package/dist/chunk-2SD5L2F2.js.map +1 -0
- package/dist/chunk-3O2RQOPV.js +1068 -0
- package/dist/chunk-3O2RQOPV.js.map +1 -0
- package/dist/chunk-4B43DZIS.js +560 -0
- package/dist/chunk-4B43DZIS.js.map +1 -0
- package/dist/chunk-4XAEES25.js +2444 -0
- package/dist/chunk-4XAEES25.js.map +1 -0
- package/dist/chunk-4XGGWW36.js +1405 -0
- package/dist/chunk-4XGGWW36.js.map +1 -0
- package/dist/chunk-5LXDPGDH.js +245 -0
- package/dist/chunk-5LXDPGDH.js.map +1 -0
- package/dist/chunk-AI7L22ZJ.js +472 -0
- package/dist/chunk-AI7L22ZJ.js.map +1 -0
- package/dist/chunk-CBZNP6RF.js +286 -0
- package/dist/chunk-CBZNP6RF.js.map +1 -0
- package/dist/chunk-ELLX3K54.js +613 -0
- package/dist/chunk-ELLX3K54.js.map +1 -0
- package/dist/chunk-F5XEAGHQ.js +1875 -0
- package/dist/chunk-F5XEAGHQ.js.map +1 -0
- package/dist/chunk-FNZEQOJY.js +628 -0
- package/dist/chunk-FNZEQOJY.js.map +1 -0
- package/dist/chunk-GTEMQXCA.js +516 -0
- package/dist/chunk-GTEMQXCA.js.map +1 -0
- package/dist/chunk-HIWTWIGQ.js +226 -0
- package/dist/chunk-HIWTWIGQ.js.map +1 -0
- package/dist/chunk-IYE2NTRX.js +764 -0
- package/dist/chunk-IYE2NTRX.js.map +1 -0
- package/dist/chunk-J26YGR2U.js +1484 -0
- package/dist/chunk-J26YGR2U.js.map +1 -0
- package/dist/chunk-JG2FTZPI.js +509 -0
- package/dist/chunk-JG2FTZPI.js.map +1 -0
- package/dist/chunk-JVBTNSPG.js +1551 -0
- package/dist/chunk-JVBTNSPG.js.map +1 -0
- package/dist/chunk-L7ZMN2FJ.js +12 -0
- package/dist/chunk-L7ZMN2FJ.js.map +1 -0
- package/dist/chunk-M5IMU3US.js +473 -0
- package/dist/chunk-M5IMU3US.js.map +1 -0
- package/dist/chunk-MLW2HPS5.js +1267 -0
- package/dist/chunk-MLW2HPS5.js.map +1 -0
- package/dist/chunk-MNCGUYLJ.js +269 -0
- package/dist/chunk-MNCGUYLJ.js.map +1 -0
- package/dist/chunk-MOCUBSTW.js +373 -0
- package/dist/chunk-MOCUBSTW.js.map +1 -0
- package/dist/chunk-NGMEI42S.js +103 -0
- package/dist/chunk-NGMEI42S.js.map +1 -0
- package/dist/chunk-NUB5GQTU.js +270 -0
- package/dist/chunk-NUB5GQTU.js.map +1 -0
- package/dist/chunk-OVSYMNCI.js +145 -0
- package/dist/chunk-OVSYMNCI.js.map +1 -0
- package/dist/chunk-QLVKMWFA.js +94 -0
- package/dist/chunk-QLVKMWFA.js.map +1 -0
- package/dist/chunk-SAG6ZYWQ.js +89 -0
- package/dist/chunk-SAG6ZYWQ.js.map +1 -0
- package/dist/chunk-SAK2JCA7.js +198 -0
- package/dist/chunk-SAK2JCA7.js.map +1 -0
- package/dist/chunk-SBS4S2PJ.js +100 -0
- package/dist/chunk-SBS4S2PJ.js.map +1 -0
- package/dist/chunk-SNEOLWXT.js +148 -0
- package/dist/chunk-SNEOLWXT.js.map +1 -0
- package/dist/chunk-TKBD2ONF.js +564 -0
- package/dist/chunk-TKBD2ONF.js.map +1 -0
- package/dist/chunk-UBXFIIAW.js +127 -0
- package/dist/chunk-UBXFIIAW.js.map +1 -0
- package/dist/chunk-VI4VSNTI.js +57 -0
- package/dist/chunk-VI4VSNTI.js.map +1 -0
- package/dist/chunk-VWCN5PMD.js +268 -0
- package/dist/chunk-VWCN5PMD.js.map +1 -0
- package/dist/chunk-XC2YD6CF.js +913 -0
- package/dist/chunk-XC2YD6CF.js.map +1 -0
- package/dist/chunk-XE4OXN2W.js +10 -0
- package/dist/chunk-XE4OXN2W.js.map +1 -0
- package/dist/chunk-YMZEUTD2.js +110 -0
- package/dist/chunk-YMZEUTD2.js.map +1 -0
- package/dist/chunk-Z4IRLBWO.js +758 -0
- package/dist/chunk-Z4IRLBWO.js.map +1 -0
- package/dist/client/internal-client.d.ts +7 -0
- package/dist/client/internal-client.js +5 -0
- package/dist/client/internal-client.js.map +1 -0
- package/dist/client-CSjIrYKS.d.ts +77 -0
- package/dist/config-UKE2E3BW.js +4 -0
- package/dist/config-UKE2E3BW.js.map +1 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +4 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/database/index.d.ts +117 -0
- package/dist/database/index.js +7 -0
- package/dist/database/index.js.map +1 -0
- package/dist/dataloader/index.d.ts +1 -0
- package/dist/dataloader/index.js +4 -0
- package/dist/dataloader/index.js.map +1 -0
- package/dist/esm-K6H7EIWK.js +1450 -0
- package/dist/esm-K6H7EIWK.js.map +1 -0
- package/dist/event-queue/index.d.ts +6 -0
- package/dist/event-queue/index.js +10 -0
- package/dist/event-queue/index.js.map +1 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.js +9 -0
- package/dist/export/index.js.map +1 -0
- package/dist/feature-flags/index.d.ts +1 -0
- package/dist/feature-flags/index.js +4 -0
- package/dist/feature-flags/index.js.map +1 -0
- package/dist/gateway/index.d.ts +4 -0
- package/dist/gateway/index.js +8 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/security/index.d.ts +2 -0
- package/dist/gateway/security/index.js +5 -0
- package/dist/gateway/security/index.js.map +1 -0
- package/dist/graph/index.d.ts +9 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph-emitter-Bk0FqD53.d.ts +47 -0
- package/dist/graphql/index.d.ts +2 -0
- package/dist/graphql/index.js +7 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/services/index.d.ts +24 -0
- package/dist/graphql/services/index.js +5 -0
- package/dist/graphql/services/index.js.map +1 -0
- package/dist/graphql-BAVrUgBF.d.ts +22 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +5 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n-DA6IPnYy.d.ts +101 -0
- package/dist/index-4gKQKZ2B.d.ts +71 -0
- package/dist/index-B18rrFru.d.ts +42 -0
- package/dist/index-B70b5mYS.d.ts +33 -0
- package/dist/index-BMq3lFjj.d.ts +247 -0
- package/dist/index-BODgvRtL.d.ts +316 -0
- package/dist/index-BS2idbnr.d.ts +874 -0
- package/dist/index-BV3G48cH.d.ts +124 -0
- package/dist/index-CHbVw5M7.d.ts +73 -0
- package/dist/index-Cq_xNjcv.d.ts +602 -0
- package/dist/index-CrQgidpx.d.ts +77 -0
- package/dist/index-CyVEg86m.d.ts +309 -0
- package/dist/index-DOcBnmMe.d.ts +166 -0
- package/dist/index-DSOpj8DI.d.ts +17 -0
- package/dist/index-DW9q22GH.d.ts +75 -0
- package/dist/index-DlFDFyWD.d.ts +55 -0
- package/dist/index-DoK0bjhH.d.ts +607 -0
- package/dist/index-Dtf6FBaD.d.ts +199 -0
- package/dist/index-KVWGHMbS.d.ts +415 -0
- package/dist/index-PaojfSdd.d.ts +71 -0
- package/dist/index-RU_M5c74.d.ts +163 -0
- package/dist/index-UhkH2eaB.d.ts +192 -0
- package/dist/index-e_18DzAg.d.ts +18 -0
- package/dist/index-jOuh_TKn.d.ts +59 -0
- package/dist/index.d.ts +584 -0
- package/dist/index.js +2626 -0
- package/dist/index.js.map +1 -0
- package/dist/init/index.d.ts +2 -0
- package/dist/init/index.js +12 -0
- package/dist/init/index.js.map +1 -0
- package/dist/instrumentation/index.d.ts +3 -0
- package/dist/instrumentation/index.js +5 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/layer/index.d.ts +2 -0
- package/dist/layer/index.js +6 -0
- package/dist/layer/index.js.map +1 -0
- package/dist/layer-DDip18KY.d.ts +67 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +4 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/middleware/index.d.ts +3 -0
- package/dist/middleware/index.js +5 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/notifications/index.d.ts +4 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/observability/index.d.ts +3 -0
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/pino-logger-RYLGXPHZ.js +5 -0
- package/dist/pino-logger-RYLGXPHZ.js.map +1 -0
- package/dist/prisma/generator/index.d.ts +1 -0
- package/dist/prisma/generator/index.js +228 -0
- package/dist/prisma/generator/index.js.map +1 -0
- package/dist/prisma/index.d.ts +5 -0
- package/dist/prisma/index.js +12 -0
- package/dist/prisma/index.js.map +1 -0
- package/dist/prisma-extension-krXnYnrN.d.ts +30 -0
- package/dist/rbac/index.d.ts +116 -0
- package/dist/rbac/index.js +7 -0
- package/dist/rbac/index.js.map +1 -0
- package/dist/sdk-THO3IWEE.js +136 -0
- package/dist/sdk-THO3IWEE.js.map +1 -0
- package/dist/server/index.d.ts +359 -0
- package/dist/server/index.js +884 -0
- package/dist/server/index.js.map +1 -0
- package/dist/telemetry/index.d.ts +83 -0
- package/dist/telemetry/index.js +209 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/temporal/index.d.ts +148 -0
- package/dist/temporal/index.js +6 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/tracker/index.d.ts +5 -0
- package/dist/tracker/index.js +9 -0
- package/dist/tracker/index.js.map +1 -0
- package/dist/types-Bo2wkjSP.d.ts +35 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/workspace-guard-LHBNK4TG.js +5 -0
- package/dist/workspace-guard-LHBNK4TG.js.map +1 -0
- package/package.json +241 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { __export, __name } from './chunk-XE4OXN2W.js';
|
|
2
|
+
|
|
3
|
+
// src/utils/index.ts
|
|
4
|
+
var utils_exports = {};
|
|
5
|
+
__export(utils_exports, {
|
|
6
|
+
chunk: () => chunk,
|
|
7
|
+
compileValidatedPattern: () => compileValidatedPattern,
|
|
8
|
+
debounce: () => debounce,
|
|
9
|
+
deepMerge: () => deepMerge,
|
|
10
|
+
formatBytes: () => formatBytes,
|
|
11
|
+
generateUUID: () => generateUUID,
|
|
12
|
+
groupBy: () => groupBy,
|
|
13
|
+
isNumberInRange: () => isNumberInRange,
|
|
14
|
+
isStringLengthValid: () => isStringLengthValid,
|
|
15
|
+
isTokenExpired: () => isTokenExpired,
|
|
16
|
+
isValidBase64: () => isValidBase64,
|
|
17
|
+
isValidEmail: () => isValidEmail,
|
|
18
|
+
isValidHexColor: () => isValidHexColor,
|
|
19
|
+
isValidIPv4: () => isValidIPv4,
|
|
20
|
+
isValidJSON: () => isValidJSON,
|
|
21
|
+
isValidPhone: () => isValidPhone,
|
|
22
|
+
isValidRegexPattern: () => isValidRegexPattern,
|
|
23
|
+
isValidSlug: () => isValidSlug,
|
|
24
|
+
isValidUUID: () => isValidUUID,
|
|
25
|
+
isValidUrl: () => isValidUrl,
|
|
26
|
+
omit: () => omit,
|
|
27
|
+
parseJWT: () => parseJWT,
|
|
28
|
+
pick: () => pick,
|
|
29
|
+
retry: () => retry,
|
|
30
|
+
sanitizeForLog: () => sanitizeForLog,
|
|
31
|
+
sleep: () => sleep,
|
|
32
|
+
throttle: () => throttle,
|
|
33
|
+
truncate: () => truncate,
|
|
34
|
+
unique: () => unique
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// src/utils/validation.ts
|
|
38
|
+
function isValidEmail(email) {
|
|
39
|
+
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$/;
|
|
40
|
+
if (!email || email.length > 320) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return emailRegex.test(email);
|
|
44
|
+
}
|
|
45
|
+
__name(isValidEmail, "isValidEmail");
|
|
46
|
+
function isValidUrl(url) {
|
|
47
|
+
try {
|
|
48
|
+
new URL(url);
|
|
49
|
+
return true;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
__name(isValidUrl, "isValidUrl");
|
|
55
|
+
function isValidRegexPattern(pattern) {
|
|
56
|
+
if (!pattern || pattern.trim().length === 0) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (pattern.length > 1e3) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
void new RegExp(pattern);
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
__name(isValidRegexPattern, "isValidRegexPattern");
|
|
70
|
+
function compileValidatedPattern(pattern) {
|
|
71
|
+
if (!isValidRegexPattern(pattern)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
return new RegExp(pattern);
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__name(compileValidatedPattern, "compileValidatedPattern");
|
|
81
|
+
function isValidPhone(phone) {
|
|
82
|
+
const phoneRegex = /^\+[1-9]\d{1,14}$/;
|
|
83
|
+
if (!phone || phone.length < 6 || phone.length > 18) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return phoneRegex.test(phone);
|
|
87
|
+
}
|
|
88
|
+
__name(isValidPhone, "isValidPhone");
|
|
89
|
+
function isValidUUID(uuid) {
|
|
90
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
91
|
+
return uuidRegex.test(uuid);
|
|
92
|
+
}
|
|
93
|
+
__name(isValidUUID, "isValidUUID");
|
|
94
|
+
function isValidIPv4(ip) {
|
|
95
|
+
const ipRegex = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
96
|
+
const match = ipRegex.exec(ip);
|
|
97
|
+
if (!match) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
for (let i = 1; i <= 4; i++) {
|
|
101
|
+
const octet = parseInt(match[i] || "0", 10);
|
|
102
|
+
if (octet < 0 || octet > 255) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
__name(isValidIPv4, "isValidIPv4");
|
|
109
|
+
function isValidSlug(slug) {
|
|
110
|
+
if (!slug || slug.length < 1 || slug.length > 100) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (!/^[a-z0-9-]+$/.test(slug)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (slug.startsWith("-") || slug.endsWith("-")) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (slug.includes("--")) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
__name(isValidSlug, "isValidSlug");
|
|
125
|
+
function isValidHexColor(color) {
|
|
126
|
+
const hexRegex = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
127
|
+
return hexRegex.test(color);
|
|
128
|
+
}
|
|
129
|
+
__name(isValidHexColor, "isValidHexColor");
|
|
130
|
+
function isValidBase64(str) {
|
|
131
|
+
if (!str || str.length === 0) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const base64Regex = /^[A-Za-z0-9+/\-_]+=*$/;
|
|
135
|
+
if (!base64Regex.test(str)) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
return Buffer.from(str, "base64").toString("base64") === str;
|
|
140
|
+
} catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
__name(isValidBase64, "isValidBase64");
|
|
145
|
+
function isValidJSON(str) {
|
|
146
|
+
try {
|
|
147
|
+
JSON.parse(str);
|
|
148
|
+
return true;
|
|
149
|
+
} catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
__name(isValidJSON, "isValidJSON");
|
|
154
|
+
function isNumberInRange(value, min, max) {
|
|
155
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (min !== null && value < min) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (max !== null && value > max) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
__name(isNumberInRange, "isNumberInRange");
|
|
167
|
+
function isStringLengthValid(value, min, max) {
|
|
168
|
+
if (typeof value !== "string") {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const length = value.length;
|
|
172
|
+
if (min !== null && length < min) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
if (max !== null && length > max) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
__name(isStringLengthValid, "isStringLengthValid");
|
|
181
|
+
|
|
182
|
+
// src/utils/index.ts
|
|
183
|
+
var uuidv4 = /* @__PURE__ */ __name(() => crypto.randomUUID(), "uuidv4");
|
|
184
|
+
async function retry(fn, options) {
|
|
185
|
+
let lastError;
|
|
186
|
+
let delay = options.initialDelay;
|
|
187
|
+
for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {
|
|
188
|
+
try {
|
|
189
|
+
return await fn();
|
|
190
|
+
} catch (error) {
|
|
191
|
+
lastError = error;
|
|
192
|
+
if (attempt === options.maxAttempts) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
await sleep(Math.min(delay, options.maxDelay));
|
|
196
|
+
delay *= options.backoffMultiplier;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw lastError || new Error("Retry failed");
|
|
200
|
+
}
|
|
201
|
+
__name(retry, "retry");
|
|
202
|
+
function sleep(ms) {
|
|
203
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
204
|
+
}
|
|
205
|
+
__name(sleep, "sleep");
|
|
206
|
+
function deepMerge(target, source) {
|
|
207
|
+
const output = {
|
|
208
|
+
...target
|
|
209
|
+
};
|
|
210
|
+
for (const key in source) {
|
|
211
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
212
|
+
const sourceValue = source[key];
|
|
213
|
+
const targetValue = output[key];
|
|
214
|
+
if (isObject(sourceValue) && isObject(targetValue)) {
|
|
215
|
+
output[key] = deepMerge(targetValue, sourceValue);
|
|
216
|
+
} else {
|
|
217
|
+
output[key] = sourceValue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return output;
|
|
222
|
+
}
|
|
223
|
+
__name(deepMerge, "deepMerge");
|
|
224
|
+
function isObject(value) {
|
|
225
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
226
|
+
}
|
|
227
|
+
__name(isObject, "isObject");
|
|
228
|
+
function generateUUID() {
|
|
229
|
+
return uuidv4();
|
|
230
|
+
}
|
|
231
|
+
__name(generateUUID, "generateUUID");
|
|
232
|
+
function sanitizeForLog(data) {
|
|
233
|
+
const sensitiveKeys = [
|
|
234
|
+
"password",
|
|
235
|
+
"token",
|
|
236
|
+
"secret",
|
|
237
|
+
"apiKey",
|
|
238
|
+
"accessToken",
|
|
239
|
+
"refreshToken"
|
|
240
|
+
];
|
|
241
|
+
const sanitized = {};
|
|
242
|
+
for (const [key, value] of Object.entries(data)) {
|
|
243
|
+
if (sensitiveKeys.some((sensitive) => key.toLowerCase().includes(sensitive.toLowerCase()))) {
|
|
244
|
+
sanitized[key] = "[REDACTED]";
|
|
245
|
+
} else if (isObject(value)) {
|
|
246
|
+
sanitized[key] = sanitizeForLog(value);
|
|
247
|
+
} else if (Array.isArray(value)) {
|
|
248
|
+
sanitized[key] = value.map((item) => isObject(item) ? sanitizeForLog(item) : item);
|
|
249
|
+
} else {
|
|
250
|
+
sanitized[key] = value;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return sanitized;
|
|
254
|
+
}
|
|
255
|
+
__name(sanitizeForLog, "sanitizeForLog");
|
|
256
|
+
function debounce(fn, delay) {
|
|
257
|
+
let timeoutId;
|
|
258
|
+
return function(...args) {
|
|
259
|
+
if (timeoutId) {
|
|
260
|
+
clearTimeout(timeoutId);
|
|
261
|
+
}
|
|
262
|
+
timeoutId = setTimeout(() => {
|
|
263
|
+
fn.apply(this, args);
|
|
264
|
+
}, delay);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
__name(debounce, "debounce");
|
|
268
|
+
function throttle(fn, delay) {
|
|
269
|
+
let lastCall = 0;
|
|
270
|
+
return function(...args) {
|
|
271
|
+
const now = Date.now();
|
|
272
|
+
if (now - lastCall >= delay) {
|
|
273
|
+
lastCall = now;
|
|
274
|
+
fn.apply(this, args);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
__name(throttle, "throttle");
|
|
279
|
+
function parseJWT(token) {
|
|
280
|
+
try {
|
|
281
|
+
const parts = token.split(".");
|
|
282
|
+
if (parts.length !== 3) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
const payload = parts[1];
|
|
286
|
+
if (!payload) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const decoded = Buffer.from(payload, "base64").toString("utf8");
|
|
290
|
+
return JSON.parse(decoded);
|
|
291
|
+
} catch {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
__name(parseJWT, "parseJWT");
|
|
296
|
+
function isTokenExpired(token) {
|
|
297
|
+
const payload = parseJWT(token);
|
|
298
|
+
if (!payload || typeof payload["exp"] !== "number") {
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
302
|
+
return payload["exp"] < now;
|
|
303
|
+
}
|
|
304
|
+
__name(isTokenExpired, "isTokenExpired");
|
|
305
|
+
function formatBytes(bytes, decimals = 2) {
|
|
306
|
+
if (bytes === 0) return "0 Bytes";
|
|
307
|
+
const k = 1024;
|
|
308
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
309
|
+
const sizes = [
|
|
310
|
+
"Bytes",
|
|
311
|
+
"KB",
|
|
312
|
+
"MB",
|
|
313
|
+
"GB",
|
|
314
|
+
"TB"
|
|
315
|
+
];
|
|
316
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
317
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
318
|
+
}
|
|
319
|
+
__name(formatBytes, "formatBytes");
|
|
320
|
+
function truncate(str, maxLength) {
|
|
321
|
+
if (str.length <= maxLength) {
|
|
322
|
+
return str;
|
|
323
|
+
}
|
|
324
|
+
return str.substring(0, maxLength - 3) + "...";
|
|
325
|
+
}
|
|
326
|
+
__name(truncate, "truncate");
|
|
327
|
+
function chunk(array, size) {
|
|
328
|
+
const chunks = [];
|
|
329
|
+
for (let i = 0; i < array.length; i += size) {
|
|
330
|
+
chunks.push(array.slice(i, i + size));
|
|
331
|
+
}
|
|
332
|
+
return chunks;
|
|
333
|
+
}
|
|
334
|
+
__name(chunk, "chunk");
|
|
335
|
+
function unique(array) {
|
|
336
|
+
return Array.from(new Set(array));
|
|
337
|
+
}
|
|
338
|
+
__name(unique, "unique");
|
|
339
|
+
function groupBy(array, key) {
|
|
340
|
+
return array.reduce((result, item) => {
|
|
341
|
+
const groupKey = String(item[key]);
|
|
342
|
+
if (!result[groupKey]) {
|
|
343
|
+
result[groupKey] = [];
|
|
344
|
+
}
|
|
345
|
+
result[groupKey].push(item);
|
|
346
|
+
return result;
|
|
347
|
+
}, {});
|
|
348
|
+
}
|
|
349
|
+
__name(groupBy, "groupBy");
|
|
350
|
+
function pick(obj, keys) {
|
|
351
|
+
const result = {};
|
|
352
|
+
for (const key of keys) {
|
|
353
|
+
if (key in obj) {
|
|
354
|
+
result[key] = obj[key];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
__name(pick, "pick");
|
|
360
|
+
function omit(obj, keys) {
|
|
361
|
+
const result = {
|
|
362
|
+
...obj
|
|
363
|
+
};
|
|
364
|
+
for (const key of keys) {
|
|
365
|
+
delete result[key];
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
__name(omit, "omit");
|
|
370
|
+
|
|
371
|
+
export { chunk, compileValidatedPattern, debounce, deepMerge, formatBytes, generateUUID, groupBy, isNumberInRange, isStringLengthValid, isTokenExpired, isValidBase64, isValidEmail, isValidHexColor, isValidIPv4, isValidJSON, isValidPhone, isValidRegexPattern, isValidSlug, isValidUUID, isValidUrl, omit, parseJWT, pick, retry, sanitizeForLog, sleep, throttle, truncate, unique, utils_exports };
|
|
372
|
+
//# sourceMappingURL=chunk-MOCUBSTW.js.map
|
|
373
|
+
//# sourceMappingURL=chunk-MOCUBSTW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../src/utils/validation.ts"],"names":["isValidEmail","email","emailRegex","length","test","isValidUrl","url","URL","isValidRegexPattern","pattern","trim","RegExp","compileValidatedPattern","isValidPhone","phone","phoneRegex","isValidUUID","uuid","uuidRegex","isValidIPv4","ip","ipRegex","match","exec","i","octet","parseInt","isValidSlug","slug","startsWith","endsWith","includes","isValidHexColor","color","hexRegex","isValidBase64","str","base64Regex","Buffer","from","toString","isValidJSON","JSON","parse","isNumberInRange","value","min","max","isNaN","isStringLengthValid","uuidv4","crypto","randomUUID","retry","fn","options","lastError","delay","initialDelay","attempt","maxAttempts","error","sleep","Math","maxDelay","backoffMultiplier","Error","ms","Promise","resolve","setTimeout","deepMerge","target","source","output","key","Object","prototype","hasOwnProperty","call","sourceValue","targetValue","isObject","Array","isArray","generateUUID","sanitizeForLog","data","sensitiveKeys","sanitized","entries","some","sensitive","toLowerCase","map","item","debounce","timeoutId","args","clearTimeout","apply","throttle","lastCall","now","Date","parseJWT","token","parts","split","payload","decoded","isTokenExpired","floor","formatBytes","bytes","decimals","k","dm","sizes","log","parseFloat","pow","toFixed","truncate","maxLength","substring","chunk","array","size","chunks","push","slice","unique","Set","groupBy","reduce","result","groupKey","String","pick","obj","keys","omit"],"mappings":";;;AAAA,IAAA,aAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACoBO,SAASA,aAAaC,KAAAA,EAAa;AAGxC,EAAA,MAAMC,UAAAA,GAAa,kDAAA;AAGnB,EAAA,IAAI,CAACD,KAAAA,IAASA,KAAAA,CAAME,MAAAA,GAAS,GAAA,EAAK;AAChC,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,OAAOD,UAAAA,CAAWE,KAAKH,KAAAA,CAAAA;AACzB;AAXgBD,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;AAsBT,SAASK,WAAWC,GAAAA,EAAW;AACpC,EAAA,IAAI;AAC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AAA,OAAO6D,MAAAA;AACT;AARgBG,MAAAA,CAAAA,IAAAA,EAAAA,MAAAA,CAAAA;AAaT,SAASG,IAAAA,CAA2DF,KAAQC,IAAAA,EAAS;AAC1F,EAAA,MAAML,MAAAA,GAAS;IAAE,GAAGI;AAAI,GAAA;AACxB,EAAA,KAAA,MAAWjE,OAAOkE,IAAAA,EAAM;AACtB,IAAA,OAAOL,OAAO7D,GAAAA,CAAAA;AAChB,EAAA;AACA,EAAA,OAAO6D,MAAAA;AACT;AANgBM,MAAAA,CAAAA,IAAAA,EAAAA,MAAAA,CAAAA","file":"chunk-MOCUBSTW.js","sourcesContent":["/**\n * Utility functions for the SDK\n */\n\nconst uuidv4 = (): string => crypto.randomUUID();\n\n/**\n * Retry function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: {\n maxAttempts: number;\n initialDelay: number;\n maxDelay: number;\n backoffMultiplier: number;\n }\n): Promise<T> {\n let lastError: Error | undefined;\n let delay = options.initialDelay;\n\n for (let attempt = 1; attempt <= options.maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt === options.maxAttempts) {\n break;\n }\n\n await sleep(Math.min(delay, options.maxDelay));\n delay *= options.backoffMultiplier;\n }\n }\n\n throw lastError || new Error('Retry failed');\n}\n\n/**\n * Sleep utility\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Deep merge two objects\n */\nexport function deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T {\n const output = { ...target };\n\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n const sourceValue = source[key];\n const targetValue = output[key];\n\n if (isObject(sourceValue) && isObject(targetValue)) {\n output[key] = deepMerge(\n targetValue as Record<string, unknown>,\n sourceValue as Record<string, unknown>\n ) as T[Extract<keyof T, string>];\n } else {\n output[key] = sourceValue as T[Extract<keyof T, string>];\n }\n }\n }\n\n return output;\n}\n\n/**\n * Check if value is a plain object\n */\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Generate UUID v4 (cryptographically secure)\n */\nexport function generateUUID(): string {\n return uuidv4();\n}\n\n/**\n * Sanitize string for logging (remove sensitive data)\n */\nexport function sanitizeForLog(data: Record<string, unknown>): Record<string, unknown> {\n const sensitiveKeys = ['password', 'token', 'secret', 'apiKey', 'accessToken', 'refreshToken'];\n const sanitized: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(data)) {\n if (sensitiveKeys.some((sensitive) => key.toLowerCase().includes(sensitive.toLowerCase()))) {\n sanitized[key] = '[REDACTED]';\n } else if (isObject(value)) {\n sanitized[key] = sanitizeForLog(value);\n } else if (Array.isArray(value)) {\n sanitized[key] = value.map((item) => (isObject(item) ? sanitizeForLog(item) : item));\n } else {\n sanitized[key] = value;\n }\n }\n\n return sanitized;\n}\n\n/**\n * Debounce function\n */\nexport function debounce<T extends (...args: unknown[]) => unknown>(\n fn: T,\n delay: number\n): (...args: Parameters<T>) => void {\n let timeoutId: NodeJS.Timeout | undefined;\n\n return function (this: unknown, ...args: Parameters<T>): void {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n fn.apply(this, args);\n }, delay);\n };\n}\n\n/**\n * Throttle function\n */\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n fn: T,\n delay: number\n): (...args: Parameters<T>) => void {\n let lastCall = 0;\n\n return function (this: unknown, ...args: Parameters<T>): void {\n const now = Date.now();\n\n if (now - lastCall >= delay) {\n lastCall = now;\n fn.apply(this, args);\n }\n };\n}\n\n/**\n * Parse JWT token (without verification)\n */\nexport function parseJWT(token: string): Record<string, unknown> | null {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return null;\n }\n\n const payload = parts[1];\n if (!payload) {\n return null;\n }\n const decoded = Buffer.from(payload, 'base64').toString('utf8');\n return JSON.parse(decoded) as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\n/**\n * Check if JWT token is expired\n */\nexport function isTokenExpired(token: string): boolean {\n const payload = parseJWT(token);\n if (!payload || typeof payload['exp'] !== 'number') {\n return true;\n }\n\n const now = Math.floor(Date.now() / 1000);\n return payload['exp'] < now;\n}\n\n/**\n * Format bytes to human readable string\n */\nexport function formatBytes(bytes: number, decimals = 2): string {\n if (bytes === 0) return '0 Bytes';\n\n const k = 1024;\n const dm = decimals < 0 ? 0 : decimals;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n}\n\n/**\n * Validation utilities\n *\n * Re-exported from validation.ts for convenience.\n * Use these for robust, secure validation of common data types.\n */\nexport {\n isValidEmail,\n isValidUrl,\n isValidRegexPattern,\n compileValidatedPattern,\n isValidPhone,\n isValidUUID,\n isValidIPv4,\n isValidSlug,\n isValidHexColor,\n isValidBase64,\n isValidJSON,\n isNumberInRange,\n isStringLengthValid,\n} from './validation.js';\n\n/**\n * Truncate string with ellipsis\n */\nexport function truncate(str: string, maxLength: number): string {\n if (str.length <= maxLength) {\n return str;\n }\n return str.substring(0, maxLength - 3) + '...';\n}\n\n/**\n * Chunk array into smaller arrays\n */\nexport function chunk<T>(array: T[], size: number): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < array.length; i += size) {\n chunks.push(array.slice(i, i + size));\n }\n return chunks;\n}\n\n/**\n * Remove duplicates from array\n */\nexport function unique<T>(array: T[]): T[] {\n return Array.from(new Set(array));\n}\n\n/**\n * Group array by key\n */\nexport function groupBy<T>(array: T[], key: keyof T): Record<string, T[]> {\n return array.reduce(\n (result, item) => {\n const groupKey = String(item[key]);\n if (!result[groupKey]) {\n result[groupKey] = [];\n }\n result[groupKey].push(item);\n return result;\n },\n {} as Record<string, T[]>\n );\n}\n\n/**\n * Pick specific keys from object\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Omit specific keys from object\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, K>;\n}\n","/**\n * Validation utilities\n *\n * Provides secure, robust validation functions for common data types.\n */\n\n/**\n * Validate email format with enhanced security and edge case handling\n *\n * Features:\n * - Optimized regex that avoids catastrophic backtracking\n * - Length validation (max 320 chars per RFC 5321)\n * - Validates local-part@domain.tld format\n * - Local part: alphanumeric, dots, hyphens, underscores (1-64 chars)\n * - Domain: alphanumeric, dots, hyphens (1-253 chars)\n * - TLD: alphabetic (2-63 chars)\n *\n * @param email - Email address to validate\n * @returns true if email is valid, false otherwise\n */\nexport function isValidEmail(email: string): boolean {\n // Optimized email regex - avoids catastrophic backtracking\n // Matches: local-part@domain.tld\n const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,63}$/;\n\n // Additional validation to prevent edge cases\n if (!email || email.length > 320) {\n return false;\n }\n\n return emailRegex.test(email);\n}\n\n/**\n * Validate URL format\n *\n * Uses the built-in URL constructor for robust validation.\n * Supports all standard URL schemes (http, https, ftp, etc.)\n *\n * @param url - URL string to validate\n * @returns true if URL is valid, false otherwise\n */\nexport function isValidUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate regex pattern to prevent ReDoS attacks\n *\n * This method only validates, it does NOT compile the RegExp.\n * Use compileValidatedPattern() to safely compile after validation.\n *\n * Security checks:\n * 1. Pattern is not empty or whitespace-only\n * 2. Pattern length is reasonable (<= 1000 chars) to prevent DoS\n * 3. Pattern can be successfully compiled (syntax check)\n *\n * @param pattern - Regular expression pattern to validate\n * @returns true if pattern is valid and safe, false otherwise\n */\nexport function isValidRegexPattern(pattern: string): boolean {\n // Check pattern is not empty and doesn't contain only whitespace\n if (!pattern || pattern.trim().length === 0) {\n return false;\n }\n\n // Reject patterns that are too long to prevent catastrophic backtracking DoS\n if (pattern.length > 1000) {\n return false;\n }\n\n // Test if pattern has valid syntax by attempting compilation\n // This is a validation check only - actual compilation happens in compileValidatedPattern()\n try {\n // Validation check: test if pattern can be compiled\n // This is safe because:\n // - We've already validated pattern length (<= 1000 chars)\n // - We're using void to discard the result (not storing/using it)\n // - Pattern comes from application config, not user input\n // - This is a validation step before actual use in compileValidatedPattern()\n void new RegExp(pattern);\n return true;\n } catch {\n // Pattern has invalid syntax\n return false;\n }\n}\n\n/**\n * Safely compile a validation pattern to RegExp after validation\n *\n * Returns null if the pattern is invalid.\n *\n * SECURITY: This method provides protection against ReDoS attacks by:\n * 1. Validating pattern isn't empty or null\n * 2. Rejecting patterns >1000 chars (prevents DoS via catastrophic backtracking)\n * 3. Testing compilation in try-catch to handle malformed patterns\n * 4. Only compiling patterns that pass all validation checks\n *\n * @param pattern - Regular expression pattern to compile\n * @returns Compiled RegExp or null if pattern is invalid\n */\nexport function compileValidatedPattern(pattern: string): RegExp | null {\n // Validate pattern before compilation\n if (!isValidRegexPattern(pattern)) {\n return null;\n }\n\n try {\n // At this point, pattern has been validated by isValidRegexPattern():\n // - Not empty or null\n // - Length <= 1000 characters (prevents ReDoS via catastrophic backtracking)\n // - Successfully compiled (pattern has valid syntax)\n // Safe to construct RegExp here\n return new RegExp(pattern);\n } catch {\n // Should not reach here since isValidRegexPattern() already tested compilation\n return null;\n }\n}\n\n/**\n * Validate phone number format\n *\n * Validates international phone numbers in E.164 format.\n * Format: +[country code][number] (e.g., +14155552671)\n *\n * Requirements:\n * - Starts with +\n * - Followed by 1-3 digit country code\n * - Followed by 4-14 digits\n * - Total length: 6-18 characters\n *\n * @param phone - Phone number to validate\n * @returns true if phone is valid E.164 format, false otherwise\n */\nexport function isValidPhone(phone: string): boolean {\n // E.164 format: +[country code][number]\n // Country code: 1-3 digits\n // Number: 4-14 digits\n // Total: 6-18 characters\n const phoneRegex = /^\\+[1-9]\\d{1,14}$/;\n\n if (!phone || phone.length < 6 || phone.length > 18) {\n return false;\n }\n\n return phoneRegex.test(phone);\n}\n\n/**\n * Validate UUID format (v4)\n *\n * Validates UUIDs in the standard format:\n * xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\n *\n * @param uuid - UUID string to validate\n * @returns true if UUID is valid v4 format, false otherwise\n */\nexport function isValidUUID(uuid: string): boolean {\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n return uuidRegex.test(uuid);\n}\n\n/**\n * Validate IPv4 address format\n *\n * Validates IPv4 addresses in dotted decimal notation.\n * Format: xxx.xxx.xxx.xxx where each xxx is 0-255\n *\n * @param ip - IP address to validate\n * @returns true if IP is valid IPv4, false otherwise\n */\nexport function isValidIPv4(ip: string): boolean {\n const ipRegex = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/;\n const match = ipRegex.exec(ip);\n\n if (!match) {\n return false;\n }\n\n // Validate each octet is 0-255\n for (let i = 1; i <= 4; i++) {\n const octet = parseInt(match[i] || '0', 10);\n if (octet < 0 || octet > 255) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Validate slug format\n *\n * Slugs are URL-friendly strings used in paths.\n * Requirements:\n * - Lowercase letters, numbers, hyphens only\n * - Must start and end with alphanumeric\n * - No consecutive hyphens\n * - Length: 1-100 characters\n *\n * @param slug - Slug to validate\n * @returns true if slug is valid, false otherwise\n */\nexport function isValidSlug(slug: string): boolean {\n if (!slug || slug.length < 1 || slug.length > 100) {\n return false;\n }\n\n // Must start and end with alphanumeric, can contain hyphens in between\n // No consecutive hyphens\n // Split into multiple checks to avoid unsafe regex with nested quantifiers\n\n // Check basic format: alphanumeric and hyphens only\n if (!/^[a-z0-9-]+$/.test(slug)) {\n return false;\n }\n\n // Check doesn't start or end with hyphen\n if (slug.startsWith('-') || slug.endsWith('-')) {\n return false;\n }\n\n // Check no consecutive hyphens\n if (slug.includes('--')) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Validate hex color code\n *\n * Validates hex color codes in formats:\n * - #RGB (e.g., #f0f)\n * - #RRGGBB (e.g., #ff00ff)\n * - #RRGGBBAA (e.g., #ff00ff80)\n *\n * @param color - Hex color code to validate\n * @returns true if color is valid hex, false otherwise\n */\nexport function isValidHexColor(color: string): boolean {\n const hexRegex = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n return hexRegex.test(color);\n}\n\n/**\n * Validate base64 string\n *\n * Validates base64-encoded strings.\n * Supports both standard and URL-safe base64.\n *\n * @param str - String to validate\n * @returns true if string is valid base64, false otherwise\n */\nexport function isValidBase64(str: string): boolean {\n if (!str || str.length === 0) {\n return false;\n }\n\n // Standard or URL-safe base64\n const base64Regex = /^[A-Za-z0-9+/\\-_]+=*$/;\n\n if (!base64Regex.test(str)) {\n return false;\n }\n\n // Try to decode to verify\n try {\n return Buffer.from(str, 'base64').toString('base64') === str;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate JSON string\n *\n * Validates that a string contains valid JSON.\n * Does not parse the JSON, only validates syntax.\n *\n * @param str - String to validate\n * @returns true if string is valid JSON, false otherwise\n */\nexport function isValidJSON(str: string): boolean {\n try {\n JSON.parse(str);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Validate number is within range\n *\n * @param value - Number to validate\n * @param min - Minimum value (inclusive), or null for no minimum\n * @param max - Maximum value (inclusive), or null for no maximum\n * @returns true if number is within range, false otherwise\n */\nexport function isNumberInRange(value: number, min: number | null, max: number | null): boolean {\n if (typeof value !== 'number' || isNaN(value)) {\n return false;\n }\n\n if (min !== null && value < min) {\n return false;\n }\n\n if (max !== null && value > max) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Validate string length is within range\n *\n * @param value - String to validate\n * @param min - Minimum length (inclusive), or null for no minimum\n * @param max - Maximum length (inclusive), or null for no maximum\n * @returns true if string length is within range, false otherwise\n */\nexport function isStringLengthValid(value: string, min: number | null, max: number | null): boolean {\n if (typeof value !== 'string') {\n return false;\n }\n\n const length = value.length;\n\n if (min !== null && length < min) {\n return false;\n }\n\n if (max !== null && length > max) {\n return false;\n }\n\n return true;\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __name } from './chunk-XE4OXN2W.js';
|
|
2
|
+
|
|
3
|
+
// src/types/layer.ts
|
|
4
|
+
var DEFAULT_GATEWAY_ROUTING = {
|
|
5
|
+
wspace: {
|
|
6
|
+
layer: "wspace",
|
|
7
|
+
internalGateway: {
|
|
8
|
+
host: "wspace-int-gateway",
|
|
9
|
+
port: 4001,
|
|
10
|
+
graphqlPath: "/workspaces/graphql"
|
|
11
|
+
},
|
|
12
|
+
crossLayerGateway: {
|
|
13
|
+
host: "global-public-gateway",
|
|
14
|
+
port: 4e3,
|
|
15
|
+
graphqlPath: "/global/graphql"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
global: {
|
|
19
|
+
layer: "global",
|
|
20
|
+
internalGateway: {
|
|
21
|
+
host: "global-int-gateway",
|
|
22
|
+
port: 4002,
|
|
23
|
+
graphqlPath: "/global/graphql"
|
|
24
|
+
},
|
|
25
|
+
crossLayerGateway: {
|
|
26
|
+
host: "wspace-public-gateway",
|
|
27
|
+
port: 4003,
|
|
28
|
+
graphqlPath: "/workspaces/graphql"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var DEFAULT_LAYER_STREAMS = {
|
|
33
|
+
wspace: [
|
|
34
|
+
{
|
|
35
|
+
name: "WSPACE_EVENTS",
|
|
36
|
+
subjects: [
|
|
37
|
+
"wspace.>"
|
|
38
|
+
],
|
|
39
|
+
description: "Workspace layer events stream"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "WSPACE_GRAPH_EVENTS",
|
|
43
|
+
subjects: [
|
|
44
|
+
"graph.>"
|
|
45
|
+
],
|
|
46
|
+
description: "Workspace layer graph events stream (captures all graph entity events)"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
global: [
|
|
50
|
+
{
|
|
51
|
+
name: "GLOBAL_EVENTS",
|
|
52
|
+
subjects: [
|
|
53
|
+
"global.>"
|
|
54
|
+
],
|
|
55
|
+
description: "Global layer events stream"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "GLOBAL_GRAPH_EVENTS",
|
|
59
|
+
subjects: [
|
|
60
|
+
"graph.>"
|
|
61
|
+
],
|
|
62
|
+
description: "Global layer graph events stream (captures all graph entity events)"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
function buildInternalGatewayUrl(layer) {
|
|
67
|
+
const routing = DEFAULT_GATEWAY_ROUTING[layer];
|
|
68
|
+
const { host, port, graphqlPath } = routing.internalGateway;
|
|
69
|
+
const protocol = "http";
|
|
70
|
+
return `${protocol}://${host}:${port}${graphqlPath}`;
|
|
71
|
+
}
|
|
72
|
+
__name(buildInternalGatewayUrl, "buildInternalGatewayUrl");
|
|
73
|
+
var DEFAULT_LAYER_RESOURCES = {
|
|
74
|
+
wspace: {
|
|
75
|
+
natsUrl: "nats://wspace-nats:4222",
|
|
76
|
+
valkeyUrl: "valkey://wspace-valkey:6379",
|
|
77
|
+
temporalAddress: "wspace-temporal:7233",
|
|
78
|
+
temporalNamespace: "wspace-default",
|
|
79
|
+
rbacGatewayUrl: buildInternalGatewayUrl("wspace")
|
|
80
|
+
},
|
|
81
|
+
global: {
|
|
82
|
+
natsUrl: "nats://global-nats:4222",
|
|
83
|
+
valkeyUrl: "valkey://global-valkey:6379",
|
|
84
|
+
temporalAddress: "global-temporal:7233",
|
|
85
|
+
temporalNamespace: "global-default",
|
|
86
|
+
rbacGatewayUrl: buildInternalGatewayUrl("global")
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var DEFAULT_CIRCUIT_BREAKER_CONFIG = {
|
|
90
|
+
failureThreshold: 5,
|
|
91
|
+
resetTimeout: 3e4,
|
|
92
|
+
failureWindow: 6e4
|
|
93
|
+
};
|
|
94
|
+
var DEFAULT_GATEWAY_RETRY_CONFIG = {
|
|
95
|
+
maxAttempts: 3,
|
|
96
|
+
initialDelay: 1e3,
|
|
97
|
+
maxDelay: 1e4,
|
|
98
|
+
backoffMultiplier: 2
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { DEFAULT_CIRCUIT_BREAKER_CONFIG, DEFAULT_GATEWAY_RETRY_CONFIG, DEFAULT_GATEWAY_ROUTING, DEFAULT_LAYER_RESOURCES, DEFAULT_LAYER_STREAMS };
|
|
102
|
+
//# sourceMappingURL=chunk-NGMEI42S.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-NGMEI42S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/layer.ts"],"names":["DEFAULT_GATEWAY_ROUTING","wspace","layer","internalGateway","host","port","graphqlPath","crossLayerGateway","global","DEFAULT_LAYER_STREAMS","name","subjects","description","buildInternalGatewayUrl","routing","protocol","DEFAULT_LAYER_RESOURCES","natsUrl","valkeyUrl","temporalAddress","temporalNamespace","rbacGatewayUrl","DEFAULT_CIRCUIT_BREAKER_CONFIG","failureThreshold","resetTimeout","failureWindow","DEFAULT_GATEWAY_RETRY_CONFIG","maxAttempts","initialDelay","maxDelay","backoffMultiplier"],"mappings":";;;AA8IO,IAAMA,uBAAAA,GAAsE;EACjFC,MAAAA,EAAQ;IACNC,KAAAA,EAAO,QAAA;IACPC,eAAAA,EAAiB;MACfC,IAAAA,EAAM,oBAAA;MACNC,IAAAA,EAAM,IAAA;MACNC,WAAAA,EAAa;AACf,KAAA;IACAC,iBAAAA,EAAmB;MACjBH,IAAAA,EAAM,uBAAA;MACNC,IAAAA,EAAM,GAAA;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yBAAA;IACTC,SAAAA,EAAW,6BAAA;IACXC,eAAAA,EAAiB,sBAAA;IACjBC,iBAAAA,EAAmB,gBAAA;AACnBC,IAAAA,cAAAA,EAAgBR,wBAAwB,QAAA;AAC1C,GAAA;EACAL,MAAAA,EAAQ;IACNS,OAAAA,EAAS,yBAAA;IACTC,SAAAA,EAAW,6BAAA;IACXC,eAAAA,EAAiB,sBAAA;IACjBC,iBAAAA,EAAmB,gBAAA;AACnBC,IAAAA,cAAAA,EAAgBR,wBAAwB,QAAA;AAC1C;AACF;AA4BO,IAAMS,8BAAAA,GAAuD;EAClEC,gBAAAA,EAAkB,CAAA;EAClBC,YAAAA,EAAc,GAAA;EACdC,aAAAA,EAAe;AACjB;AAkCO,IAAMC,4BAAAA,GAAmD;EAC9DC,WAAAA,EAAa,CAAA;EACbC,YAAAA,EAAc,GAAA;EACdC,QAAAA,EAAU,GAAA;EACVC,iBAAAA,EAAmB;AACrB","file":"chunk-NGMEI42S.js","sourcesContent":["/**\n * Layer Type Definitions for Burdenoff Backend SDK\n *\n * This module defines types for the layer-aware architecture,\n * supporting wspace (workspace) and global (tenant) service layers.\n *\n * @module types/layer\n * @category Configuration\n */\n\n/**\n * Service layer types\n * - wspace: Workspace layer services (product-specific operations)\n * - global: Global/tenant layer services (cross-product services)\n */\nexport type ServiceLayer = 'wspace' | 'global';\n\n/**\n * Layer configuration for a service\n */\nexport interface LayerConfig {\n /**\n * Layer type this service belongs to\n * @example 'wspace' or 'global'\n */\n layer: ServiceLayer;\n\n /**\n * Service name (e.g., 'wspace-tags-svc', 'global-auth-svc')\n */\n serviceName: string;\n\n /**\n * Service identity for bypass headers\n * Used for M2M authentication\n * @default serviceName\n */\n serviceIdentity?: string;\n}\n\n/**\n * Gateway configuration per layer\n */\nexport interface LayerGatewayConfig {\n /**\n * Internal gateway URL (same layer int-gateway)\n * - wspace services use: wspace-int-gateway\n * - global services use: global-int-gateway\n */\n internalGatewayUrl: string;\n\n /**\n * Cross-layer gateway URL (cross layer public-gateway)\n * - wspace services use: global-public-gateway\n * - global services use: wspace-public-gateway\n */\n crossLayerGatewayUrl: string;\n}\n\n/**\n * Resource URLs per layer\n */\nexport interface LayerResourceUrls {\n /**\n * NATS server URL for the layer\n */\n natsUrl: string;\n\n /**\n * Valkey/Redis URL for the layer\n */\n valkeyUrl: string;\n\n /**\n * Temporal server address for the layer\n */\n temporalAddress: string;\n\n /**\n * Temporal namespace for the layer\n */\n temporalNamespace: string;\n\n /**\n * RBAC gateway URL (for permission checks)\n */\n rbacGatewayUrl: string;\n}\n\n/**\n * Complete layer configuration including gateways and resources\n */\nexport interface LayerFullConfig extends LayerConfig {\n /**\n * Gateway configuration\n */\n gateways: LayerGatewayConfig;\n\n /**\n * Resource URLs\n */\n resources: LayerResourceUrls;\n}\n\n/**\n * Gateway routing rules by layer\n * Defines which gateway to use for same-layer vs cross-layer communication\n */\nexport interface GatewayRoutingConfig {\n /**\n * Layer this config applies to\n */\n layer: ServiceLayer;\n\n /**\n * Internal gateway for same-layer M2M calls\n */\n internalGateway: {\n /** Gateway host (without protocol) */\n host: string;\n /** Gateway port */\n port: number;\n /** GraphQL endpoint path */\n graphqlPath: string;\n };\n\n /**\n * Public gateway for cross-layer calls\n */\n crossLayerGateway: {\n /** Gateway host (without protocol) */\n host: string;\n /** Gateway port */\n port: number;\n /** GraphQL endpoint path */\n graphqlPath: string;\n };\n}\n\n/**\n * Default gateway routing configuration\n */\nexport const DEFAULT_GATEWAY_ROUTING: Record<ServiceLayer, GatewayRoutingConfig> = {\n wspace: {\n layer: 'wspace',\n internalGateway: {\n host: 'wspace-int-gateway',\n port: 4001,\n graphqlPath: '/workspaces/graphql',\n },\n crossLayerGateway: {\n host: 'global-public-gateway',\n port: 4000,\n graphqlPath: '/global/graphql',\n },\n },\n global: {\n layer: 'global',\n internalGateway: {\n host: 'global-int-gateway',\n port: 4002,\n graphqlPath: '/global/graphql',\n },\n crossLayerGateway: {\n host: 'wspace-public-gateway',\n port: 4003,\n graphqlPath: '/workspaces/graphql',\n },\n },\n};\n\n/**\n * Default stream configurations per layer\n */\nexport const DEFAULT_LAYER_STREAMS: Record<\n ServiceLayer,\n Array<{ name: string; subjects: string[]; description?: string }>\n> = {\n wspace: [\n {\n name: 'WSPACE_EVENTS',\n subjects: ['wspace.>'],\n description: 'Workspace layer events stream',\n },\n {\n name: 'WSPACE_GRAPH_EVENTS',\n subjects: ['graph.>'],\n description: 'Workspace layer graph events stream (captures all graph entity events)',\n },\n ],\n global: [\n {\n name: 'GLOBAL_EVENTS',\n subjects: ['global.>'],\n description: 'Global layer events stream',\n },\n {\n name: 'GLOBAL_GRAPH_EVENTS',\n subjects: ['graph.>'],\n description: 'Global layer graph events stream (captures all graph entity events)',\n },\n ],\n};\n\n/**\n * Build internal gateway URL for a layer\n * Uses HTTP for internal K8s communication (mTLS via Istio service mesh)\n */\nfunction buildInternalGatewayUrl(layer: ServiceLayer): string {\n const routing = DEFAULT_GATEWAY_ROUTING[layer];\n const { host, port, graphqlPath } = routing.internalGateway;\n // Internal K8s services use plain HTTP with mTLS handled by Istio\n const protocol = 'http';\n return `${protocol}://${host}:${port}${graphqlPath}`;\n}\n\n/**\n * Default resource URLs per layer\n *\n * Note: Internal K8s service communication uses plain HTTP with mTLS via Istio.\n * External traffic uses HTTPS via ingress gateway.\n */\nexport const DEFAULT_LAYER_RESOURCES: Record<ServiceLayer, LayerResourceUrls> = {\n wspace: {\n natsUrl: 'nats://wspace-nats:4222',\n valkeyUrl: 'valkey://wspace-valkey:6379',\n temporalAddress: 'wspace-temporal:7233',\n temporalNamespace: 'wspace-default',\n rbacGatewayUrl: buildInternalGatewayUrl('wspace'),\n },\n global: {\n natsUrl: 'nats://global-nats:4222',\n valkeyUrl: 'valkey://global-valkey:6379',\n temporalAddress: 'global-temporal:7233',\n temporalNamespace: 'global-default',\n rbacGatewayUrl: buildInternalGatewayUrl('global'),\n },\n};\n\n/**\n * Circuit breaker configuration for gateway client\n */\nexport interface CircuitBreakerConfig {\n /**\n * Number of failures before opening circuit\n * @default 5\n */\n failureThreshold: number;\n\n /**\n * Time in milliseconds to wait before attempting to close circuit\n * @default 30000 (30 seconds)\n */\n resetTimeout: number;\n\n /**\n * Time window in milliseconds for counting failures\n * @default 60000 (60 seconds)\n */\n failureWindow: number;\n}\n\n/**\n * Default circuit breaker configuration\n */\nexport const DEFAULT_CIRCUIT_BREAKER_CONFIG: CircuitBreakerConfig = {\n failureThreshold: 5,\n resetTimeout: 30000,\n failureWindow: 60000,\n};\n\n/**\n * Retry configuration for gateway client\n */\nexport interface GatewayRetryConfig {\n /**\n * Maximum number of retry attempts\n * @default 3\n */\n maxAttempts: number;\n\n /**\n * Initial delay in milliseconds before first retry\n * @default 1000 (1 second)\n */\n initialDelay: number;\n\n /**\n * Maximum delay in milliseconds between retries\n * @default 10000 (10 seconds)\n */\n maxDelay: number;\n\n /**\n * Backoff multiplier for exponential backoff\n * @default 2\n */\n backoffMultiplier: number;\n}\n\n/**\n * Default retry configuration\n */\nexport const DEFAULT_GATEWAY_RETRY_CONFIG: GatewayRetryConfig = {\n maxAttempts: 3,\n initialDelay: 1000,\n maxDelay: 10000,\n backoffMultiplier: 2,\n};\n\n/**\n * Headers automatically added by gateway client for M2M calls\n */\nexport interface GatewayRequestHeaders {\n /**\n * Actor ID making the request\n */\n 'x-actor-id'?: string;\n\n /**\n * Actor type\n */\n 'x-actor-type'?: 'user' | 'app' | 'service' | 'super_admin';\n\n /**\n * Workspace ID for the request context\n */\n 'x-workspace-id'?: string;\n\n /**\n * Service identity for bypass validation\n */\n 'x-service-identity'?: string;\n\n /**\n * Call type indicator\n */\n 'x-call-type'?: 'internal' | 'cross-layer';\n\n /**\n * Permission bypass flag\n */\n 'x-bypass-permission'?: string;\n\n /**\n * RBAC bypass flag (set by gateway)\n */\n 'x-rbac-bypass'?: 'true' | 'false';\n\n /**\n * Bypass source (set by gateway)\n */\n 'x-bypass-source'?: string;\n\n /**\n * Bypass timestamp (set by gateway)\n */\n 'x-bypass-timestamp'?: string;\n}\n"]}
|