@renovatebot/osv-offline 1.4.1 → 1.5.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.
@@ -1,2 +1,2 @@
1
1
  import { Result } from './types';
2
- export declare function tryDownloadDb(): Promise<Result>;
2
+ export declare function tryDownloadDb(githubToken?: string): Promise<Result>;
@@ -20,7 +20,7 @@ const baseParameters = {
20
20
  owner: 'renovatebot',
21
21
  repo: 'osv-offline',
22
22
  };
23
- async function tryDownloadDb() {
23
+ async function tryDownloadDb(githubToken) {
24
24
  await fs_extra_1.default.ensureDir(osv_offline_db_1.OsvOfflineDb.rootDirectory);
25
25
  if (process.env['OSV_OFFLINE_DISABLE_DOWNLOAD']?.toLowerCase() === 'true') {
26
26
  return (0, types_1.success)();
@@ -38,7 +38,7 @@ async function tryDownloadDb() {
38
38
  return (0, types_1.success)();
39
39
  }
40
40
  const octokitOptions = {
41
- auth: process.env['GITHUB_COM_TOKEN'],
41
+ auth: githubToken ?? process.env['GITHUB_COM_TOKEN'],
42
42
  request: { fetch: node_fetch_1.default },
43
43
  };
44
44
  let latestRelease = null;
@@ -10,7 +10,7 @@ export declare class OsvOffline {
10
10
  * Asynchronously creates a new instance of {@link OsvOffline}
11
11
  * @returns A new instance of {@link OsvOffline}
12
12
  */
13
- static create(): Promise<OsvOffline>;
13
+ static create(githubToken?: string): Promise<OsvOffline>;
14
14
  /**
15
15
  * Query the local database for any package vulnerabilities
16
16
  * @param ecosystem The package ecosystem
@@ -10,8 +10,8 @@ class OsvOffline {
10
10
  /**
11
11
  * Asynchronous code required as part of class instantiation
12
12
  */
13
- async initialize() {
14
- const result = await (0, download_1.tryDownloadDb)();
13
+ async initialize(githubToken) {
14
+ const result = await (0, download_1.tryDownloadDb)(githubToken);
15
15
  if (!result.success) {
16
16
  throw result.error;
17
17
  }
@@ -21,9 +21,9 @@ class OsvOffline {
21
21
  * Asynchronously creates a new instance of {@link OsvOffline}
22
22
  * @returns A new instance of {@link OsvOffline}
23
23
  */
24
- static async create() {
24
+ static async create(githubToken) {
25
25
  const instance = new OsvOffline();
26
- await instance.initialize();
26
+ await instance.initialize(githubToken);
27
27
  return instance;
28
28
  }
29
29
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renovatebot/osv-offline",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "url": "https://github.com/renovatebot/osv-offline.git"
13
13
  },
14
14
  "dependencies": {
15
- "@renovatebot/osv-offline-db": "1.5.1",
15
+ "@renovatebot/osv-offline-db": "1.6.0",
16
16
  "@octokit/rest": "^20.0.2",
17
17
  "adm-zip": "~0.5.10",
18
18
  "fs-extra": "^11.2.0",
@@ -23,9 +23,9 @@
23
23
  "devDependencies": {
24
24
  "@types/adm-zip": "0.5.5",
25
25
  "@types/fs-extra": "11.0.4",
26
- "@types/luxon": "3.4.0",
27
- "@types/node": "20.10.8",
28
- "@types/node-fetch": "2.6.10",
26
+ "@types/luxon": "3.4.2",
27
+ "@types/node": "20.11.16",
28
+ "@types/node-fetch": "2.6.11",
29
29
  "prettier": "2.8.8",
30
30
  "ts-node": "10.9.2",
31
31
  "typescript": "5.1.3"