@arkstack/common 0.14.22 → 0.15.1
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/index.d.ts +25 -1
- package/dist/index.js +39 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -789,4 +789,28 @@ declare class ConfigLoader {
|
|
|
789
789
|
*/
|
|
790
790
|
declare const configLoader: ConfigLoader;
|
|
791
791
|
//#endregion
|
|
792
|
-
|
|
792
|
+
//#region src/tls.d.ts
|
|
793
|
+
interface TlsCredentials {
|
|
794
|
+
/** PEM-encoded private key. */
|
|
795
|
+
key: string;
|
|
796
|
+
/** PEM-encoded certificate. */
|
|
797
|
+
cert: string;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Generate (and cache) an in-memory self-signed TLS certificate for local HTTPS
|
|
801
|
+
* development. `selfsigned` is imported lazily so it's only loaded when secure
|
|
802
|
+
* dev mode is actually used.
|
|
803
|
+
*
|
|
804
|
+
* The certificate is not trusted by browsers (expect the usual self-signed
|
|
805
|
+
* warning); it exists only so the dev server can speak HTTPS.
|
|
806
|
+
*
|
|
807
|
+
* @param host The common name for the certificate (defaults to `localhost`).
|
|
808
|
+
*/
|
|
809
|
+
declare const devTlsCredentials: (host?: string) => Promise<TlsCredentials>;
|
|
810
|
+
/**
|
|
811
|
+
* The machine's first non-internal IPv4 address — its address on the local
|
|
812
|
+
* network — or `undefined` when only loopback interfaces are available.
|
|
813
|
+
*/
|
|
814
|
+
declare const localNetworkAddress: () => string | undefined;
|
|
815
|
+
//#endregion
|
|
816
|
+
export { AbstractModelConstructor, AppConfig, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, ConfigLoader, ConfigRegistry, ConfigShape, DotPath, DotPathValue, Encryption, EnvKey, EnvLoader, EnvLookup, EnvRegistry, EnvReturn, ErrorHandler, Exception, FileImporter, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, Primitive, PublishEntry, PublishFilter, PublishGroup, Publisher, RequestException, TlsCredentials, UnionToIntersection, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ModelNotFoundException } from "arkormx";
|
|
|
8
8
|
import { detect } from "detect-port";
|
|
9
9
|
import pino from "pino";
|
|
10
10
|
import chalk from "chalk";
|
|
11
|
+
import { networkInterfaces } from "node:os";
|
|
11
12
|
//#region src/lifecycle.ts
|
|
12
13
|
const bindGracefulShutdown = (shutdown, defer) => {
|
|
13
14
|
if (defer) return;
|
|
@@ -531,4 +532,41 @@ var Hook = class {
|
|
|
531
532
|
};
|
|
532
533
|
};
|
|
533
534
|
//#endregion
|
|
534
|
-
|
|
535
|
+
//#region src/tls.ts
|
|
536
|
+
let devCertCache;
|
|
537
|
+
/**
|
|
538
|
+
* Generate (and cache) an in-memory self-signed TLS certificate for local HTTPS
|
|
539
|
+
* development. `selfsigned` is imported lazily so it's only loaded when secure
|
|
540
|
+
* dev mode is actually used.
|
|
541
|
+
*
|
|
542
|
+
* The certificate is not trusted by browsers (expect the usual self-signed
|
|
543
|
+
* warning); it exists only so the dev server can speak HTTPS.
|
|
544
|
+
*
|
|
545
|
+
* @param host The common name for the certificate (defaults to `localhost`).
|
|
546
|
+
*/
|
|
547
|
+
const devTlsCredentials = async (host = "localhost") => {
|
|
548
|
+
if (devCertCache) return devCertCache;
|
|
549
|
+
const mod = await import("selfsigned");
|
|
550
|
+
const pems = (mod.default ?? mod).generate([{
|
|
551
|
+
name: "commonName",
|
|
552
|
+
value: host
|
|
553
|
+
}], {
|
|
554
|
+
days: 365,
|
|
555
|
+
keySize: 2048,
|
|
556
|
+
algorithm: "sha256"
|
|
557
|
+
});
|
|
558
|
+
devCertCache = {
|
|
559
|
+
key: pems.private,
|
|
560
|
+
cert: pems.cert
|
|
561
|
+
};
|
|
562
|
+
return devCertCache;
|
|
563
|
+
};
|
|
564
|
+
/**
|
|
565
|
+
* The machine's first non-internal IPv4 address — its address on the local
|
|
566
|
+
* network — or `undefined` when only loopback interfaces are available.
|
|
567
|
+
*/
|
|
568
|
+
const localNetworkAddress = () => {
|
|
569
|
+
for (const list of Object.values(networkInterfaces())) for (const net of list ?? []) if (net.family === "IPv4" && !net.internal) return net.address;
|
|
570
|
+
};
|
|
571
|
+
//#endregion
|
|
572
|
+
export { AppException, CONFIG_KEY, ConfigLoader, Encryption, EnvLoader, ErrorHandler, Exception, Hash, Hook, Logger, Publisher, RequestException, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -40,13 +40,14 @@
|
|
|
40
40
|
"dotenv": "^17.4.2",
|
|
41
41
|
"jiti": "^2.7.0",
|
|
42
42
|
"otpauth": "^9.5.1",
|
|
43
|
-
"pino": "^10.3.1"
|
|
43
|
+
"pino": "^10.3.1",
|
|
44
|
+
"selfsigned": "^2.4.1"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"@h3ravel/support": "^2.2.0",
|
|
47
48
|
"arkormx": "^2.10.1",
|
|
48
|
-
"@arkstack/
|
|
49
|
-
"@arkstack/
|
|
49
|
+
"@arkstack/foundry": "^0.15.1",
|
|
50
|
+
"@arkstack/contract": "^0.15.1"
|
|
50
51
|
},
|
|
51
52
|
"optionalDependencies": {
|
|
52
53
|
"@faker-js/faker": "^10.4.0"
|