@arkstack/common 0.18.7 → 0.18.9

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/faker.js CHANGED
@@ -1,4 +1,4 @@
1
- import { g as configLoader } from "./system-Die_Dv5y.js";
1
+ import { g as configLoader } from "./system-BH1phDBR.js";
2
2
  import * as fakerLocales from "@faker-js/faker";
3
3
  import { Faker } from "@faker-js/faker";
4
4
  import { pictwoImage } from "@pictwo/faker";
@@ -388,6 +388,10 @@ interface PublishConfirmation {
388
388
  */
389
389
  callback?: (choice: Choice<string>['value'], stub: string) => string | Promise<string>;
390
390
  }
391
+ type Concrete<T extends abstract new (...args: any[]) => any> = Omit<T, 'prototype'> & {
392
+ new (...args: ConstructorParameters<T>): InstanceType<T>;
393
+ prototype: InstanceType<T>;
394
+ };
391
395
  //#endregion
392
396
  //#region src/utils/encryption.d.ts
393
397
  /**
@@ -680,4 +684,4 @@ declare const abortIf: <T>(boolean: T, message?: string, code?: number) => asser
680
684
  */
681
685
  declare const assertFound: <T>(value: T | null | undefined, message: string, code?: number) => asserts value is T;
682
686
  //#endregion
