-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into use-full-relative-paths
- Loading branch information
Showing
12 changed files
with
1,277 additions
and
1,709 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
Large diffs are not rendered by default.
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
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,13 @@ | ||
import { sign as signMethod } from "@octokit/webhooks-methods"; | ||
|
||
import { toNormalizedJsonString } from "./to-normalized-json-string"; | ||
|
||
export async function sign( | ||
secret: string, | ||
payload: string | object | ||
): Promise<any> { | ||
return signMethod( | ||
secret, | ||
typeof payload === "string" ? payload : toNormalizedJsonString(payload) | ||
); | ||
} |
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 @@ | ||
/** | ||
* GitHub sends its JSON with an indentation of 2 spaces and a line break at the end | ||
*/ | ||
export function toNormalizedJsonString(payload: object) { | ||
const payloadString = JSON.stringify(payload, null, 2) + "\n"; | ||
return payloadString.replace(/[^\\]\\u[\da-f]{4}/g, (s) => { | ||
return s.substr(0, 3) + s.substr(3).toUpperCase(); | ||
}); | ||
} |
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,15 @@ | ||
import { verify as verifyMethod } from "@octokit/webhooks-methods"; | ||
|
||
import { toNormalizedJsonString } from "./to-normalized-json-string"; | ||
|
||
export async function verify( | ||
secret: string, | ||
payload: string | object, | ||
signature: string | ||
): Promise<any> { | ||
return verifyMethod( | ||
secret, | ||
typeof payload === "string" ? payload : toNormalizedJsonString(payload), | ||
signature | ||
); | ||
} |
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
Oops, something went wrong.