scrapebadger 0.79.0 → 0.80.0

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,2 +1,2 @@
1
- export { a8 as ApiResponse, a4 as Article, ao as BillingLog, ap as BillingLogList, a7 as Broadcast, o as CommunitiesClient, _ as Community, Y as CommunityBanner, $ as CommunityMember, a5 as CommunityNote, Z as CommunityRule, w as CommunityTweetType, aq as ConnectOptions, ag as ConnectedEvent, ad as CreateMonitorParams, am as DeliveryLog, an as DeliveryLogList, aj as ErrorEvent, at as FilterRuleCreate, ay as FilterRuleDeliveryLog, az as FilterRuleDeliveryLogListResponse, aw as FilterRuleListResponse, av as FilterRulePricingTier, aA as FilterRulePricingTiersResponse, as as FilterRuleResponse, ar as FilterRuleStatus, au as FilterRuleUpdate, ax as FilterRuleValidateResponse, G as GeoClient, q as GeoSearchOptions, H as Hashtag, X as List, a9 as ListResponse, L as ListsClient, a1 as Location, M as Media, aa as MonitorStatus, ah as PingEvent, a3 as Place, a2 as PlaceTrends, y as Poll, x as PollOption, Q as QueryType, a6 as Space, t as SpacesClient, r as StreamClient, s as StreamEmitter, ak as StreamEvent, al as StreamEventType, ab as StreamMonitor, ac as StreamMonitorList, af as StreamTweet, a0 as Trend, u as TrendCategory, p as TrendsClient, F as Tweet, ai as TweetEvent, E as TweetPlace, n as TweetsClient, T as TwitterClient, ae as UpdateMonitorParams, z as Url, J as User, K as UserAbout, O as UserIds, D as UserMention, U as UsersClient, v as verifyWebhookSignature } from '../index-D029O2qo.cjs';
1
+ export { ac as ApiResponse, a8 as Article, as as BillingLog, at as BillingLogList, ab as Broadcast, s as CommunitiesClient, a2 as Community, a0 as CommunityBanner, a3 as CommunityMember, a9 as CommunityNote, a1 as CommunityRule, D as CommunityTweetType, au as ConnectOptions, ak as ConnectedEvent, ah as CreateMonitorParams, aq as DeliveryLog, ar as DeliveryLogList, an as ErrorEvent, ax as FilterRuleCreate, aC as FilterRuleDeliveryLog, aD as FilterRuleDeliveryLogListResponse, aA as FilterRuleListResponse, az as FilterRulePricingTier, aE as FilterRulePricingTiersResponse, aw as FilterRuleResponse, av as FilterRuleStatus, ay as FilterRuleUpdate, aB as FilterRuleValidateResponse, G as GeoClient, u as GeoSearchOptions, J as Hashtag, $ as List, ad as ListResponse, L as ListsClient, a5 as Location, M as Media, ae as MonitorStatus, al as PingEvent, a7 as Place, a6 as PlaceTrends, F as Poll, E as PollOption, Q as QueryType, aa as Space, y as SpacesClient, w as StreamClient, x as StreamEmitter, ao as StreamEvent, ap as StreamEventType, af as StreamMonitor, ag as StreamMonitorList, aj as StreamTweet, a4 as Trend, z as TrendCategory, t as TrendsClient, X as Tweet, am as TweetEvent, O as TweetPlace, r as TweetsClient, a as TwitterClient, ai as UpdateMonitorParams, H as Url, Y as User, Z as UserAbout, _ as UserIds, K as UserMention, U as UsersClient, v as verifyWebhookSignature } from '../index-BGPGvrzY.cjs';
2
2
  import 'node:events';
