Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bugs": "https://github.com/TRUEPIC/webhook-verifier-nodejs/issues",
"license": "MIT",
"main": "./src/main.js",
"types": "./src/main.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/TRUEPIC/webhook-verifier-nodejs.git"
Expand Down
36 changes: 36 additions & 0 deletions src/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Options for verifying a Truepic webhook.
*/
interface VerifyTruepicWebhookOptions {
/** The full URL that received the request and is registered with Truepic. */
url: string
/** The shared secret that's registered with Truepic. */
secret: string
/** The value of the `truepic-signature` header from the request. */
header: string
/** The raw body (unparsed JSON) from the request. */
body: string
/** The number of minutes allowed between the request being sent and received. Defaults to `5`. */
leewayMinutes?: number
}

/**
* The custom error thrown when webhook verification fails.
*/
declare class TruepicWebhookVerifierError extends Error {
constructor(message: string)
name: 'TruepicWebhookVerifierError'
}

/**
* Verify a webhook from Truepic Vision or Lens.
*/
declare function verifyTruepicWebhook(
options: VerifyTruepicWebhookOptions,
): true

declare namespace verifyTruepicWebhook {
export { TruepicWebhookVerifierError }
}

export = verifyTruepicWebhook
Loading