@nodesecure/scanner 5.2.1 → 6.0.0

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 (90) hide show
  1. package/README.md +6 -116
  2. package/dist/class/logger.class.d.ts +27 -0
  3. package/dist/class/logger.class.d.ts.map +1 -0
  4. package/dist/class/logger.class.js +52 -0
  5. package/dist/class/logger.class.js.map +1 -0
  6. package/dist/comparePayloads.d.ts +66 -0
  7. package/dist/comparePayloads.d.ts.map +1 -0
  8. package/dist/comparePayloads.js +147 -0
  9. package/dist/comparePayloads.js.map +1 -0
  10. package/dist/depWalker.d.ts +10 -0
  11. package/dist/depWalker.d.ts.map +1 -0
  12. package/dist/depWalker.js +205 -0
  13. package/dist/depWalker.js.map +1 -0
  14. package/dist/i18n/english.d.ts +9 -0
  15. package/dist/i18n/english.d.ts.map +1 -0
  16. package/dist/i18n/english.js +6 -0
  17. package/dist/i18n/english.js.map +1 -0
  18. package/dist/i18n/french.d.ts +9 -0
  19. package/dist/i18n/french.d.ts.map +1 -0
  20. package/dist/i18n/french.js +6 -0
  21. package/dist/i18n/french.js.map +1 -0
  22. package/dist/index.d.ts +11 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +68 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/npmRegistry.d.ts +9 -0
  27. package/dist/npmRegistry.d.ts.map +1 -0
  28. package/dist/npmRegistry.js +125 -0
  29. package/dist/npmRegistry.js.map +1 -0
  30. package/dist/types.d.ts +216 -0
  31. package/dist/types.d.ts.map +1 -0
  32. package/dist/types.js +4 -0
  33. package/dist/types.js.map +1 -0
  34. package/dist/utils/addMissingVersionFlags.d.ts +3 -0
  35. package/dist/utils/addMissingVersionFlags.d.ts.map +1 -0
  36. package/dist/utils/addMissingVersionFlags.js +21 -0
  37. package/dist/utils/addMissingVersionFlags.js.map +1 -0
  38. package/dist/utils/dirname.d.ts +2 -0
  39. package/dist/utils/dirname.d.ts.map +1 -0
  40. package/dist/utils/dirname.js +8 -0
  41. package/dist/utils/dirname.js.map +1 -0
  42. package/dist/utils/getLinks.d.ts +7 -0
  43. package/dist/utils/getLinks.d.ts.map +1 -0
  44. package/dist/utils/getLinks.js +32 -0
  45. package/dist/utils/getLinks.js.map +1 -0
  46. package/dist/utils/index.d.ts +11 -0
  47. package/dist/utils/index.d.ts.map +1 -0
  48. package/dist/utils/index.js +9 -0
  49. package/dist/utils/index.js.map +1 -0
  50. package/dist/utils/urlToString.d.ts +2 -0
  51. package/dist/utils/urlToString.d.ts.map +1 -0
  52. package/dist/utils/urlToString.js +6 -0
  53. package/dist/utils/urlToString.js.map +1 -0
  54. package/dist/utils/warnings.d.ts +9 -0
  55. package/dist/utils/warnings.d.ts.map +1 -0
  56. package/dist/utils/warnings.js +49 -0
  57. package/dist/utils/warnings.js.map +1 -0
  58. package/package.json +23 -42
  59. package/LICENSE +0 -21
  60. package/i18n/english.js +0 -6
  61. package/i18n/french.js +0 -7
  62. package/index.d.ts +0 -14
  63. package/index.js +0 -74
  64. package/src/class/dependency.class.js +0 -113
  65. package/src/class/logger.class.js +0 -54
  66. package/src/constants.js +0 -13
  67. package/src/depWalker.js +0 -388
  68. package/src/manifest.js +0 -94
  69. package/src/npmRegistry.js +0 -136
  70. package/src/tarball.js +0 -210
  71. package/src/utils/addMissingVersionFlags.js +0 -24
  72. package/src/utils/analyzeDependencies.js +0 -71
  73. package/src/utils/booleanToFlags.js +0 -12
  74. package/src/utils/dirname.js +0 -9
  75. package/src/utils/filterDependencyKind.js +0 -44
  76. package/src/utils/getLinks.js +0 -36
  77. package/src/utils/getPackageName.js +0 -21
  78. package/src/utils/getTarballComposition.js +0 -38
  79. package/src/utils/index.js +0 -18
  80. package/src/utils/isGitDependency.js +0 -11
  81. package/src/utils/isSensitiveFile.js +0 -17
  82. package/src/utils/mergeDependencies.js +0 -30
  83. package/src/utils/parseManifestAuthor.js +0 -45
  84. package/src/utils/semver.js +0 -62
  85. package/src/utils/warnings.js +0 -44
  86. package/types/api.d.ts +0 -15
  87. package/types/logger.d.ts +0 -38
  88. package/types/scanner.d.ts +0 -244
  89. package/types/tarball.d.ts +0 -63
  90. package/types/walker.d.ts +0 -8
