11import { createHmac } from 'crypto' ;
22import { inject , injectable } from 'inversify' ;
33import { EventEmitter , Uri } from 'vscode' ;
4- import { EnableTrustedNotebooks } from '../../common/experiments/groups' ;
5- import { IConfigurationService , IExperimentService } from '../../common/types' ;
4+ import { IConfigurationService } from '../../common/types' ;
65import { IDigestStorage , ITrustService } from '../types' ;
76
87@injectable ( )
@@ -14,14 +13,10 @@ export class TrustService implements ITrustService {
1413 return this . configService . getSettings ( ) . datascience . alwaysTrustNotebooks ;
1514 }
1615 protected readonly _onDidSetNotebookTrust = new EventEmitter < void > ( ) ;
17- private enabled : Promise < boolean > ;
1816 constructor (
19- @inject ( IExperimentService ) private readonly experimentService : IExperimentService ,
2017 @inject ( IDigestStorage ) private readonly digestStorage : IDigestStorage ,
2118 @inject ( IConfigurationService ) private configService : IConfigurationService
22- ) {
23- this . enabled = this . isInExperiment ( ) ;
24- }
19+ ) { }
2520
2621 /**
2722 * When a notebook is opened, we check the database to see if a trusted checkpoint
@@ -31,8 +26,8 @@ export class TrustService implements ITrustService {
3126 * markdown will be rendered until notebook as a whole is marked trusted
3227 */
3328 public async isNotebookTrusted ( uri : Uri , notebookContents : string ) {
34- if ( this . alwaysTrustNotebooks || ! ( await this . enabled ) ) {
35- return true ; // Skip check if user manually overrode our trust checking, or if user is not in experiment
29+ if ( this . alwaysTrustNotebooks ) {
30+ return true ; // Skip check if user manually overrode our trust checking
3631 }
3732 // Compute digest and see if notebook is trusted
3833 const digest = await this . computeDigest ( notebookContents ) ;
@@ -45,7 +40,7 @@ export class TrustService implements ITrustService {
4540 * I.e. if the notebook has already been trusted by the user
4641 */
4742 public async trustNotebook ( uri : Uri , notebookContents : string ) {
48- if ( ! this . alwaysTrustNotebooks && ( await this . enabled ) ) {
43+ if ( ! this . alwaysTrustNotebooks ) {
4944 // Only update digest store if the user wants us to check trust
5045 const digest = await this . computeDigest ( notebookContents ) ;
5146 await this . digestStorage . saveDigest ( uri , digest ) ;
@@ -58,8 +53,4 @@ export class TrustService implements ITrustService {
5853 hmac . update ( notebookContents ) ;
5954 return hmac . digest ( 'hex' ) ;
6055 }
61-
62- private async isInExperiment ( ) {
63- return this . experimentService . inExperiment ( EnableTrustedNotebooks . experiment ) ;
64- }
6556}
0 commit comments