-
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.
style: use double instead of single quotes
- Loading branch information
1 parent
b2caf17
commit 55315d5
Showing
8 changed files
with
63 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": true | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": true | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
extensions: ['ts'], | ||
require: ['ts-node/register/transpile-only'], | ||
extensions: ["ts"], | ||
require: ["ts-node/register/transpile-only"], | ||
environmentVariables: { | ||
TS_NODE_PROJECT: 'tsconfig.base.json', | ||
TS_NODE_PROJECT: "tsconfig.base.json", | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
'use strict'; | ||
"use strict"; | ||
|
||
module.exports = { | ||
branches: ['main'], | ||
branches: ["main"], | ||
plugins: [ | ||
'@semantic-release/commit-analyzer', | ||
'@semantic-release/release-notes-generator', | ||
'@semantic-release/changelog', | ||
'@semantic-release/npm', | ||
'@semantic-release/git', | ||
'@semantic-release/github', | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
"@semantic-release/git", | ||
"@semantic-release/github", | ||
], | ||
}; |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { createHmac } from 'crypto'; | ||
import { createHmac } from "crypto"; | ||
|
||
export function verify(body: string, secret: string, signature?: string | string[]): boolean { | ||
if (!signature) { | ||
return false; | ||
} | ||
const hmac = createHmac('sha1', secret); | ||
const hmac = createHmac("sha1", secret); | ||
hmac.update(body); | ||
const calculated = `sha1=${hmac.digest('hex')}`; | ||
const calculated = `sha1=${hmac.digest("hex")}`; | ||
return signature === calculated; | ||
} |
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import test from 'ava'; | ||
import { verify } from '../../src/verify'; | ||
import test from "ava"; | ||
import { verify } from "../../src/verify"; | ||
|
||
const body = JSON.stringify({ | ||
foo: 'bar', | ||
foo: "bar", | ||
}); | ||
const signature = 'sha1=30a233839fe2ddd9233c49fd593e8f1aec68f553'; | ||
const signature = "sha1=30a233839fe2ddd9233c49fd593e8f1aec68f553"; | ||
|
||
test('return "false" when signature is missing', (t) => { | ||
const valid = verify(body, 'my-secret'); | ||
const valid = verify(body, "my-secret"); | ||
t.false(valid); | ||
}); | ||
|
||
test('return "false" when signature is an Array', (t) => { | ||
const valid = verify(body, 'wrong-secret', signature); | ||
const valid = verify(body, "wrong-secret", signature); | ||
t.false(valid); | ||
}); | ||
|
||
test('return "false" when secret is wrong', (t) => { | ||
const valid = verify(body, 'wrong-secret', signature); | ||
const valid = verify(body, "wrong-secret", signature); | ||
t.false(valid); | ||
}); | ||
|
||
test('return "true" when secret is correct', (t) => { | ||
const valid = verify(body, 'my-secret', signature); | ||
const valid = verify(body, "my-secret", signature); | ||
t.true(valid); | ||
}); |