From af838131ee1f2cd3d135f62fa2303f4070adc1de Mon Sep 17 00:00:00 2001 From: queue-it Date: Mon, 24 Jan 2022 15:35:16 +0000 Subject: [PATCH] Preparing release 3.0.5 --- QueueITHelpers.ts | 2 +- README.md | 2 +- akamaiContextProvider.ts | 5 +---- main.ts | 22 +++++++++++++++++----- package.json | 4 ++-- sdk/queueit-knownuserv3-sdk.js | 3 ++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/QueueITHelpers.ts b/QueueITHelpers.ts index 33af01d..6be7d5d 100644 --- a/QueueITHelpers.ts +++ b/QueueITHelpers.ts @@ -1,5 +1,5 @@ -const AKAMAI_SDK_VERSION = "3.0.4"; +const AKAMAI_SDK_VERSION = "3.0.5"; export class QueueITHelper { diff --git a/README.md b/README.md index 4e7c680..c009f7c 100644 --- a/README.md +++ b/README.md @@ -177,4 +177,4 @@ A token could be used for queueing the users. This makes it even more protected. To use the EnqueueToken follow the below steps: - The waiting room should be configured to accept this token. This configuration could be made in Queue-it Go platform. -- SHOULD_INCLUDE_ENQUEUETOKEN variable should be set to ```true``` in the ```main.js``` file. +- SHOULD_INCLUDE_ENQUEUETOKEN variable should be set to ```true``` in the ```main.js``` file. \ No newline at end of file diff --git a/akamaiContextProvider.ts b/akamaiContextProvider.ts index 67def22..7dca05a 100644 --- a/akamaiContextProvider.ts +++ b/akamaiContextProvider.ts @@ -28,7 +28,7 @@ export class AkamaiContextProvider implements IConnectorContextProvider { public setEnqueueTokenProvider( setting: Settings, validityTime: Number, - clientIp?: string, + clientIp: string, customData?: any) { if (!setting || validityTime < -1) { @@ -45,9 +45,6 @@ export class AkamaiContextProvider implements IConnectorContextProvider { } public getEnqueueTokenProvider() { - if (!this._enqueueTokenProvider) { - throw new Error('EnqueueTokenProvider is not set!'); - } return this._enqueueTokenProvider; } diff --git a/main.ts b/main.ts index 75eac2b..a9fab0c 100644 --- a/main.ts +++ b/main.ts @@ -15,9 +15,14 @@ const QUEUEIT_CONNECTOR_EXECUTED_HEADER_NAME = 'x-queueit-connector'; const QUEUEIT_FAILED_HEADERNAME = 'x-queueit-failed'; const QUEUEIT_CONNECTOR_NAME = "akamai"; const SHOULD_IGNORE_OPTIONS_REQUESTS = false; +const SHOULD_INCLUDE_ENQUEUETOKEN = false; +const EXECUTED_VARIABLE_NAME = 'PMUSER_QUEUEIT_EXECUTED'; export async function onClientRequest(request) { try { + // Set PMUSER variable to allow validation that EdgeWorker was executed + request.setVariable(EXECUTED_VARIABLE_NAME, 'true'); + if (isIgnored(request)) { return; } @@ -32,11 +37,14 @@ export async function onClientRequest(request) { } }); const settings = QueueITHelper.getSettingsFromPMVariables(request); - httpContext.setEnqueueTokenProvider( - settings, - 60000, - httpContext.getHttpRequest().getUserHostAddress() - ); + + if (includeEnqueueToken()) { + httpContext.setEnqueueTokenProvider( + settings, + 60000, + httpContext.getHttpRequest().getUserHostAddress() + ); + } let { queueitToken, requestUrlWithoutToken, validationResult } = await validateRequest(httpContext, settings); @@ -134,6 +142,10 @@ function isIgnored(request) { return SHOULD_IGNORE_OPTIONS_REQUESTS && request.method === 'OPTIONS'; } +function includeEnqueueToken() { + return SHOULD_INCLUDE_ENQUEUETOKEN; +} + async function getQueueItToken(httpContext, requestUrl: string) { let queueitToken = QueueITHelper.getParameterByName(KnownUser.QueueITTokenKey, requestUrl); if (queueitToken) { diff --git a/package.json b/package.json index ae48ff0..5735f28 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,11 @@ "repository": "https://github.com/queueit/KnownUser.V3.Akamai", "license": "MIT", "main": "./dist/index.js", - "version": "3.0.4", + "version": "3.0.5", "type": "module", "scripts": {}, "dependencies": { - "queueit-knownuser": "^3.7.8", + "queueit-knownuser": "^3.7.9", "@queue-it/queue-token": "~1.0.2" }, "devDependencies": {}, diff --git a/sdk/queueit-knownuserv3-sdk.js b/sdk/queueit-knownuserv3-sdk.js index 6e2febf..3fab026 100644 --- a/sdk/queueit-knownuserv3-sdk.js +++ b/sdk/queueit-knownuserv3-sdk.js @@ -879,8 +879,9 @@ var UserInQueueService = /** @class */ (function () { return new Models_1.RequestValidationResult(Models_1.ActionTypes.QueueAction, config.eventId, null, redirectUrl, null, config.actionName); }; UserInQueueService.prototype.getQueueResult = function (targetUrl, config, customerId) { + var _a; var enqueueToken = this.contextProvider.getEnqueueTokenProvider - && this.contextProvider.getEnqueueTokenProvider().getEnqueueToken(config.eventId); + && ((_a = this.contextProvider.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);