@digilogiclabs/platform-core 1.5.0 → 1.6.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 +2 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +1268 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.mjs +1175 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/index-CkyVz0hQ.d.mts +1367 -0
- package/dist/index-CkyVz0hQ.d.ts +1367 -0
- package/dist/index.d.mts +6 -1369
- package/dist/index.d.ts +6 -1369
- package/dist/index.js +95 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/dist/index.mjs
CHANGED
|
@@ -17964,11 +17964,8 @@ function buildKeycloakCallbacks(config) {
|
|
|
17964
17964
|
*
|
|
17965
17965
|
* Compatible with Auth.js v5 JWT callback signature.
|
|
17966
17966
|
*/
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
user,
|
|
17970
|
-
account
|
|
17971
|
-
}) {
|
|
17967
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17968
|
+
async jwt({ token, user, account }) {
|
|
17972
17969
|
if (user) {
|
|
17973
17970
|
token.id = token.sub ?? user.id;
|
|
17974
17971
|
}
|
|
@@ -18014,10 +18011,8 @@ function buildKeycloakCallbacks(config) {
|
|
|
18014
18011
|
*
|
|
18015
18012
|
* Compatible with Auth.js v5 session callback signature.
|
|
18016
18013
|
*/
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
token
|
|
18020
|
-
}) {
|
|
18014
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18015
|
+
async session({ session, token }) {
|
|
18021
18016
|
const user = session.user;
|
|
18022
18017
|
if (user) {
|
|
18023
18018
|
user.id = token.id || token.sub;
|
|
@@ -18639,6 +18634,97 @@ function createAuditLogger(options = {}) {
|
|
|
18639
18634
|
return { log, createTimedAudit };
|
|
18640
18635
|
}
|
|
18641
18636
|
|
|
18637
|
+
// src/env.ts
|
|
18638
|
+
function getRequiredEnv(key) {
|
|
18639
|
+
const value = process.env[key];
|
|
18640
|
+
if (!value) {
|
|
18641
|
+
throw new Error(`Missing required environment variable: ${key}`);
|
|
18642
|
+
}
|
|
18643
|
+
return value;
|
|
18644
|
+
}
|
|
18645
|
+
function getOptionalEnv(key, defaultValue) {
|
|
18646
|
+
return process.env[key] || defaultValue;
|
|
18647
|
+
}
|
|
18648
|
+
function getBoolEnv(key, defaultValue = false) {
|
|
18649
|
+
const value = process.env[key];
|
|
18650
|
+
if (value === void 0 || value === "") return defaultValue;
|
|
18651
|
+
return value === "true" || value === "1";
|
|
18652
|
+
}
|
|
18653
|
+
function getIntEnv(key, defaultValue) {
|
|
18654
|
+
const value = process.env[key];
|
|
18655
|
+
if (value === void 0 || value === "") return defaultValue;
|
|
18656
|
+
const parsed = parseInt(value, 10);
|
|
18657
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
18658
|
+
}
|
|
18659
|
+
function validateEnvVars(config) {
|
|
18660
|
+
const result = checkEnvVars(config);
|
|
18661
|
+
if (!result.valid) {
|
|
18662
|
+
const lines = [];
|
|
18663
|
+
if (result.missing.length > 0) {
|
|
18664
|
+
lines.push(
|
|
18665
|
+
"Missing required environment variables:",
|
|
18666
|
+
...result.missing.map((v) => ` - ${v}`)
|
|
18667
|
+
);
|
|
18668
|
+
}
|
|
18669
|
+
if (result.missingOneOf.length > 0) {
|
|
18670
|
+
for (const group of result.missingOneOf) {
|
|
18671
|
+
lines.push(`Missing one of: ${group.join(" | ")}`);
|
|
18672
|
+
}
|
|
18673
|
+
}
|
|
18674
|
+
if (result.invalid.length > 0) {
|
|
18675
|
+
lines.push(
|
|
18676
|
+
"Invalid environment variables:",
|
|
18677
|
+
...result.invalid.map((v) => ` - ${v.key}: ${v.reason}`)
|
|
18678
|
+
);
|
|
18679
|
+
}
|
|
18680
|
+
throw new Error(lines.join("\n"));
|
|
18681
|
+
}
|
|
18682
|
+
}
|
|
18683
|
+
function checkEnvVars(config) {
|
|
18684
|
+
const missing = [];
|
|
18685
|
+
const invalid = [];
|
|
18686
|
+
const missingOneOf = [];
|
|
18687
|
+
if (config.required) {
|
|
18688
|
+
for (const key of config.required) {
|
|
18689
|
+
if (!process.env[key]) {
|
|
18690
|
+
missing.push(key);
|
|
18691
|
+
}
|
|
18692
|
+
}
|
|
18693
|
+
}
|
|
18694
|
+
if (config.requireOneOf) {
|
|
18695
|
+
for (const group of config.requireOneOf) {
|
|
18696
|
+
const hasAny = group.some((key) => !!process.env[key]);
|
|
18697
|
+
if (!hasAny) {
|
|
18698
|
+
missingOneOf.push(group);
|
|
18699
|
+
}
|
|
18700
|
+
}
|
|
18701
|
+
}
|
|
18702
|
+
if (config.validators) {
|
|
18703
|
+
for (const [key, validator] of Object.entries(config.validators)) {
|
|
18704
|
+
const value = process.env[key];
|
|
18705
|
+
if (value) {
|
|
18706
|
+
const result = validator(value);
|
|
18707
|
+
if (result !== true) {
|
|
18708
|
+
invalid.push({ key, reason: result });
|
|
18709
|
+
}
|
|
18710
|
+
}
|
|
18711
|
+
}
|
|
18712
|
+
}
|
|
18713
|
+
return {
|
|
18714
|
+
valid: missing.length === 0 && invalid.length === 0 && missingOneOf.length === 0,
|
|
18715
|
+
missing,
|
|
18716
|
+
invalid,
|
|
18717
|
+
missingOneOf
|
|
18718
|
+
};
|
|
18719
|
+
}
|
|
18720
|
+
function getEnvSummary(keys) {
|
|
18721
|
+
const summary = {};
|
|
18722
|
+
for (const key of keys) {
|
|
18723
|
+
summary[key] = !!process.env[key];
|
|
18724
|
+
}
|
|
18725
|
+
return summary;
|
|
18726
|
+
}
|
|
18727
|
+
|
|
18642
18728
|
// src/http/health.ts
|
|
18643
18729
|
function createHealthEndpoints(platform, options = {}) {
|
|
18644
18730
|
const {
|
|
@@ -30599,97 +30685,6 @@ function generateId2() {
|
|
|
30599
30685
|
return randomBytes36(8).toString("hex") + Date.now().toString(36);
|
|
30600
30686
|
}
|
|
30601
30687
|
|
|
30602
|
-
// src/env.ts
|
|
30603
|
-
function getRequiredEnv(key) {
|
|
30604
|
-
const value = process.env[key];
|
|
30605
|
-
if (!value) {
|
|
30606
|
-
throw new Error(`Missing required environment variable: ${key}`);
|
|
30607
|
-
}
|
|
30608
|
-
return value;
|
|
30609
|
-
}
|
|
30610
|
-
function getOptionalEnv(key, defaultValue) {
|
|
30611
|
-
return process.env[key] || defaultValue;
|
|
30612
|
-
}
|
|
30613
|
-
function getBoolEnv(key, defaultValue = false) {
|
|
30614
|
-
const value = process.env[key];
|
|
30615
|
-
if (value === void 0 || value === "") return defaultValue;
|
|
30616
|
-
return value === "true" || value === "1";
|
|
30617
|
-
}
|
|
30618
|
-
function getIntEnv(key, defaultValue) {
|
|
30619
|
-
const value = process.env[key];
|
|
30620
|
-
if (value === void 0 || value === "") return defaultValue;
|
|
30621
|
-
const parsed = parseInt(value, 10);
|
|
30622
|
-
return isNaN(parsed) ? defaultValue : parsed;
|
|
30623
|
-
}
|
|
30624
|
-
function validateEnvVars(config) {
|
|
30625
|
-
const result = checkEnvVars(config);
|
|
30626
|
-
if (!result.valid) {
|
|
30627
|
-
const lines = [];
|
|
30628
|
-
if (result.missing.length > 0) {
|
|
30629
|
-
lines.push(
|
|
30630
|
-
"Missing required environment variables:",
|
|
30631
|
-
...result.missing.map((v) => ` - ${v}`)
|
|
30632
|
-
);
|
|
30633
|
-
}
|
|
30634
|
-
if (result.missingOneOf.length > 0) {
|
|
30635
|
-
for (const group of result.missingOneOf) {
|
|
30636
|
-
lines.push(`Missing one of: ${group.join(" | ")}`);
|
|
30637
|
-
}
|
|
30638
|
-
}
|
|
30639
|
-
if (result.invalid.length > 0) {
|
|
30640
|
-
lines.push(
|
|
30641
|
-
"Invalid environment variables:",
|
|
30642
|
-
...result.invalid.map((v) => ` - ${v.key}: ${v.reason}`)
|
|
30643
|
-
);
|
|
30644
|
-
}
|
|
30645
|
-
throw new Error(lines.join("\n"));
|
|
30646
|
-
}
|
|
30647
|
-
}
|
|
30648
|
-
function checkEnvVars(config) {
|
|
30649
|
-
const missing = [];
|
|
30650
|
-
const invalid = [];
|
|
30651
|
-
const missingOneOf = [];
|
|
30652
|
-
if (config.required) {
|
|
30653
|
-
for (const key of config.required) {
|
|
30654
|
-
if (!process.env[key]) {
|
|
30655
|
-
missing.push(key);
|
|
30656
|
-
}
|
|
30657
|
-
}
|
|
30658
|
-
}
|
|
30659
|
-
if (config.requireOneOf) {
|
|
30660
|
-
for (const group of config.requireOneOf) {
|
|
30661
|
-
const hasAny = group.some((key) => !!process.env[key]);
|
|
30662
|
-
if (!hasAny) {
|
|
30663
|
-
missingOneOf.push(group);
|
|
30664
|
-
}
|
|
30665
|
-
}
|
|
30666
|
-
}
|
|
30667
|
-
if (config.validators) {
|
|
30668
|
-
for (const [key, validator] of Object.entries(config.validators)) {
|
|
30669
|
-
const value = process.env[key];
|
|
30670
|
-
if (value) {
|
|
30671
|
-
const result = validator(value);
|
|
30672
|
-
if (result !== true) {
|
|
30673
|
-
invalid.push({ key, reason: result });
|
|
30674
|
-
}
|
|
30675
|
-
}
|
|
30676
|
-
}
|
|
30677
|
-
}
|
|
30678
|
-
return {
|
|
30679
|
-
valid: missing.length === 0 && invalid.length === 0 && missingOneOf.length === 0,
|
|
30680
|
-
missing,
|
|
30681
|
-
invalid,
|
|
30682
|
-
missingOneOf
|
|
30683
|
-
};
|
|
30684
|
-
}
|
|
30685
|
-
function getEnvSummary(keys) {
|
|
30686
|
-
const summary = {};
|
|
30687
|
-
for (const key of keys) {
|
|
30688
|
-
summary[key] = !!process.env[key];
|
|
30689
|
-
}
|
|
30690
|
-
return summary;
|
|
30691
|
-
}
|
|
30692
|
-
|
|
30693
30688
|
// src/app-logger.ts
|
|
30694
30689
|
var LEVEL_PRIORITY2 = {
|
|
30695
30690
|
debug: 0,
|