-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding ssri.create for a crypto style interface (#2)
* feat: adding ssri.create for a crypto style interface adding crypto.create adding toJSON to Integrity * chore: standard * fix: update nits and fix documentation for create. create was misdocumented as returning Integrity but it return a Hash
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const test = require('tap').test | ||
|
||
const ssri = require('..') | ||
|
||
test('works just like from', function (t) { | ||
const integrity = ssri.fromData('hi') | ||
const integrityCreate = ssri.create().update('hi').digest() | ||
|
||
t.ok(integrityCreate instanceof integrity.constructor, 'should be same Integrity that fromData returns') | ||
t.equals(integrity + '', integrityCreate + '', 'should be the sam as fromData') | ||
t.end() | ||
}) | ||
|
||
test('can pass options', function (t) { | ||
const integrity = ssri.create({algorithms: ['sha256', 'sha384']}).update('hi').digest() | ||
|
||
t.equals( | ||
integrity + '', | ||
'sha256-j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ= ' + | ||
'sha384-B5EAbfgShHckT1PQ/c4hDbgfVXV1EOJqzuNcGKa86qKNzbv9bcBBubTcextU439S', | ||
'should be expected value' | ||
) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters