Skip to content

Commit

Permalink
Preparing release 3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
queue-it committed Jan 24, 2022
1 parent 7cb528d commit af83813
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion QueueITHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const AKAMAI_SDK_VERSION = "3.0.4";
const AKAMAI_SDK_VERSION = "3.0.5";

export class QueueITHelper {

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 1 addition & 4 deletions akamaiContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -45,9 +45,6 @@ export class AkamaiContextProvider implements IConnectorContextProvider {
}

public getEnqueueTokenProvider() {
if (!this._enqueueTokenProvider) {
throw new Error('EnqueueTokenProvider is not set!');
}
return this._enqueueTokenProvider;
}

Expand Down
22 changes: 17 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
3 changes: 2 additions & 1 deletion sdk/queueit-knownuserv3-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit af83813

Please sign in to comment.