@contrast/core 1.30.0 → 1.31.1

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/lib/app-info.js CHANGED
@@ -36,12 +36,14 @@ module.exports = function (core) {
36
36
  let cmd;
37
37
  let entrypoint;
38
38
  let pkgInfo;
39
+ let name;
39
40
  let err;
40
41
 
41
42
  try {
42
43
  cmd = getCommand();
43
44
  pkgInfo = getPackageInfo();
44
45
  entrypoint = getEntrypoint();
46
+ name = getApplicationName();
45
47
  } catch (_err) {
46
48
  err = _err;
47
49
  }
@@ -59,7 +61,7 @@ module.exports = function (core) {
59
61
  indexFile: entrypoint,
60
62
  path: pkgInfo.packageFile,
61
63
  pkg: pkgInfo.packageData,
62
- name: config.application.name || pkgInfo.packageData.name,
64
+ name,
63
65
  app_dir: pkgInfo.dir,
64
66
  version: config.application.version || pkgInfo.packageData.version,
65
67
  serverVersion: config.server.version,
@@ -197,4 +199,20 @@ module.exports = function (core) {
197
199
  packageFile,
198
200
  };
199
201
  }
202
+
203
+ /**
204
+ * The name field is required e.g. reporting, rewrite caching, etc.
205
+ * @throws {Error} if there is no name identified
206
+ */
207
+ function getApplicationName() {
208
+ name = config.application.name || pkgInfo.packageData.name;
209
+ if (!name) {
210
+ throw new Error(
211
+ 'The application\'s name was not identified. ' +
212
+ 'Please provide name in package.json field or with the agent\'s application.name config option.'
213
+ );
214
+ }
215
+
216
+ return name;
217
+ }
200
218
  };
@@ -106,22 +106,6 @@ module.exports = function (core) {
106
106
  );
107
107
  },
108
108
 
109
- // Import Statements
110
- importDefault(...args) {
111
- // noop
112
- },
113
-
114
- importStarAs(...args) {
115
- // noop
116
- },
117
-
118
- importNamed(...args) {
119
- // noop
120
- },
121
- import(...args) {
122
- // noop BAM
123
- },
124
-
125
109
  // Injections
126
110
  Function: core.patcher.patch(global.Function, {
127
111
  name: 'global.Function',
package/lib/index.d.ts CHANGED
@@ -13,36 +13,22 @@
13
13
  * way not consistent with the End User License Agreement.
14
14
  */
15
15
 
16
- import { Agentify } from '@contrast/agentify';
17
- import { Config } from '@contrast/config';
18
- import { Logger } from '@contrast/logger';
19
16
  import { AppInfo, Messages } from '@contrast/common';
20
- import { Patcher } from '@contrast/patcher';
21
- import { ReporterBus } from '@contrast/reporter';
22
- import { Protect } from '@contrast/protect';
23
- import { Rewriter } from '@contrast/rewriter';
24
- import RequireHook from '@contrast/require-hook';
25
- import { Scopes } from '@contrast/scopes';
26
- import { Deadzones } from '@contrast/deadzones';
27
17
 
28
18
  export interface Core {
29
- agentName: string,
30
- agentVersion: string,
31
- agentify: Agentify<Core>;
32
- config: Config;
33
- depHooks: RequireHook;
19
+ agentName: string;
20
+ agentVersion: string;
21
+
34
22
  appInfo: AppInfo;
35
- logger: Logger;
23
+
24
+ captureStackTrace(...args: any[]): any;
25
+ captureSnapshot(...args: any[]): any;
26
+
27
+ isAgentPath(path: string): boolean;
28
+
36
29
  messages: Messages;
37
- patcher: Patcher;
38
- reporter: ReporterBus;
39
- protect: Protect;
40
- rewriter: Rewriter;
41
- scopes: Scopes;
42
- deadzones: Deadzones;
43
- getEffectiveConfig: any;
44
- }
45
30
 
46
- declare function init(): Core;
31
+ sensitiveDataMasking: any;
47
32
 
48
- export = init;
33
+ getSystemInfo(): any;
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/core",
3
- "version": "1.30.0",
3
+ "version": "1.31.1",
4
4
  "description": "Preconfigured Contrast agent core services and models",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -10,13 +10,13 @@
10
10
  "types": "lib/index.d.ts",
11
11
  "engines": {
12
12
  "npm": ">=6.13.7 <7 || >= 8.3.1",
13
- "node": ">= 14.15.0"
13
+ "node": ">= 14.18.0"
14
14
  },
15
15
  "scripts": {
16
16
  "test": "../scripts/test.sh"
17
17
  },
18
18
  "dependencies": {
19
- "@contrast/common": "1.19.0",
19
+ "@contrast/common": "1.20.1",
20
20
  "@contrast/find-package-json": "^1.0.0",
21
21
  "@contrast/fn-inspect": "^4.0.0"
22
22
  }