hanzio 1.0.9 → 1.0.10

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.
@@ -6,7 +6,6 @@ export type DefineSecretSetOptions<SecretKey extends string> = {
6
6
  readonly clientIdEnvKey?: string;
7
7
  readonly clientSecretEnvKey?: string;
8
8
  readonly loader?: SecretSetLoader<SecretKey>;
9
- readonly getLocalIp?: () => string;
10
9
  };
11
10
  export type SecretSetLoaderContext<SecretKey extends string> = {
12
11
  readonly keys: readonly SecretKey[];
package/dist/src/index.js CHANGED
@@ -1209,9 +1209,6 @@ function viteSecretSetPlugin(secretSet) {
1209
1209
  };
1210
1210
  }
1211
1211
 
1212
- // src/secrets/index.ts
1213
- import { networkInterfaces } from "node:os";
1214
-
1215
1212
  // src/cool-console-log/index.ts
1216
1213
  var terminalColors = {
1217
1214
  reset: "\x1B[0m",
@@ -1319,8 +1316,6 @@ function logBanner(text, color = "cyan", options = {}) {
1319
1316
 
1320
1317
  // src/secrets/index.ts
1321
1318
  var DEFAULT_INFISICAL_SITE_URL = "https://eu.infisical.com";
1322
- var LOCAL_IP_VALUE = "LOCAL_IP";
1323
- var VPN_INTERFACE_RE = /^(utun|tun|tailscale|wg|ipsec|ppp)/i;
1324
1319
  var logger = createCoolLogger();
1325
1320
  function getSecretEnvironment() {
1326
1321
  const env = process.env.SECRETS_ENV || "development";
@@ -1333,13 +1328,7 @@ function getSecretEnvironment() {
1333
1328
  async function defineSecretSet(keys, options) {
1334
1329
  const keySet = [...new Set(keys)];
1335
1330
  const loader = options.loader ?? loadInfisicalSecrets;
1336
- const getLocalIp = options.getLocalIp ?? getLocalIpAddress;
1337
1331
  let cachedSecrets = null;
1338
- const resolveValue = (value) => {
1339
- if (value === LOCAL_IP_VALUE)
1340
- return getLocalIp();
1341
- return value;
1342
- };
1343
1332
  const loadSecrets = async (force = false) => {
1344
1333
  const envSecrets = readEnvSecrets(keySet, force ? cachedSecrets : null);
1345
1334
  const keysMissingFromEnv = keySet.filter((key) => !envSecrets[key]);
@@ -1359,7 +1348,7 @@ async function defineSecretSet(keys, options) {
1359
1348
  }
1360
1349
  const nextSecrets = Object.fromEntries(keySet.map((key) => [
1361
1350
  key,
1362
- resolveValue(envSecrets[key] ?? loadedSecrets[key])
1351
+ envSecrets[key] ?? loadedSecrets[key]
1363
1352
  ]));
1364
1353
  for (const [key, value] of Object.entries(nextSecrets)) {
1365
1354
  process.env[key] = value;
@@ -1373,7 +1362,7 @@ async function defineSecretSet(keys, options) {
1373
1362
  if (!value) {
1374
1363
  throw new Error(`Secret ${key} not found`);
1375
1364
  }
1376
- return resolveValue(value);
1365
+ return value;
1377
1366
  },
1378
1367
  secrets() {
1379
1368
  if (!cachedSecrets) {
@@ -1406,22 +1395,6 @@ function readEnvSecrets(keys, previousSecrets = null) {
1406
1395
  return value && value !== previousSecrets?.[key];
1407
1396
  }).map((key) => [key, process.env[key]]));
1408
1397
  }
1409
- function getLocalIpAddress() {
1410
- const interfaces = networkInterfaces();
1411
- for (const name of Object.keys(interfaces)) {
1412
- if (VPN_INTERFACE_RE.test(name))
1413
- continue;
1414
- const nets = interfaces[name];
1415
- if (!nets)
1416
- continue;
1417
- for (const net of nets) {
1418
- if (net.family === "IPv4" && !net.internal) {
1419
- return net.address;
1420
- }
1421
- }
1422
- }
1423
- return "127.0.0.1";
1424
- }
1425
1398
 
1426
1399
  // src/typedswitch/index.ts
1427
1400
  function runSwitch(value, keyOrCases, casesOrDefault, defaultCase) {
@@ -351,9 +351,6 @@ function viteSecretSetPlugin(secretSet) {
351
351
  };
352
352
  }
353
353
 
354
- // src/secrets/index.ts
355
- import { networkInterfaces } from "node:os";
356
-
357
354
  // src/cool-console-log/index.ts
358
355
  var terminalColors = {
359
356
  reset: "\x1B[0m",
@@ -461,8 +458,6 @@ function logBanner(text, color = "cyan", options = {}) {
461
458
 
462
459
  // src/secrets/index.ts
463
460
  var DEFAULT_INFISICAL_SITE_URL = "https://eu.infisical.com";
464
- var LOCAL_IP_VALUE = "LOCAL_IP";
465
- var VPN_INTERFACE_RE = /^(utun|tun|tailscale|wg|ipsec|ppp)/i;
466
461
  var logger = createCoolLogger();
467
462
  function getSecretEnvironment() {
468
463
  const env = process.env.SECRETS_ENV || "development";
@@ -475,13 +470,7 @@ function getSecretEnvironment() {
475
470
  async function defineSecretSet(keys, options) {
476
471
  const keySet = [...new Set(keys)];
477
472
  const loader = options.loader ?? loadInfisicalSecrets;
478
- const getLocalIp = options.getLocalIp ?? getLocalIpAddress;
479
473
  let cachedSecrets = null;
480
- const resolveValue = (value) => {
481
- if (value === LOCAL_IP_VALUE)
482
- return getLocalIp();
483
- return value;
484
- };
485
474
  const loadSecrets = async (force = false) => {
486
475
  const envSecrets = readEnvSecrets(keySet, force ? cachedSecrets : null);
487
476
  const keysMissingFromEnv = keySet.filter((key) => !envSecrets[key]);
@@ -501,7 +490,7 @@ async function defineSecretSet(keys, options) {
501
490
  }
502
491
  const nextSecrets = Object.fromEntries(keySet.map((key) => [
503
492
  key,
504
- resolveValue(envSecrets[key] ?? loadedSecrets[key])
493
+ envSecrets[key] ?? loadedSecrets[key]
505
494
  ]));
506
495
  for (const [key, value] of Object.entries(nextSecrets)) {
507
496
  process.env[key] = value;
@@ -515,7 +504,7 @@ async function defineSecretSet(keys, options) {
515
504
  if (!value) {
516
505
  throw new Error(`Secret ${key} not found`);
517
506
  }
518
- return resolveValue(value);
507
+ return value;
519
508
  },
520
509
  secrets() {
521
510
  if (!cachedSecrets) {
@@ -548,22 +537,6 @@ function readEnvSecrets(keys, previousSecrets = null) {
548
537
  return value && value !== previousSecrets?.[key];
549
538
  }).map((key) => [key, process.env[key]]));
550
539
  }
551
- function getLocalIpAddress() {
552
- const interfaces = networkInterfaces();
553
- for (const name of Object.keys(interfaces)) {
554
- if (VPN_INTERFACE_RE.test(name))
555
- continue;
556
- const nets = interfaces[name];
557
- if (!nets)
558
- continue;
559
- for (const net of nets) {
560
- if (net.family === "IPv4" && !net.internal) {
561
- return net.address;
562
- }
563
- }
564
- }
565
- return "127.0.0.1";
566
- }
567
540
  export {
568
541
  viteSecretSetPlugin,
569
542
  loadInfisicalSecrets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanzio",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "A lightweight set of utility functions for TypeScript",
5
5
  "type": "module",
6
6
  "module": "./dist/src/index.js",
@@ -1,10 +1,7 @@
1
- import { networkInterfaces } from 'node:os'
2
1
  import { colorize, createCoolLogger } from '../cool-console-log'
3
2
  import { loadInfisicalSecrets } from './infisical'
4
3
 
5
4
  const DEFAULT_INFISICAL_SITE_URL = 'https://eu.infisical.com'
6
- const LOCAL_IP_VALUE = 'LOCAL_IP'
7
- const VPN_INTERFACE_RE = /^(utun|tun|tailscale|wg|ipsec|ppp)/i
8
5
  const logger = createCoolLogger()
9
6
 
10
7
  export type SecretEnvironment = 'dev' | 'staging' | 'prod'
@@ -16,7 +13,6 @@ export type DefineSecretSetOptions<SecretKey extends string> = {
16
13
  readonly clientIdEnvKey?: string
17
14
  readonly clientSecretEnvKey?: string
18
15
  readonly loader?: SecretSetLoader<SecretKey>
19
- readonly getLocalIp?: () => string
20
16
  }
21
17
 
22
18
  export type SecretSetLoaderContext<SecretKey extends string> = {
@@ -58,14 +54,8 @@ export async function defineSecretSet<
58
54
 
59
55
  const keySet = [...new Set(keys)] as SecretKey[]
60
56
  const loader = options.loader ?? loadInfisicalSecrets
61
- const getLocalIp = options.getLocalIp ?? getLocalIpAddress
62
57
  let cachedSecrets: Record<SecretKey, string> | null = null
63
58
 
64
- const resolveValue = (value: string) => {
65
- if (value === LOCAL_IP_VALUE) return getLocalIp()
66
- return value
67
- }
68
-
69
59
  const loadSecrets = async (force = false) => {
70
60
  const envSecrets = readEnvSecrets(keySet, force ? cachedSecrets : null)
71
61
  const keysMissingFromEnv = keySet.filter((key) => !envSecrets[key])
@@ -96,7 +86,7 @@ export async function defineSecretSet<
96
86
  const nextSecrets = Object.fromEntries(
97
87
  keySet.map((key) => [
98
88
  key,
99
- resolveValue((envSecrets[key] ?? loadedSecrets[key]) as string)
89
+ (envSecrets[key] ?? loadedSecrets[key]) as string
100
90
  ])
101
91
  ) as Record<SecretKey, string>
102
92
 
@@ -113,7 +103,7 @@ export async function defineSecretSet<
113
103
  if (!value) {
114
104
  throw new Error(`Secret ${key} not found`)
115
105
  }
116
- return resolveValue(value)
106
+ return value
117
107
  },
118
108
  secrets() {
119
109
  if (!cachedSecrets) {
@@ -161,21 +151,3 @@ function readEnvSecrets<SecretKey extends string>(
161
151
  .map((key) => [key, process.env[key] as string])
162
152
  ) as Partial<Record<SecretKey, string>>
163
153
  }
164
-
165
- function getLocalIpAddress(): string {
166
- const interfaces = networkInterfaces()
167
-
168
- for (const name of Object.keys(interfaces)) {
169
- if (VPN_INTERFACE_RE.test(name)) continue
170
- const nets = interfaces[name]
171
- if (!nets) continue
172
-
173
- for (const net of nets) {
174
- if (net.family === 'IPv4' && !net.internal) {
175
- return net.address
176
- }
177
- }
178
- }
179
-
180
- return '127.0.0.1'
181
- }