@rsdk/db 5.8.0-next.1 → 5.8.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { NeverRunningInTransaction, CallOutOfContextWithMandatory, IncompatibleI
5
5
  export { TransactionRunner } from './transactional.runner';
6
6
  export { Propagation } from './propagation.enum';
7
7
  export { HEALTH_CHECK_QUERY } from './constants';
8
+ export { getSecureContextOptions } from './tls';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HEALTH_CHECK_QUERY = exports.Propagation = exports.TransactionRunner = exports.IncompatibleIsolationLevels = exports.CallOutOfContextWithMandatory = exports.NeverRunningInTransaction = exports.BaseContext = exports.ContextStorage = void 0;
3
+ exports.getSecureContextOptions = exports.HEALTH_CHECK_QUERY = exports.Propagation = exports.TransactionRunner = exports.IncompatibleIsolationLevels = exports.CallOutOfContextWithMandatory = exports.NeverRunningInTransaction = exports.BaseContext = exports.ContextStorage = void 0;
4
4
  var context_storage_1 = require("./context.storage");
5
5
  Object.defineProperty(exports, "ContextStorage", { enumerable: true, get: function () { return context_storage_1.ContextStorage; } });
6
6
  var context_base_1 = require("./context.base");
@@ -15,4 +15,6 @@ var propagation_enum_1 = require("./propagation.enum");
15
15
  Object.defineProperty(exports, "Propagation", { enumerable: true, get: function () { return propagation_enum_1.Propagation; } });
16
16
  var constants_1 = require("./constants");
17
17
  Object.defineProperty(exports, "HEALTH_CHECK_QUERY", { enumerable: true, get: function () { return constants_1.HEALTH_CHECK_QUERY; } });
18
+ var tls_1 = require("./tls");
19
+ Object.defineProperty(exports, "getSecureContextOptions", { enumerable: true, get: function () { return tls_1.getSecureContextOptions; } });
18
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAEpB,2CAIsB;AAHpB,uHAAA,yBAAyB,OAAA;AACzB,2HAAA,6BAA6B,OAAA;AAC7B,yHAAA,2BAA2B,OAAA;AAE7B,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAiD;AAAxC,+GAAA,WAAW,OAAA;AACpB,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAEpB,2CAIsB;AAHpB,uHAAA,yBAAyB,OAAA;AACzB,2HAAA,6BAA6B,OAAA;AAC7B,yHAAA,2BAA2B,OAAA;AAE7B,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAiD;AAAxC,+GAAA,WAAW,OAAA;AACpB,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA;AAC3B,6BAAgD;AAAvC,8GAAA,uBAAuB,OAAA"}
package/dist/tls.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { SecureContextOptions } from 'node:tls';
2
+ export interface SecureConfig {
3
+ allowSelfSignedCert?: boolean | undefined;
4
+ tlsCa?: string | undefined;
5
+ tlsCert?: string | undefined;
6
+ tlsKey?: string | undefined;
7
+ }
8
+ export declare const getSecureContextOptions: (config: SecureConfig) => (Pick<SecureContextOptions, "ca" | "cert" | "key"> & {
9
+ rejectUnauthorized: boolean;
10
+ }) | false;
package/dist/tls.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSecureContextOptions = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const getSecureContextOptions = (config) => typeof config.allowSelfSignedCert === 'boolean' ||
9
+ config.tlsCa ||
10
+ config.tlsKey ||
11
+ config.tlsCert
12
+ ? {
13
+ rejectUnauthorized: !config.allowSelfSignedCert,
14
+ ...(config.tlsCa && {
15
+ ca: readFileIfExistsSync(config.tlsCa) ?? config.tlsCa,
16
+ }),
17
+ ...(config.tlsKey && {
18
+ key: readFileIfExistsSync(config.tlsKey) ?? config.tlsKey,
19
+ }),
20
+ ...(config.tlsCert && {
21
+ cert: readFileIfExistsSync(config.tlsCert) ?? config.tlsCert,
22
+ }),
23
+ }
24
+ : false;
25
+ exports.getSecureContextOptions = getSecureContextOptions;
26
+ const readFileIfExistsSync = (path) => node_fs_1.default.existsSync(path) ? node_fs_1.default.readFileSync(path) : undefined;
27
+ //# sourceMappingURL=tls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.js","sourceRoot":"","sources":["../src/tls.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AAUlB,MAAM,uBAAuB,GAAG,CACrC,MAAoB,EAKZ,EAAE,CACV,OAAO,MAAM,CAAC,mBAAmB,KAAK,SAAS;IAC/C,MAAM,CAAC,KAAK;IACZ,MAAM,CAAC,MAAM;IACb,MAAM,CAAC,OAAO;IACZ,CAAC,CAAC;QACE,kBAAkB,EAAE,CAAC,MAAM,CAAC,mBAAmB;QAC/C,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;YAClB,EAAE,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK;SACvD,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI;YACnB,GAAG,EAAE,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM;SAC1D,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI;YACpB,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO;SAC7D,CAAC;KACH;IACH,CAAC,CAAC,KAAK,CAAC;AAvBC,QAAA,uBAAuB,2BAuBxB;AAEZ,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAsB,EAAE,CAChE,iBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/db",
3
- "version": "5.8.0-next.1",
3
+ "version": "5.8.0-next.3",
4
4
  "description": "Common functionality and interfaces for relational database plugins",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -18,5 +18,5 @@
18
18
  "@rsdk/decorators": "*",
19
19
  "reflect-metadata": "^0.1.12 || ^0.2.0"
20
20
  },