@@ -1,38 +0,0 @@
1
- // Import Node.js Dependencies
2
- import fs from "fs/promises";
3
- import path from "path";
4
-
5
- // Import Third-party Dependencies
6
- import { walk } from "@nodesecure/fs-walk";
7
-
8
- export async function getTarballComposition(tarballDir) {
9
- const ext = new Set();
10
- const files = [];
11
- const dirs = [];
12
- let { size } = await fs.stat(tarballDir);
13
-
14
- for await (const [dirent, file] of walk(tarballDir)) {
15
- if (dirent.isFile()) {
16
- ext.add(path.extname(file));
17
- files.push(file);
18
- }
19
- else if (dirent.isDirectory()) {
20
- dirs.push(file);
21
- }
22
- }
23
-
24
- const sizeUnfilteredResult = await Promise.allSettled([
25
- ...files.map((file) => fs.stat(file)),
26
- ...dirs.map((file) => fs.stat(file))
27
- ]);
28
- const sizeAll = sizeUnfilteredResult
29
- .filter((promiseSettledResult) => promiseSettledResult.status === "fulfilled")
30
- .map((promiseSettledResult) => promiseSettledResult.value);
31
- size += sizeAll.reduce((prev, curr) => prev + curr.size, 0);
32
-
33
- return {
34
- ext,
35
- size,
36
- files: files.map((fileLocation) => path.relative(tarballDir, fileLocation)).sort()
37
- };
38
- }
@@ -1,18 +0,0 @@
1
- export * from "./getTarballComposition.js";
2
- export * from "./isSensitiveFile.js";
3
- export * from "./isGitDependency.js";
4
- export * from "./getPackageName.js";
5
- export * from "./mergeDependencies.js";
6
- export * from "./semver.js";
7
- export * from "./dirname.js";
8
- export * from "./warnings.js";
9
- export * from "./filterDependencyKind.js";
10
- export * from "./analyzeDependencies.js";
11
- export * from "./booleanToFlags.js";
12
- export * from "./addMissingVersionFlags.js";
13
- export * from "./parseManifestAuthor.js";
14
- export * from "./getLinks.js";
15
-
16
- export const NPM_TOKEN = typeof process.env.NODE_SECURE_TOKEN === "string" ?
17
- { token: process.env.NODE_SECURE_TOKEN } :
18
- {};
@@ -1,11 +0,0 @@
1
- /**
2
- * @example isGitDependency("github:NodeSecure/scanner") // => true
3
- * @example isGitDependency("git+ssh://git@github.com:npm/cli#semver:^5.0") // => true
4
- * @example isGitDependency(">=1.0.2 <2.1.2") // => false
5
- * @example isGitDependency("http://asdf.com/asdf.tar.gz") // => false
6
- * @param {string} version
7
- * @returns {boolean}
8
- */
9
- export function isGitDependency(version) {
10
- return /^git(:|\+|hub:)/.test(version);
11
- }
@@ -1,17 +0,0 @@
1
- // Import Node.js Dependencies
2
- import path from "path";
3
-
4
- // CONSTANTS
5
- const kSensitiveFileName = new Set([".npmrc", ".env"]);
6
- const kSensitiveFileExtension = new Set([".key", ".pem"]);
7
-
8
- /**
9
- * @see https://github.com/jandre/safe-commit-hook/blob/master/git-deny-patterns.json
10
- *
11
- * @param {!string} fileName
12
- * @returns {boolean}
13
- */
14
- export function isSensitiveFile(fileName) {
15
- return kSensitiveFileName.has(path.basename(fileName)) ||
16
- kSensitiveFileExtension.has(path.extname(fileName));
17
- }
@@ -1,30 +0,0 @@
1
- export function mergeDependencies(manifest, types = ["dependencies"]) {
2
- const dependencies = new Map();
3
- const customResolvers = new Map();
4
- const alias = new Map();
5
-
6
- for (const fieldName of types) {
7
- if (!Reflect.has(manifest, fieldName)) {
8
- continue;
9
- }
10
- const dep = manifest[fieldName];
11
-
12
- for (const [name, version] of Object.entries(dep)) {
13
- /**
14
- * Version can be file:, github:, git:, git+, ./...
15
- * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#dependencies
16
- */
17
- if (/^([a-zA-Z]+:|git\+|\.\\)/.test(version)) {
18
- customResolvers.set(name, version);
19
- if (!version.startsWith("npm:")) {
20
- continue;
21
- }
22
- alias.set(name, version.slice(4));
23
- }
24
-
25
- dependencies.set(name, version);
26
- }
27
- }
28
-
29
- return { dependencies, customResolvers, alias };
30
- }
@@ -1,45 +0,0 @@
1
- export function manifestAuthorRegex() {
2
- return /^([^<(]+?)?[ \t]*(?:<([^>(]+?)>)?[ \t]*(?:\(([^)]+?)\)|$)/gm;
3
- }
4
-
5
- /**
6
- * @see https://docs.npmjs.com/cli/v7/configuring-npm/package-json#people-fields-author-contributors
7
- */
8
- export function parseManifestAuthor(manifestAuthorField) {
9
- if (typeof manifestAuthorField !== "string") {
10
- throw new TypeError("expected manifestAuthorField to be a string");
11
- }
12
-
13
- if (!/\w/.test(manifestAuthorField)) {
14
- return null;
15
- }
16
-
17
- const match = manifestAuthorRegex().exec(manifestAuthorField);
18
- if (!match) {
19
- return null;
20
- }
21
- const author = {
22
- name: match[1]
23
- };
24
-
25
- for (let id = 2; id < match.length; id++) {
26
- const val = match[id] || "";
27
-
28
- if (val.includes("@")) {
29
- author.email = val;
30
- }
31
- else if (val.includes("http")) {
32
- author.url = val;
33
- }
34
- }
35
-
36
- return author;
37
- }
38
-
39
- export function parseAuthor(author) {
40
- if (typeof author === "string") {
41
- return parseManifestAuthor(author);
42
- }
43
-
44
- return !author || Object.keys(author).length === 0 ? null : author;
45
- }
@@ -1,62 +0,0 @@
1
- // Import Third-party Dependencies
2
- import pacote from "pacote";
3
- import semver from "semver";
4
- import { getLocalRegistryURL } from "@nodesecure/npm-registry-sdk";
5
-
6
- // Import Internal Dependencies
7
- import { NPM_TOKEN } from "./index.js";
8
-
9
- /**
10
- * @param {!string} version semver range
11
- * @returns {string} semver version
12
- *
13
- * @example
14
- * cleanRange(">=1.5.0"); // 1.5.0
15
- * cleanRange("^2.0.0"); // 2.0.0
16
- */
17
- export function cleanRange(version) {
18
- // TODO: how do we handle complicated range like pkg-name@1 || 2 or pkg-name@2.1.2 < 3
19
- const firstChar = version.charAt(0);
20
- if (firstChar === "^" || firstChar === "<" || firstChar === ">" || firstChar === "=" || firstChar === "~") {
21
- return version.slice(version.charAt(1) === "=" ? 2 : 1);
22
- }
23
-
24
- return version;
25
- }
26
-
27
- /**
28
- * @param {!string} depName dependency name (WITHOUT version/range)
29
- * @param {!string} range semver range, ex: >=1.5.0
30
- */
31
- export async function getExpectedSemVer(depName, range) {
32
- try {
33
- const { versions, "dist-tags": { latest } } = await pacote.packument(depName, {
34
- ...NPM_TOKEN, registry: getLocalRegistryURL()
35
- });
36
- const currVersion = semver.maxSatisfying(Object.keys(versions), range);
37
-
38
- return currVersion === null ? [latest, true] : [currVersion, semver.eq(latest, currVersion)];
39
- }
40
- catch (err) {
41
- return [cleanRange(range), true];
42
- }
43
- }
44
-
45
- export async function getCleanDependencyName([depName, range]) {
46
- const [depVer, isLatest] = await getExpectedSemVer(depName, range);
47
-
48
- return [`${depName}@${range}`, `${depName}@${depVer}`, isLatest];
49
- }
50
-
51
- export function getSemVerWarning(value) {
52
- return {
53
- kind: "zero-semver",
54
- file: "package.json",
55
- value,
56
- location: null,
57
- i18n: "sast_warnings.zeroSemVer",
58
- severity: "Information",
59
- source: "Scanner",
60
- experimental: false
61
- };
62
- }
@@ -1,44 +0,0 @@
1
- // Import Node.js Dependencies
2
- import path from "node:path";
3
-
4
- // Import Third-party Dependencies
5
- import * as i18n from "@nodesecure/i18n";
6
- import { extractAllAuthors } from "@nodesecure/authors";
7
-
8
- // Import Internal Dependencies
9
- import { getDirNameFromUrl } from "./dirname.js";
10
-
11
- await i18n.extendFromSystemPath(
12
- path.join(getDirNameFromUrl(import.meta.url), "..", "..", "i18n")
13
- );
14
-
15
- // CONSTANTS
16
- const kDetectedDep = i18n.taggedString`The dependency '${0}' has been detected in the dependency Tree.`;
17
- const kFlaggedAuthors = [{
18
- name: "marak",
19
- email: "marak.squires@gmail.com"
20
- }];
21
- const kDependencyWarnMessage = Object.freeze({
22
- "@scarf/scarf": await i18n.getToken("scanner.disable_scarf"),
23
- iohook: await i18n.getToken("scanner.keylogging")
24
- });
25
-
26
- /**
27
- * @param {Map<string, any>} dependenciesMap
28
- */
29
- export async function getDependenciesWarnings(dependenciesMap) {
30
- const warnings = [...Object.keys(kDependencyWarnMessage)]
31
- .filter((depName) => dependenciesMap.has(depName))
32
- .map((depName) => `${kDetectedDep(depName)} ${kDependencyWarnMessage[depName]}`);
33
-
34
- // TODO: add support for RC configuration
35
- const res = await extractAllAuthors(
36
- { dependencies: Object.fromEntries(dependenciesMap) },
37
- { flags: kFlaggedAuthors, domainInformations: false }
38
- );
39
-
40
- return {
41
- warnings,
42
- flaggedAuthors: res.flaggedAuthors
43
- };
44
- }
package/types/api.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import Scanner from "./scanner.js";
2
- import { Logger, LoggerEvents } from "./logger.js";
3
-
4
- export {
5
- cwd,
6
- from,
7
- verify,
8
- ScannerLoggerEvents
9
- }
10
-
11
- declare const ScannerLoggerEvents: LoggerEvents;
12
-
13
- declare function cwd(location: string, options?: Scanner.Options, logger?: Logger): Promise<Scanner.Payload>;
14
- declare function from(packageName: string, options?: Omit<Scanner.Options, "includeDevDeps">, logger?: Logger): Promise<Scanner.Payload>;
15
- declare function verify(packageName?: string | null): Promise<Scanner.VerifyPayload>;
package/types/logger.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { EventEmitter } from "events";
2
-
3
- export {
4
- Logger,
5
- LoggerEventData,
6
- LoggerEvents
7
- }
8
-
9
- interface LoggerEvents {
10
- readonly done: "depWalkerFinished";
11
- readonly analysis: {
12
- readonly tree: "walkTree";
13
- readonly tarball: "tarball";
14
- readonly registry: "registry";
15
- };
16
- readonly manifest: {
17
- readonly read: "readManifest";
18
- readonly fetch: "fetchManifest";
19
- };
20
- }
21
-
22
- interface LoggerEventData {
23
- /** UNIX Timestamp */
24
- startedAt: number;
25
- /** Count of triggered event */
26
- count: number;
27
- }
28
-
29
- declare class Logger extends EventEmitter {
30
- public events: Map<string, LoggerEventData>;
31
-
32
- constructor();
33
-
34
- start(eventName: string): Logger;
35
- end(eventName: string): Logger;
36
- tick(eventName: string): Logger;
37
- count(eventName: string): number;
38
- }
@@ -1,244 +0,0 @@
1
- // Import NodeSecure Dependencies
2
- import * as JSXRay from "@nodesecure/js-x-ray";
3
- import { license as License } from "@nodesecure/ntlp";
4
- import * as Vuln from "@nodesecure/vuln";
5
-
6
- // Import Third-party Dependencies
7
- import { extractedAuthor } from "@nodesecure/authors";
8
-
9
- export = Scanner;
10
-
11
- declare namespace Scanner {
12
- export interface Author {
13
- name: string;
14
- email?: string;
15
- url?: string;
16
- }
17
-
18
- export interface Maintainer {
19
- name: string;
20
- email: string;
21
- }
22
-
23
- export interface Publisher {
24
- /**
25
- * Publisher npm user name.
26
- */
27
- name: string;
28
- /**
29
- * Publisher npm user email.
30
- */
31
- email: string;
32
- /**
33
- * First version published.
34
- */
35
- version: string;
36
- /**
37
- * Date of the first publication
38
- * @example 2021-08-10T20:45:08.342Z
39
- */
40
- at: string;
41
- }
42
-
43
- export interface DependencyLinks {
44
- /** NPM Registry page */
45
- npm: string;
46
- /** Homepage URL */
47
- homepage?: string;
48
- /** VCS repository URL */
49
- repository?: string;
50
- }
51
-
52
- export interface DependencyVersion {
53
- /** Id of the package (useful for usedBy relation) */
54
- id: number;
55
- isDevDependency: boolean;
56
- /**
57
- * Tell if the given package exist on the configured remote registry (npm by default)
58
- * @default true
59
- */
60
- existOnRemoteRegistry: boolean;
61
- /** By whom (id) is used the package */
62
- usedBy: Record<string, string>;
63
- /** Size on disk of the extracted tarball (in bytes) */
64
- size: number;
65
- /** Package description */
66
- description: string;
67
- /** Author of the package. This information is not trustable and can be empty. */
68
- author: Author | null;
69
- engines: {
70
- node?: string;
71
- npm?: string;
72
- };
73
- repository: {
74
- type: string;
75
- url: string;
76
- };
77
- scripts: Record<string, string>;
78
- /**
79
- * JS-X-Ray warnings
80
- *
81
- * @see https://github.com/NodeSecure/js-x-ray/blob/master/WARNINGS.md
82
- */
83
- warnings: JSXRay.Warning<JSXRay.WarningDefault>[];
84
- /** Tarball composition (files and dependencies) */
85
- composition: {
86
- /** Files extensions (.js, .md, .exe etc..) */
87
- extensions: string[];
88
- files: string[];
89
- /** Minified files (foo.min.js etc..) */
90
- minified: string[];
91
- alias: Record<string, string>;
92
- required_files: string[];
93
- required_thirdparty: string[];
94
- required_nodejs: string[];
95
- required_subpath: string[];
96
- unused: string[];
97
- missing: string[];
98
- };
99
- /**
100
- * Package licenses with SPDX expression.
101
- *
102
- * @see https://github.com/NodeSecure/licenses-conformance
103
- * @see https://github.com/NodeSecure/npm-tarball-license-parser
104
- */
105
- license: License[];
106
- /**
107
- * Flags (Array of string)
108
- *
109
- * @see https://github.com/NodeSecure/flags/blob/main/FLAGS.md
110
- */
111
- flags: string[];
112
- /**
113
- * If the dependency is a GIT repository
114
- */
115
- gitUrl: null | string;
116
- /**
117
- * Version MD5 integrity hash
118
- * Generated by the scanner to verify manifest/tarball confusion
119
- *
120
- * (Not supported on GIT dependency)
121
- */
122
- integrity?: string;
123
- links: DependencyLinks;
124
- }
125
-
126
- export interface Dependency {
127
- /** NPM Registry metadata */
128
- metadata: {
129
- /** Count of dependencies */
130
- dependencyCount: number;
131
- /** Number of releases published on npm */
132
- publishedCount: number;
133
- lastUpdateAt: number;
134
- /** Last version SemVer */
135
- lastVersion: number;
136
- hasChangedAuthor: boolean;
137
- hasManyPublishers: boolean;
138
- hasReceivedUpdateInOneYear: boolean;
139
- /** Author of the package. This information is not trustable and can be empty. */
140
- author: Author | null;
141
- /** Package home page */
142
- homepage: string | null;
143
- /**
144
- * List of maintainers (list of people in the organization related to the package)
145
- */
146
- maintainers: Maintainer[];
147
- /**
148
- * List of people who published this package
149
- */
150
- publishers: Publisher[];
151
- /**
152
- * Version MD5 integrity hash
153
- * Generated by the scanner to verify manifest/tarball confusion
154
- */
155
- integrity: Record<string, string>;
156
- }
157
- /** List of versions of this package available in the dependency tree (In the payload) */
158
- versions: Record<string, DependencyVersion>;
159
- /**
160
- * Vulnerabilities fetched dependending on the selected vulnerabilityStrategy
161
- *
162
- * @see https://github.com/NodeSecure/vuln
163
- */
164
- vulnerabilities: Vuln.Strategy.StandardVulnerability[];
165
- }
166
-
167
- export type GlobalWarning = string[];
168
- export type FlaggedAuthors = extractedAuthor[];
169
- export type Dependencies = Record<string, Dependency>;
170
-
171
- export interface Payload {
172
- /** Payload unique id */
173
- id: string;
174
- /** Name of the analyzed package */
175
- rootDependencyName: string;
176
- /** Global warnings list */
177
- warnings: GlobalWarning[];
178
- /** List of flagged authors */
179
- flaggedAuthors: FlaggedAuthors[];
180
- /** All the dependencies of the package (flattened) */
181
- dependencies: Dependencies;
182
- /** Version of the scanner used to generate the result */
183
- scannerVersion: string;
184
- /** Vulnerability strategy name (npm, snyk, node) */
185
- vulnerabilityStrategy: Vuln.Strategy.Kind;
186
- }
187
-
188
- export interface VerifyPayload {
189
- files: {
190
- list: string[];
191
- extensions: string[];
192
- minified: string[];
193
- };
194
- directorySize: number;
195
- uniqueLicenseIds: string[];
196
- licenses: License[];
197
- ast: {
198
- dependencies: Record<string, JSXRay.Dependency>;
199
- warnings: JSXRay.Warning<JSXRay.WarningDefault>[];
200
- };
201
- }
202
-
203
- export interface Options {
204
- /**
205
- * Maximum tree depth
206
- *
207
- * @default 4
208
- */
209
- readonly maxDepth?: number;
210
- readonly registry?: string | URL;
211
- /**
212
- * Use root package-lock.json. This will have the effect of triggering the Arborist package.
213
- *
214
- * @default false for from() API
215
- * @default true for cwd() API
216
- */
217
- readonly usePackageLock?: boolean;
218
- /**
219
- * Include project devDependencies (only available for cwd command)
220
- *
221
- * @default false
222
- */
223
- readonly includeDevDeps?: boolean;
224
- /**
225
- * Vulnerability strategy name (npm, snyk, node)
226
- *
227
- * @default NONE
228
- */
229
- readonly vulnerabilityStrategy: Vuln.Strategy.Kind;
230
- /**
231
- * Analyze root package.
232
- *
233
- * @default false for from() API
234
- * @default true for cwd() API
235
- */
236
- readonly forceRootAnalysis?: boolean;
237
- /**
238
- * Deeper dependencies analysis with cwd() API.
239
- *
240
- * @default false
241
- */
242
- readonly fullLockMode?: boolean;
243
- }
244
- }
@@ -1,63 +0,0 @@
1
- import ntlp from "@nodesecure/ntlp";
2
- import Locker from "@slimio/lock";
3
- import { Logger } from "./logger.js";
4
-
5
- export = tarball;
6
-
7
- declare namespace tarball {
8
- export interface ManifestData {
9
- /** Dependencies in package.json */
10
- packageDeps: string[];
11
- /** DevDependencies in package.json */
12
- packageDevDeps: string[];
13
- /** Does package.json contain a 'gypfile' property ? */
14
- packageGyp: boolean;
15
- }
16
-
17
- export interface ScannedFileResult {
18
- /** Dependencies in try/catch block (probably optional dependencies) */
19
- inTryDeps: string[];
20
- /** Dependencies required or imported */
21
- dependencies: string[];
22
- /** Required or imported javascript files */
23
- filesDependencies: string[];
24
- }
25
-
26
- export interface ScannedPackageResult {
27
- files: {
28
- /** Complete list of files for the given package */
29
- list: string[];
30
- /** Complete list of extensions (.js, .md etc.) */
31
- extensions: string[];
32
- /** List of minified javascript files */
33
- minified: string[];
34
- };
35
- /** Size of the directory in bytes */
36
- directorySize: number;
37
- /** Unique license contained in the tarball (MIT, ISC ..) */
38
- uniqueLicenseIds: string[];
39
- /** All licenses with their SPDX */
40
- licenses: ntlp.license[];
41
- ast: {
42
- dependencies: any;
43
- warnings: any[];
44
- };
45
- }
46
-
47
- export interface ScanDirOrArchiveOptions {
48
- ref: any;
49
- locker: Locker;
50
- tmpLocation: string;
51
- logger: Logger;
52
- }
53
-
54
- export interface ScanFileOptions {
55
- name: string;
56
- ref: any;
57
- }
58
-
59
- export function readManifest(dest: string, ref: any): Promise<ManifestData>;
60
- export function scanFile(dest: string, file: string, options: ScanFileOptions): Promise<ScannedFileResult | null>;
61
- export function scanPackage(dest: string, packageName?: string): Promise<ScannedPackageResult>;
62
- export function scanDirOrArchive(name: string, version: string, options: ScanDirOrArchiveOptions): Promise<void>;
63
- }
package/types/walker.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Manifest } from "@npm/types";
2
- import Scanner from "./scanner.js";
3
-
4
- export {
5
- depWalker
6
- }
7
-
8
- declare function depWalker(manifest: Manifest, options?: Scanner.Options): Promise<Scanner.Payload>;