@@ -1,2 +1,2 @@
1
- export { a8 as ApiResponse, a4 as Article, ao as BillingLog, ap as BillingLogList, a7 as Broadcast, o as CommunitiesClient, _ as Community, Y as CommunityBanner, $ as CommunityMember, a5 as CommunityNote, Z as CommunityRule, w as CommunityTweetType, aq as ConnectOptions, ag as ConnectedEvent, ad as CreateMonitorParams, am as DeliveryLog, an as DeliveryLogList, aj as ErrorEvent, at as FilterRuleCreate, ay as FilterRuleDeliveryLog, az as FilterRuleDeliveryLogListResponse, aw as FilterRuleListResponse, av as FilterRulePricingTier, aA as FilterRulePricingTiersResponse, as as FilterRuleResponse, ar as FilterRuleStatus, au as FilterRuleUpdate, ax as FilterRuleValidateResponse, G as GeoClient, q as GeoSearchOptions, H as Hashtag, X as List, a9 as ListResponse, L as ListsClient, a1 as Location, M as Media, aa as MonitorStatus, ah as PingEvent, a3 as Place, a2 as PlaceTrends, y as Poll, x as PollOption, Q as QueryType, a6 as Space, t as SpacesClient, r as StreamClient, s as StreamEmitter, ak as StreamEvent, al as StreamEventType, ab as StreamMonitor, ac as StreamMonitorList, af as StreamTweet, a0 as Trend, u as TrendCategory, p as TrendsClient, F as Tweet, ai as TweetEvent, E as TweetPlace, n as TweetsClient, T as TwitterClient, ae as UpdateMonitorParams, z as Url, J as User, K as UserAbout, O as UserIds, D as UserMention, U as UsersClient, v as verifyWebhookSignature } from '../index-D029O2qo.js';
1
+ export { ac as ApiResponse, a8 as Article, as as BillingLog, at as BillingLogList, ab as Broadcast, s as CommunitiesClient, a2 as Community, a0 as CommunityBanner, a3 as CommunityMember, a9 as CommunityNote, a1 as CommunityRule, D as CommunityTweetType, au as ConnectOptions, ak as ConnectedEvent, ah as CreateMonitorParams, aq as DeliveryLog, ar as DeliveryLogList, an as ErrorEvent, ax as FilterRuleCreate, aC as FilterRuleDeliveryLog, aD as FilterRuleDeliveryLogListResponse, aA as FilterRuleListResponse, az as FilterRulePricingTier, aE as FilterRulePricingTiersResponse, aw as FilterRuleResponse, av as FilterRuleStatus, ay as FilterRuleUpdate, aB as FilterRuleValidateResponse, G as GeoClient, u as GeoSearchOptions, J as Hashtag, $ as List, ad as ListResponse, L as ListsClient, a5 as Location, M as Media, ae as MonitorStatus, al as PingEvent, a7 as Place, a6 as PlaceTrends, F as Poll, E as PollOption, Q as QueryType, aa as Space, y as SpacesClient, w as StreamClient, x as StreamEmitter, ao as StreamEvent, ap as StreamEventType, af as StreamMonitor, ag as StreamMonitorList, aj as StreamTweet, a4 as Trend, z as TrendCategory, t as TrendsClient, X as Tweet, am as TweetEvent, O as TweetPlace, r as TweetsClient, a as TwitterClient, ai as UpdateMonitorParams, H as Url, Y as User, Z as UserAbout, _ as UserIds, K as UserMention, U as UsersClient, v as verifyWebhookSignature } from '../index-BGPGvrzY.js';
2
2
  import 'node:events';
@@ -1,6 +1,6 @@
1
- import { createHmac, timingSafeEqual } from 'crypto';
2
1
  import { EventEmitter } from 'events';
3
2
  import WebSocket from 'ws';
3
+ import { createHmac, timingSafeEqual } from 'crypto';
4
4
 
5
5
  // src/internal/pagination.ts
6
6
  function createPaginatedResponse(data, cursor) {
@@ -1362,6 +1362,30 @@ var WebSocketStreamError = class _WebSocketStreamError extends ScrapeBadgerError
1362
1362
  Object.setPrototypeOf(this, _WebSocketStreamError.prototype);
1363
1363
  }
1364
1364
  };
1365
+ var DEFAULT_TOLERANCE_S = 300;
1366
+ var SIGNATURE_RE = /^sha256=([0-9a-fA-F]{64})$/;
1367
+ function rawBytes(rawBody, fn) {
1368
+ if (typeof rawBody === "string") return Buffer.from(rawBody, "utf-8");
1369
+ if (rawBody instanceof Uint8Array) {
1370
+ return Buffer.from(rawBody.buffer, rawBody.byteOffset, rawBody.byteLength);
1371
+ }
1372
+ if (rawBody instanceof ArrayBuffer) return Buffer.from(rawBody);
1373
+ throw new TypeError(
1374
+ `${fn} needs the raw request body (a string or Buffer) exactly as received, not a parsed object: read it with express.raw({ type: "application/json" }) or equivalent.`
1375
+ );
1376
+ }
1377
+ function verifyWebhookSignature(secret, rawBody, signature, options = {}) {
1378
+ const body = rawBytes(rawBody, "verifyWebhookSignature");
1379
+ if (!secret || typeof signature !== "string") return false;
1380
+ const match = SIGNATURE_RE.exec(signature.trim());
1381
+ if (!match?.[1]) return false;
1382
+ const expected = createHmac("sha256", secret).update(body).digest();
1383
+ if (!timingSafeEqual(expected, Buffer.from(match[1], "hex"))) return false;
1384
+ const { sentAt, toleranceS = DEFAULT_TOLERANCE_S } = options;
1385
+ if (sentAt === void 0 || sentAt === null) return true;
1386
+ const sentAtS = typeof sentAt === "number" ? sentAt : Number(sentAt.trim() || Number.NaN);
1387
+ return Math.abs(Date.now() / 1e3 - sentAtS) <= toleranceS;
1388
+ }
1365
1389
 
1366
1390
  // src/twitter/stream.ts
1367
1391
  var MIN_RECONNECT_DELAY_SECONDS = 5;
@@ -2042,19 +2066,6 @@ var StreamClient = class {
2042
2066
  }
2043
2067
  }
2044
2068
  };
2045
- function verifyWebhookSignature(secret, body, signatureHeader) {
2046
- if (!signatureHeader.startsWith("sha256=")) {
2047
- return false;
2048
- }
2049
- const expectedHex = signatureHeader.slice("sha256=".length);
2050
- const bodyBuffer = typeof body === "string" ? Buffer.from(body, "utf-8") : body;
2051
- const actualHex = createHmac("sha256", secret).update(bodyBuffer).digest("hex");
2052
- try {
2053
- return timingSafeEqual(Buffer.from(expectedHex, "hex"), Buffer.from(actualHex, "hex"));
2054
- } catch {
2055
- return false;
2056
- }
2057
- }
2058
2069
 
2059
2070
  // src/twitter/spaces.ts
2060
2071
  var SpacesClient = class {