683
- export { IHook as $, SerializedKeyPair as A, EnvKey as B, FingerprintOptions as C, NodeCipher as D, Keys as E, Choices as F, GlobalConfig as G, EnvRegistry as H, ConfigRegistry as I, HookFor as J, GlobalEnv as K, ConfigShape as L, ArkstackErrorPayload as M, ArkstackErrorShape as N, SealedBox as O, Choice as P, HookRegistry as Q, DotPath as R, EncryptionKey as S, KeyPair as T, EnvReturn as U, EnvLookup as V, FileImporter as W, HookPos as X, HookName as Y, HookPositions as Z, CipherOptions as _, abortIf as a, Primitive as at, DerivedKey as b, getModelSync as c, PublishFilter as ct, normalizePositiveInteger as d, Logger as dt, LoggerChalk as et, perPage as f, Cipher as g, ChannelOptions as h, abort as i, PaginationOptions as it, AppConfig as j, SecureChannel as k, initializeGlobalContext as l, PublishGroup as lt, Hash as m, ModelConstructor as n, LoggerParseSignature as nt, assertFound as o, PublishConfirmation as ot, resolvePagination as p, HookArgs as q, ModelRegistry as r, MergedConfig as rt, getModel$1 as s, PublishEntry as st, AbstractModelConstructor as t, LoggerLog as tt, isClass as u, UnionToIntersection as ut, Codec as v, KeyInput as w, Encryption as x, DeriveOptions as y, DotPathValue as z };
687
+ export { HookRegistry as $, SerializedKeyPair as A, DotPathValue as B, FingerprintOptions as C, NodeCipher as D, Keys as E, Choices as F, FileImporter as G, EnvLookup as H, Concrete as I, HookArgs as J, GlobalConfig as K, ConfigRegistry as L, ArkstackErrorPayload as M, ArkstackErrorShape as N, SealedBox as O, Choice as P, HookPositions as Q, ConfigShape as R, EncryptionKey as S, KeyPair as T, EnvRegistry as U, EnvKey as V, EnvReturn as W, HookName as X, HookFor as Y, HookPos as Z, CipherOptions as _, abortIf as a, PaginationOptions as at, DerivedKey as b, getModelSync as c, PublishEntry as ct, normalizePositiveInteger as d, UnionToIntersection as dt, IHook as et, perPage as f, Logger as ft, Cipher as g, ChannelOptions as h, abort as i, MergedConfig as it, AppConfig as j, SecureChannel as k, initializeGlobalContext as l, PublishFilter as lt, Hash as m, ModelConstructor as n, LoggerLog as nt, assertFound as o, Primitive as ot, resolvePagination as p, GlobalEnv as q, ModelRegistry as r, LoggerParseSignature as rt, getModel$1 as s, PublishConfirmation as st, AbstractModelConstructor as t, LoggerChalk as tt, isClass as u, PublishGroup as ut, Codec as v, KeyInput as w, Encryption as x, DeriveOptions as y, DotPath as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { $ as IHook, A as SerializedKeyPair, B as EnvKey, C as FingerprintOptions, D as NodeCipher, E as Keys, F as Choices, G as GlobalConfig, H as EnvRegistry, I as ConfigRegistry, J as HookFor, K as GlobalEnv, L as ConfigShape, M as ArkstackErrorPayload, N as ArkstackErrorShape, O as SealedBox, P as Choice, Q as HookRegistry, R as DotPath, S as EncryptionKey, T as KeyPair, U as EnvReturn, V as EnvLookup, W as FileImporter, X as HookPos, Y as HookName, Z as HookPositions, _ as CipherOptions, a as abortIf, at as Primitive, b as DerivedKey, c as getModelSync, ct as PublishFilter, d as normalizePositiveInteger, dt as Logger, et as LoggerChalk, f as perPage, g as Cipher, h as ChannelOptions, i as abort, it as PaginationOptions, j as AppConfig, k as SecureChannel, l as initializeGlobalContext, lt as PublishGroup, m as Hash, n as ModelConstructor, nt as LoggerParseSignature, o as assertFound, ot as PublishConfirmation, p as resolvePagination, q as HookArgs, r as ModelRegistry, rt as MergedConfig, s as getModel, st as PublishEntry, t as AbstractModelConstructor, tt as LoggerLog, u as isClass, ut as UnionToIntersection, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions, z as DotPathValue } from "./helpers-Bn-0uv3R.js";
2
+ import { $ as HookRegistry, A as SerializedKeyPair, B as DotPathValue, C as FingerprintOptions, D as NodeCipher, E as Keys, F as Choices, G as FileImporter, H as EnvLookup, I as Concrete, J as HookArgs, K as GlobalConfig, L as ConfigRegistry, M as ArkstackErrorPayload, N as ArkstackErrorShape, O as SealedBox, P as Choice, Q as HookPositions, R as ConfigShape, S as EncryptionKey, T as KeyPair, U as EnvRegistry, V as EnvKey, W as EnvReturn, X as HookName, Y as HookFor, Z as HookPos, _ as CipherOptions, a as abortIf, at as PaginationOptions, b as DerivedKey, c as getModelSync, ct as PublishEntry, d as normalizePositiveInteger, dt as UnionToIntersection, et as IHook, f as perPage, ft as Logger, g as Cipher, h as ChannelOptions, i as abort, it as MergedConfig, j as AppConfig, k as SecureChannel, l as initializeGlobalContext, lt as PublishFilter, m as Hash, n as ModelConstructor, nt as LoggerLog, o as assertFound, ot as Primitive, p as resolvePagination, q as GlobalEnv, r as ModelRegistry, rt as LoggerParseSignature, s as getModel, st as PublishConfirmation, t as AbstractModelConstructor, tt as LoggerChalk, u as isClass, ut as PublishGroup, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions, z as DotPath } from "./helpers-DgIgQLDu.js";
3
3
  import { Arkstack } from "@arkstack/contract";
4
4
  import { ForkOptions } from "node:child_process";
5
5
  import pino from "pino";
@@ -407,10 +407,29 @@ declare class EnvLoader {
407
407
  * Read an environment variable, coercing booleans, numbers and `null`, and
408
408
  * falling back to `defaultValue` when it is unset.
409
409
  *
410
+ * A value is only read as a number when the number says exactly what was
411
+ * written. See {@link isExactNumber}.
412
+ *
410
413
  * @param name The variable name.
411
414
  * @param defaultValue Returned when the variable is unset.
412
415
  */
413
416
  get<X = never, D = undefined, K extends string = string>(name: K, defaultValue?: D): EnvReturn<X, K, D>;
417
+ /**
418
+ * Whether a number would say exactly what the variable says.
419
+ *
420
+ * `Number()` accepts far more than decimal digits: hexadecimal, binary and
421
+ * octal literals, exponents, surrounding whitespace, and integers wider
422
+ * than a double can hold. Coercing those loses information silently, and
423
+ * the values that look like numbers by accident tend to be the ones where
424
+ * that matters most - a 32-byte key beginning `0x` becomes a float that
425
+ * keeps roughly its first thirteen digits, and nothing downstream can tell
426
+ * that it happened.
427
+ *
428
+ * Converting back and comparing is the whole test: `'6379'` survives it,
429
+ * `'0x1f'`, `'007'`, `'1e5'` and `'12345678901234567890'` do not, and so
430
+ * they stay the strings they were written as.
431
+ */
432
+ private isExactNumber;
414
433
  }
415
434
  /**
416
435
  * Shared environment loader backing {@link env}.
@@ -514,4 +533,4 @@ declare const devServer: (options: DevServerRunnerOptions) => {
514
533
  closeWatcher(): Promise<void>;
515
534
  };
516
535
  //#endregion
517
- export { AbstractModelConstructor, AppConfig, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, type ChannelOptions, Choice, Choices, Cipher, type CipherOptions, Codec, ConfigLoader, ConfigRegistry, ConfigShape, type DeriveOptions, type DerivedKey, DevServerRunnerOptions, DotPath, DotPathValue, Encryption, EncryptionKey, EnvKey, EnvLoader, EnvLookup, EnvRegistry, EnvReturn, ErrorHandler, Exception, FileImporter, type FingerprintOptions, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, type KeyInput, KeyPair, Keys, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, NodeCipher, PaginationOptions, Primitive, PublishConfirmation, PublishEntry, PublishFilter, PublishGroup, Publisher, RequestException, SealedBox, SecureChannel, type SerializedKeyPair, TlsCredentials, UnionToIntersection, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
536
+ export { AbstractModelConstructor, AppConfig, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, type ChannelOptions, Choice, Choices, Cipher, type CipherOptions, Codec, Concrete, ConfigLoader, ConfigRegistry, ConfigShape, type DeriveOptions, type DerivedKey, DevServerRunnerOptions, DotPath, DotPathValue, Encryption, EncryptionKey, EnvKey, EnvLoader, EnvLookup, EnvRegistry, EnvReturn, ErrorHandler, Exception, FileImporter, type FingerprintOptions, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, type KeyInput, KeyPair, Keys, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, NodeCipher, PaginationOptions, Primitive, PublishConfirmation, PublishEntry, PublishFilter, PublishGroup, Publisher, RequestException, SealedBox, SecureChannel, type SerializedKeyPair, TlsCredentials, UnionToIntersection, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-Die_Dv5y.js";
2
- import { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, _ as RequestException, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as AppException, w as EncryptionKey, x as Cipher, y as Exception } from "./utils-gKiLoXG9.js";
1
+ import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-BH1phDBR.js";
2
+ import { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, _ as RequestException, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as AppException, w as EncryptionKey, x as Cipher, y as Exception } from "./utils-4xEVrT0Z.js";
3
3
  import { Hook as Hook$1 } from "@arkstack/foundry";
4
4
  import { Arkstack } from "@arkstack/contract";
5
5
  import { str } from "@h3ravel/support";
@@ -42,6 +42,9 @@ var EnvLoader = class {
42
42
  * Read an environment variable, coercing booleans, numbers and `null`, and
43
43
  * falling back to `defaultValue` when it is unset.
44
44
  *
45
+ * A value is only read as a number when the number says exactly what was
46
+ * written. See {@link isExactNumber}.
47
+ *
45
48
  * @param name The variable name.
46
49
  * @param defaultValue Returned when the variable is unset.
47
50
  */
@@ -60,12 +63,31 @@ var EnvLoader = class {
60
63
  "true",
61
64
  "on"
62
65
  ].includes(val);
63
- if (!isNaN(Number(val)) && typeof val !== "boolean" && typeof val !== "undefined" && val !== "") val = Number(val);
66
+ if (typeof val === "string" && this.isExactNumber(val)) val = Number(val);
64
67
  if (val === "") val = void 0;
65
68
  if (val === "null") val = null;
66
69
  val ??= defaultValue;
67
70
  return val;
68
71
  }
