@queue-it/connector-javascript
Advanced tools
Comparing version 4.2.2 to 4.3.0
@@ -13,2 +13,3 @@ export declare class IntegrationConfigModel { | ||
QueueDomain: string; | ||
QueuePathPrefix?: string | null; | ||
RedirectLogic: string; | ||
@@ -15,0 +16,0 @@ ForcedTargetUrl: string; |
@@ -83,11 +83,12 @@ "use strict"; | ||
KnownUser.generateTargetUrl = function (originalTargetUrl, contextProvider) { | ||
return !this.isQueueAjaxCall(contextProvider) | ||
? originalTargetUrl | ||
: queueitHelpers_1.Utils.decodeUrl(contextProvider | ||
if (this.isQueueAjaxCall(contextProvider)) { | ||
var ajaxPageUrlHeader = contextProvider | ||
.getHttpRequest() | ||
.getHeader(this.QueueITAjaxHeaderKey)); | ||
.getHeader(this.QueueITAjaxHeaderKey); | ||
return queueitHelpers_1.Utils.decodeUrl(ajaxPageUrlHeader); | ||
} | ||
return originalTargetUrl; | ||
}; | ||
KnownUser.logExtraRequestDetails = function (debugEntries, contextProvider) { | ||
debugEntries["ServerUtcTime"] = | ||
new Date().toISOString().split(".")[0] + "Z"; | ||
debugEntries["ServerUtcTime"] = new Date().toISOString().split(".")[0] + "Z"; | ||
debugEntries["RequestIP"] = contextProvider | ||
@@ -120,4 +121,5 @@ .getHttpRequest() | ||
} | ||
if (!cookieValue) | ||
if (!cookieValue) { | ||
return; | ||
} | ||
contextProvider.getHttpResponse().setCookie(this.QueueITDebugKey, cookieValue, null, queueitHelpers_1.Utils.getCurrentTime() + 20 * 60, // now + 20 mins | ||
@@ -139,18 +141,25 @@ false, false); | ||
.getAbsoluteUri(); | ||
debugEntries["QueueConfig"] = | ||
queueConfig !== null ? queueConfig.getString() : "NULL"; | ||
debugEntries["QueueConfig"] = queueConfig !== null | ||
? queueConfig.getString() | ||
: "NULL"; | ||
this.logExtraRequestDetails(debugEntries, contextProvider); | ||
} | ||
if (!customerId) | ||
if (!customerId) { | ||
throw new models_1.ConnectorException("customerId can not be null or empty."); | ||
if (!secretKey) | ||
} | ||
if (!secretKey) { | ||
throw new models_1.ConnectorException("secretKey can not be null or empty."); | ||
if (!queueConfig) | ||
} | ||
if (!queueConfig) { | ||
throw new models_1.ConnectorException("queueConfig can not be null."); | ||
if (!queueConfig.eventId) | ||
} | ||
if (!queueConfig.eventId) { | ||
throw new models_1.ConnectorException("queueConfig.eventId can not be null or empty."); | ||
if (!queueConfig.queueDomain) | ||
} | ||
if (!queueConfig.queueDomain) { | ||
throw new models_1.ConnectorException("queueConfig.queueDomain can not be null or empty."); | ||
if (queueConfig.cookieValidityMinute <= 0) | ||
} | ||
if (queueConfig.cookieValidityMinute <= 0) { | ||
throw new models_1.ConnectorException("queueConfig.cookieValidityMinute should be integer greater than 0."); | ||
} | ||
userInQueueService = this.getUserInQueueService(contextProvider); | ||
@@ -173,4 +182,3 @@ return [4 /*yield*/, userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey, apiKey)]; | ||
debugEntries["QueueitToken"] = queueitToken; | ||
debugEntries["CancelConfig"] = | ||
cancelConfig !== null ? cancelConfig.getString() : "NULL"; | ||
debugEntries["CancelConfig"] = cancelConfig !== null ? cancelConfig.getString() : "NULL"; | ||
debugEntries["OriginalUrl"] = contextProvider | ||
@@ -181,14 +189,20 @@ .getHttpRequest() | ||
} | ||
if (!targetUrl) | ||
if (!targetUrl) { | ||
throw new models_1.ConnectorException("targetUrl can not be null or empty."); | ||
if (!customerId) | ||
} | ||
if (!customerId) { | ||
throw new models_1.ConnectorException("customerId can not be null or empty."); | ||
if (!secretKey) | ||
} | ||
if (!secretKey) { | ||
throw new models_1.ConnectorException("secretKey can not be null or empty."); | ||
if (!cancelConfig) | ||
} | ||
if (!cancelConfig) { | ||
throw new models_1.ConnectorException("cancelConfig can not be null."); | ||
if (!(((_a = cancelConfig.waitingRoomIds) === null || _a === void 0 ? void 0 : _a.length) > 0)) | ||
} | ||
if (!(((_a = cancelConfig.waitingRoomIds) === null || _a === void 0 ? void 0 : _a.length) > 0)) { | ||
throw new models_1.ConnectorException("cancelConfig.waitingRoomIds can not be null or empty."); | ||
if (!cancelConfig.queueDomain) | ||
} | ||
if (!cancelConfig.queueDomain) { | ||
throw new models_1.ConnectorException("cancelConfig.queueDomain can not be null or empty."); | ||
} | ||
var userInQueueService = this.getUserInQueueService(contextProvider); | ||
@@ -216,3 +230,3 @@ var result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey); | ||
} | ||
queueEventConfig = new models_1.QueueEventConfig(matchedConfig.EventId, matchedConfig.InvolvedWaitingRoomIds, matchedConfig.LayoutName, matchedConfig.Culture, matchedConfig.QueueDomain, matchedConfig.ExtendCookieValidity, matchedConfig.CookieValidityMinute, matchedConfig.CookieDomain, matchedConfig.IsCookieHttpOnly || false, matchedConfig.IsCookieSecure || false, customerIntegrationInfo.Version, matchedConfig.Name, matchedConfig.VerifyQueueIdEnabled, matchedConfig.QueueIdUsageLimit); | ||
queueEventConfig = new models_1.QueueEventConfig(matchedConfig.EventId, matchedConfig.InvolvedWaitingRoomIds, matchedConfig.LayoutName, matchedConfig.Culture, matchedConfig.QueueDomain, matchedConfig.QueuePathPrefix, matchedConfig.ExtendCookieValidity, matchedConfig.CookieValidityMinute, matchedConfig.CookieDomain, matchedConfig.IsCookieHttpOnly || false, matchedConfig.IsCookieSecure || false, customerIntegrationInfo.Version, matchedConfig.Name, matchedConfig.VerifyQueueIdEnabled, matchedConfig.QueueIdUsageLimit); | ||
return [4 /*yield*/, this._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueEventConfig, customerId, secretKey, contextProvider, debugEntries, isDebug, apiKey)]; | ||
@@ -225,3 +239,4 @@ case 1: return [2 /*return*/, _a.sent()]; | ||
KnownUser.handleCancelAction = function (currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, matchedConfig, contextProvider, debugEntries, isDebug) { | ||
var cancelEventConfig = new models_1.CancelEventConfig(queueitHelpers_1.Utils.concatenateWaitingRoomIds(matchedConfig.EventId, matchedConfig.InvolvedWaitingRoomIds), matchedConfig.QueueDomain, matchedConfig.CookieDomain, matchedConfig.IsCookieHttpOnly || false, matchedConfig.IsCookieSecure || false, customerIntegrationInfo.Version, matchedConfig.Name); | ||
var waitingRoomIds = queueitHelpers_1.Utils.concatenateWaitingRoomIds(matchedConfig.EventId, matchedConfig.InvolvedWaitingRoomIds); | ||
var cancelEventConfig = new models_1.CancelEventConfig(waitingRoomIds, matchedConfig.QueueDomain, matchedConfig.QueuePathPrefix, matchedConfig.CookieDomain, matchedConfig.IsCookieHttpOnly || false, matchedConfig.IsCookieSecure || false, customerIntegrationInfo.Version, matchedConfig.Name); | ||
var targetUrl = this.generateTargetUrl(currentUrlWithoutQueueITToken, contextProvider); | ||
@@ -237,8 +252,11 @@ return this._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelEventConfig, customerId, secretKey, contextProvider, debugEntries, isDebug); | ||
KnownUser.extendQueueCookie = function (eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey, contextProvider) { | ||
if (!eventId) | ||
if (!eventId) { | ||
throw new models_1.ConnectorException("eventId can not be null or empty."); | ||
if (!secretKey) | ||
} | ||
if (!secretKey) { | ||
throw new models_1.ConnectorException("secretKey can not be null or empty."); | ||
if (cookieValidityMinute <= 0) | ||
} | ||
if (cookieValidityMinute <= 0) { | ||
throw new models_1.ConnectorException("cookieValidityMinute should be integer greater than 0."); | ||
} | ||
var userInQueueService = this.getUserInQueueService(contextProvider); | ||
@@ -255,4 +273,5 @@ userInQueueService.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, secretKey); | ||
connectorDiagnostics = queueitHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken, contextProvider); | ||
if (connectorDiagnostics.hasError) | ||
if (connectorDiagnostics.hasError) { | ||
return [2 /*return*/, connectorDiagnostics.validationResult]; | ||
} | ||
_a.label = 1; | ||
@@ -266,4 +285,5 @@ case 1: | ||
e_1 = _a.sent(); | ||
if (connectorDiagnostics.isEnabled) | ||
if (connectorDiagnostics.isEnabled) { | ||
debugEntries["Exception"] = e_1.message; | ||
} | ||
throw e_1; | ||
@@ -286,4 +306,5 @@ case 4: | ||
connectorDiagnostics = queueitHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken, contextProvider); | ||
if (connectorDiagnostics.hasError) | ||
if (connectorDiagnostics.hasError) { | ||
return [2 /*return*/, connectorDiagnostics.validationResult]; | ||
} | ||
_b.label = 1; | ||
@@ -308,6 +329,8 @@ case 1: | ||
} | ||
if (!currentUrlWithoutQueueITToken) | ||
if (!currentUrlWithoutQueueITToken) { | ||
throw new models_1.ConnectorException("currentUrlWithoutQueueITToken can not be null or empty."); | ||
if (!customerIntegrationInfo || !customerIntegrationInfo.Version) | ||
} | ||
if (!customerIntegrationInfo || !customerIntegrationInfo.Version) { | ||
throw new models_1.ConnectorException("integrationsConfigString can not be null or empty."); | ||
} | ||
configEvaluator = new IntegrationConfigHelpers.IntegrationEvaluator(); | ||
@@ -320,4 +343,5 @@ matchedConfig = configEvaluator.getMatchedIntegrationConfig(customerIntegrationInfo, currentUrlWithoutQueueITToken, contextProvider.getHttpRequest()); | ||
} | ||
if (!matchedConfig) | ||
if (!matchedConfig) { | ||
return [2 /*return*/, new models_1.RequestValidationResult(null, null, null, null, null, null, null)]; | ||
} | ||
_a = matchedConfig.ActionType; | ||
@@ -344,4 +368,5 @@ switch (_a) { | ||
e_2 = _b.sent(); | ||
if (connectorDiagnostics.isEnabled) | ||
if (connectorDiagnostics.isEnabled) { | ||
debugEntries["Exception"] = e_2.message; | ||
} | ||
throw e_2; | ||
@@ -359,4 +384,5 @@ case 8: | ||
var connectorDiagnostics = queueitHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken, contextProvider); | ||
if (connectorDiagnostics.hasError) | ||
if (connectorDiagnostics.hasError) { | ||
return connectorDiagnostics.validationResult; | ||
} | ||
try { | ||
@@ -366,4 +392,5 @@ return this._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, contextProvider, debugEntries, connectorDiagnostics.isEnabled); | ||
catch (e) { | ||
if (connectorDiagnostics.isEnabled) | ||
if (connectorDiagnostics.isEnabled) { | ||
debugEntries["Exception"] = e.message; | ||
} | ||
throw e; | ||
@@ -370,0 +397,0 @@ } |
@@ -7,2 +7,3 @@ export declare class QueueEventConfig { | ||
queueDomain: string; | ||
queuePathPrefix: string; | ||
extendCookieValidity: boolean; | ||
@@ -17,3 +18,3 @@ cookieValidityMinute: number; | ||
queueIdUsageLimit: number | null; | ||
constructor(eventId: string, allowedWaitingRoomIds: Array<string>, layoutName: string, culture: string, queueDomain: string, extendCookieValidity: boolean, cookieValidityMinute: number, cookieDomain: string, isCookieHttpOnly: boolean, isCookieSecure: boolean, version: number, actionName: string, verifyActionEnabled: boolean, queueIdUsageLimit: number | null); | ||
constructor(eventId: string, allowedWaitingRoomIds: Array<string>, layoutName: string, culture: string, queueDomain: string, queuePathPrefix: string, extendCookieValidity: boolean, cookieValidityMinute: number, cookieDomain: string, isCookieHttpOnly: boolean, isCookieSecure: boolean, version: number, actionName: string, verifyActionEnabled: boolean, queueIdUsageLimit: number | null); | ||
getString(): string; | ||
@@ -24,2 +25,3 @@ } | ||
queueDomain: string; | ||
queuePathPrefix: string; | ||
cookieDomain: string; | ||
@@ -30,3 +32,3 @@ isCookieHttpOnly: boolean; | ||
actionName: string; | ||
constructor(waitingRoomIds: Array<string>, queueDomain: string, cookieDomain: string, isCookieHttpOnly: boolean, isCookieSecure: boolean, version: number, actionName?: string); | ||
constructor(waitingRoomIds: Array<string>, queueDomain: string, queuePathPrefix: string, cookieDomain: string, isCookieHttpOnly: boolean, isCookieSecure: boolean, version: number, actionName?: string); | ||
getString(): string; | ||
@@ -33,0 +35,0 @@ } |
@@ -6,3 +6,3 @@ "use strict"; | ||
var QueueEventConfig = /** @class */ (function () { | ||
function QueueEventConfig(eventId, allowedWaitingRoomIds, layoutName, culture, queueDomain, extendCookieValidity, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, version, actionName, verifyActionEnabled, queueIdUsageLimit) { | ||
function QueueEventConfig(eventId, allowedWaitingRoomIds, layoutName, culture, queueDomain, queuePathPrefix, extendCookieValidity, cookieValidityMinute, cookieDomain, isCookieHttpOnly, isCookieSecure, version, actionName, verifyActionEnabled, queueIdUsageLimit) { | ||
if (actionName === void 0) { actionName = "unspecified"; } | ||
@@ -15,2 +15,3 @@ if (verifyActionEnabled === void 0) { verifyActionEnabled = false; } | ||
this.queueDomain = queueDomain; | ||
this.queuePathPrefix = queuePathPrefix; | ||
this.extendCookieValidity = extendCookieValidity; | ||
@@ -25,2 +26,5 @@ this.cookieValidityMinute = cookieValidityMinute; | ||
this.queueIdUsageLimit = queueIdUsageLimit; | ||
if (!this.queuePathPrefix) { | ||
this.queuePathPrefix = ""; | ||
} | ||
} | ||
@@ -33,2 +37,3 @@ QueueEventConfig.prototype.getString = function () { | ||
"&QueueDomain:".concat(this.queueDomain) + | ||
(this.queuePathPrefix ? "&QueuePathPrefix:".concat(this.queuePathPrefix) : "") + | ||
"&CookieDomain:".concat(this.cookieDomain) + | ||
@@ -46,6 +51,7 @@ "&IsCookieHttpOnly:".concat(this.isCookieHttpOnly) + | ||
var CancelEventConfig = /** @class */ (function () { | ||
function CancelEventConfig(waitingRoomIds, queueDomain, cookieDomain, isCookieHttpOnly, isCookieSecure, version, actionName) { | ||
function CancelEventConfig(waitingRoomIds, queueDomain, queuePathPrefix, cookieDomain, isCookieHttpOnly, isCookieSecure, version, actionName) { | ||
if (actionName === void 0) { actionName = "unspecified"; } | ||
this.waitingRoomIds = waitingRoomIds; | ||
this.queueDomain = queueDomain; | ||
this.queuePathPrefix = queuePathPrefix; | ||
this.cookieDomain = cookieDomain; | ||
@@ -56,2 +62,5 @@ this.isCookieHttpOnly = isCookieHttpOnly; | ||
this.actionName = actionName; | ||
if (!this.queuePathPrefix) { | ||
this.queuePathPrefix = ""; | ||
} | ||
} | ||
@@ -62,2 +71,3 @@ CancelEventConfig.prototype.getString = function () { | ||
"&QueueDomain:".concat(this.queueDomain) + | ||
(this.queuePathPrefix ? "&QueuePathPrefix:".concat(this.queuePathPrefix) : "") + | ||
"&CookieDomain:".concat(this.cookieDomain) + | ||
@@ -64,0 +74,0 @@ "&IsCookieHttpOnly:".concat(this.isCookieHttpOnly) + |
@@ -62,6 +62,8 @@ "use strict"; | ||
queueItTokenParam + | ||
"&ts=".concat(queueitHelpers_1.Utils.getCurrentTime()) + | ||
(targetUrl ? "&t=".concat(queueitHelpers_1.Utils.encodeUrl(targetUrl)) : ""); | ||
"&ts=".concat(queueitHelpers_1.Utils.getCurrentTime()); | ||
if (targetUrl) { | ||
query += "&t=".concat(queueitHelpers_1.Utils.encodeUrl(targetUrl)); | ||
} | ||
var uriPath = "error/".concat(errorCode, "/"); | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, uriPath, query); | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, config.queuePathPrefix, uriPath, query); | ||
return new models_1.RequestValidationResult(models_1.ActionTypes.QueueAction, config.eventId, config.allowedWaitingRoomIds, null, redirectUrl, null, config.actionName); | ||
@@ -74,4 +76,7 @@ }; | ||
.getEnqueueTokenProvider()) === null || _a === void 0 ? void 0 : _a.getEnqueueToken(config.eventId)); | ||
var query = this.getQueryString(customerId, config.eventId, config.version, config.culture, config.layoutName, config.actionName, null, enqueueToken) + (targetUrl ? "&t=" + queueitHelpers_1.Utils.encodeUrl(targetUrl) : ""); | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, "", query); | ||
var query = this.getQueryString(customerId, config.eventId, config.version, config.culture, config.layoutName, config.actionName, null, enqueueToken); | ||
if (targetUrl) { | ||
query += "&t=".concat(queueitHelpers_1.Utils.encodeUrl(targetUrl)); | ||
} | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, config.queuePathPrefix, "", query); | ||
return new models_1.RequestValidationResult(models_1.ActionTypes.QueueAction, config.eventId, config.allowedWaitingRoomIds, null, redirectUrl, null, config.actionName); | ||
@@ -100,6 +105,13 @@ }; | ||
}; | ||
UserInQueueService.prototype.generateRedirectUrl = function (queueDomain, uriPath, query) { | ||
if (!queueitHelpers_1.Utils.endsWith(queueDomain, "/")) | ||
queueDomain = queueDomain + "/"; | ||
return "https://".concat(queueDomain).concat(uriPath, "?").concat(query); | ||
UserInQueueService.prototype.generateRedirectUrl = function (queueDomain, queuePathPrefix, uriPath, query) { | ||
if (!queueitHelpers_1.Utils.endsWith(queueDomain, "/")) { | ||
queueDomain += "/"; | ||
} | ||
if (queuePathPrefix.startsWith("/")) { | ||
queuePathPrefix = queuePathPrefix.substring(1); | ||
} | ||
if (queuePathPrefix && !queueitHelpers_1.Utils.endsWith(queuePathPrefix, "/")) { | ||
queuePathPrefix += "/"; | ||
} | ||
return "https://".concat(queueDomain).concat(queuePathPrefix).concat(uriPath, "?").concat(query); | ||
}; | ||
@@ -214,4 +226,6 @@ UserInQueueService.prototype.validateQueueRequest = function (targetUrl, queueitToken, config, customerId, secretKey, apiKey) { | ||
}); | ||
query_1 += targetUrl ? "&r=" + queueitHelpers_1.Utils.encodeUrl(targetUrl) : ""; | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, uriPath, query_1); | ||
if (targetUrl) { | ||
query_1 += "&r=".concat(queueitHelpers_1.Utils.encodeUrl(targetUrl)); | ||
} | ||
var redirectUrl = this.generateRedirectUrl(config.queueDomain, config.queuePathPrefix, uriPath, query_1); | ||
return new models_1.RequestValidationResult(models_1.ActionTypes.CancelAction, null, config.waitingRoomIds, state.queueId, redirectUrl, state.redirectType, config.actionName); | ||
@@ -325,3 +339,3 @@ } | ||
}; | ||
UserInQueueService.SDK_VERSION = "javascript-" + "4.2.2"; | ||
UserInQueueService.SDK_VERSION = "javascript-" + "4.3.0"; | ||
return UserInQueueService; | ||
@@ -328,0 +342,0 @@ }()); |
{ | ||
"name": "@queue-it/connector-javascript", | ||
"version": "4.2.2", | ||
"version": "4.3.0", | ||
"description": "Connector to integrate Queue-it into a javascript based server side application.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
277977
4166