@venizia/ignis-helpers 0.4.8-13 → 0.4.8-14

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.
Files changed (120) hide show
  1. package/dist/esm/common/redact.js.map +1 -1
  2. package/dist/esm/common/types/class.d.ts +14 -12
  3. package/dist/esm/common/types/class.js.map +1 -1
  4. package/dist/esm/common/types/const-value.d.ts +3 -3
  5. package/dist/esm/common/types/const-value.js.map +1 -1
  6. package/dist/esm/common/types/injection.d.ts +1 -1
  7. package/dist/esm/common/types/injection.js.map +1 -1
  8. package/dist/esm/common/types/utility.d.ts +0 -4
  9. package/dist/esm/common/types/utility.js.map +1 -1
  10. package/dist/esm/modules/env/app-env.d.ts +17 -8
  11. package/dist/esm/modules/env/app-env.js +18 -15
  12. package/dist/esm/modules/env/app-env.js.map +1 -1
  13. package/dist/esm/modules/env/common/types.d.ts +22 -6
  14. package/dist/esm/modules/env/common/types.js.map +1 -1
  15. package/dist/esm/modules/logger/base/abstract.d.ts +6 -7
  16. package/dist/esm/modules/logger/base/abstract.js.map +1 -1
  17. package/dist/esm/modules/logger/base/base.d.ts +7 -8
  18. package/dist/esm/modules/logger/base/base.js.map +1 -1
  19. package/dist/esm/modules/logger/base/console.d.ts +6 -7
  20. package/dist/esm/modules/logger/base/console.js.map +1 -1
  21. package/dist/esm/modules/logger/common/types.d.ts +7 -7
  22. package/dist/esm/modules/logger/common/types.js.map +1 -1
  23. package/dist/esm/modules/logger/factory.js.map +1 -1
  24. package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
  25. package/dist/esm/modules/logger/hf/logger.d.ts +6 -7
  26. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  27. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  28. package/dist/esm/modules/logger/pino/destination.d.ts +1 -1
  29. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  30. package/dist/esm/modules/logger/pino/logger.d.ts +1 -2
  31. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  32. package/dist/esm/modules/logger/winston/formats.js +2 -2
  33. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  34. package/dist/esm/modules/logger/winston/logger.d.ts +1 -2
  35. package/dist/esm/modules/logger/winston/logger.js.map +1 -1
  36. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -1
  37. package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -1
  38. package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
  39. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +5 -5
  40. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  41. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +1 -2
  42. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
  43. package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts +1 -1
  44. package/dist/esm/modules/network/http-request/fetcher/common/types.js.map +1 -1
  45. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +1 -2
  46. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +5 -6
  47. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  48. package/dist/esm/modules/network/utilities/query-string.d.ts +2 -2
  49. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  50. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  51. package/dist/esm/modules/queue/kafka/base.d.ts +1 -1
  52. package/dist/esm/modules/queue/kafka/base.js +13 -2
  53. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  54. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -1
  55. package/dist/esm/modules/redis/cluster/cluster.helper.js +10 -3
  56. package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
  57. package/dist/esm/modules/redis/cluster/index.d.ts +1 -0
  58. package/dist/esm/modules/redis/cluster/index.js +1 -0
  59. package/dist/esm/modules/redis/cluster/index.js.map +1 -1
  60. package/dist/esm/modules/redis/cluster/types.d.ts +20 -0
  61. package/dist/esm/modules/redis/cluster/types.js +2 -0
  62. package/dist/esm/modules/redis/cluster/types.js.map +1 -0
  63. package/dist/esm/modules/redis/common/constants.d.ts +2 -8
  64. package/dist/esm/modules/redis/common/constants.js +2 -5
  65. package/dist/esm/modules/redis/common/constants.js.map +1 -1
  66. package/dist/esm/modules/redis/common/types.d.ts +9 -62
  67. package/dist/esm/modules/redis/common/types.js.map +1 -1
  68. package/dist/esm/modules/redis/factory.d.ts +3 -4
  69. package/dist/esm/modules/redis/factory.js.map +1 -1
  70. package/dist/esm/modules/redis/sentinel/constants.d.ts +14 -0
  71. package/dist/esm/modules/redis/sentinel/constants.js +11 -0
  72. package/dist/esm/modules/redis/sentinel/constants.js.map +1 -0
  73. package/dist/esm/modules/redis/sentinel/index.d.ts +2 -0
  74. package/dist/esm/modules/redis/sentinel/index.js +2 -0
  75. package/dist/esm/modules/redis/sentinel/index.js.map +1 -1
  76. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -1
  77. package/dist/esm/modules/redis/sentinel/sentinel.helper.js +18 -9
  78. package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
  79. package/dist/esm/modules/redis/sentinel/types.d.ts +26 -0
  80. package/dist/esm/modules/redis/sentinel/types.js +2 -0
  81. package/dist/esm/modules/redis/sentinel/types.js.map +1 -0
  82. package/dist/esm/modules/redis/single/index.d.ts +1 -0
  83. package/dist/esm/modules/redis/single/index.js +1 -0
  84. package/dist/esm/modules/redis/single/index.js.map +1 -1
  85. package/dist/esm/modules/redis/single/single.helper.d.ts +1 -1
  86. package/dist/esm/modules/redis/single/single.helper.js +1 -1
  87. package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
  88. package/dist/esm/modules/redis/single/types.d.ts +15 -0
  89. package/dist/esm/modules/redis/single/types.js +2 -0
  90. package/dist/esm/modules/redis/single/types.js.map +1 -0
  91. package/dist/esm/modules/secrets/base/abstract.helper.js +6 -1
  92. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  93. package/dist/esm/modules/secrets/common/types/registration.d.ts +25 -6
  94. package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
  95. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -1
  96. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
  97. package/dist/esm/modules/secrets/factory.js +7 -6
  98. package/dist/esm/modules/secrets/factory.js.map +1 -1
  99. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +12 -10
  100. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +50 -25
  101. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  102. package/dist/esm/modules/storage/in-memory/helper.d.ts +2 -3
  103. package/dist/esm/modules/storage/in-memory/helper.js.map +1 -1
  104. package/dist/esm/modules/worker-thread/common/types.d.ts +2 -2
  105. package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
  106. package/dist/esm/modules/worker-thread/thread/abstract.d.ts +2 -2
  107. package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
  108. package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -1
  109. package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
  110. package/dist/esm/utilities/module.utility.d.ts +8 -5
  111. package/dist/esm/utilities/module.utility.js +5 -1
  112. package/dist/esm/utilities/module.utility.js.map +1 -1
  113. package/dist/esm/utilities/parse.utility.d.ts +34 -6
  114. package/dist/esm/utilities/parse.utility.js +82 -15
  115. package/dist/esm/utilities/parse.utility.js.map +1 -1
  116. package/dist/esm/utilities/performance.utility.d.ts +3 -3
  117. package/dist/esm/utilities/performance.utility.js.map +1 -1
  118. package/dist/esm/utilities/promise.utility.d.ts +1 -1
  119. package/dist/esm/utilities/promise.utility.js.map +1 -1
  120. package/package.json +3 -3
@@ -1,63 +1,19 @@
1
- import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';
2
- import type { TRedisSentinelRole } from './constants.js';
1
+ import type { Cluster, Redis } from 'ioredis';
3
2
  import type { IRedisHelper } from './interfaces.js';
4
3
  /** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */
5
4
  export type TRedisClient = Redis | Cluster;
