diff --git a/package-lock.json b/package-lock.json index a7ba8108e39b..eaeb530cc933 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "arch": "^2.1.0", "fs-extra": "^11.2.0", "glob": "^7.2.0", - "hash.js": "^1.1.7", "iconv-lite": "^0.6.3", "inversify": "^6.0.2", "jsonc-parser": "^3.0.0", @@ -7744,6 +7743,7 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -9622,7 +9622,8 @@ "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true }, "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", @@ -20623,6 +20624,7 @@ "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, "requires": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -22054,7 +22056,8 @@ "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true }, "minimalistic-crypto-utils": { "version": "1.0.1", diff --git a/package.json b/package.json index cb0d3fdea22d..c8fe74cc8255 100644 --- a/package.json +++ b/package.json @@ -1560,7 +1560,6 @@ "arch": "^2.1.0", "fs-extra": "^11.2.0", "glob": "^7.2.0", - "hash.js": "^1.1.7", "iconv-lite": "^0.6.3", "inversify": "^6.0.2", "jsonc-parser": "^3.0.0", diff --git a/src/client/telemetry/importTracker.ts b/src/client/telemetry/importTracker.ts index 48b20f053453..cf8e1ed48837 100644 --- a/src/client/telemetry/importTracker.ts +++ b/src/client/telemetry/importTracker.ts @@ -1,3 +1,4 @@ +/* eslint-disable class-methods-use-this */ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. @@ -7,6 +8,7 @@ import { inject, injectable } from 'inversify'; import * as path from 'path'; import { clearTimeout, setTimeout } from 'timers'; import { TextDocument } from 'vscode'; +import { createHash } from 'crypto'; import { sendTelemetryEvent } from '.'; import { IExtensionSingleActivationService } from '../activation/types'; import { IDocumentManager } from '../common/application/types'; @@ -53,9 +55,6 @@ export class ImportTracker implements IExtensionSingleActivationService { private static sentMatches: Set = new Set(); - // eslint-disable-next-line global-require - private hashFn = require('hash.js').sha256; - constructor( @inject(IDocumentManager) private documentManager: IDocumentManager, @inject(IDisposableRegistry) private disposables: IDisposableRegistry, @@ -120,7 +119,7 @@ export class ImportTracker implements IExtensionSingleActivationService { ImportTracker.sentMatches.add(packageName); // Hash the package name so that we will never accidentally see a // user's private package name. - const hash = this.hashFn().update(packageName).digest('hex'); + const hash = createHash('sha256').update(packageName).digest('hex'); sendTelemetryEvent(EventName.HASHED_PACKAGE_NAME, undefined, { hashedName: hash }); }