-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from encrypit/refactor/module
refactor(module): move `mjs` files from `src` to `module` directory
- Loading branch information
Showing
13 changed files
with
111 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
|
||
npm run lint:tsc | ||
npm run test:ci | ||
npm run test:module | ||
npx lint-staged |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export { digest } from '../lib/browser.js'; |
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,45 @@ | ||
import crypto from 'node:crypto'; | ||
import { before, describe, it } from 'node:test'; | ||
|
||
import assert from 'assert'; | ||
|
||
describe('browser', () => { | ||
let digest; | ||
|
||
before(async () => { | ||
global.crypto = crypto; | ||
digest = (await import('./browser.mjs')).digest; | ||
}); | ||
|
||
it('exports "digest" function', () => { | ||
assert.strictEqual(typeof digest, 'function'); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-1"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-1', ''), | ||
'da39a3ee5e6b4b0d3255bfef95601890afd80709' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-256"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-256', ''), | ||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-384"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-384', ''), | ||
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-512"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-384', ''), | ||
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' | ||
); | ||
}); | ||
}); |
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 @@ | ||
export { digest } from '../lib/index.js'; |
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,39 @@ | ||
import { describe, it } from 'node:test'; | ||
|
||
import assert from 'assert'; | ||
|
||
import { digest } from './index.mjs'; | ||
|
||
describe('index', () => { | ||
it('exports "digest" function', () => { | ||
assert.strictEqual(typeof digest, 'function'); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-1"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-1', ''), | ||
'da39a3ee5e6b4b0d3255bfef95601890afd80709' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-256"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-256', ''), | ||
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-384"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-384', ''), | ||
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' | ||
); | ||
}); | ||
|
||
it('hashes message with algorithm "SHA-512"', async () => { | ||
assert.strictEqual( | ||
await digest('SHA-384', ''), | ||
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' | ||
); | ||
}); | ||
}); |
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`digest hashes message with algorithm "SHA-1" 1`] = `"da39a3ee5e6b4b0d3255bfef95601890afd80709"`; | ||
|
||
exports[`digest hashes message with algorithm "SHA-256" 1`] = `"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"`; | ||
|
||
exports[`digest hashes message with algorithm "SHA-384" 1`] = `"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"`; | ||
|
||
exports[`digest hashes message with algorithm "SHA-512" 1`] = `"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"`; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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