@digilogiclabs/platform-core 1.8.0 → 1.10.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/dist/auth.d.mts +116 -3
- package/dist/auth.d.ts +116 -3
- package/dist/auth.js +91 -16
- package/dist/auth.js.map +1 -1
- package/dist/auth.mjs +86 -16
- package/dist/auth.mjs.map +1 -1
- package/dist/email-templates.d.mts +210 -0
- package/dist/email-templates.d.ts +210 -0
- package/dist/email-templates.js +345 -0
- package/dist/email-templates.js.map +1 -0
- package/dist/email-templates.mjs +304 -0
- package/dist/email-templates.mjs.map +1 -0
- package/dist/{env-jqNJdZVt.d.mts → env-CYKVNpLl.d.mts} +7 -88
- package/dist/{env-jqNJdZVt.d.ts → env-CYKVNpLl.d.ts} +7 -88
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +43 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -27
- package/dist/index.mjs.map +1 -1
- package/dist/security-BvLXaQkv.d.mts +88 -0
- package/dist/security-BvLXaQkv.d.ts +88 -0
- package/package.json +6 -1
package/dist/index.mjs
CHANGED
|
@@ -14032,7 +14032,10 @@ var MemoryBeta = class {
|
|
|
14032
14032
|
return { valid: false, message: "This invite code has expired." };
|
|
14033
14033
|
}
|
|
14034
14034
|
if (invite.currentUses >= invite.maxUses) {
|
|
14035
|
-
return {
|
|
14035
|
+
return {
|
|
14036
|
+
valid: false,
|
|
14037
|
+
message: "This invite code has reached its usage limit."
|
|
14038
|
+
};
|
|
14036
14039
|
}
|
|
14037
14040
|
return {
|
|
14038
14041
|
valid: true,
|
|
@@ -14082,7 +14085,9 @@ var MemoryBeta = class {
|
|
|
14082
14085
|
async getStats() {
|
|
14083
14086
|
const codes = Array.from(this.codes.values());
|
|
14084
14087
|
const activeCodes = codes.filter((c) => c.isActive);
|
|
14085
|
-
const testers = Array.from(this.testers.values()).filter(
|
|
14088
|
+
const testers = Array.from(this.testers.values()).filter(
|
|
14089
|
+
(t) => t.isBetaTester
|
|
14090
|
+
);
|
|
14086
14091
|
const joinDates = testers.map((t) => t.betaJoinedAt).sort((a, b) => a.getTime() - b.getTime());
|
|
14087
14092
|
return {
|
|
14088
14093
|
totalBetaTesters: testers.length,
|
|
@@ -18554,6 +18559,12 @@ var CommonRateLimits = {
|
|
|
18554
18559
|
limit: 10,
|
|
18555
18560
|
windowSeconds: 3600,
|
|
18556
18561
|
blockDurationSeconds: 3600
|
|
18562
|
+
},
|
|
18563
|
+
/** Beta code validation: 5/min with 5min block (prevents brute force guessing) */
|
|
18564
|
+
betaValidation: {
|
|
18565
|
+
limit: 5,
|
|
18566
|
+
windowSeconds: 60,
|
|
18567
|
+
blockDurationSeconds: 300
|
|
18557
18568
|
}
|
|
18558
18569
|
};
|
|
18559
18570
|
function createMemoryRateLimitStore() {
|
|
@@ -18916,14 +18927,11 @@ function createBetaClient(config = {}) {
|
|
|
18916
18927
|
async function fetchBetaSettings(config = {}) {
|
|
18917
18928
|
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
18918
18929
|
try {
|
|
18919
|
-
const response = await fetch(
|
|
18920
|
-
|
|
18921
|
-
{
|
|
18922
|
-
|
|
18923
|
-
|
|
18924
|
-
cache: "no-store"
|
|
18925
|
-
}
|
|
18926
|
-
);
|
|
18930
|
+
const response = await fetch(`${cfg.baseUrl}${cfg.settingsEndpoint}`, {
|
|
18931
|
+
method: "GET",
|
|
18932
|
+
headers: { "Content-Type": "application/json" },
|
|
18933
|
+
cache: "no-store"
|
|
18934
|
+
});
|
|
18927
18935
|
if (!response.ok) {
|
|
18928
18936
|
throw new Error(`Failed to fetch beta settings: ${response.status}`);
|
|
18929
18937
|
}
|
|
@@ -18951,14 +18959,11 @@ async function validateBetaCode(code, config = {}) {
|
|
|
18951
18959
|
};
|
|
18952
18960
|
}
|
|
18953
18961
|
try {
|
|
18954
|
-
const response = await fetch(
|
|
18955
|
-
|
|
18956
|
-
{
|
|
18957
|
-
|
|
18958
|
-
|
|
18959
|
-
body: JSON.stringify({ code: code.trim().toUpperCase() })
|
|
18960
|
-
}
|
|
18961
|
-
);
|
|
18962
|
+
const response = await fetch(`${cfg.baseUrl}${cfg.validateEndpoint}`, {
|
|
18963
|
+
method: "POST",
|
|
18964
|
+
headers: { "Content-Type": "application/json" },
|
|
18965
|
+
body: JSON.stringify({ code: code.trim().toUpperCase() })
|
|
18966
|
+
});
|
|
18962
18967
|
if (response.status === 429) {
|
|
18963
18968
|
return {
|
|
18964
18969
|
valid: false,
|
|
@@ -31118,17 +31123,20 @@ var PostgresBeta = class {
|
|
|
31118
31123
|
updated_by VARCHAR(255)
|
|
31119
31124
|
)
|
|
31120
31125
|
`);
|
|
31121
|
-
await client.query(
|
|
31126
|
+
await client.query(
|
|
31127
|
+
`
|
|
31122
31128
|
INSERT INTO ${this.t("beta_settings")} (key, value, description) VALUES
|
|
31123
31129
|
('beta_mode', $1, 'Whether the app is in beta mode'),
|
|
31124
31130
|
('require_invite_code', $2, 'Whether an invite code is required to sign up'),
|
|
31125
31131
|
('beta_message', $3, 'Message displayed during beta')
|
|
31126
31132
|
ON CONFLICT (key) DO NOTHING
|
|
31127
|
-
`,
|
|
31128
|
-
|
|
31129
|
-
|
|
31130
|
-
|
|
31131
|
-
|
|
31133
|
+
`,
|
|
31134
|
+
[
|
|
31135
|
+
String(this.config.defaultBetaMode),
|
|
31136
|
+
String(this.config.defaultRequireInviteCode),
|
|
31137
|
+
this.config.defaultBetaMessage
|
|
31138
|
+
]
|
|
31139
|
+
);
|
|
31132
31140
|
await client.query(`
|
|
31133
31141
|
CREATE TABLE IF NOT EXISTS ${this.t("beta_invites")} (
|
|
31134
31142
|
id VARCHAR(255) PRIMARY KEY,
|
|
@@ -31203,7 +31211,10 @@ var PostgresBeta = class {
|
|
|
31203
31211
|
updates.push({ key: "beta_mode", value: String(options.betaMode) });
|
|
31204
31212
|
}
|
|
31205
31213
|
if (options.requireInviteCode !== void 0) {
|
|
31206
|
-
updates.push({
|
|
31214
|
+
updates.push({
|
|
31215
|
+
key: "require_invite_code",
|
|
31216
|
+
value: String(options.requireInviteCode)
|
|
31217
|
+
});
|
|
31207
31218
|
}
|
|
31208
31219
|
if (options.betaMessage !== void 0) {
|
|
31209
31220
|
updates.push({ key: "beta_message", value: options.betaMessage });
|
|
@@ -31262,7 +31273,9 @@ var PostgresBeta = class {
|
|
|
31262
31273
|
}
|
|
31263
31274
|
}
|
|
31264
31275
|
if (!inserted) {
|
|
31265
|
-
throw new Error(
|
|
31276
|
+
throw new Error(
|
|
31277
|
+
`Failed to generate unique code after ${attempts} attempts`
|
|
31278
|
+
);
|
|
31266
31279
|
}
|
|
31267
31280
|
if (options.code) break;
|
|
31268
31281
|
}
|
|
@@ -31373,7 +31386,10 @@ var PostgresBeta = class {
|
|
|
31373
31386
|
return { valid: false, message: "This invite code has expired." };
|
|
31374
31387
|
}
|
|
31375
31388
|
if (existRow.current_uses >= existRow.max_uses) {
|
|
31376
|
-
return {
|
|
31389
|
+
return {
|
|
31390
|
+
valid: false,
|
|
31391
|
+
message: "This invite code has reached its usage limit."
|
|
31392
|
+
};
|
|
31377
31393
|
}
|
|
31378
31394
|
return { valid: false, message: "Invalid invite code." };
|
|
31379
31395
|
}
|