@hookflo/tern 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { WebhookVerificationResult } from '../types';
1
+ import { WebhookVerificationResult } from "../types";
2
2
  export declare abstract class WebhookVerifier {
3
3
  protected secret: string;
4
4
  protected toleranceInSeconds: number;
@@ -9,7 +9,9 @@ class WebhookVerifier {
9
9
  }
10
10
  isTimestampValid(timestamp) {
11
11
  const now = Math.floor(Date.now() / 1000);
12
- return Math.abs(now - timestamp) <= this.toleranceInSeconds;
12
+ // WorkOS sends milliseconds — auto-detect by magnitude
13
+ const timestampInSeconds = timestamp > 1e12 ? Math.floor(timestamp / 1000) : timestamp;
14
+ return Math.abs(now - timestampInSeconds) <= this.toleranceInSeconds;
13
15
  }
14
16
  safeCompare(a, b) {
15
17
  if (a.length !== b.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hookflo/tern",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "A robust, scalable webhook verification framework supporting multiple platforms and signature algorithms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",