backend-test-tools 1.0.1 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"factory.types.js","names":[],"sources":["../../src/factory/factory.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ConnectionModel,\n ConnectionBuildOptions,\n OrganizationModel,\n UserModel,\n UserBuildOptions,\n} from './workers';\n\ntype FactoryTyping = {\n /** Mapping for the connection model */\n connection: {\n /** Options for the connection model */\n options: ConnectionBuildOptions;\n /** Return type for the connection model */\n return: ConnectionModel;\n };\n /** Mapping for the user model */\n user: {\n /** Options for the user model */\n options: UserBuildOptions;\n /** Return type for the user model */\n return: UserModel;\n };\n};\n\nexport type FactoryModel = keyof FactoryTyping;\n\nexport type FactoryModelOverride<T extends FactoryModel> = Partial<FactoryTyping[T]['return']> & {\n /** Id of the model */\n id?: string;\n};\n\nexport type FactoryBuildOptions<T extends FactoryModel> = FactoryTyping[T]['options'];\n\nexport type FactoryReturnType<T extends FactoryModel> = FactoryTyping[T]['return'] & {\n /** Id of the model */\n id: string;\n};\n\nexport type ModelsMap = {\n [T in FactoryModel]: (buildOptions: FactoryTyping[T]['options']) => FactoryTyping[T]['return'];\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"factory.types.js","names":[],"sources":["../../src/factory/factory.types.ts"],"sourcesContent":["import {\n ConnectionModel,\n ConnectionBuildOptions,\n UserModel,\n UserBuildOptions,\n} from './workers';\n\ntype FactoryTyping = {\n /** Mapping for the connection model */\n connection: {\n /** Options for the connection model */\n options: ConnectionBuildOptions;\n /** Return type for the connection model */\n return: ConnectionModel;\n };\n /** Mapping for the user model */\n user: {\n /** Options for the user model */\n options: UserBuildOptions;\n /** Return type for the user model */\n return: UserModel;\n };\n};\n\nexport type FactoryModel = keyof FactoryTyping;\n\nexport type FactoryModelOverride<T extends FactoryModel> = Partial<FactoryTyping[T]['return']> & {\n /** Id of the model */\n id?: string;\n};\n\nexport type FactoryBuildOptions<T extends FactoryModel> = FactoryTyping[T]['options'];\n\nexport type FactoryReturnType<T extends FactoryModel> = FactoryTyping[T]['return'] & {\n /** Id of the model */\n id: string;\n};\n\nexport type ModelsMap = {\n [T in FactoryModel]: (buildOptions: FactoryTyping[T]['options']) => FactoryTyping[T]['return'];\n};\n"],"mappings":"","ignoreList":[]}
@@ -1,3 +1,2 @@
1
- import { generateImageBufferOptions } from './generateImageBuffer.types';
2
- /** Generate a binary buffer containing a PNG image */
3
- export declare function generateImageBuffer(options?: generateImageBufferOptions): Promise<Buffer>;
1
+ /** Generate a random image buffer */
2
+ export declare function generateRandomImageBuffer(width?: number, height?: number): Promise<Buffer>;
@@ -4,20 +4,30 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.generateImageBuffer = generateImageBuffer;
8
- var _jimp = _interopRequireDefault(require("jimp"));
9
- /** Generate a binary buffer containing a PNG image */
10
- async function generateImageBuffer(options = {}) {
11
- const image = await generateImage(options);
12
- return image.getBufferAsync(_jimp.default.MIME_PNG);
13
- }
7
+ exports.generateRandomImageBuffer = generateRandomImageBuffer;
8
+ var _sharp = _interopRequireDefault(require("sharp"));
9
+ /** Generate a random image buffer */
10
+ async function generateRandomImageBuffer(width = 150, height = 150) {
11
+ // Create a blank image buffer
12
+ const buffer = Buffer.alloc(width * height * 3); // RGB buffer (no alpha channel)
13
+
14
+ // Fill the buffer with random colors
15
+ for (let i = 0; i < buffer.length; i += 3) {
16
+ buffer[i] = Math.floor(Math.random() * 256); // Red
17
+ buffer[i + 1] = Math.floor(Math.random() * 256); // Green
18
+ buffer[i + 2] = Math.floor(Math.random() * 256); // Blue
19
+ }
20
+
21
+ // Use sharp to create an image from the buffer and convert it to PNG
22
+ const imageBuffer = await (0, _sharp.default)(buffer, {
23
+ raw: {
24
+ width: width,
25
+ height: height,
26
+ channels: 3 // RGB
27
+ }
28
+ }).toFormat('png') // Convert to PNG format
29
+ .toBuffer(); // Return the image buffer
14
30
 
15
- /** Generate the asynchronously image using Jimp */
16
- async function generateImage(options = {}) {
17
- return new Promise(resolve => {
18
- new _jimp.default(options.width ?? 150, options.height ?? 150, function (err, image) {
19
- resolve(image);
20
- });
21
- });
31
+ return imageBuffer;
22
32
  }
23
33
  //# sourceMappingURL=generateImageBuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateImageBuffer.js","names":["_jimp","_interopRequireDefault","require","generateImageBuffer","options","image","generateImage","getBufferAsync","Jimp","MIME_PNG","Promise","resolve","width","height","err"],"sources":["../../src/generators/generateImageBuffer.ts"],"sourcesContent":["import Jimp from 'jimp';\nimport {generateImageBufferOptions} from './generateImageBuffer.types';\n\n/** Generate a binary buffer containing a PNG image */\nexport async function generateImageBuffer(\n options: generateImageBufferOptions = {},\n): Promise<Buffer> {\n const image = await generateImage(options);\n return image.getBufferAsync(Jimp.MIME_PNG);\n}\n\n/** Generate the asynchronously image using Jimp */\nasync function generateImage(options: generateImageBufferOptions = {}): Promise<Jimp> {\n return new Promise<Jimp>((resolve) => {\n new Jimp(options.width ?? 150, options.height ?? 150, function (err, image) {\n resolve(image);\n });\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA;AACO,eAAeC,mBAAmBA,CACvCC,OAAmC,GAAG,CAAC,CAAC,EACvB;EACjB,MAAMC,KAAK,GAAG,MAAMC,aAAa,CAACF,OAAO,CAAC;EAC1C,OAAOC,KAAK,CAACE,cAAc,CAACC,aAAI,CAACC,QAAQ,CAAC;AAC5C;;AAEA;AACA,eAAeH,aAAaA,CAACF,OAAmC,GAAG,CAAC,CAAC,EAAiB;EACpF,OAAO,IAAIM,OAAO,CAAQC,OAAO,IAAK;IACpC,IAAIH,aAAI,CAACJ,OAAO,CAACQ,KAAK,IAAI,GAAG,EAAER,OAAO,CAACS,MAAM,IAAI,GAAG,EAAE,UAAUC,GAAG,EAAET,KAAK,EAAE;MAC1EM,OAAO,CAACN,KAAK,CAAC;IAChB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"generateImageBuffer.js","names":["_sharp","_interopRequireDefault","require","generateRandomImageBuffer","width","height","buffer","Buffer","alloc","i","length","Math","floor","random","imageBuffer","sharp","raw","channels","toFormat","toBuffer"],"sources":["../../src/generators/generateImageBuffer.ts"],"sourcesContent":["import sharp from 'sharp';\n\n/** Generate a random image buffer */\nexport async function generateRandomImageBuffer(\n width: number = 150,\n height: number = 150\n): Promise<Buffer> {\n // Create a blank image buffer\n const buffer = Buffer.alloc(width * height * 3); // RGB buffer (no alpha channel)\n\n // Fill the buffer with random colors\n for (let i = 0; i < buffer.length; i += 3) {\n buffer[i] = Math.floor(Math.random() * 256); // Red\n buffer[i + 1] = Math.floor(Math.random() * 256); // Green\n buffer[i + 2] = Math.floor(Math.random() * 256); // Blue\n }\n\n // Use sharp to create an image from the buffer and convert it to PNG\n const imageBuffer = await sharp(buffer, {\n raw: {\n width: width,\n height: height,\n channels: 3 // RGB\n }\n })\n .toFormat('png') // Convert to PNG format\n .toBuffer(); // Return the image buffer\n\n return imageBuffer;\n}"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACO,eAAeC,yBAAyBA,CAC7CC,KAAa,GAAG,GAAG,EACnBC,MAAc,GAAG,GAAG,EACH;EACjB;EACA,MAAMC,MAAM,GAAGC,MAAM,CAACC,KAAK,CAACJ,KAAK,GAAGC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;;EAEjD;EACA,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,MAAM,CAACI,MAAM,EAAED,CAAC,IAAI,CAAC,EAAE;IACzCH,MAAM,CAACG,CAAC,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAK;IACjDP,MAAM,CAACG,CAAC,GAAG,CAAC,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACjDP,MAAM,CAACG,CAAC,GAAG,CAAC,CAAC,GAAGE,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;EACnD;;EAEA;EACA,MAAMC,WAAW,GAAG,MAAM,IAAAC,cAAK,EAACT,MAAM,EAAE;IACtCU,GAAG,EAAE;MACHZ,KAAK,EAAEA,KAAK;MACZC,MAAM,EAAEA,MAAM;MACdY,QAAQ,EAAE,CAAC,CAAC;IACd;EACF,CAAC,CAAC,CACCC,QAAQ,CAAC,KAAK,CAAC,CAAC;EAAA,CAChBC,QAAQ,CAAC,CAAC,CAAC,CAAC;;EAEf,OAAOL,WAAW;AACpB","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Request } from 'supertest';
1
+ import { Agent } from 'supertest';
2
2
  import { tlsRequestOptions } from './tlsRequest.types';
3
3
  /**
4
4
  * Wrapper for supertest that adds TLS encryption
5
5
  */
6
- export declare function tlsRequest(options?: tlsRequestOptions): Promise<Request>;
6
+ export declare function tlsRequest(options?: tlsRequestOptions): Promise<Agent>;
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.tlsRequest = tlsRequest;
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
  var _supertest = require("supertest");
10
+ // Import Agent type
11
+
10
12
  const customAgent = (0, _supertest.agent)(`https://localhost:${process.env.PORT}`);
11
13
  let settings;
12
14
 
@@ -19,6 +21,8 @@ async function tlsRequest(options = {}) {
19
21
  const key = options.key ? _fs.default.readFileSync(options.key, 'utf-8') : settings.key;
20
22
  const cert = options.cert ? _fs.default.readFileSync(options.cert, 'utf-8') : settings.cert;
21
23
  if (!ca || !key || !cert) throw new Error('Missing some TLS configuration');
24
+
25
+ // Return Agent with configured TLS options
22
26
  return customAgent.ca(ca).key(key).cert(cert);
23
27
  }
24
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"tlsRequest.js","names":["_fs","_interopRequireDefault","require","_supertest","customAgent","agent","process","env","PORT","settings","tlsRequest","options","loadDefaultSettings","ca","fs","readFileSync","key","cert","Error","TLS_REQUEST_KEY","TLS_REQUEST_CERT","TLS_REQUEST_CA","TLS_SERVER_KEY","TLS_SERVER_CERT","TLS_CA"],"sources":["../../src/utils/tlsRequest.ts"],"sourcesContent":["import fs from 'fs';\nimport {agent, Request} from 'supertest';\nimport {tlsRequestOptions} from './tlsRequest.types';\n\nconst customAgent = agent(`https://localhost:${process.env.PORT as string}`);\n\nlet settings: tlsRequestOptions;\n\n/**\n * Wrapper for supertest that adds TLS encryption\n */\nexport async function tlsRequest(options: tlsRequestOptions = {}): Promise<Request> {\n if (!settings) loadDefaultSettings();\n const ca = options.ca ? fs.readFileSync(options.ca, 'utf-8') : settings.ca;\n const key = options.key ? fs.readFileSync(options.key, 'utf-8') : settings.key;\n const cert = options.cert ? fs.readFileSync(options.cert, 'utf-8') : settings.cert;\n if (!ca || !key || !cert) throw new Error('Missing some TLS configuration');\n return customAgent.ca(ca).key(key).cert(cert);\n}\n\n/** Load TLS settings from env variables */\nfunction loadDefaultSettings(): void {\n const {\n TLS_REQUEST_KEY,\n TLS_REQUEST_CERT,\n TLS_REQUEST_CA,\n TLS_SERVER_KEY,\n TLS_SERVER_CERT,\n TLS_CA,\n } = process.env;\n\n if (!(TLS_REQUEST_KEY || TLS_SERVER_KEY)) {\n throw new Error('TLS Request: no TLS setting specified');\n }\n\n settings = {\n key: fs.readFileSync((TLS_REQUEST_KEY ?? TLS_SERVER_KEY) as string, 'utf-8'),\n cert: fs.readFileSync((TLS_REQUEST_CERT ?? TLS_SERVER_CERT) as string, 'utf-8'),\n ca: fs.readFileSync((TLS_REQUEST_CA ?? TLS_CA) as string, 'utf-8'),\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA,MAAME,WAAW,GAAG,IAAAC,gBAAK,EAAC,qBAAqBC,OAAO,CAACC,GAAG,CAACC,IAAI,EAAY,CAAC;AAE5E,IAAIC,QAA2B;;AAE/B;AACA;AACA;AACO,eAAeC,UAAUA,CAACC,OAA0B,GAAG,CAAC,CAAC,EAAoB;EAClF,IAAI,CAACF,QAAQ,EAAEG,mBAAmB,CAAC,CAAC;EACpC,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAE,GAAGC,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACE,EAAE,EAAE,OAAO,CAAC,GAAGJ,QAAQ,CAACI,EAAE;EAC1E,MAAMG,GAAG,GAAGL,OAAO,CAACK,GAAG,GAAGF,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACK,GAAG,EAAE,OAAO,CAAC,GAAGP,QAAQ,CAACO,GAAG;EAC9E,MAAMC,IAAI,GAAGN,OAAO,CAACM,IAAI,GAAGH,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACM,IAAI,EAAE,OAAO,CAAC,GAAGR,QAAQ,CAACQ,IAAI;EAClF,IAAI,CAACJ,EAAE,IAAI,CAACG,GAAG,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,gCAAgC,CAAC;EAC3E,OAAOd,WAAW,CAACS,EAAE,CAACA,EAAE,CAAC,CAACG,GAAG,CAACA,GAAG,CAAC,CAACC,IAAI,CAACA,IAAI,CAAC;AAC/C;;AAEA;AACA,SAASL,mBAAmBA,CAAA,EAAS;EACnC,MAAM;IACJO,eAAe;IACfC,gBAAgB;IAChBC,cAAc;IACdC,cAAc;IACdC,eAAe;IACfC;EACF,CAAC,GAAGlB,OAAO,CAACC,GAAG;EAEf,IAAI,EAAEY,eAAe,IAAIG,cAAc,CAAC,EAAE;IACxC,MAAM,IAAIJ,KAAK,CAAC,uCAAuC,CAAC;EAC1D;EAEAT,QAAQ,GAAG;IACTO,GAAG,EAAEF,WAAE,CAACC,YAAY,CAAEI,eAAe,IAAIG,cAAc,EAAa,OAAO,CAAC;IAC5EL,IAAI,EAAEH,WAAE,CAACC,YAAY,CAAEK,gBAAgB,IAAIG,eAAe,EAAa,OAAO,CAAC;IAC/EV,EAAE,EAAEC,WAAE,CAACC,YAAY,CAAEM,cAAc,IAAIG,MAAM,EAAa,OAAO;EACnE,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"tlsRequest.js","names":["_fs","_interopRequireDefault","require","_supertest","customAgent","agent","process","env","PORT","settings","tlsRequest","options","loadDefaultSettings","ca","fs","readFileSync","key","cert","Error","TLS_REQUEST_KEY","TLS_REQUEST_CERT","TLS_REQUEST_CA","TLS_SERVER_KEY","TLS_SERVER_CERT","TLS_CA"],"sources":["../../src/utils/tlsRequest.ts"],"sourcesContent":["import fs from 'fs';\nimport { agent, Agent } from 'supertest'; // Import Agent type\nimport { tlsRequestOptions } from './tlsRequest.types';\n\nconst customAgent = agent(`https://localhost:${process.env.PORT as string}`);\n\nlet settings: tlsRequestOptions;\n\n/**\n * Wrapper for supertest that adds TLS encryption\n */\nexport async function tlsRequest(options: tlsRequestOptions = {}): Promise<Agent> {\n if (!settings) loadDefaultSettings();\n \n const ca = options.ca ? fs.readFileSync(options.ca, 'utf-8') : settings.ca;\n const key = options.key ? fs.readFileSync(options.key, 'utf-8') : settings.key;\n const cert = options.cert ? fs.readFileSync(options.cert, 'utf-8') : settings.cert;\n\n if (!ca || !key || !cert) throw new Error('Missing some TLS configuration');\n\n // Return Agent with configured TLS options\n return customAgent.ca(ca).key(key).cert(cert);\n}\n\n/** Load TLS settings from env variables */\nfunction loadDefaultSettings(): void {\n const {\n TLS_REQUEST_KEY,\n TLS_REQUEST_CERT,\n TLS_REQUEST_CA,\n TLS_SERVER_KEY,\n TLS_SERVER_CERT,\n TLS_CA,\n } = process.env;\n\n if (!(TLS_REQUEST_KEY || TLS_SERVER_KEY)) {\n throw new Error('TLS Request: no TLS setting specified');\n }\n\n settings = {\n key: fs.readFileSync((TLS_REQUEST_KEY ?? TLS_SERVER_KEY) as string, 'utf-8'),\n cert: fs.readFileSync((TLS_REQUEST_CERT ?? TLS_SERVER_CERT) as string, 'utf-8'),\n ca: fs.readFileSync((TLS_REQUEST_CA ?? TLS_CA) as string, 'utf-8'),\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA2C;;AAG3C,MAAME,WAAW,GAAG,IAAAC,gBAAK,EAAC,qBAAqBC,OAAO,CAACC,GAAG,CAACC,IAAI,EAAY,CAAC;AAE5E,IAAIC,QAA2B;;AAE/B;AACA;AACA;AACO,eAAeC,UAAUA,CAACC,OAA0B,GAAG,CAAC,CAAC,EAAkB;EAChF,IAAI,CAACF,QAAQ,EAAEG,mBAAmB,CAAC,CAAC;EAEpC,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAE,GAAGC,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACE,EAAE,EAAE,OAAO,CAAC,GAAGJ,QAAQ,CAACI,EAAE;EAC1E,MAAMG,GAAG,GAAGL,OAAO,CAACK,GAAG,GAAGF,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACK,GAAG,EAAE,OAAO,CAAC,GAAGP,QAAQ,CAACO,GAAG;EAC9E,MAAMC,IAAI,GAAGN,OAAO,CAACM,IAAI,GAAGH,WAAE,CAACC,YAAY,CAACJ,OAAO,CAACM,IAAI,EAAE,OAAO,CAAC,GAAGR,QAAQ,CAACQ,IAAI;EAElF,IAAI,CAACJ,EAAE,IAAI,CAACG,GAAG,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIC,KAAK,CAAC,gCAAgC,CAAC;;EAE3E;EACA,OAAOd,WAAW,CAACS,EAAE,CAACA,EAAE,CAAC,CAACG,GAAG,CAACA,GAAG,CAAC,CAACC,IAAI,CAACA,IAAI,CAAC;AAC/C;;AAEA;AACA,SAASL,mBAAmBA,CAAA,EAAS;EACnC,MAAM;IACJO,eAAe;IACfC,gBAAgB;IAChBC,cAAc;IACdC,cAAc;IACdC,eAAe;IACfC;EACF,CAAC,GAAGlB,OAAO,CAACC,GAAG;EAEf,IAAI,EAAEY,eAAe,IAAIG,cAAc,CAAC,EAAE;IACxC,MAAM,IAAIJ,KAAK,CAAC,uCAAuC,CAAC;EAC1D;EAEAT,QAAQ,GAAG;IACTO,GAAG,EAAEF,WAAE,CAACC,YAAY,CAAEI,eAAe,IAAIG,cAAc,EAAa,OAAO,CAAC;IAC5EL,IAAI,EAAEH,WAAE,CAACC,YAAY,CAAEK,gBAAgB,IAAIG,eAAe,EAAa,OAAO,CAAC;IAC/EV,EAAE,EAAEC,WAAE,CAACC,YAAY,CAAEM,cAAc,IAAIG,MAAM,EAAa,OAAO;EACnE,CAAC;AACH","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-test-tools",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Node test tools",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -21,43 +21,42 @@
21
21
  },
22
22
  "homepage": "https://github.com/prakashmahendran/backend-test-tools#readme",
23
23
  "devDependencies": {
24
- "@babel/cli": "^7.25.7",
25
- "@babel/core": "^7.25.8",
26
- "@babel/plugin-transform-class-properties": "^7.25.7",
27
- "@babel/plugin-transform-runtime": "^7.25.7",
28
- "@babel/preset-env": "^7.25.8",
29
- "@babel/preset-typescript": "^7.25.7",
30
- "@babel/register": "^7.25.7",
31
- "@eslint/js": "^9.12.0",
32
- "@faker-js/faker": "^9.0.3",
33
- "@types/chai": "^4.3.0",
34
- "@types/jsonwebtoken": "^8.5.9",
35
- "@types/mocha": "^9.1.1",
36
- "@types/node": "^16.18.114",
37
- "@types/node-forge": "^0.10.10",
38
- "@types/sinon": "^10.0.20",
39
- "@types/superagent": "^4.1.24",
40
- "@types/supertest": "^2.0.16",
24
+ "@babel/cli": "^7.26.4",
25
+ "@babel/core": "^7.26.0",
26
+ "@babel/plugin-transform-class-properties": "^7.25.9",
27
+ "@babel/plugin-transform-runtime": "^7.25.9",
28
+ "@babel/preset-env": "^7.26.0",
29
+ "@babel/preset-typescript": "^7.26.0",
30
+ "@babel/register": "^7.25.9",
31
+ "@eslint/js": "^9.17.0",
32
+ "@faker-js/faker": "^9.3.0",
33
+ "@types/chai": "^5.0.1",
34
+ "@types/jsonwebtoken": "^9.0.7",
35
+ "@types/mocha": "^10.0.10",
36
+ "@types/node": "^22.10.2",
37
+ "@types/node-forge": "^1.3.11",
38
+ "@types/sinon": "^17.0.3",
39
+ "@types/superagent": "^8.1.9",
40
+ "@types/supertest": "^6.0.2",
41
41
  "@types/validator": "^13.12.2",
42
- "@typescript-eslint/eslint-plugin": "^8.8.1",
42
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
43
43
  "babel-plugin-istanbul": "^7.0.0",
44
44
  "babel-plugin-module-resolver": "^5.0.2",
45
45
  "babel-plugin-tsconfig-paths": "^1.0.3",
46
- "core-js": "^3.38.1",
47
- "eslint": "^9.13.0",
48
- "globals": "^15.11.0",
49
- "husky": "^4.3.8",
50
- "lint-staged": "^10.5.4",
51
- "mocha": "^9.2.2",
52
- "move-cli": "^2.0.0",
53
- "nyc": "^15.1.0",
54
- "prettier": "^3.3.3",
46
+ "core-js": "^3.39.0",
47
+ "eslint": "^9.17.0",
48
+ "globals": "^15.14.0",
49
+ "husky": "^9.1.7",
50
+ "lint-staged": "^15.2.11",
51
+ "mocha": "^11.0.1",
52
+ "nyc": "^17.1.0",
53
+ "prettier": "^3.4.2",
55
54
  "rimraf": "^6.0.1",
56
55
  "ts-node": "^10.9.2",
57
56
  "tsc-alias": "^1.8.10",
58
57
  "tsconfig-paths": "^4.2.0",
59
- "typescript": "^5.5.4",
60
- "typescript-eslint": "^8.8.1"
58
+ "typescript": "^5.7.2",
59
+ "typescript-eslint": "^8.18.1"
61
60
  },
62
61
  "husky": {
63
62
  "hooks": {
@@ -68,16 +67,15 @@
68
67
  "*.js": "eslint",
69
68
  "*.ts": "eslint"
70
69
  },
70
+ "peerDependencies": {
71
+ "node-server-engine": "^1.1.4"
72
+ },
71
73
  "dependencies": {
72
- "@babel/runtime": "^7.25.7",
73
- "jimp": "^0.16.13",
74
- "jsonwebtoken": "^8.5.1",
74
+ "@babel/runtime": "^7.26.0",
75
+ "jsonwebtoken": "^9.0.2",
75
76
  "node-forge": "^1.3.1",
76
77
  "rfdc": "^1.4.1",
77
- "sinon": "^9.2.4",
78
- "supertest": "^4.0.2"
79
- },
80
- "peerDependencies": {
81
- "node-server-engine": "^1.0.5"
78
+ "sinon": "^19.0.2",
79
+ "supertest": "^7.0.0"
82
80
  }
83
81
  }
@@ -1,8 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import {
3
2
  ConnectionModel,
4
3
  ConnectionBuildOptions,
5
- OrganizationModel,
6
4
  UserModel,
7
5
  UserBuildOptions,
8
6
  } from './workers';
@@ -1,19 +1,30 @@
1
- import Jimp from 'jimp';
2
- import {generateImageBufferOptions} from './generateImageBuffer.types';
1
+ import sharp from 'sharp';
3
2
 
4
- /** Generate a binary buffer containing a PNG image */
5
- export async function generateImageBuffer(
6
- options: generateImageBufferOptions = {},
3
+ /** Generate a random image buffer */
4
+ export async function generateRandomImageBuffer(
5
+ width: number = 150,
6
+ height: number = 150
7
7
  ): Promise<Buffer> {
8
- const image = await generateImage(options);
9
- return image.getBufferAsync(Jimp.MIME_PNG);
10
- }
8
+ // Create a blank image buffer
9
+ const buffer = Buffer.alloc(width * height * 3); // RGB buffer (no alpha channel)
11
10
 
12
- /** Generate the asynchronously image using Jimp */
13
- async function generateImage(options: generateImageBufferOptions = {}): Promise<Jimp> {
14
- return new Promise<Jimp>((resolve) => {
15
- new Jimp(options.width ?? 150, options.height ?? 150, function (err, image) {
16
- resolve(image);
17
- });
18
- });
19
- }
11
+ // Fill the buffer with random colors
12
+ for (let i = 0; i < buffer.length; i += 3) {
13
+ buffer[i] = Math.floor(Math.random() * 256); // Red
14
+ buffer[i + 1] = Math.floor(Math.random() * 256); // Green
15
+ buffer[i + 2] = Math.floor(Math.random() * 256); // Blue
16
+ }
17
+
18
+ // Use sharp to create an image from the buffer and convert it to PNG
19
+ const imageBuffer = await sharp(buffer, {
20
+ raw: {
21
+ width: width,
22
+ height: height,
23
+ channels: 3 // RGB
24
+ }
25
+ })
26
+ .toFormat('png') // Convert to PNG format
27
+ .toBuffer(); // Return the image buffer
28
+
29
+ return imageBuffer;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs';
2
- import {agent, Request} from 'supertest';
3
- import {tlsRequestOptions} from './tlsRequest.types';
2
+ import { agent, Agent } from 'supertest'; // Import Agent type
3
+ import { tlsRequestOptions } from './tlsRequest.types';
4
4
 
5
5
  const customAgent = agent(`https://localhost:${process.env.PORT as string}`);
6
6
 
@@ -9,12 +9,16 @@ let settings: tlsRequestOptions;
9
9
  /**
10
10
  * Wrapper for supertest that adds TLS encryption
11
11
  */
12
- export async function tlsRequest(options: tlsRequestOptions = {}): Promise<Request> {
12
+ export async function tlsRequest(options: tlsRequestOptions = {}): Promise<Agent> {
13
13
  if (!settings) loadDefaultSettings();
14
+
14
15
  const ca = options.ca ? fs.readFileSync(options.ca, 'utf-8') : settings.ca;
15
16
  const key = options.key ? fs.readFileSync(options.key, 'utf-8') : settings.key;
16
17
  const cert = options.cert ? fs.readFileSync(options.cert, 'utf-8') : settings.cert;
18
+
17
19
  if (!ca || !key || !cert) throw new Error('Missing some TLS configuration');
20
+
21
+ // Return Agent with configured TLS options
18
22
  return customAgent.ca(ca).key(key).cert(cert);
19
23
  }
20
24