twitch-eventsub
Advanced tools
Comparing version 4.4.8 to 4.4.9
@@ -10,2 +10,3 @@ import type { ApiClient, HelixUser } from 'twitch'; | ||
type: EventSubStreamOnlineEventStreamType; | ||
started_at: string; | ||
} | ||
@@ -40,3 +41,7 @@ /** | ||
get streamType(): EventSubStreamOnlineEventStreamType; | ||
/** | ||
* The date and time when the stream was started. | ||
*/ | ||
get startDate(): Date; | ||
} | ||
export {}; |
@@ -69,2 +69,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(EventSubStreamOnlineEvent.prototype, "startDate", { | ||
/** | ||
* The date and time when the stream was started. | ||
*/ | ||
get: function () { | ||
return new Date(this._data.started_at); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
tslib_1.__decorate([ | ||
@@ -71,0 +81,0 @@ shared_utils_1.Enumerable(false) |
@@ -650,32 +650,39 @@ "use strict"; | ||
algoAndSignature = req.headers['twitch-eventsub-message-signature']; | ||
verified = subscription._verifyData(messageId, timestamp, body, algoAndSignature); | ||
if (verified) { | ||
data = JSON.parse(body); | ||
if (type === 'webhook_callback_verification') { | ||
verificationBody = data; | ||
subscription._verify(); | ||
if (twitchSubscription) { | ||
twitchSubscription._status = 'enabled'; | ||
if (algoAndSignature === undefined) { | ||
this._logger.warn("Dropping unsigned message for action " + type + " of event: " + id); | ||
res.writeHead(410); | ||
res.end(); | ||
} | ||
else { | ||
verified = subscription._verifyData(messageId, timestamp, body, algoAndSignature); | ||
if (verified) { | ||
data = JSON.parse(body); | ||
if (type === 'webhook_callback_verification') { | ||
verificationBody = data; | ||
subscription._verify(); | ||
if (twitchSubscription) { | ||
twitchSubscription._status = 'enabled'; | ||
} | ||
res.setHeader('Content-Length', verificationBody.challenge.length); | ||
res.writeHead(200, undefined); | ||
res.end(verificationBody.challenge); | ||
this._logger.debug("Successfully subscribed to event: " + id); | ||
} | ||
res.setHeader('Content-Length', verificationBody.challenge.length); | ||
res.writeHead(200, undefined); | ||
res.end(verificationBody.challenge); | ||
this._logger.debug("Successfully subscribed to event: " + id); | ||
else if (type === 'notification') { | ||
subscription._handleData(data.event); | ||
res.writeHead(202); | ||
res.end(); | ||
} | ||
else { | ||
this._logger.warn("Unknown action " + type + " for event: " + id); | ||
res.writeHead(400); | ||
res.end(); | ||
} | ||
} | ||
else if (type === 'notification') { | ||
subscription._handleData(data.event); | ||
res.writeHead(202); | ||
res.end(); | ||
} | ||
else { | ||
this._logger.warn("Unknown action " + type + " for event: " + id); | ||
res.writeHead(400); | ||
this._logger.warn("Could not verify action " + type + " of event: " + id); | ||
res.writeHead(410); | ||
res.end(); | ||
} | ||
} | ||
else { | ||
this._logger.warn("Could not verify action " + type + " of event: " + id); | ||
res.writeHead(410); | ||
res.end(); | ||
} | ||
return [3 /*break*/, 3]; | ||
@@ -682,0 +689,0 @@ case 2: |
@@ -13,3 +13,2 @@ import type { HelixEventSubSubscription, HelixEventSubTransportOptions } from 'twitch'; | ||
private _twitchSubscriptionData?; | ||
private _unsubscribeResolver?; | ||
/** @private */ | ||
@@ -30,4 +29,2 @@ protected constructor(_handler: (obj: T) => void, _client: EventSubListener); | ||
_handleData(body: Record<string, unknown>): void; | ||
/** @private */ | ||
_handleUnsubscribe(): boolean; | ||
/** | ||
@@ -34,0 +31,0 @@ * Activates the subscription. |
@@ -60,11 +60,2 @@ "use strict"; | ||
}; | ||
/** @private */ | ||
EventSubSubscription.prototype._handleUnsubscribe = function () { | ||
if (this._unsubscribeResolver) { | ||
this._unsubscribeResolver(); | ||
this._unsubscribeResolver = undefined; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
/** | ||
@@ -106,4 +97,2 @@ * Activates the subscription. | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var unsubscribePromise; | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -115,9 +104,5 @@ switch (_a.label) { | ||
} | ||
unsubscribePromise = new Promise(function (resolve) { return (_this._unsubscribeResolver = resolve); }); | ||
return [4 /*yield*/, this._unsubscribe()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, unsubscribePromise]; | ||
case 2: | ||
_a.sent(); | ||
this._twitchSubscriptionData = undefined; | ||
@@ -124,0 +109,0 @@ return [2 /*return*/]; |
{ | ||
"name": "twitch-eventsub", | ||
"version": "4.4.8", | ||
"version": "4.4.9", | ||
"description": "Listen to events on Twitch via their EventSub API.", | ||
@@ -37,7 +37,7 @@ "keywords": [ | ||
"tslib": "^2.0.3", | ||
"twitch-auth": "^4.4.8", | ||
"twitch-common": "^4.4.8" | ||
"twitch-auth": "^4.4.9", | ||
"twitch-common": "^4.4.9" | ||
}, | ||
"devDependencies": { | ||
"twitch": "^4.4.8" | ||
"twitch": "^4.4.9" | ||
}, | ||
@@ -57,3 +57,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "d6566af624793c488cc896571e518518851e4d37" | ||
"gitHead": "cc8d1a9abc2f4964243f9669b90dffdf6c3a3bd3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
408124
10065
Updatedtwitch-auth@^4.4.9
Updatedtwitch-common@^4.4.9