@arkstack/common 0.18.8 → 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";
package/dist/index.d.ts CHANGED
@@ -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}.
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,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.8",
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.8"
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.8",
52
- "@arkstack/foundry": "^0.18.8"
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"