Skip to content

Commit 63c3780

Browse files
authored
Remove usage of hash.js (#24504)
Component Governance
1 parent b342559 commit 63c3780

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

package-lock.json

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,6 @@
15601560
"arch": "^2.1.0",
15611561
"fs-extra": "^11.2.0",
15621562
"glob": "^7.2.0",
1563-
"hash.js": "^1.1.7",
15641563
"iconv-lite": "^0.6.3",
15651564
"inversify": "^6.0.2",
15661565
"jsonc-parser": "^3.0.0",

src/client/telemetry/importTracker.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable class-methods-use-this */
12
// Copyright (c) Microsoft Corporation. All rights reserved.
23
// Licensed under the MIT License.
34

@@ -7,6 +8,7 @@ import { inject, injectable } from 'inversify';
78
import * as path from 'path';
89
import { clearTimeout, setTimeout } from 'timers';
910
import { TextDocument } from 'vscode';
11+
import { createHash } from 'crypto';
1012
import { sendTelemetryEvent } from '.';
1113
import { IExtensionSingleActivationService } from '../activation/types';
1214
import { IDocumentManager } from '../common/application/types';
@@ -53,9 +55,6 @@ export class ImportTracker implements IExtensionSingleActivationService {
5355

5456
private static sentMatches: Set<string> = new Set<string>();
5557

56-
// eslint-disable-next-line global-require
57-
private hashFn = require('hash.js').sha256;
58-
5958
constructor(
6059
@inject(IDocumentManager) private documentManager: IDocumentManager,
6160
@inject(IDisposableRegistry) private disposables: IDisposableRegistry,
@@ -120,7 +119,7 @@ export class ImportTracker implements IExtensionSingleActivationService {
120119
ImportTracker.sentMatches.add(packageName);
121120
// Hash the package name so that we will never accidentally see a
122121
// user's private package name.
123-
const hash = this.hashFn().update(packageName).digest('hex');
122+
const hash = createHash('sha256').update(packageName).digest('hex');
124123
sendTelemetryEvent(EventName.HASHED_PACKAGE_NAME, undefined, { hashedName: hash });
125124
}
126125

0 commit comments

Comments
 (0)