@@ -4,8 +4,9 @@ exports.TrustedMetadataStore = void 0;
4
4
const models_1 = require ( "@tufjs/models" ) ;
5
5
const error_1 = require ( "./error" ) ;
6
6
class TrustedMetadataStore {
7
+ trustedSet = { } ;
8
+ referenceTime ;
7
9
constructor ( rootData ) {
8
- this . trustedSet = { } ;
9
10
// Client workflow 5.1: record fixed update start time
10
11
this . referenceTime = new Date ( ) ;
11
12
// Client workflow 5.2: load trusted root metadata
@@ -30,7 +31,9 @@ class TrustedMetadataStore {
30
31
return this . trustedSet [ name ] ;
31
32
}
32
33
updateRoot ( bytesBuffer ) {
34
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
33
35
const data = JSON . parse ( bytesBuffer . toString ( 'utf8' ) ) ;
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
34
37
const newRoot = models_1 . Metadata . fromJSON ( models_1 . MetadataKind . Root , data ) ;
35
38
if ( newRoot . signed . type != models_1 . MetadataKind . Root ) {
36
39
throw new error_1 . RepositoryError ( `Expected 'root', got ${ newRoot . signed . type } ` ) ;
@@ -54,7 +57,9 @@ class TrustedMetadataStore {
54
57
if ( this . root . signed . isExpired ( this . referenceTime ) ) {
55
58
throw new error_1 . ExpiredMetadataError ( 'Final root.json is expired' ) ;
56
59
}
60
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
57
61
const data = JSON . parse ( bytesBuffer . toString ( 'utf8' ) ) ;
62
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
58
63
const newTimestamp = models_1 . Metadata . fromJSON ( models_1 . MetadataKind . Timestamp , data ) ;
59
64
if ( newTimestamp . signed . type != models_1 . MetadataKind . Timestamp ) {
60
65
throw new error_1 . RepositoryError ( `Expected 'timestamp', got ${ newTimestamp . signed . type } ` ) ;
@@ -102,7 +107,9 @@ class TrustedMetadataStore {
102
107
if ( ! trusted ) {
103
108
snapshotMeta . verify ( bytesBuffer ) ;
104
109
}
110
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
105
111
const data = JSON . parse ( bytesBuffer . toString ( 'utf8' ) ) ;
112
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
106
113
const newSnapshot = models_1 . Metadata . fromJSON ( models_1 . MetadataKind . Snapshot , data ) ;
107
114
if ( newSnapshot . signed . type != models_1 . MetadataKind . Snapshot ) {
108
115
throw new error_1 . RepositoryError ( `Expected 'snapshot', got ${ newSnapshot . signed . type } ` ) ;
@@ -147,7 +154,9 @@ class TrustedMetadataStore {
147
154
}
148
155
// Client workflow 5.6.2: check against snapshot role's targets hash
149
156
meta . verify ( bytesBuffer ) ;
157
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
150
158
const data = JSON . parse ( bytesBuffer . toString ( 'utf8' ) ) ;
159
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
151
160
const newDelegate = models_1 . Metadata . fromJSON ( models_1 . MetadataKind . Targets , data ) ;
152
161
if ( newDelegate . signed . type != models_1 . MetadataKind . Targets ) {
153
162
throw new error_1 . RepositoryError ( `Expected 'targets', got ${ newDelegate . signed . type } ` ) ;
@@ -168,7 +177,9 @@ class TrustedMetadataStore {
168
177
// Verifies and loads data as trusted root metadata.
169
178
// Note that an expired initial root is still considered valid.
170
179
loadTrustedRoot ( bytesBuffer ) {
180
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
171
181
const data = JSON . parse ( bytesBuffer . toString ( 'utf8' ) ) ;
182
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
172
183
const root = models_1 . Metadata . fromJSON ( models_1 . MetadataKind . Root , data ) ;
173
184
if ( root . signed . type != models_1 . MetadataKind . Root ) {
174
185
throw new error_1 . RepositoryError ( `Expected 'root', got ${ root . signed . type } ` ) ;
0 commit comments