21
- "gitHead": "466ee102dcc2bce0b90df8f561c3e73d889c8468"
21
+ "gitHead": "0f2d793fff0ebfa56506a569495d24ad3b055797"
22
22
  }
package/src/index.ts CHANGED
@@ -9,3 +9,4 @@ export {
9
9
  export { TransactionRunner } from './transactional.runner';
10
10
  export { Propagation } from './propagation.enum';
11
11
  export { HEALTH_CHECK_QUERY } from './constants';
12
+ export { getSecureContextOptions } from './tls';
package/src/tls.ts ADDED
@@ -0,0 +1,37 @@
1
+ import fs from 'node:fs';
2
+ import type { SecureContextOptions } from 'node:tls';
3
+
4
+ export interface SecureConfig {
5
+ allowSelfSignedCert?: boolean | undefined;
6
+ tlsCa?: string | undefined;
7
+ tlsCert?: string | undefined;
8
+ tlsKey?: string | undefined;
9
+ }
10
+
11
+ export const getSecureContextOptions = (
12
+ config: SecureConfig,
13
+ ):
14
+ | (Pick<SecureContextOptions, 'ca' | 'cert' | 'key'> & {
15
+ rejectUnauthorized: boolean;
16
+ })
17
+ | false =>
18
+ typeof config.allowSelfSignedCert === 'boolean' ||
19
+ config.tlsCa ||
20
+ config.tlsKey ||
21
+ config.tlsCert
22
+ ? {
23
+ rejectUnauthorized: !config.allowSelfSignedCert,
24
+ ...(config.tlsCa && {
25
+ ca: readFileIfExistsSync(config.tlsCa) ?? config.tlsCa,
26
+ }),
27
+ ...(config.tlsKey && {
28
+ key: readFileIfExistsSync(config.tlsKey) ?? config.tlsKey,
29
+ }),
30
+ ...(config.tlsCert && {
31
+ cert: readFileIfExistsSync(config.tlsCert) ?? config.tlsCert,
32
+ }),
33
+ }
34
+ : false;
35
+
36
+ const readFileIfExistsSync = (path: string): Buffer | undefined =>
37
+ fs.existsSync(path) ? fs.readFileSync(path) : undefined;