6
- /** Connection settings for a single Redis node. */
7
- export interface IRedisSingleHelperProps {
8
- name: string;
5
+ /** The address of one Redis node. A node has no credentials of its own: ioredis reads only the host and port of a Sentinel endpoint, and applies a cluster node's credentials to the startup nodes only. */
6
+ export interface IRedisNode {
9
7
  host: string;
10
- port: string | number;
11
- /** The Redis ACL user to authenticate as, with `password`. Omit it to authenticate as the `default` user. */
8
+ /** @default RedisDefaults.PORT (6379), or RedisSentinelDefaults.PORT (26379) for a Sentinel node */
9
+ port?: string | number;
10
+ }
11
+ /** An ACL user and its password. Omit both to authenticate as the `default` user with no password. */
12
+ export interface IRedisCredentials {
13
+ /** The Redis ACL user, with `password`. Omit it to authenticate as the `default` user. */
12
14
  username?: string;
13
15
  /** Omit it for a Redis with no password. */
14
16
  password?: string;
15
- /** @default 0 */
16
- database?: number;
17
- /** @default true */
18
- autoConnect?: boolean;
19
- /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
20
- maxRetry?: number;
21
- }
22
- /** Connection settings for a Redis Cluster: the startup `nodes`, plus raw ioredis `clusterOptions` that override the helper defaults. */
23
- export interface IRedisClusterHelperProps {
24
- name: string;
25
- nodes: Array<{
26
- host: string;
27
- port: string | number;
28
- password?: string;
29
- }>;
30
- /**
31
- * Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`.
32
- *
33
- * @default true
34
- */
35
- autoConnect?: boolean;
36
- /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. `clusterOptions` still overrides. @default RedisDefaults.MAX_RETRY (5) */
37
- maxRetry?: number;
38
- clusterOptions?: ClusterOptions;
39
- }
40
- /** Connection settings for Redis behind Sentinel. `redisOptions` overrides the helper defaults. */
41
- export interface IRedisSentinelHelperProps {
42
- name: string;
43
- sentinels: Array<{
44
- host: string;
45
- /** @default 26379 */
46
- port?: string | number;
47
- }>;
48
- masterName: string;
49
- /** @default RedisSentinelRoles.MASTER */
50
- role?: TRedisSentinelRole;
51
- password?: string;
52
- sentinelPassword?: string;
53
- sentinelUsername?: string;
54
- /** @default 0 */
55
- database?: number;
56
- /** @default true */
57
- autoConnect?: boolean;
58
- /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
59
- maxRetry?: number;
60
- redisOptions?: Partial<RedisOptions>;
61
17
  }
62
18
  /** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */
63
19
  export interface IRedisHelperCallbacks {
@@ -87,13 +43,4 @@ export interface IRedisHelperCallbacks {
87
43
  export interface IRedisModuleOption {
88
44
  module?: typeof import('ioredis');
89
45
  }
90
- /** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
91
- export interface IRedisSingleHelperOptions extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
92
- }
93
- /** Options for `RedisClusterHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
94
- export interface IRedisClusterHelperOptions extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
95
- }
96
- /** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
97
- export interface IRedisSentinelHelperOptions extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
98
- }
99
46
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Cluster, ClusterOptions, Redis, RedisOptions } from 'ioredis';\nimport type { TRedisSentinelRole } from './constants';\nimport type { IRedisHelper } from './interfaces';\n\n/** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */\nexport type TRedisClient = Redis | Cluster;\n\n/** Connection settings for a single Redis node. */\nexport interface IRedisSingleHelperProps {\n name: string;\n host: string;\n port: string | number;\n /** The Redis ACL user to authenticate as, with `password`. Omit it to authenticate as the `default` user. */\n username?: string;\n /** Omit it for a Redis with no password. */\n password?: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n}\n\n/** Connection settings for a Redis Cluster: the startup `nodes`, plus raw ioredis `clusterOptions` that override the helper defaults. */\nexport interface IRedisClusterHelperProps {\n name: string;\n nodes: Array<{ host: string; port: string | number; password?: string }>;\n /**\n * Same meaning as on single and sentinel: `false` holds the client open for a later `connect()`.\n *\n * @default true\n */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. `clusterOptions` still overrides. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n clusterOptions?: ClusterOptions;\n}\n\n/** Connection settings for Redis behind Sentinel. `redisOptions` overrides the helper defaults. */\nexport interface IRedisSentinelHelperProps {\n name: string;\n sentinels: Array<{\n host: string;\n /** @default 26379 */\n port?: string | number;\n }>;\n masterName: string;\n /** @default RedisSentinelRoles.MASTER */\n role?: TRedisSentinelRole;\n password?: string;\n sentinelPassword?: string;\n sentinelUsername?: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n redisOptions?: Partial<RedisOptions>;\n}\n\n/** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */\nexport interface IRedisHelperCallbacks {\n onInitialized?: (opts: { name: string; helper: IRedisHelper }) => void;\n onConnected?: (opts: { name: string; helper: IRedisHelper }) => void;\n onReady?: (opts: { name: string; helper: IRedisHelper }) => void;\n onError?: (opts: { name: string; helper: IRedisHelper; error: unknown }) => void;\n}\n\n/**\n * `ioredis` is an optional peer, loaded when a client is built. A `bun build --compile` binary\n * carries no `node_modules` to load it from: pass the module here, or register it once with\n * `ModuleUtility.register({ modules: { ioredis } })` at the entry.\n */\nexport interface IRedisModuleOption {\n module?: typeof import('ioredis');\n}\n\n/** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSingleHelperOptions\n extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\n/** Options for `RedisClusterHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisClusterHelperOptions\n extends IRedisClusterHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n\n/** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSentinelHelperOptions\n extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Cluster, Redis } from 'ioredis';\nimport type { IRedisHelper } from './interfaces';\n\n/** The ioredis client a helper wraps: a single or Sentinel `Redis`, or a `Cluster`. */\nexport type TRedisClient = Redis | Cluster;\n\n/** The address of one Redis node. A node has no credentials of its own: ioredis reads only the host and port of a Sentinel endpoint, and applies a cluster node's credentials to the startup nodes only. */\nexport interface IRedisNode {\n host: string;\n /** @default RedisDefaults.PORT (6379), or RedisSentinelDefaults.PORT (26379) for a Sentinel node */\n port?: string | number;\n}\n\n/** An ACL user and its password. Omit both to authenticate as the `default` user with no password. */\nexport interface IRedisCredentials {\n /** The Redis ACL user, with `password`. Omit it to authenticate as the `default` user. */\n username?: string;\n /** Omit it for a Redis with no password. */\n password?: string;\n}\n\n/** Lifecycle hooks a Redis helper calls; each receives the helper name and the helper itself. */\nexport interface IRedisHelperCallbacks {\n onInitialized?: (opts: { name: string; helper: IRedisHelper }) => void;\n onConnected?: (opts: { name: string; helper: IRedisHelper }) => void;\n onReady?: (opts: { name: string; helper: IRedisHelper }) => void;\n onError?: (opts: { name: string; helper: IRedisHelper; error: unknown }) => void;\n}\n\n/**\n * `ioredis` is an optional peer, loaded when a client is built. A `bun build --compile` binary\n * carries no `node_modules` to load it from: pass the module here, or register it once with\n * `ModuleUtility.register({ modules: { ioredis } })` at the entry.\n */\nexport interface IRedisModuleOption {\n module?: typeof import('ioredis');\n}\n"]}
@@ -1,7 +1,6 @@
1
- import { RedisClusterHelper } from './cluster/index.js';
2
- import type { IRedisClusterHelperOptions, IRedisSentinelHelperOptions, IRedisSingleHelperOptions } from './common/index.js';
3
- import { RedisSentinelHelper } from './sentinel/index.js';
4
- import { RedisSingleHelper } from './single/index.js';
1
+ import { RedisClusterHelper, type IRedisClusterHelperOptions } from './cluster/index.js';
2
+ import { RedisSentinelHelper, type IRedisSentinelHelperOptions } from './sentinel/index.js';
3
+ import { RedisSingleHelper, type IRedisSingleHelperOptions } from './single/index.js';
5
4
  /** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */
6
5
  export declare class RedisHelperFactory {
7
6
  static single(opts: IRedisSingleHelperOptions): RedisSingleHelper;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/redis/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,0HAA0H;AAC1H,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAC3C,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAgC;QAC7C,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAiC;QAC/C,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { RedisClusterHelper } from './cluster';\nimport type {\n IRedisClusterHelperOptions,\n IRedisSentinelHelperOptions,\n IRedisSingleHelperOptions,\n} from './common';\nimport { RedisSentinelHelper } from './sentinel';\nimport { RedisSingleHelper } from './single';\n\n/** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */\nexport class RedisHelperFactory {\n static single(opts: IRedisSingleHelperOptions) {\n return new RedisSingleHelper(opts);\n }\n\n static cluster(opts: IRedisClusterHelperOptions) {\n return new RedisClusterHelper(opts);\n }\n\n static sentinel(opts: IRedisSentinelHelperOptions) {\n return new RedisSentinelHelper(opts);\n }\n}\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../src/modules/redis/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmC,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAoC,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAkC,MAAM,UAAU,CAAC;AAE7E,0HAA0H;AAC1H,MAAM,OAAO,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAA+B;QAC3C,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAgC;QAC7C,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAiC;QAC/C,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { RedisClusterHelper, type IRedisClusterHelperOptions } from './cluster';\nimport { RedisSentinelHelper, type IRedisSentinelHelperOptions } from './sentinel';\nimport { RedisSingleHelper, type IRedisSingleHelperOptions } from './single';\n\n/** Creates the Redis helper of one topology: `single`, `cluster` or `sentinel`. Each returns its concrete helper type. */\nexport class RedisHelperFactory {\n static single(opts: IRedisSingleHelperOptions) {\n return new RedisSingleHelper(opts);\n }\n\n static cluster(opts: IRedisClusterHelperOptions) {\n return new RedisClusterHelper(opts);\n }\n\n static sentinel(opts: IRedisSentinelHelperOptions) {\n return new RedisSentinelHelper(opts);\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { TConstValue } from '../../../common/types/index.js';
2
+ /** Role of the node a Sentinel-backed client connects to. */
3
+ export declare class RedisSentinelRoles {
4
+ static readonly MASTER = "master";
5
+ static readonly SLAVE = "slave";
6
+ }
7
+ /** Union of the `RedisSentinelRoles` values. */
8
+ export type TRedisSentinelRole = TConstValue<typeof RedisSentinelRoles>;
9
+ /** Defaults of the Sentinel helper. */
10
+ export declare class RedisSentinelDefaults {
11
+ /** The port of a Sentinel process when none is given. */
12
+ static readonly PORT = 26379;
13
+ }
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Role of the node a Sentinel-backed client connects to. */
2
+ export class RedisSentinelRoles {
3
+ static { this.MASTER = 'master'; }
4
+ static { this.SLAVE = 'slave'; }
5
+ }
6
+ /** Defaults of the Sentinel helper. */
7
+ export class RedisSentinelDefaults {
8
+ /** The port of a Sentinel process when none is given. */
9
+ static { this.PORT = 26379; }
10
+ }
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/constants.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,OAAO,kBAAkB;aACb,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;;AAMlC,uCAAuC;AACvC,MAAM,OAAO,qBAAqB;IAChC,yDAAyD;aACzC,SAAI,GAAG,KAAK,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Role of the node a Sentinel-backed client connects to. */\nexport class RedisSentinelRoles {\n static readonly MASTER = 'master';\n static readonly SLAVE = 'slave';\n}\n\n/** Union of the `RedisSentinelRoles` values. */\nexport type TRedisSentinelRole = TConstValue<typeof RedisSentinelRoles>;\n\n/** Defaults of the Sentinel helper. */\nexport class RedisSentinelDefaults {\n /** The port of a Sentinel process when none is given. */\n static readonly PORT = 26379;\n}\n"]}
@@ -1,2 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
1
3
  export * from './sentinel.helper.js';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './types.js';
1
3
  export * from './sentinel.helper.js';
2
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './sentinel.helper';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './constants';\nexport * from './types';\nexport * from './sentinel.helper';\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
- import { type IRedisSentinelHelperOptions } from './../common/index.js';
3
+ import type { IRedisSentinelHelperOptions } from './types.js';
4
4
  /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
5
5
  export declare class RedisSentinelHelper extends AbstractRedisHelper<Redis> {
6
6
  constructor(opts: IRedisSentinelHelperOptions);
@@ -1,14 +1,22 @@
1
+ import { getError } from '../../error/index.js';
1
2
  import { ModuleUtility } from '../../../utilities/module.utility.js';
2
3
  import { ParseUtility } from '../../../utilities/parse.utility.js';
3
4
  import { AbstractRedisHelper } from './../base/index.js';
4
- import { RedisDefaults, RedisSentinelRoles } from './../common/index.js';
5
+ import { RedisDefaults } from './../common/index.js';
6
+ import { RedisSentinelDefaults, RedisSentinelRoles } from './constants.js';
5
7
  /** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */
6
8
  export class RedisSentinelHelper extends AbstractRedisHelper {
7
9
  constructor(opts) {
8
- const { name, sentinels, masterName, role = RedisSentinelRoles.MASTER, password, sentinelPassword, sentinelUsername, database = 0, autoConnect = true, maxRetry = RedisDefaults.MAX_RETRY, redisOptions = {}, } = opts;
9
- const normalizedSentinels = sentinels.map((sentinel) => ({
10
- host: sentinel.host,
11
- port: ParseUtility.toInt({ input: sentinel.port ?? 26379 }),
10
+ const { name, sentinel, username, password, database = 0, autoConnect = true, maxRetry = RedisDefaults.MAX_RETRY, redisOptions = {}, } = opts;
11
+ // A JavaScript caller (or a config read from a file) may still pass the old shape, `masterName` and `sentinels` at the top level.
12
+ if (!Array.isArray(sentinel?.nodes) || sentinel.nodes.length === 0) {
13
+ throw getError({
14
+ message: `[${RedisSentinelHelper.name}] sentinel.nodes is required | pass sentinel: { masterName, nodes }`,
15
+ });
16
+ }
17
+ const normalizedSentinels = sentinel.nodes.map((node) => ({
18
+ host: node.host,
19
+ port: ParseUtility.toInt({ input: node.port ?? RedisSentinelDefaults.PORT }),
12
20
  }));
13
21
  const ioredis = opts.module ?? ModuleUtility.loadSync({ module: 'ioredis' });
14
22
  super({
@@ -24,13 +32,14 @@ export class RedisSentinelHelper extends AbstractRedisHelper {
24
32
  }),
25
33
  ...redisOptions,
26
34
  sentinels: normalizedSentinels,
27
- name: masterName,
28
- role,
35
+ name: sentinel.masterName,
36
+ role: sentinel.role ?? RedisSentinelRoles.MASTER,
29
37
  db: database,
30
38
  lazyConnect: !autoConnect,
39
+ username: username ?? redisOptions.username,
31
40
  password: password ?? redisOptions.password,
32
- sentinelPassword: sentinelPassword ?? redisOptions.sentinelPassword,
33
- sentinelUsername: sentinelUsername ?? redisOptions.sentinelUsername,
41
+ sentinelUsername: sentinel.username ?? redisOptions.sentinelUsername,
42
+ sentinelPassword: sentinel.password ?? redisOptions.sentinelPassword,
34
43
  }),
35
44
  });
36
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sentinel.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/sentinel.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAoC,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElG,4JAA4J;AAC5J,MAAM,OAAO,mBAAoB,SAAQ,mBAA0B;IACjE,YAAY,IAAiC;QAC3C,MAAM,EACJ,IAAI,EACJ,SAAS,EACT,UAAU,EACV,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAChC,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,EAClC,YAAY,GAAG,EAAE,GAClB,GAAG,IAAI,CAAC;QAET,MAAM,mBAAmB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACvD,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC;SAC5D,CAAC,CAAC,CAAC;QAEJ,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAA2B,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAEzF,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,mBAAmB,CAAC,IAAI;YAC/B,UAAU,EAAE,IAAI;YAChB,oNAAoN;YACpN,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;oBACtC,KAAK,EAAE,mBAAmB,CAAC,IAAI;oBAC/B,IAAI;oBACJ,QAAQ;iBACT,CAAC;gBACF,GAAG,YAAY;gBACf,SAAS,EAAE,mBAAmB;gBAC9B,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,QAAQ,EAAE,QAAQ,IAAI,YAAY,CAAC,QAAQ;gBAC3C,gBAAgB,EAAE,gBAAgB,IAAI,YAAY,CAAC,gBAAgB;gBACnE,gBAAgB,EAAE,gBAAgB,IAAI,YAAY,CAAC,gBAAgB;aACpE,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { RedisDefaults, type IRedisSentinelHelperOptions, RedisSentinelRoles } from './../common';\n\n/** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */\nexport class RedisSentinelHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSentinelHelperOptions) {\n const {\n name,\n sentinels,\n masterName,\n role = RedisSentinelRoles.MASTER,\n password,\n sentinelPassword,\n sentinelUsername,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n redisOptions = {},\n } = opts;\n\n const normalizedSentinels = sentinels.map((sentinel) => ({\n host: sentinel.host,\n port: ParseUtility.toInt({ input: sentinel.port ?? 26379 }),\n }));\n\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSentinelHelper.name,\n identifier: name,\n // Precedence (low -> high): framework defaults, the redisOptions escape hatch, then first-class fields. An auth field left unset falls back to `redisOptions`, so an undefined first-class field never clobbers it.\n client: new ioredis.Redis({\n ...AbstractRedisHelper.buildDefaultOpts({\n scope: RedisSentinelHelper.name,\n name,\n maxRetry,\n }),\n ...redisOptions,\n sentinels: normalizedSentinels,\n name: masterName,\n role,\n db: database,\n lazyConnect: !autoConnect,\n password: password ?? redisOptions.password,\n sentinelPassword: sentinelPassword ?? redisOptions.sentinelPassword,\n sentinelUsername: sentinelUsername ?? redisOptions.sentinelUsername,\n }),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"sentinel.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/sentinel.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGxE,4JAA4J;AAC5J,MAAM,OAAO,mBAAoB,SAAQ,mBAA0B;IACjE,YAAY,IAAiC;QAC3C,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,EAClC,YAAY,GAAG,EAAE,GAClB,GAAG,IAAI,CAAC;QAET,kIAAkI;QAClI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,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Y,CAAC,gBAAgB;gBACpE,gBAAgB,EAAE,QAAQ,CAAC,QAAQ,IAAI,YAAY,CAAC,gBAAgB;aACrE,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { RedisDefaults } from './../common';\nimport { RedisSentinelDefaults, RedisSentinelRoles } from './constants';\nimport type { IRedisSentinelHelperOptions } from './types';\n\n/** Redis helper for a master and replicas behind Sentinel. `redisOptions` overrides the helper defaults; the first-class fields override `redisOptions`. */\nexport class RedisSentinelHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSentinelHelperOptions) {\n const {\n name,\n sentinel,\n username,\n password,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n redisOptions = {},\n } = opts;\n\n // A JavaScript caller (or a config read from a file) may still pass the old shape, `masterName` and `sentinels` at the top level.\n if (!Array.isArray(sentinel?.nodes) || sentinel.nodes.length === 0) {\n throw getError({\n message: `[${RedisSentinelHelper.name}] sentinel.nodes is required | pass sentinel: { masterName, nodes }`,\n });\n }\n\n const normalizedSentinels = sentinel.nodes.map((node) => ({\n host: node.host,\n port: ParseUtility.toInt({ input: node.port ?? RedisSentinelDefaults.PORT }),\n }));\n\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSentinelHelper.name,\n identifier: name,\n // Precedence (low -> high): framework defaults, the redisOptions escape hatch, then first-class fields. An auth field left unset falls back to `redisOptions`, so an undefined first-class field never clobbers it.\n client: new ioredis.Redis({\n ...AbstractRedisHelper.buildDefaultOpts({\n scope: RedisSentinelHelper.name,\n name,\n maxRetry,\n }),\n ...redisOptions,\n sentinels: normalizedSentinels,\n name: sentinel.masterName,\n role: sentinel.role ?? RedisSentinelRoles.MASTER,\n db: database,\n lazyConnect: !autoConnect,\n username: username ?? redisOptions.username,\n password: password ?? redisOptions.password,\n sentinelUsername: sentinel.username ?? redisOptions.sentinelUsername,\n sentinelPassword: sentinel.password ?? redisOptions.sentinelPassword,\n }),\n });\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { RedisOptions } from 'ioredis';
2
+ import type { IRedisCredentials, IRedisHelperCallbacks, IRedisModuleOption, IRedisNode } from './../common/index.js';
3
+ import type { TRedisSentinelRole } from './constants.js';
4
+ /** Connection settings for Redis behind Sentinel. Top-level `username` and `password` are the data nodes' (master and replica) credentials; everything Sentinel-specific is in `sentinel`. Precedence (low -> high): the helper defaults, `redisOptions`, then the first-class fields; an auth field left unset falls back to `redisOptions`. */
5
+ export interface IRedisSentinelHelperProps extends IRedisCredentials {
6
+ name: string;
7
+ /** The monitored group, which side to read, the Sentinel processes' own credentials and their addresses. `username` and `password` here are the Sentinel processes' (ioredis `sentinelUsername`, `sentinelPassword`), never the data nodes'. */
8
+ sentinel: IRedisCredentials & {
9
+ /** The group name in sentinel.conf (`sentinel monitor <masterName> ...`). Maps to ioredis `name`. */
10
+ masterName: string;
11
+ /** Connect to the master or to a replica. @default RedisSentinelRoles.MASTER */
12
+ role?: TRedisSentinelRole;
13
+ nodes: IRedisNode[];
14
+ };
15
+ /** @default 0 */
16
+ database?: number;
17
+ /** @default true */
18
+ autoConnect?: boolean;
19
+ /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
20
+ maxRetry?: number;
21
+ redisOptions?: Partial<RedisOptions>;
22
+ }
23
+ /** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
24
+ export interface IRedisSentinelHelperOptions extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/sentinel/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RedisOptions } from 'ioredis';\nimport type {\n IRedisCredentials,\n IRedisHelperCallbacks,\n IRedisModuleOption,\n IRedisNode,\n} from './../common';\nimport type { TRedisSentinelRole } from './constants';\n\n/** Connection settings for Redis behind Sentinel. Top-level `username` and `password` are the data nodes' (master and replica) credentials; everything Sentinel-specific is in `sentinel`. Precedence (low -> high): the helper defaults, `redisOptions`, then the first-class fields; an auth field left unset falls back to `redisOptions`. */\nexport interface IRedisSentinelHelperProps extends IRedisCredentials {\n name: string;\n /** The monitored group, which side to read, the Sentinel processes' own credentials and their addresses. `username` and `password` here are the Sentinel processes' (ioredis `sentinelUsername`, `sentinelPassword`), never the data nodes'. */\n sentinel: IRedisCredentials & {\n /** The group name in sentinel.conf (`sentinel monitor <masterName> ...`). Maps to ioredis `name`. */\n masterName: string;\n /** Connect to the master or to a replica. @default RedisSentinelRoles.MASTER */\n role?: TRedisSentinelRole;\n nodes: IRedisNode[];\n };\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n redisOptions?: Partial<RedisOptions>;\n}\n\n/** Options for `RedisSentinelHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSentinelHelperOptions\n extends IRedisSentinelHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
@@ -1,2 +1,3 @@
1
+ export * from './types.js';
1
2
  export * from './single.helper.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
+ export * from './types.js';
1
2
  export * from './single.helper.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './single.helper';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './types';\nexport * from './single.helper';\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Redis } from 'ioredis';
2
2
  import { AbstractRedisHelper } from './../base/index.js';
3
- import { type IRedisSingleHelperOptions } from './../common/index.js';
3
+ import type { IRedisSingleHelperOptions } from './types.js';
4
4
  /** Redis helper over one ioredis `Redis` client connected to a single node. */
5
5
  export declare class RedisSingleHelper extends AbstractRedisHelper<Redis> {
6
6
  constructor(opts: IRedisSingleHelperOptions);
@@ -15,7 +15,7 @@ export class RedisSingleHelper extends AbstractRedisHelper {
15
15
  client: new ioredis.Redis({
16
16
  name,
17
17
  host,
18
- port: ParseUtility.toInt({ input: port }),
18
+ port: ParseUtility.toInt({ input: port ?? RedisDefaults.PORT }),
19
19
  username,
20
20
  password,
21
21
  db: database,
@@ -1 +1 @@
1
- {"version":3,"file":"single.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/single.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAkC,MAAM,aAAa,CAAC;AAE5E,+EAA+E;AAC/E,MAAM,OAAO,iBAAkB,SAAQ,mBAA0B;IAC/D,YAAY,IAA+B;QACzC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,GACnC,GAAG,IAAI,CAAC;QAET,0FAA0F;QAC1F,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAA2B,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAEzF,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;gBACzC,QAAQ;gBACR,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC3F,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { RedisDefaults, type IRedisSingleHelperOptions } from './../common';\n\n/** Redis helper over one ioredis `Redis` client connected to a single node. */\nexport class RedisSingleHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSingleHelperOptions) {\n const {\n name,\n host,\n port,\n username,\n password,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n } = opts;\n\n // Optional peer, loaded when a client is built: an app with no Redis installs no ioredis.\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSingleHelper.name,\n identifier: name,\n client: new ioredis.Redis({\n name,\n host,\n port: ParseUtility.toInt({ input: port }),\n username,\n password,\n db: database,\n lazyConnect: !autoConnect,\n ...AbstractRedisHelper.buildDefaultOpts({ scope: RedisSingleHelper.name, name, maxRetry }),\n }),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"single.helper.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/single.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,+EAA+E;AAC/E,MAAM,OAAO,iBAAkB,SAAQ,mBAA0B;IAC/D,YAAY,IAA+B;QACzC,MAAM,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,aAAa,CAAC,SAAS,GACnC,GAAG,IAAI,CAAC;QAET,0FAA0F;QAC1F,MAAM,OAAO,GACX,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAA2B,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAEzF,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;gBACxB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBAC/D,QAAQ;gBACR,QAAQ;gBACR,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,CAAC,WAAW;gBACzB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aAC3F,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ModuleUtility } from '@/utilities/module.utility';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport type { Redis } from 'ioredis';\nimport { AbstractRedisHelper } from './../base';\nimport { RedisDefaults } from './../common';\nimport type { IRedisSingleHelperOptions } from './types';\n\n/** Redis helper over one ioredis `Redis` client connected to a single node. */\nexport class RedisSingleHelper extends AbstractRedisHelper<Redis> {\n constructor(opts: IRedisSingleHelperOptions) {\n const {\n name,\n host,\n port,\n username,\n password,\n database = 0,\n autoConnect = true,\n maxRetry = RedisDefaults.MAX_RETRY,\n } = opts;\n\n // Optional peer, loaded when a client is built: an app with no Redis installs no ioredis.\n const ioredis =\n opts.module ?? ModuleUtility.loadSync<typeof import('ioredis')>({ module: 'ioredis' });\n\n super({\n ...opts,\n scope: RedisSingleHelper.name,\n identifier: name,\n client: new ioredis.Redis({\n name,\n host,\n port: ParseUtility.toInt({ input: port ?? RedisDefaults.PORT }),\n username,\n password,\n db: database,\n lazyConnect: !autoConnect,\n ...AbstractRedisHelper.buildDefaultOpts({ scope: RedisSingleHelper.name, name, maxRetry }),\n }),\n });\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { IRedisCredentials, IRedisHelperCallbacks, IRedisModuleOption, IRedisNode } from './../common/index.js';
2
+ /** Connection settings for a single Redis node. */
3
+ export interface IRedisSingleHelperProps extends IRedisNode, IRedisCredentials {
4
+ name: string;
5
+ /** @default 0 */
6
+ database?: number;
7
+ /** @default true */
8
+ autoConnect?: boolean;
9
+ /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */
10
+ maxRetry?: number;
11
+ }
12
+ /** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */
13
+ export interface IRedisSingleHelperOptions extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/redis/single/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n IRedisCredentials,\n IRedisHelperCallbacks,\n IRedisModuleOption,\n IRedisNode,\n} from './../common';\n\n/** Connection settings for a single Redis node. */\nexport interface IRedisSingleHelperProps extends IRedisNode, IRedisCredentials {\n name: string;\n /** @default 0 */\n database?: number;\n /** @default true */\n autoConnect?: boolean;\n /** Reconnect attempts: `0` never reconnects, `-1` never gives up; any other value is refused. @default RedisDefaults.MAX_RETRY (5) */\n maxRetry?: number;\n}\n\n/** Options for `RedisSingleHelper`: connection props, lifecycle callbacks and an optional `ioredis` module. */\nexport interface IRedisSingleHelperOptions\n extends IRedisSingleHelperProps, IRedisHelperCallbacks, IRedisModuleOption {}\n"]}
@@ -3,7 +3,12 @@ import { getError } from '../../error/index.js';
3
3
  const DEFAULT_CLOCK = { now: () => Date.now() };
4
4
  const DEFAULT_TIMERS = {
5
5
  set: (handler, ms) => setTimeout(handler, ms),
6
- clear: (handle) => clearTimeout(handle),
6
+ clear: (handle) => {
7
+ // Only a real timer handle can be cleared: a number, or an object that carries `unref` (Node and Bun timers); an opaque fake from a test adapter has nothing to clear.
8
+ if (typeof handle === 'number' || (typeof handle === 'object' && 'unref' in handle)) {
9
+ clearTimeout(handle);
10
+ }
11
+ },
7
12
  };
8
13
  const DEFAULT_CACHE_TTL_SECONDS = 300;
9
14
  const DEFAULT_RENEW_BEFORE_RATIO = 0.66;
@@ -1 +1 @@
1
- {"version":3,"file":"abstract.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/base/abstract.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAw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EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { AnyType } from '@/common/types';\nimport { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport type {\n IClock,\n IGetSecretOptions,\n ISecretLease,\n ISecretRotatable,\n ISecretRotationEvent,\n ISecretsHelper,\n ISecretsHelperOptions,\n ITimerAdapter,\n TSecretRotationHandler,\n TTimerHandle,\n} from '../common';\n\ninterface ICacheEntry {\n value: Record<string, string>;\n expiresAt: number;\n}\n\ninterface IRawFetchResult {\n value: Record<string, string>;\n lease?: { leaseId: string; ttlSeconds: number; renewable: boolean };\n}\n\nconst DEFAULT_CLOCK: IClock = { now: () => Date.now() };\nconst DEFAULT_TIMERS: ITimerAdapter = {\n set: (handler, ms) => setTimeout(handler, ms),\n clear: (handle) => clearTimeout(handle as AnyType),\n};\n\nconst DEFAULT_CACHE_TTL_SECONDS = 300;\nconst DEFAULT_RENEW_BEFORE_RATIO = 0.66;\n\n// setTimeout coerces any delay above this to 1ms, triggering an immediate renewal storm.\nconst TIMEOUT_MAX_MS = 2_147_483_647;\n// Floor so an invalid/tiny ttl never becomes a 0ms busy-loop.\nconst MIN_RENEW_DELAY_MS = 1_000;\n// Bounded exponential backoff for the renewal retry loop when Vault is unreachable.\nconst BACKOFF_BASE_MS = 1_000;\n// Capped at 31 to keep 2 ** (attempt - 1) inside double range: past ~1024 it overflows to Infinity and clampDelayMs's non-finite branch returns the FLOOR, collapsing a long backoff into a 1/sec retry storm.\nconst MAX_BACKOFF_ATTEMPT_EXPONENT = 31;\n\n/** Base for secrets providers: caches bundles for `cacheTtlSeconds`, tracks leases and renews them at `renewBeforeRatio` of their TTL, and notifies rotation handlers. Subclasses implement `fetchRaw`, `renewRaw` and `revokeRaw`. The constructor throws when `renewBeforeRatio` is outside (0, 1]. */\nexport abstract class AbstractSecretsHelper extends BaseHelper implements ISecretsHelper {\n protected readonly clock: IClock;\n protected readonly timers: ITimerAdapter;\n protected readonly cacheTtlSeconds: number;\n protected readonly renewBeforeRatio: number;\n\n private readonly cache = new Map<string, ICacheEntry>();\n private readonly leases = new Map<string, ISecretLease>();\n private readonly leasePaths = new Map<string, string>();\n private readonly timerHandles = new Map<string, TTimerHandle>();\n private readonly rotatables = new Map<string, ISecretRotatable[]>();\n private readonly rotateHandlers: TSecretRotationHandler[] = [];\n private readonly backoffAttempts = new Map<string, number>();\n private closed = false;\n\n constructor(opts: ISecretsHelperOptions) {\n super({ scope: opts.scope, identifier: opts.identifier });\n this.clock = opts.clock ?? DEFAULT_CLOCK;\n this.timers = opts.timers ?? DEFAULT_TIMERS;\n this.cacheTtlSeconds = opts.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;\n\n const ratio = opts.renewBeforeRatio ?? DEFAULT_RENEW_BEFORE_RATIO;\n\n if (!Number.isFinite(ratio) || ratio <= 0 || ratio > 1) {\n throw getError({\n message: `[constructor] renewBeforeRatio must be within (0, 1] | received: ${ratio}`,\n });\n }\n\n this.renewBeforeRatio = ratio;\n }\n\n protected abstract fetchRaw(opts: { path: string }): Promise<IRawFetchResult>;\n protected abstract renewRaw(opts: {\n leaseId: string;\n ttlSeconds: number;\n }): Promise<{ ttlSeconds: number } | null>;\n protected abstract revokeRaw(opts: { leaseId: string }): Promise<void>;\n\n // Concrete providers override to authenticate; default is a no-op.\n async configure(): Promise<void> {\n return;\n }\n\n async getBundle(opts: { path: string }): Promise<Record<string, string>> {\n this.evictExpiredCache();\n const cached = this.cache.get(opts.path);\n\n if (cached && cached.expiresAt > this.clock.now()) {\n return cached.value;\n }\n\n const fresh = await this.fetchRaw({ path: opts.path });\n\n // A shutdown that ran while fetchRaw was in flight already cleared `cache` - honor that and hand back the fetched value uncached rather than resurrecting a map shutdown just emptied.\n if (this.closed) {\n return fresh.value;\n }\n\n this.writeCache({ path: opts.path, value: fresh.value });\n\n return fresh.value;\n }\n\n async get(opts: IGetSecretOptions<string>): Promise<string>;\n async get<TValue>(opts: IGetSecretOptions<TValue>): Promise<TValue>;\n async get<TValue = string>(opts: IGetSecretOptions<TValue>): Promise<TValue> {\n const bundle = await this.getBundle({ path: opts.path });\n const raw = opts.key\n ? Object.hasOwn(bundle, opts.key)\n ? bundle[opts.key]\n : undefined\n : (bundle as AnyType);\n\n return (raw ?? opts.defaultValue) as TValue;\n }\n\n async lease(opts: { path: string; key: string }): Promise<ISecretLease> {\n const fresh = await this.fetchRaw({ path: opts.path });\n\n // A shutdown that ran while fetchRaw was in flight already revoked/cleared every lease - committing this one now would resurrect leases/leasePaths with a lease no live provider will ever renew or revoke, so surface the shutdown instead of silently leaking it back in.\n if (this.closed) {\n throw getError({\n message: `[lease] Provider is shut down | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n\n if (!fresh.lease) {\n throw getError({\n message: `[lease] Path returned no lease | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.leasePaths.set(opts.key, opts.path);\n this.scheduleRenewal({ key: opts.key, lease });\n\n return lease;\n }\n\n onRotate(handler: TSecretRotationHandler): void {\n this.rotateHandlers.push(handler);\n }\n\n registerRotatable(opts: { key: string; target: ISecretRotatable }): void {\n const list = this.rotatables.get(opts.key) ?? [];\n list.push(opts.target);\n this.rotatables.set(opts.key, list);\n }\n\n async shutdown(): Promise<void> {\n const logger = this.logger.for(this.shutdown.name);\n this.closed = true;\n\n const timerHandlesValues = this.timerHandles.values();\n\n for (const handle of timerHandlesValues) {\n this.timers.clear(handle);\n }\n\n this.timerHandles.clear();\n this.backoffAttempts.clear();\n\n for (const [key, lease] of this.leases) {\n try {\n await this.revokeRaw({ leaseId: lease.leaseId });\n } catch (error) {\n logger.error(\n 'Revoke failed | key: %s | leaseId: %s | error: %s',\n key,\n lease.leaseId,\n error,\n );\n }\n }\n\n this.leases.clear();\n this.leasePaths.clear();\n this.cache.clear();\n }\n\n private writeCache(opts: { path: string; value: Record<string, string> }): void {\n this.cache.set(opts.path, {\n value: opts.value,\n expiresAt: this.clock.now() + this.cacheTtlSeconds * 1000,\n });\n }\n\n private evictExpiredCache(): void {\n const now = this.clock.now();\n\n for (const [path, entry] of this.cache) {\n if (entry.expiresAt <= now) {\n this.cache.delete(path);\n }\n }\n }\n\n private clampDelayMs(opts: { delayMs: number }): number {\n if (!Number.isFinite(opts.delayMs) || opts.delayMs <= 0) {\n return MIN_RENEW_DELAY_MS;\n }\n\n return Math.min(Math.max(opts.delayMs, MIN_RENEW_DELAY_MS), TIMEOUT_MAX_MS);\n }\n\n private armTimer(opts: { key: string; delayMs: number }): void {\n const existing = this.timerHandles.get(opts.key);\n\n if (existing) {\n this.timers.clear(existing);\n }\n\n const handle = this.timers.set(() => {\n this.handleRenewal({ key: opts.key }).catch((error) => {\n this.logger\n .for(this.armTimer.name)\n .error('Renewal handler crashed | key: %s | error: %s', opts.key, error);\n });\n }, opts.delayMs);\n this.timerHandles.set(opts.key, handle);\n }\n\n private scheduleRenewal(opts: { key: string; lease: ISecretLease }): void {\n if (this.closed) {\n return;\n }\n\n this.backoffAttempts.delete(opts.key);\n const delayMs = this.clampDelayMs({\n delayMs: opts.lease.ttlSeconds * this.renewBeforeRatio * 1000,\n });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n // A transient Vault failure must not kill the loop; retry with bounded exponential backoff.\n private scheduleBackoffRetry(opts: { key: string }): void {\n if (this.closed) {\n return;\n }\n\n const attempt = (this.backoffAttempts.get(opts.key) ?? 0) + 1;\n this.backoffAttempts.set(opts.key, attempt);\n const cappedAttempt = Math.min(attempt, MAX_BACKOFF_ATTEMPT_EXPONENT);\n const delayMs = this.clampDelayMs({ delayMs: BACKOFF_BASE_MS * 2 ** (cappedAttempt - 1) });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n private async handleRenewal(opts: { key: string }): Promise<void> {\n if (this.closed) {\n return;\n }\n\n const logger = this.logger.for(this.handleRenewal.name);\n const lease = this.leases.get(opts.key);\n\n if (!lease) {\n logger.debug('No lease to renew | key: %s', opts.key);\n\n return;\n }\n\n try {\n if (!lease.renewable) {\n await this.rotate({ key: opts.key });\n\n return;\n }\n\n const renewed = await this.renewRaw({\n leaseId: lease.leaseId,\n ttlSeconds: lease.ttlSeconds,\n });\n\n if (this.closed) {\n return;\n }\n\n if (!renewed) {\n await this.rotate({ key: opts.key });\n\n return;\n }\n\n const next: ISecretLease = { ...lease, ttlSeconds: renewed.ttlSeconds };\n this.leases.set(opts.key, next);\n this.scheduleRenewal({ key: opts.key, lease: next });\n } catch (error) {\n if (this.closed) {\n return;\n }\n\n logger.error(\n 'Renewal cycle failed; scheduling backoff retry | key: %s | error: %s',\n opts.key,\n error,\n );\n this.scheduleBackoffRetry({ key: opts.key });\n }\n }\n\n private async rotate(opts: { key: string }): Promise<void> {\n const path = this.leasePaths.get(opts.key);\n\n if (!path) {\n throw getError({ message: `[rotate] No lease path registered | key: ${opts.key}` });\n }\n\n const fresh = await this.fetchRaw({ path });\n\n if (this.closed) {\n return;\n }\n\n if (!fresh.lease) {\n throw getError({ message: `[rotate] Path returned no lease on rotation | key: ${opts.key}` });\n }\n\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.writeCache({ path, value: fresh.value });\n // Arm the next renewal BEFORE dispatching: a wedged consumer must not stall the loop.\n this.scheduleRenewal({ key: opts.key, lease });\n await this.dispatchRotation({ key: opts.key, lease });\n }\n\n private async dispatchRotation(event: ISecretRotationEvent): Promise<void> {\n const logger = this.logger.for(this.dispatchRotation.name);\n\n for (const handler of this.rotateHandlers) {\n try {\n await handler(event);\n } catch (error) {\n logger.error('onRotate handler failed | key: %s | error: %s', event.key, error);\n }\n }\n\n const targets = this.rotatables.get(event.key) ?? [];\n\n for (const target of targets) {\n try {\n await target.onSecretRotated({ key: event.key, secret: event.lease.value });\n } catch (error) {\n logger.error('Rotatable failed | key: %s | error: %s', event.key, error);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"abstract.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/base/abstract.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAwB3C,MAAM,aAAa,GAAW,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACxD,MAAM,cAAc,GAAkB;IACpC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;IAC7C,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE;QAChB,uKAAuK;QACvK,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC;YACpF,YAAY,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;CACF,CAAC;AAEF,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAExC,yFAAyF;AACzF,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,8DAA8D;AAC9D,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,oFAAoF;AACpF,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,+MAA+M;AAC/M,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,ySAAyS;AACzS,MAAM,OAAgB,qBAAsB,SAAQ,UAAU;IAe5D,YAAY,IAA2B;QACrC,KAAK,CAAC,EAAE,KAAK,EA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I,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAE3D,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAClF,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAErD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9E,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@/modules/base';\nimport { getError } from '@/modules/error';\nimport type {\n IClock,\n IGetSecretOptions,\n ISecretLease,\n ISecretRotatable,\n ISecretRotationEvent,\n ISecretsHelper,\n ISecretsHelperOptions,\n ITimerAdapter,\n TSecretRotationHandler,\n TTimerHandle,\n} from '../common';\n\ninterface ICacheEntry {\n value: Record<string, string>;\n expiresAt: number;\n}\n\ninterface IRawFetchResult {\n value: Record<string, string>;\n lease?: { leaseId: string; ttlSeconds: number; renewable: boolean };\n}\n\nconst DEFAULT_CLOCK: IClock = { now: () => Date.now() };\nconst DEFAULT_TIMERS: ITimerAdapter = {\n set: (handler, ms) => setTimeout(handler, ms),\n clear: (handle) => {\n // Only a real timer handle can be cleared: a number, or an object that carries `unref` (Node and Bun timers); an opaque fake from a test adapter has nothing to clear.\n if (typeof handle === 'number' || (typeof handle === 'object' && 'unref' in handle)) {\n clearTimeout(handle);\n }\n },\n};\n\nconst DEFAULT_CACHE_TTL_SECONDS = 300;\nconst DEFAULT_RENEW_BEFORE_RATIO = 0.66;\n\n// setTimeout coerces any delay above this to 1ms, triggering an immediate renewal storm.\nconst TIMEOUT_MAX_MS = 2_147_483_647;\n// Floor so an invalid/tiny ttl never becomes a 0ms busy-loop.\nconst MIN_RENEW_DELAY_MS = 1_000;\n// Bounded exponential backoff for the renewal retry loop when Vault is unreachable.\nconst BACKOFF_BASE_MS = 1_000;\n// Capped at 31 to keep 2 ** (attempt - 1) inside double range: past ~1024 it overflows to Infinity and clampDelayMs's non-finite branch returns the FLOOR, collapsing a long backoff into a 1/sec retry storm.\nconst MAX_BACKOFF_ATTEMPT_EXPONENT = 31;\n\n/** Base for secrets providers: caches bundles for `cacheTtlSeconds`, tracks leases and renews them at `renewBeforeRatio` of their TTL, and notifies rotation handlers. Subclasses implement `fetchRaw`, `renewRaw` and `revokeRaw`. The constructor throws when `renewBeforeRatio` is outside (0, 1]. */\nexport abstract class AbstractSecretsHelper extends BaseHelper implements ISecretsHelper {\n protected readonly clock: IClock;\n protected readonly timers: ITimerAdapter;\n protected readonly cacheTtlSeconds: number;\n protected readonly renewBeforeRatio: number;\n\n private readonly cache = new Map<string, ICacheEntry>();\n private readonly leases = new Map<string, ISecretLease>();\n private readonly leasePaths = new Map<string, string>();\n private readonly timerHandles = new Map<string, TTimerHandle>();\n private readonly rotatables = new Map<string, ISecretRotatable[]>();\n private readonly rotateHandlers: TSecretRotationHandler[] = [];\n private readonly backoffAttempts = new Map<string, number>();\n private closed = false;\n\n constructor(opts: ISecretsHelperOptions) {\n super({ scope: opts.scope, identifier: opts.identifier });\n this.clock = opts.clock ?? DEFAULT_CLOCK;\n this.timers = opts.timers ?? DEFAULT_TIMERS;\n this.cacheTtlSeconds = opts.cacheTtlSeconds ?? DEFAULT_CACHE_TTL_SECONDS;\n\n const ratio = opts.renewBeforeRatio ?? DEFAULT_RENEW_BEFORE_RATIO;\n\n if (!Number.isFinite(ratio) || ratio <= 0 || ratio > 1) {\n throw getError({\n message: `[constructor] renewBeforeRatio must be within (0, 1] | received: ${ratio}`,\n });\n }\n\n this.renewBeforeRatio = ratio;\n }\n\n protected abstract fetchRaw(opts: { path: string }): Promise<IRawFetchResult>;\n protected abstract renewRaw(opts: {\n leaseId: string;\n ttlSeconds: number;\n }): Promise<{ ttlSeconds: number } | null>;\n protected abstract revokeRaw(opts: { leaseId: string }): Promise<void>;\n\n // Concrete providers override to authenticate; default is a no-op.\n async configure(): Promise<void> {\n return;\n }\n\n async getBundle(opts: { path: string }): Promise<Record<string, string>> {\n this.evictExpiredCache();\n const cached = this.cache.get(opts.path);\n\n if (cached && cached.expiresAt > this.clock.now()) {\n return cached.value;\n }\n\n const fresh = await this.fetchRaw({ path: opts.path });\n\n // A shutdown that ran while fetchRaw was in flight already cleared `cache` - honor that and hand back the fetched value uncached rather than resurrecting a map shutdown just emptied.\n if (this.closed) {\n return fresh.value;\n }\n\n this.writeCache({ path: opts.path, value: fresh.value });\n\n return fresh.value;\n }\n\n async get(opts: IGetSecretOptions<string>): Promise<string>;\n async get<TValue>(opts: IGetSecretOptions<TValue>): Promise<TValue>;\n async get<TValue = string>(opts: IGetSecretOptions<TValue>): Promise<TValue> {\n const bundle = await this.getBundle({ path: opts.path });\n const raw = opts.key\n ? Object.hasOwn(bundle, opts.key)\n ? bundle[opts.key]\n : undefined\n : bundle;\n\n return (raw ?? opts.defaultValue) as TValue;\n }\n\n async lease(opts: { path: string; key: string }): Promise<ISecretLease> {\n const fresh = await this.fetchRaw({ path: opts.path });\n\n // A shutdown that ran while fetchRaw was in flight already revoked/cleared every lease - committing this one now would resurrect leases/leasePaths with a lease no live provider will ever renew or revoke, so surface the shutdown instead of silently leaking it back in.\n if (this.closed) {\n throw getError({\n message: `[lease] Provider is shut down | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n\n if (!fresh.lease) {\n throw getError({\n message: `[lease] Path returned no lease | path: ${opts.path} | key: ${opts.key}`,\n });\n }\n\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.leasePaths.set(opts.key, opts.path);\n this.scheduleRenewal({ key: opts.key, lease });\n\n return lease;\n }\n\n onRotate(handler: TSecretRotationHandler): void {\n this.rotateHandlers.push(handler);\n }\n\n registerRotatable(opts: { key: string; target: ISecretRotatable }): void {\n const list = this.rotatables.get(opts.key) ?? [];\n list.push(opts.target);\n this.rotatables.set(opts.key, list);\n }\n\n async shutdown(): Promise<void> {\n const logger = this.logger.for(this.shutdown.name);\n this.closed = true;\n\n const timerHandlesValues = this.timerHandles.values();\n\n for (const handle of timerHandlesValues) {\n this.timers.clear(handle);\n }\n\n this.timerHandles.clear();\n this.backoffAttempts.clear();\n\n for (const [key, lease] of this.leases) {\n try {\n await this.revokeRaw({ leaseId: lease.leaseId });\n } catch (error) {\n logger.error(\n 'Revoke failed | key: %s | leaseId: %s | error: %s',\n key,\n lease.leaseId,\n error,\n );\n }\n }\n\n this.leases.clear();\n this.leasePaths.clear();\n this.cache.clear();\n }\n\n private writeCache(opts: { path: string; value: Record<string, string> }): void {\n this.cache.set(opts.path, {\n value: opts.value,\n expiresAt: this.clock.now() + this.cacheTtlSeconds * 1000,\n });\n }\n\n private evictExpiredCache(): void {\n const now = this.clock.now();\n\n for (const [path, entry] of this.cache) {\n if (entry.expiresAt <= now) {\n this.cache.delete(path);\n }\n }\n }\n\n private clampDelayMs(opts: { delayMs: number }): number {\n if (!Number.isFinite(opts.delayMs) || opts.delayMs <= 0) {\n return MIN_RENEW_DELAY_MS;\n }\n\n return Math.min(Math.max(opts.delayMs, MIN_RENEW_DELAY_MS), TIMEOUT_MAX_MS);\n }\n\n private armTimer(opts: { key: string; delayMs: number }): void {\n const existing = this.timerHandles.get(opts.key);\n\n if (existing) {\n this.timers.clear(existing);\n }\n\n const handle = this.timers.set(() => {\n this.handleRenewal({ key: opts.key }).catch((error) => {\n this.logger\n .for(this.armTimer.name)\n .error('Renewal handler crashed | key: %s | error: %s', opts.key, error);\n });\n }, opts.delayMs);\n this.timerHandles.set(opts.key, handle);\n }\n\n private scheduleRenewal(opts: { key: string; lease: ISecretLease }): void {\n if (this.closed) {\n return;\n }\n\n this.backoffAttempts.delete(opts.key);\n const delayMs = this.clampDelayMs({\n delayMs: opts.lease.ttlSeconds * this.renewBeforeRatio * 1000,\n });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n // A transient Vault failure must not kill the loop; retry with bounded exponential backoff.\n private scheduleBackoffRetry(opts: { key: string }): void {\n if (this.closed) {\n return;\n }\n\n const attempt = (this.backoffAttempts.get(opts.key) ?? 0) + 1;\n this.backoffAttempts.set(opts.key, attempt);\n const cappedAttempt = Math.min(attempt, MAX_BACKOFF_ATTEMPT_EXPONENT);\n const delayMs = this.clampDelayMs({ delayMs: BACKOFF_BASE_MS * 2 ** (cappedAttempt - 1) });\n this.armTimer({ key: opts.key, delayMs });\n }\n\n private async handleRenewal(opts: { key: string }): Promise<void> {\n if (this.closed) {\n return;\n }\n\n const logger = this.logger.for(this.handleRenewal.name);\n const lease = this.leases.get(opts.key);\n\n if (!lease) {\n logger.debug('No lease to renew | key: %s', opts.key);\n\n return;\n }\n\n try {\n if (!lease.renewable) {\n await this.rotate({ key: opts.key });\n\n return;\n }\n\n const renewed = await this.renewRaw({\n leaseId: lease.leaseId,\n ttlSeconds: lease.ttlSeconds,\n });\n\n if (this.closed) {\n return;\n }\n\n if (!renewed) {\n await this.rotate({ key: opts.key });\n\n return;\n }\n\n const next: ISecretLease = { ...lease, ttlSeconds: renewed.ttlSeconds };\n this.leases.set(opts.key, next);\n this.scheduleRenewal({ key: opts.key, lease: next });\n } catch (error) {\n if (this.closed) {\n return;\n }\n\n logger.error(\n 'Renewal cycle failed; scheduling backoff retry | key: %s | error: %s',\n opts.key,\n error,\n );\n this.scheduleBackoffRetry({ key: opts.key });\n }\n }\n\n private async rotate(opts: { key: string }): Promise<void> {\n const path = this.leasePaths.get(opts.key);\n\n if (!path) {\n throw getError({ message: `[rotate] No lease path registered | key: ${opts.key}` });\n }\n\n const fresh = await this.fetchRaw({ path });\n\n if (this.closed) {\n return;\n }\n\n if (!fresh.lease) {\n throw getError({ message: `[rotate] Path returned no lease on rotation | key: ${opts.key}` });\n }\n\n const lease: ISecretLease = { value: fresh.value, ...fresh.lease };\n this.leases.set(opts.key, lease);\n this.writeCache({ path, value: fresh.value });\n // Arm the next renewal BEFORE dispatching: a wedged consumer must not stall the loop.\n this.scheduleRenewal({ key: opts.key, lease });\n await this.dispatchRotation({ key: opts.key, lease });\n }\n\n private async dispatchRotation(event: ISecretRotationEvent): Promise<void> {\n const logger = this.logger.for(this.dispatchRotation.name);\n\n for (const handler of this.rotateHandlers) {\n try {\n await handler(event);\n } catch (error) {\n logger.error('onRotate handler failed | key: %s | error: %s', event.key, error);\n }\n }\n\n const targets = this.rotatables.get(event.key) ?? [];\n\n for (const target of targets) {\n try {\n await target.onSecretRotated({ key: event.key, secret: event.lease.value });\n } catch (error) {\n logger.error('Rotatable failed | key: %s | error: %s', event.key, error);\n }\n }\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
- import type { AnyObject } from '../../../../common/types/index.js';
2
- import type { TSecretProvider } from '../constants.js';
1
+ import type { IDotenvVaultHelperOptions } from '../../dotenv/dotenv.helper.js';
2
+ import type { IHashiCorpVaultHelperOptions } from '../../hashicorp/hashicorp.helper.js';
3
+ import type { SecretProviders } from '../constants.js';
3
4
  /** A bundle at `path` to copy into environment variables; keys map by `prefix` or by explicit `keys`. */
4
5
  export interface ISecretHydrateEntry {
5
6
  path: string;
@@ -13,10 +14,8 @@ export interface ISecretLeaseEntry {
13
14
  key: string;
14
15
  path: string;
15
16
  }
16
- /** Declares a secrets provider with the bundles to hydrate and the secrets to lease. */
17
- export interface ISecretsRegistration {
18
- provider: TSecretProvider;
19
- config?: AnyObject;
17
+ /** What every registration carries, whatever its provider. */
18
+ interface ISecretsRegistrationBase {
20
19
  hydrate?: Array<ISecretHydrateEntry>;
21
20
  lease?: Array<ISecretLeaseEntry>;
22
21
  /**
@@ -32,4 +31,24 @@ export interface ISecretsRegistration {
32
31
  */
33
32
  cacheTtlSeconds?: number;
34
33
  }
34
+ /** The helper options a registration's `config` fills; the registration owns the identifier, the cache TTL and the renewal ratio. */
35
+ type TRegistrationConfig<Options> = Omit<Options, 'identifier' | 'cacheTtlSeconds' | 'renewBeforeRatio'>;
36
+ /** Registers the process environment as the provider; it takes no `config`. */
37
+ export interface ISystemEnvsSecretsRegistration extends ISecretsRegistrationBase {
38
+ provider: typeof SecretProviders.SYSTEM_ENVS;
39
+ config?: undefined;
40
+ }
41
+ /** Registers HashiCorp Vault; `config` carries the endpoint and the auth. */
42
+ export interface IHashiCorpSecretsRegistration extends ISecretsRegistrationBase {
43
+ provider: typeof SecretProviders.HASHICORP_VAULT;
44
+ config: TRegistrationConfig<IHashiCorpVaultHelperOptions>;
45
+ }
46
+ /** Registers a dotenv vault file; `config` is optional. */
47
+ export interface IDotenvSecretsRegistration extends ISecretsRegistrationBase {
48
+ provider: typeof SecretProviders.DOTENV_VAULT;
49
+ config?: TRegistrationConfig<IDotenvVaultHelperOptions>;
50
+ }
51
+ /** Declares a secrets provider with the bundles to hydrate and the secrets to lease: the `provider` selects the shape of `config`. */
52
+ export type ISecretsRegistration = ISystemEnvsSecretsRegistration | IHashiCorpSecretsRegistration | IDotenvSecretsRegistration;
53
+ export {};
35
54
  //# sourceMappingURL=registration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../../../src/modules/secrets/common/types/registration.ts"],"names":[],"mappings":"","sourcesContent":["import type { AnyObject } from '@/common/types';\nimport type { TSecretProvider } from '../constants';\n\n/** A bundle at `path` to copy into environment variables; keys map by `prefix` or by explicit `keys`. */\nexport interface ISecretHydrateEntry {\n path: string;\n prefix?: string;\n /** Explicit vaultKey -> envKey overrides. Takes precedence over `prefix`. */\n keys?: Record<string, string>;\n}\n\n/** A leased secret at `path`, registered under the consumer binding `key`. */\nexport interface ISecretLeaseEntry {\n /** Logical/binding key of the consuming datasource, e.g. 'datasources.postgres'. */\n key: string;\n path: string;\n}\n\n/** Declares a secrets provider with the bundles to hydrate and the secrets to lease. */\nexport interface ISecretsRegistration {\n provider: TSecretProvider;\n config?: AnyObject;\n hydrate?: Array<ISecretHydrateEntry>;\n lease?: Array<ISecretLeaseEntry>;\n /**\n * Renew a lease at ttl * ratio.\n *\n * @default 0.66\n */\n renewBeforeRatio?: number;\n /**\n * TTL (seconds) for the static get/getBundle cache.\n *\n * @default 300\n */\n cacheTtlSeconds?: number;\n}\n"]}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../../../src/modules/secrets/common/types/registration.ts"],"names":[],"mappings":"","sourcesContent":["import type { IDotenvVaultHelperOptions } from '../../dotenv/dotenv.helper';\nimport type { IHashiCorpVaultHelperOptions } from '../../hashicorp/hashicorp.helper';\nimport type { SecretProviders } from '../constants';\n\n/** A bundle at `path` to copy into environment variables; keys map by `prefix` or by explicit `keys`. */\nexport interface ISecretHydrateEntry {\n path: string;\n prefix?: string;\n /** Explicit vaultKey -> envKey overrides. Takes precedence over `prefix`. */\n keys?: Record<string, string>;\n}\n\n/** A leased secret at `path`, registered under the consumer binding `key`. */\nexport interface ISecretLeaseEntry {\n /** Logical/binding key of the consuming datasource, e.g. 'datasources.postgres'. */\n key: string;\n path: string;\n}\n\n/** What every registration carries, whatever its provider. */\ninterface ISecretsRegistrationBase {\n hydrate?: Array<ISecretHydrateEntry>;\n lease?: Array<ISecretLeaseEntry>;\n /**\n * Renew a lease at ttl * ratio.\n *\n * @default 0.66\n */\n renewBeforeRatio?: number;\n /**\n * TTL (seconds) for the static get/getBundle cache.\n *\n * @default 300\n */\n cacheTtlSeconds?: number;\n}\n\n/** The helper options a registration's `config` fills; the registration owns the identifier, the cache TTL and the renewal ratio. */\ntype TRegistrationConfig<Options> = Omit<\n Options,\n 'identifier' | 'cacheTtlSeconds' | 'renewBeforeRatio'\n>;\n\n/** Registers the process environment as the provider; it takes no `config`. */\nexport interface ISystemEnvsSecretsRegistration extends ISecretsRegistrationBase {\n provider: typeof SecretProviders.SYSTEM_ENVS;\n config?: undefined;\n}\n\n/** Registers HashiCorp Vault; `config` carries the endpoint and the auth. */\nexport interface IHashiCorpSecretsRegistration extends ISecretsRegistrationBase {\n provider: typeof SecretProviders.HASHICORP_VAULT;\n config: TRegistrationConfig<IHashiCorpVaultHelperOptions>;\n}\n\n/** Registers a dotenv vault file; `config` is optional. */\nexport interface IDotenvSecretsRegistration extends ISecretsRegistrationBase {\n provider: typeof SecretProviders.DOTENV_VAULT;\n config?: TRegistrationConfig<IDotenvVaultHelperOptions>;\n}\n\n/** Declares a secrets provider with the bundles to hydrate and the secrets to lease: the `provider` selects the shape of `config`. */\nexport type ISecretsRegistration =\n | ISystemEnvsSecretsRegistration\n | IHashiCorpSecretsRegistration\n | IDotenvSecretsRegistration;\n"]}
@@ -25,7 +25,7 @@ export class DotenvVaultHelper extends AbstractSecretsHelper {
25
25
  ...(this.dotenvKey ? { DOTENV_KEY: this.dotenvKey } : {}),
26
26
  overload: true,
27
27
  });
28
- const parsed = (result?.parsed ?? {});
28
+ const parsed = result?.parsed ?? {};
29
29
  return { value: parsed };
30
30
  }
31
31
  async renewRaw() {
@@ -1 +1 @@
1
- {"version":3,"file":"dotenv.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/dotenv/dotenv.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAqBhD,6JAA6J;AAC7J,MAAM,OAAO,iBAAkB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C,SAAS;QACvB,OAAO;IACT,CAAC;IAEQ,KAAK,CAAC,KAAK,CAAC,KAAoC;QACvD,MAAM,QAAQ,CAAC;YACb,OAAO,EACL,yFAAyF;SAC5F,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { AnyType } from '@/common/types';\nimport { getError } from '@/modules/error';\nimport { ModuleUtility } from '@/utilities/module.utility';\nimport { AbstractSecretsHelper } from '../base';\nimport type { IClock, ISecretLease, ITimerAdapter } from '../common';\n\n/** Options for `DotenvVaultHelper`. `dotenvKey` is the decryption key passed to dotenvx when set. */\nexport interface IDotenvVaultHelperOptions {\n /** @default '.env.vault' */\n path?: string;\n dotenvKey?: string;\n identifier?: string;\n /**\n * TTL in seconds of the get/getBundle cache.\n *\n * @default 300\n */\n cacheTtlSeconds?: number;\n clock?: IClock;\n timers?: ITimerAdapter;\n /** Injection seam for tests; production decrypts via @dotenvx/dotenvx. */\n decode?: (opts: { path: string; dotenvKey?: string }) => Record<string, string>;\n}\n\n/** Secrets provider that decrypts a dotenv vault file with `@dotenvx/dotenvx` and serves its entries. Dynamic leases are not supported: `lease()` throws. */\nexport class DotenvVaultHelper extends AbstractSecretsHelper {\n private readonly path: string;\n private readonly dotenvKey?: string;\n private readonly decode?: IDotenvVaultHelperOptions['decode'];\n\n constructor(opts: IDotenvVaultHelperOptions) {\n super({\n scope: DotenvVaultHelper.name,\n identifier: opts.identifier,\n cacheTtlSeconds: opts.cacheTtlSeconds,\n clock: opts.clock,\n timers: opts.timers,\n });\n this.path = opts.path ?? '.env.vault';\n this.dotenvKey = opts.dotenvKey;\n this.decode = opts.decode;\n }\n\n protected async fetchRaw() {\n if (this.decode) {\n return { value: this.decode({ path: this.path, dotenvKey: this.dotenvKey }) };\n }\n\n const dotenvx = await ModuleUtility.load<AnyType>({ module: '@dotenvx/dotenvx' });\n const result = dotenvx.config({\n path: this.path,\n ...(this.dotenvKey ? { DOTENV_KEY: this.dotenvKey } : {}),\n overload: true,\n });\n const parsed = (result?.parsed ?? {}) as Record<string, string>;\n\n return { value: parsed };\n }\n\n protected async renewRaw() {\n return null;\n }\n\n protected async revokeRaw() {\n return;\n }\n\n override async lease(_opts: { path: string; key: string }): Promise<ISecretLease> {\n throw getError({\n message:\n '[DotenvVaultHelper.lease] Dynamic leases are not supported by the dotenv-vault provider',\n });\n }\n}\n"]}
1
+ {"version":3,"file":"dotenv.helper.js","sourceRoot":"","sources":["../../../../../src/modules/secrets/dotenv/dotenv.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA8BhD,6JAA6J;AAC7J,MAAM,OAAO,iBAAkB,SAAQ,qBAAqB;IAK1D,YAAY,IAA+B;QACzC,KAAK,CAAC;YACJ,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,YAAY,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;QAChF,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,IAAI,CAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;QACzF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;QAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,SAAS;QACvB,OAAO;IACT,CAAC;IAEQ,KAAK,CAAC,KAAK,CAAC,KAAoC;QACvD,MAAM,QAAQ,CAAC;YACb,OAAO,EACL,yFAAyF;SAC5F,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { ModuleUtility } from '@/utilities/module.utility';\nimport { AbstractSecretsHelper } from '../base';\nimport type { IClock, ISecretLease, ITimerAdapter } from '../common';\n\n/** The part of `@dotenvx/dotenvx` this helper calls: `config` loads and decrypts the vault file. */\ninterface IDotenvxModule {\n config(opts: {\n path: string;\n DOTENV_KEY?: string;\n overload: boolean;\n }): { parsed?: Record<string, string> } | undefined;\n}\n\n/** Options for `DotenvVaultHelper`. `dotenvKey` is the decryption key passed to dotenvx when set. */\nexport interface IDotenvVaultHelperOptions {\n /** @default '.env.vault' */\n path?: string;\n dotenvKey?: string;\n identifier?: string;\n /**\n * TTL in seconds of the get/getBundle cache.\n *\n * @default 300\n */\n cacheTtlSeconds?: number;\n clock?: IClock;\n timers?: ITimerAdapter;\n /** Injection seam for tests; production decrypts via @dotenvx/dotenvx. */\n decode?: (opts: { path: string; dotenvKey?: string }) => Record<string, string>;\n}\n\n/** Secrets provider that decrypts a dotenv vault file with `@dotenvx/dotenvx` and serves its entries. Dynamic leases are not supported: `lease()` throws. */\nexport class DotenvVaultHelper extends AbstractSecretsHelper {\n private readonly path: string;\n private readonly dotenvKey?: string;\n private readonly decode?: IDotenvVaultHelperOptions['decode'];\n\n constructor(opts: IDotenvVaultHelperOptions) {\n super({\n scope: DotenvVaultHelper.name,\n identifier: opts.identifier,\n cacheTtlSeconds: opts.cacheTtlSeconds,\n clock: opts.clock,\n timers: opts.timers,\n });\n this.path = opts.path ?? '.env.vault';\n this.dotenvKey = opts.dotenvKey;\n this.decode = opts.decode;\n }\n\n protected async fetchRaw() {\n if (this.decode) {\n return { value: this.decode({ path: this.path, dotenvKey: this.dotenvKey }) };\n }\n\n const dotenvx = await ModuleUtility.load<IDotenvxModule>({ module: '@dotenvx/dotenvx' });\n const result = dotenvx.config({\n path: this.path,\n ...(this.dotenvKey ? { DOTENV_KEY: this.dotenvKey } : {}),\n overload: true,\n });\n const parsed = result?.parsed ?? {};\n\n return { value: parsed };\n }\n\n protected async renewRaw() {\n return null;\n }\n\n protected async revokeRaw() {\n return;\n }\n\n override async lease(_opts: { path: string; key: string }): Promise<ISecretLease> {\n throw getError({\n message:\n '[DotenvVaultHelper.lease] Dynamic leases are not supported by the dotenv-vault provider',\n });\n }\n}\n"]}