72
+ /**
73
+ * Whether a number would say exactly what the variable says.
74
+ *
75
+ * `Number()` accepts far more than decimal digits: hexadecimal, binary and
76
+ * octal literals, exponents, surrounding whitespace, and integers wider
77
+ * than a double can hold. Coercing those loses information silently, and
78
+ * the values that look like numbers by accident tend to be the ones where
79
+ * that matters most - a 32-byte key beginning `0x` becomes a float that
80
+ * keeps roughly its first thirteen digits, and nothing downstream can tell
81
+ * that it happened.
82
+ *
83
+ * Converting back and comparing is the whole test: `'6379'` survives it,
84
+ * `'0x1f'`, `'007'`, `'1e5'` and `'12345678901234567890'` do not, and so
85
+ * they stay the strings they were written as.
86
+ */
87
+ isExactNumber(value) {
88
+ const parsed = Number(value);
89
+ return Number.isFinite(parsed) && String(parsed) === value;
90
+ }
69
91
  };
70
92
  /**
71
93
  * Shared environment loader backing {@link env}.
@@ -1,4 +1,4 @@
1
- import { A as SerializedKeyPair, C as FingerprintOptions, D as NodeCipher, E as Keys, O as SealedBox, S as EncryptionKey, T as KeyPair, _ as CipherOptions, a as abortIf, b as DerivedKey, c as getModelSync, d as normalizePositiveInteger, f as perPage, g as Cipher, h as ChannelOptions, i as abort, k as SecureChannel, l as initializeGlobalContext, m as Hash, n as ModelConstructor, o as assertFound, p as resolvePagination, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as isClass, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions } from "../helpers-Bn-0uv3R.js";
1
+ import { A as SerializedKeyPair, C as FingerprintOptions, D as NodeCipher, E as Keys, O as SealedBox, S as EncryptionKey, T as KeyPair, _ as CipherOptions, a as abortIf, b as DerivedKey, c as getModelSync, d as normalizePositiveInteger, f as perPage, g as Cipher, h as ChannelOptions, i as abort, k as SecureChannel, l as initializeGlobalContext, m as Hash, n as ModelConstructor, o as assertFound, p as resolvePagination, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as isClass, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions } from "../helpers-DgIgQLDu.js";
2
2
  import { Model } from "arkormx";
3
3
  //#region src/utils/traits.d.ts
4
4
  declare const crc32: (str: string) => number;
@@ -1,2 +1,2 @@
1
- import { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, a as use, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as EncryptionKey, x as Cipher } from "../utils-gKiLoXG9.js";
1
+ import { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, a as use, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as EncryptionKey, x as Cipher } from "../utils-4xEVrT0Z.js";
2
2
  export { Cipher, Codec, Encryption, EncryptionKey, Hash, KeyPair, Keys, NodeCipher, SealedBox, SecureChannel, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, trait, use, uses };
@@ -1,4 +1,4 @@
1
- import { a as env, t as appKey } from "./system-Die_Dv5y.js";
1
+ import { a as env, t as appKey } from "./system-BH1phDBR.js";
2
2
  import { Cipher, Codec, EncryptionKey, KeyPair, Keys, SealedBox, SecureChannel } from "@arkstack/encryption";
3
3
  import { NodeCipher } from "@arkstack/encryption/node";
4
4
  import { Secret, TOTP } from "otpauth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/common",
3
- "version": "0.18.7",
3
+ "version": "0.18.9",
4
4
  "type": "module",
5
5
  "description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -43,13 +43,13 @@
43
43
  "otpauth": "^9.5.1",
44
44
  "pino": "^10.3.1",
45
45
  "selfsigned": "^2.4.1",
46
- "@arkstack/encryption": "^0.18.7"
46
+ "@arkstack/encryption": "^0.18.9"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@h3ravel/support": "^2.2.7",
50
50
  "arkormx": "^2.12.8",
51
- "@arkstack/contract": "^0.18.7",
52
- "@arkstack/foundry": "^0.18.7"
51
+ "@arkstack/contract": "^0.18.9",
52
+ "@arkstack/foundry": "^0.18.9"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@faker-js/faker": "^10.4.0"