@@ -5,15 +5,16 @@ import { BaseFetcher, Fetcher } from './fetcher';
55import { Metadata , Targets } from './models' ;
66import { TargetFile } from './models/file' ;
77import { TrustedMetadataStore } from './store' ;
8- import { updaterConfig } from './utils/config' ;
8+ import { Config , defaultConfig } from './utils/config' ;
99import { MetadataKind } from './utils/types' ;
1010
11- interface UodaterOptions {
11+ interface UpdaterOptions {
1212 metadataDir : string ;
1313 metadataBaseUrl : string ;
1414 targetDir ?: string ;
1515 targetBaseUrl ?: string ;
1616 fetcher ?: BaseFetcher ;
17+ config ?: Config ;
1718}
1819
1920interface Delegation {
@@ -27,12 +28,18 @@ export class Updater {
2728 private targetDir ?: string ;
2829 private targetBaseUrl ?: string ;
2930 private trustedSet : TrustedMetadataStore ;
30- private config : typeof updaterConfig ;
31+ private config : Config ;
3132 private fetcher : BaseFetcher ;
3233
33- constructor ( options : UodaterOptions ) {
34- const { metadataDir, metadataBaseUrl, targetDir, targetBaseUrl, fetcher } =
35- options ;
34+ constructor ( options : UpdaterOptions ) {
35+ const {
36+ metadataDir,
37+ metadataBaseUrl,
38+ targetDir,
39+ targetBaseUrl,
40+ fetcher,
41+ config,
42+ } = options ;
3643
3744 this . dir = metadataDir ;
3845 this . metadataBaseUrl = metadataBaseUrl ;
@@ -41,13 +48,10 @@ export class Updater {
4148 this . targetBaseUrl = targetBaseUrl ;
4249
4350 const data = this . loadLocalMetadata ( MetadataKind . Root ) ;
44- this . trustedSet = new TrustedMetadataStore ( data ) ;
45- this . config = updaterConfig ;
4651
52+ this . trustedSet = new TrustedMetadataStore ( data ) ;
53+ this . config = { ...defaultConfig , ...config } ;
4754 this . fetcher = fetcher || new Fetcher ( this . config . fetchTimeout ) ;
48-
49- // self._trusted_set = trusted_metadata_set.TrustedMetadataSet(data)
50- // self.config = config or UpdaterConfig()
5155 }
5256
5357 public async refresh ( ) {
0 commit comments