@@ -62,7 +62,7 @@ ssri.checkData(fs.readFileSync('./my-file'), integrity) // => 'sha512'
62
62
* Strict standard compliance.
63
63
* ` ?foo ` metadata option support.
64
64
* Multiple entries for the same algorithm.
65
- * Object-based integrity metadata manipulation.
65
+ * Object-based integrity hash manipulation.
66
66
* Small footprint: no dependencies, concise implementation.
67
67
* Full test coverage.
68
68
* Customizable algorithm picker.
@@ -80,9 +80,9 @@ jump in if you'd like to, or even ask us questions if something isn't clear.
80
80
#### <a name =" parse " ></a > ` > ssri.parse(sri, [opts]) -> Integrity `
81
81
82
82
Parses ` sri ` into an ` Integrity ` data structure. ` sri ` can be an integrity
83
- string, an ` IntegrityMetadata ` -like with ` digest ` and ` algorithm ` fields and an
84
- optional ` options ` field, or an ` Integrity ` -like object. The resulting object
85
- will be an ` Integrity ` instance that has this shape:
83
+ string, an ` Hash ` -like with ` digest ` and ` algorithm ` fields and an optional
84
+ ` options ` field, or an ` Integrity ` -like object. The resulting object will be an
85
+ ` Integrity ` instance that has this shape:
86
86
87
87
``` javascript
88
88
{
@@ -94,9 +94,9 @@ will be an `Integrity` instance that has this shape:
94
94
}
95
95
```
96
96
97
- If ` opts.single ` is truthy, a single ` IntegrityMetadata ` object will be
98
- returned. That is, a single object that looks like `{algorithm, digest,
99
- options}`, as opposed to a larger object with multiple of these.
97
+ If ` opts.single ` is truthy, a single ` Hash ` object will be returned. That is, a
98
+ single object that looks like ` {algorithm, digest, options} ` , as opposed to a
99
+ larger object with multiple of these.
100
100
101
101
If ` opts.strict ` is truthy, the resulting object will be filtered such that
102
102
it strictly follows the Subresource Integrity spec, throwing away any entries
@@ -116,7 +116,7 @@ ssri.parse('sha512-9KhgCRIx/AmzC8xqYJTZRrnO8OW2Pxyl2DIMZSBOr0oDvtEFyht3xpp71j/r/
116
116
117
117
This function is identical to [ ` Integrity#toString() ` ] ( #integrity-to-string ) ,
118
118
except it can be used on _ any_ object that [ ` parse ` ] ( #parse ) can handle -- that
119
- is, a string, an ` IntegrityMetadata ` -like, or an ` Integrity ` -like.
119
+ is, a string, an ` Hash ` -like, or an ` Integrity ` -like.
120
120
121
121
The ` opts.sep ` option defines the string to use when joining multiple entries
122
122
together. To be spec-compliant, this _ must_ be whitespace. The default is a
@@ -132,7 +132,7 @@ parsing rules. See [`ssri.parse`](#parse).
132
132
ssri .stringify (' \n\r sha512-foo\n\t\t sha384-bar' )
133
133
// -> 'sha512-foo sha384-bar'
134
134
135
- // IntegrityMetadata -like: only a single entry.
135
+ // Hash -like: only a single entry.
136
136
ssri .stringify ({
137
137
algorithm: ' sha512' ,
138
138
digest: ' 9KhgCRIx/AmzC8xqYJTZRrnO8OW2Pxyl2DIMZSBOr0oDvtEFyht3xpp71j/r/pAe1DM+JI/A+line3jUBgzQ7A==' ,
@@ -157,8 +157,8 @@ ssri.stringify({
157
157
158
158
#### <a name =" integrity-concat " ></a > ` > Integrity#concat(otherIntegrity, [opts]) -> Integrity `
159
159
160
- Concatenates an ` Integrity ` object with another IntegrityLike, or a string
161
- representing integrity metadata .
160
+ Concatenates an ` Integrity ` object with another IntegrityLike, or an integrity
161
+ string .
162
162
163
163
This is functionally equivalent to concatenating the string format of both
164
164
integrity arguments, and calling [ ` ssri.parse ` ] ( #ssri-parse ) on the new string.
@@ -183,7 +183,7 @@ desktopIntegrity.concat(mobileIntegrity)
183
183
184
184
#### <a name =" integrity-to-string " ></a > ` > Integrity#toString([opts]) -> String `
185
185
186
- Returns the string representation of an ` Integrity ` object. All metadata entries
186
+ Returns the string representation of an ` Integrity ` object. All hash entries
187
187
will be concatenated in the string by ` opts.sep ` , which defaults to ` ' ' ` .
188
188
189
189
If you want to serialize an object that didn't from from an ` ssri ` function,
@@ -219,9 +219,9 @@ ssri.parse('sha1-WEakDigEST sha512-yzd8ELD1piyANiWnmdnpCL5F52f10UfUdEkHywVZeqTt0
219
219
220
220
#### <a name =" integrity-hex-digest " ></a > ` > Integrity#hexDigest() -> String `
221
221
222
- ` Integrity ` is assumed to be either a single-hash ` Integrity ` instance, or an
223
- ` IntegrityMetadata ` instance. Returns its ` digest ` , converted to a hex
224
- representation of the base64 data.
222
+ ` Integrity ` is assumed to be either a single-hash ` Integrity ` instance, or a
223
+ ` Hash ` instance. Returns its ` digest ` , converted to a hex representation of the
224
+ base64 data.
225
225
226
226
##### Example
227
227
@@ -240,15 +240,15 @@ algorithm + '-' + Buffer.from(hexDigest, 'hex').toString('base64')
240
240
```
241
241
242
242
` opts.options ` may optionally be passed in: it must be an array of option
243
- strings that will be added to all generated integrity metadata generated by
243
+ strings that will be added to all generated integrity hashes generated by
244
244
` fromData ` . This is a loosely-specified feature of SRIs, and currently has no
245
245
specified semantics besides being ` ? ` -separated. Use at your own risk, and
246
246
probably avoid if your integrity strings are meant to be used with browsers.
247
247
248
248
If ` opts.strict ` is true, the integrity object will be created using strict
249
249
parsing rules. See [ ` ssri.parse ` ] ( #parse ) .
250
250
251
- If ` opts.single ` is true, a single ` IntegrityMetadata ` object will be returned.
251
+ If ` opts.single ` is true, a single ` Hash ` object will be returned.
252
252
253
253
##### Example
254
254
@@ -261,13 +261,13 @@ ssri.fromHex('75e69d6de79f', 'sha1').toString() // 'sha1-deadbeef'
261
261
Creates an ` Integrity ` object from either string or ` Buffer ` data, calculating
262
262
all the requested hashes and adding any specified options to the object.
263
263
264
- ` opts.algorithms ` determines which algorithms to generate metadata for. All
264
+ ` opts.algorithms ` determines which algorithms to generate hashes for. All
265
265
results will be included in a single ` Integrity ` object. The default value for
266
266
` opts.algorithms ` is ` ['sha512'] ` . All algorithm strings must be hashes listed
267
267
in ` crypto.getHashes() ` for the host Node.js platform.
268
268
269
269
` opts.options ` may optionally be passed in: it must be an array of option
270
- strings that will be added to all generated integrity metadata generated by
270
+ strings that will be added to all generated integrity hashes generated by
271
271
` fromData ` . This is a loosely-specified feature of SRIs, and currently has no
272
272
specified semantics besides being ` ? ` -separated. Use at your own risk, and
273
273
probably avoid if your integrity strings are meant to be used with browsers.
@@ -312,7 +312,7 @@ ssri.fromStream(fs.createReadStream('index.js'), {
312
312
}) // succeeds
313
313
```
314
314
315
- #### <a name =" check-data " ></a > ` > ssri.checkData(data, sri, [opts]) -> IntegrityMetadata |false `
315
+ #### <a name =" check-data " ></a > ` > ssri.checkData(data, sri, [opts]) -> Hash |false `
316
316
317
317
Verifies ` data ` integrity against an ` sri ` argument. ` data ` may be either a
318
318
` String ` or a ` Buffer ` , and ` sri ` can be any subresource integrity
@@ -334,14 +334,14 @@ ssri.checkData(data, 'sha256-l981iLWj8kurw4UbNy8Lpxqdzd7UOxS50Glhv8FwfZ0')
334
334
ssri .checkData (data, ' sha1-BaDDigEST' ) // -> false
335
335
```
336
336
337
- #### <a name =" check-stream " ></a > ` > ssri.checkStream(stream, sri, [opts]) -> Promise<IntegrityMetadata > `
337
+ #### <a name =" check-stream " ></a > ` > ssri.checkStream(stream, sri, [opts]) -> Promise<Hash > `
338
338
339
339
Verifies the contents of ` stream ` against an ` sri ` argument. ` stream ` will be
340
340
consumed in its entirety by this process. ` sri ` can be any subresource integrity
341
341
representation that [ ` ssri.parse ` ] ( #parse ) can handle.
342
342
343
343
` checkStream ` will return a Promise that either resolves to the
344
- ` IntegrityMetadata ` that succeeded verification, or, if the verification fails
344
+ ` Hash ` that succeeded verification, or, if the verification fails
345
345
or an error happens with ` stream ` , the Promise will be rejected.
346
346
347
347
If the Promise is rejected because verification failed, the returned error will
@@ -373,7 +373,7 @@ ssri.checkStream(
373
373
ssri .checkStream (
374
374
fs .createReadStream (' index.js' ),
375
375
' sha256-l981iLWj8kurw4UbNy8Lpxqdzd7UOxS50Glhv8FwfZ0'
376
- ) // -> Promise<IntegrityMetadata >
376
+ ) // -> Promise<Hash >
377
377
378
378
ssri .checkStream (
379
379
fs .createReadStream (' index.js' ),
@@ -392,15 +392,13 @@ data, respectively.
392
392
If ` opts.algorithms ` is passed in, the listed algorithms will be calculated when
393
393
generating the final ` Integrity ` instance. The default is ` ['sha512'] ` .
394
394
395
- If ` opts.single ` is passed in, a single ` IntegrityMetadata ` instance will be
396
- returned.
395
+ If ` opts.single ` is passed in, a single ` Hash ` instance will be returned.
397
396
398
397
If ` opts.integrity ` is passed in, it should be an ` integrity ` value understood
399
398
by [ ` parse ` ] ( #parse ) that the stream will check the data against. If
400
399
verification succeeds, the integrity stream will emit a ` verified ` event whose
401
- value is a single ` IntegrityMetadata ` object that is the one that succeeded
402
- verification. If verification fails, the stream will error with an
403
- ` EBADCHECKSUM ` error code.
400
+ value is a single ` Hash ` object that is the one that succeeded verification. If
401
+ verification fails, the stream will error with an ` EBADCHECKSUM ` error code.
404
402
405
403
If ` opts.size ` is given, it will be matched against the stream size. An error
406
404
with ` err.code ` ` EBADSIZE ` will be emitted by the stream if the expected size
0 commit comments