Skip to content

Commit c77bbed

Browse files
authored
Add TypeScript declaration file (#32)
1 parent 197c539 commit c77bbed

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"bugs": "https://github.com/TRUEPIC/webhook-verifier-nodejs/issues",
77
"license": "MIT",
88
"main": "./src/main.js",
9+
"types": "./src/main.d.ts",
910
"repository": {
1011
"type": "git",
1112
"url": "git+https://github.com/TRUEPIC/webhook-verifier-nodejs.git"

src/main.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Options for verifying a Truepic webhook.
3+
*/
4+
interface VerifyTruepicWebhookOptions {
5+
/** The full URL that received the request and is registered with Truepic. */
6+
url: string
7+
/** The shared secret that's registered with Truepic. */
8+
secret: string
9+
/** The value of the `truepic-signature` header from the request. */
10+
header: string
11+
/** The raw body (unparsed JSON) from the request. */
12+
body: string
13+
/** The number of minutes allowed between the request being sent and received. Defaults to `5`. */
14+
leewayMinutes?: number
15+
}
16+
17+
/**
18+
* The custom error thrown when webhook verification fails.
19+
*/
20+
declare class TruepicWebhookVerifierError extends Error {
21+
constructor(message: string)
22+
name: 'TruepicWebhookVerifierError'
23+
}
24+
25+
/**
26+
* Verify a webhook from Truepic Vision or Lens.
27+
*/
28+
declare function verifyTruepicWebhook(
29+
options: VerifyTruepicWebhookOptions,
30+
): true
31+
32+
declare namespace verifyTruepicWebhook {
33+
export { TruepicWebhookVerifierError }
34+
}
35+
36+
export = verifyTruepicWebhook

0 commit comments

Comments
 (0)