From cee5ec6990f226129d9c9f72eea20f3b338b76fb Mon Sep 17 00:00:00 2001 From: Vasil Date: Tue, 16 Nov 2021 21:19:02 +0100 Subject: [PATCH] Cleanup --- .gitconfig | 40 - .gulp.json | 5 - README.md | 37 +- gulpfile.cjs | 75 -- package.json | 18 - src/akamaiHttpContextProvider.js | 60 -- src/bundle.json | 4 - src/integrationConfigProvider.js | 46 -- src/lib/edgekv.js | 251 ------- src/lib/edgekv_tokens.js | 7 - src/lib/sha256.js | 504 ------------- src/main.js | 123 --- src/queueitHelpers.js | 58 -- src/sdk/queueitknownuser.bundle.js | 1113 ---------------------------- 14 files changed, 28 insertions(+), 2313 deletions(-) delete mode 100644 .gitconfig delete mode 100644 .gulp.json delete mode 100644 gulpfile.cjs delete mode 100644 src/akamaiHttpContextProvider.js delete mode 100644 src/bundle.json delete mode 100644 src/integrationConfigProvider.js delete mode 100644 src/lib/edgekv.js delete mode 100644 src/lib/edgekv_tokens.js delete mode 100644 src/lib/sha256.js delete mode 100644 src/main.js delete mode 100644 src/queueitHelpers.js delete mode 100644 src/sdk/queueitknownuser.bundle.js diff --git a/.gitconfig b/.gitconfig deleted file mode 100644 index 2316c60..0000000 --- a/.gitconfig +++ /dev/null @@ -1,40 +0,0 @@ -[merge] - tool = kdiff3 - guitool = kdiff3 -[diff] - guitool = kdiff3 - tool = vsdiffmerge -[core] - editor = \"F:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor - autocrlf = false -[user] - name = Vasil - email = vava@queue-it.com -[pull] - rebase = false -[fetch] - prune = false -[rebase] - autoStash = false -[winUpdater] - recentlySeenVersion = 2.26.1.windows.1 -[mergetool "kdiff3"] - path = C:/Program Files/KDiff3/kdiff3.exe - cmd = \"C:/Program Files/KDiff3/kdiff3.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\" -[difftool "kdiff3"] - path = C:/Program Files/KDiff3/kdiff3.exe - cmd = \"C:/Program Files/KDiff3/kdiff3.exe\" \"$LOCAL\" \"$REMOTE\" -[url "git@git.smartmodule.net:"] - insteadOf = https://git.smartmodule.net/ -[difftool] - prompt = true -[difftool "vsdiffmerge"] - cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t - keepBackup = false -[filter "lfs"] - clean = git-lfs clean -- %f - smudge = git-lfs smudge -- %f - process = git-lfs filter-process - required = true -[credential] - helper = "!f() { /root/.vscode-server/bin/2b9aebd5354a3629c3aba0a5f5df49f43d6689f8/node /tmp/vscode-remote-containers-9669530c1ddca4fa7b1438b95129151b954035ef.js $*; }; f" diff --git a/.gulp.json b/.gulp.json deleted file mode 100644 index 4ae4cb8..0000000 --- a/.gulp.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "flags": { - "gulpfile": "gulpfile.cjs" - } -} \ No newline at end of file diff --git a/README.md b/README.md index bf19bcb..e7356ae 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # KnownUser.V3.Akamai + The Queue-it Security Framework ensures that end-users are not able to access your online application without first going through the queue for any and all “protected” areas and paths on your sites. The queue system is implemented by adding a server-side (request-level) integration that protects your online application by redirecting users to a waiting room according to web traffic settings in the Queue-it GO Platform. After the integration is complete, queue system behavior and operations are managed in Queue-it’s Go Platform and/or via the Queue-it Admin API. -This Akamai Queue-it Connector SDK (aka, Queue-it’s server-side KnownUser connector) uses Akamai Edge Workers to integrate Queue-it functionality into Akamai’s CDN network. +This Akamai Queue-it Connector SDK (aka, Queue-it’s server-side KnownUser connector) uses Akamai Edge Workers to integrate Queue-it functionality into Akamai’s CDN network. A subscription / access to Akamai Edge Workers is required to utilize this connector, and Akamai resources and professional services should be consulted. @@ -18,9 +19,11 @@ A subscription / access to Akamai Edge Workers is required to utilize this conne 6. The user browses to a new page and the presence of a valid Queue-it session cookie prevent a return to the queue ## Installation + ### Note: EdgeWorker should be created using the Dynamic Compute resource tier. + Installing the edge worker the first time requires uploading an archive file (TGZ format) to the Edge Worker manager in the Akamai Control Center. Once uploaded, the service worker code can be customized and updated with specific configurations (protection schema) managed and exported from the Queue-it GO Platform. - - Step 1: Download all js files plus bundle.json and create bundle and upload to Akamai Edge Worker manager ** + - Step 1: Download all ts(or the released tar.gz) files and bundle.json and create bundle and upload to Akamai Edge Worker manager ** - Step 2: Create desired waiting room(s), triggers, and actions in GO. Then, save/publish the Configuration. - Step 3: Provide integration config by implementing one of the following methods. - 3.1 Manually updating integration config within Edge worker code @@ -41,27 +44,32 @@ Installing the edge worker the first time requires uploading an archive file (TG ** https://learn.akamai.com/en-us/webhelp/edgeworkers/edgeworkers-user-guide/GUID-53F43F70-BEBC-4BA4-A2FB-3F23A6125106.html ### Providing the queue configuration -The configuration specifies a set of Triggers and Actions. A Trigger is an expression matching one, more or all URLs on your website. -When a user enter your website and the URL matches a Trigger-expression the corresponding Action will be triggered. + +The configuration specifies a set of Triggers and Actions. A Trigger is an expression matching one, more or all URLs on your website. +When a user enter your website and the URL matches a Trigger-expression the corresponding Action will be triggered. The Action specifies which queue the users should be send to. In this way you can specify which queue(s) should protect which page(s) on the fly without changing the server-side integration. This configuration can then be used in Edge Worker by three ways. ### 3.1 Manually updating integration config within Edge worker code + Latest integration config can be downloaded from GO Queue-it Platform and then updated by replacing "inlineIntegrationConfig" variable value in integrationConfigProvider.js file. To use the inline integration config, set 'QUEUEIT_CONFIG_TYPE' queue-it variable value to 'inline' in Akamai property manager. ### 3.2 Dynamically download and cache integration config -#### NOTE: If you are deploying to a staging environment that has an IP-filter applied, make sure to whitelist the path to the integration config, so the IP-filter doesn’t apply. Otherwise, the Queue-it Edge Worker will be blocked from accessing the configuration path. + +#### NOTE: If you are deploying to a staging environment that has an IP-filter applied, make sure to whitelist the path to the integration config, so the IP-filter doesn’t apply. Otherwise, the Queue-it Edge Worker will be blocked from accessing the configuration path. Integration config can be downloaded by calling Queue-IT API endpoint and then cached in Akamai network. In Akamai property manager, set variables 'PMUSER_QUEUEIT_CONFIG_TYPE' to 'cache' and 'PMUSER_QUEUEIT_API_KEY' to your API key. Configure the following Akamai property rules by setting the criteria, out going request path and caching behavior to download and cache the integration config. #### Edgeworker rule + Define edgeworker rule in Akamai property and set criteria as illustrated in picture. ![Edge worker criteria](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/edgeworkerCriteria.PNG) #### Download integration config rule + Define property rule to download integration config and add following configuration illustrated in the pictures. ![Download integration config criteria](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/integrationConfigDownloadCriteria.PNG) @@ -73,6 +81,7 @@ Define property rule to download integration config and add following configurat ![Download integration config cache](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/integrationConfigCache.png) ### 3.3 Push integration config to Akamai EdgeKV + Before you start using Akamai edgekv to store and fetch integration config, make sure that you have entitlements for both EdgeKV products on contract. Integration config can be pushed and stored in Akamai EdgeKV from GO Queue-it Platform. Connector can fetch stored integration config from Edgekv by setting the 'PMUSER_QUEUEIT_CONFIG_TYPE' variable to 'edgekv' in Akamai property manager. Apply the following steps to setup and use integration config from EdgeKV in the connector. @@ -80,13 +89,15 @@ Integration config can be pushed and stored in Akamai EdgeKV from GO Queue-it Pl - Download Akamai client credentials and these credential will be used to complete the following step in GO Queue-it Platform. - Update and publish integration config in GO Queue-it Platform. - Generate Akamai EdgeKV token from GO Queue-it Platform and copy into 'lib/edgekv_tokens.js' file in the connector code. -- Push integration config to Akamai EdgeKV from GO Queue-it Platform. +- Push integration config to Akamai EdgeKV from GO Queue-it Platform. #### Assign roles and permissions + You need to assign roles to create and manage access to EdgeKV in Akamai Control Center. Administrator can add individual users, then create and assign roles and access rights. You can find detailed instructions for managing users, roles, and permissions in the Akamai Identity and Access Management online help. #### Set up authentication for an API client: + - Create an API client with the necessary credential for a single Control Center account. This credential applies to all APIs for all products you currently have access to with that Control Center account. - Launch Identity and Access Management. In Control Center, you can navigate there by selecting → ACCOUNT ADMIN → Identity & access. - From the Users and API Clients tab, click New API client for me to open the Customize API client screen. @@ -96,7 +107,8 @@ Administrator can add individual users, then create and assign roles and access ![Akamai API Client](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/AkamaiAPIClient.PNG) #### Generate API client credentials -To make EdgeKV API calls over the Akamai network, you first need to generate API credentials. + +To make EdgeKV API calls over the Akamai network, you first need to generate API credentials. - To use EdgeKV management APIs or the Edge KV CLI, the API credentials need to be created using the Admin role. - To add permissions to your API credentials go to the Account Admin > Identity & access section in Akamai Control Center. @@ -106,16 +118,18 @@ To make EdgeKV API calls over the Akamai network, you first need to generate API - Select the EdgeKV API. - Select READ-WRITE from the Access Level dropdown and submit your changes. - Download the credentials from API client page in Akamai control center - + ![Access Level Edgekv API](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/accessLevelEdgekvAPI.PNG) #### Akamai Settings in Go Queue-IT Platform -EdgeKV API host url is required to store integration config and generate the EdgeKV token for edgeworker. Add host url in 'Web End Point' field on Integration => Overview => Settings page. + +EdgeKV API host url is required to store integration config and generate the EdgeKV token for edgeworker. Add host url in 'Web End Point' field on Integration => Overview => Settings page. You can find Akamai host url from API client page in Akamai control center. ![Akamai Host Settings](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/AkamaiHostSettings.PNG) #### Generate EdgeKV token + Queue-IT connector needs Akamai EdgeKV API token to get integration config from EdgeKV. The token can also be generated using Akamai EdgeKV CLI/API. GO Queue-it Platform also has functionality to generate and retrieve EdgeKV tokens on a button click which reduce the complexity of using Akamai API/Cli. Currently, it is only possible to generate one token to use in both environments (staging/production). Default life time of the token is 6 months if generated from GO Queue-it Platform. Generate or retrieve the Akamai EdgeKV tokens by providing the required information in GO Queue-it Platform (on integration overview page). ##### Important Note: Remember to generate new token before existing one expires and update the 'lib/edgekv_tokens.js' file. @@ -124,11 +138,13 @@ Queue-IT connector needs Akamai EdgeKV API token to get integration config from ![Generate token](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/AkamaiGenerateToken.PNG) #### Push integration config + Integration config can be pushed to Akamai EdgeKV from GO Queue-it Platform by providing Akamai client credentials and environment. This process will initialize the EdgeKV if it is not initialized and then create namespace "QueueIT", group "integrations" and item "integrationConfig" in EdgeKV to store integration config. Following picture shows the required information to push the integration config. ![Akamai Push Config Form](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/AkamaiPushConfigForm.PNG) #### Update token in edgeworker bundle + Copy the valid token name and value from GO Queue-it Platform and update 'lib/edgekv_tokens.js' file in Edgeworker code bundle to get integration config from EdgeKV. Edgekv library will use this token to authenticate the request from edgeworker. ``` @@ -142,6 +158,7 @@ export { edgekv_access_tokens }; ``` ### QueueIT variables + To integrate with QueueIT Akamai connector it is required to define queueit variables in your Akamai property. These variables should be named as 'PMUSER_QUEUEIT_CUSTOMERID', 'PMUSER_QUEUEIT_CONFIG_TYPE', 'PMUSER_QUEUEIT_SECRET_KEY', 'PMUSER_QUEUEIT_API_KEY' and of type **Hidden** in Akamai property manager. The following table describes the options for variable values. @@ -154,11 +171,13 @@ and of type **Hidden** in Akamai property manager. The following table describes | PMUSER_QUEUEIT_API_KEY | If 'PMUSER_QUEUEIT_CONFIG_TYPE' is set to cache | Find your Api key in the GO Queue-it Platform. | ### Adding a Site Failover behaviour + After the EdgeWokrewr behaviour you need to add a Site Failover to do a retry if EW fails. ![Site Failover Behaviour](https://github.com/queueit/KnownUser.V3.Akamai/blob/main/failover.PNG) ## Protecting AJAX calls + If you need to protect AJAX calls beside page loads you need to add the below JavaScript tags to your pages: ``` diff --git a/gulpfile.cjs b/gulpfile.cjs deleted file mode 100644 index 92646db..0000000 --- a/gulpfile.cjs +++ /dev/null @@ -1,75 +0,0 @@ -const {src, dest} = require("gulp"); -const tar = require('gulp-tar'); -const gzip = require('gulp-gzip'); -const modifyFile = require('gulp-modify-file'); -const path = require('path') - -function addExports(content) { - content = "var exportObject = {};\n" + content; - content += ` -var Utils = exportObject.Utils; -var KnownUser = exportObject.KnownUser; -export { KnownUser, Utils };`; - const lastPropertyDefinition = content.lastIndexOf('Object.defineProperty('); - const newLine = content.indexOf('\n', lastPropertyDefinition); - const firstPart = content.substring(0, newLine); - const secondPart = content.substring(newLine + 1); - return firstPart + ` - exportObject.KnownUser = KnownUser_1.KnownUser; - exportObject.Utils = QueueITHelpers_1.Utils; - ` + secondPart; -} - -exports.packageArtifacts = () => { - return src([ - 'bundle.json', - 'outDir/*.js', - 'outDir/**/*.js' - ]) - .pipe(modifyFile((content, filePath, _) => { - let filename = path.basename(filePath); - if (filename !== 'queueit-knownuserv3-sdk.js') { - return content; - } - content = addExports(content); - return content; - })) - .pipe(tar('kuedge.tar')) - .pipe(gzip()) - .pipe(dest('dist')); -} - -exports.prepare = ()=>{ - return src([ - 'sdk/*.js' - ]) - .pipe(modifyFile((content, filePath, _) => { - let filename = path.basename(filePath); - if (filename !== 'queueit-knownuserv3-sdk.js') { - return content; - } - content = addExports(content); - return content; - })) - .pipe(dest('outDir/sdk')); -} - -exports.packageForDeployment = () => { - return src([ - 'bundle.json', - 'edgegrid.edgerc', - 'outDir/*.js', - 'outDir/**/*.js' - ]) - .pipe(modifyFile((content, filePath, _) => { - let filename = path.basename(filePath); - if (filename !== 'queueit-knownuserv3-sdk.js') { - return content; - } - content = addExports(content); - return content; - })) - .pipe(tar('kuedge.deployment.tar')) - .pipe(gzip()) - .pipe(dest('dist')); -} diff --git a/package.json b/package.json index a7753a6..b55fe7c 100644 --- a/package.json +++ b/package.json @@ -6,29 +6,11 @@ "version": "3.0.1", "type": "module", "scripts": { - "postinstall": "postinstall", - "prepare": "postinstall && gulp prepare", - "build": "tsc && gulp packageForDeployment", - "buildArtifacts": "tsc && gulp packageArtifacts", - "serve": "gulp prepare && node --loader esm-fake-loader test/testServer.mjs" }, "dependencies": { "queueit-knownuser": "^3.7.4" }, "devDependencies": { - "@types/node": "^14.17.32", - "browserify": "^17.0.0", - "esm-fake-loader": "^1.3.12", - "fast-sha256": "^1.3.0", - "gulp": "^4.0.2", - "gulp-gzip": "^1.4.2", - "gulp-modify-file": "^1.0.1", - "gulp-tar": "^3.1.0", - "node-fetch": "^3.0.0", - "postinstall": "^0.7.4", - "postinstall-browserify": "^0.7.1", - "ts-node": "^10.4.0", - "typescript": "^4.4.4" }, "prepare": { "queueit-knownuser/dist/index.js": { diff --git a/src/akamaiHttpContextProvider.js b/src/akamaiHttpContextProvider.js deleted file mode 100644 index 879313d..0000000 --- a/src/akamaiHttpContextProvider.js +++ /dev/null @@ -1,60 +0,0 @@ -/// -import { Cookies } from 'cookies'; -export class AkamaiHttpContextProvider { - constructor(akamiNativeRequest, akamaiNativeResponse) { - this._httpRequest = new AkamaiHttpRequest(akamiNativeRequest); - this._httpResponse = new AkamaiHttpResponse(akamaiNativeResponse); - } - getHttpRequest() { - return this._httpRequest; - } - getHttpResponse() { - return this._httpResponse; - } -} -class AkamaiHttpRequest { - constructor(_akamiNativeRequest) { - this._akamiNativeRequest = _akamiNativeRequest; - } - getUserAgent() { - return this.getHeader("user-agent"); - } - getHeader(headerNameArg) { - return (this._akamiNativeRequest.getHeader(headerNameArg) || []).toString(); - } - getAbsoluteUri() { - return `${this._akamiNativeRequest.scheme}://${this._akamiNativeRequest.host}${this._akamiNativeRequest.url}`; - } - getUserHostAddress() { - return this._akamiNativeRequest.getVariable('PMUSER_TRUE_CLIENT_IP'); - } - getCookieValue(cookieKey) { - try { - let cookies = new Cookies(this._akamiNativeRequest.getHeader('Cookie')); - let cookieValue = cookies.get(cookieKey); - if (cookieValue) - return decodeURIComponent(cookieValue); - } - catch (_a) { - return undefined; - } - } - getRequestBodyAsString() { - return ""; - } -} -class AkamaiHttpResponse { - constructor(_akamiNativeRequest) { - this._akamiNativeRequest = _akamiNativeRequest; - } - setCookie(cookieName, cookieValue, domain, expiration) { - // expiration is in secs, but Date needs it in milisecs - let expirationDate = new Date(expiration * 1000); - var setCookieString = `${cookieName}=${encodeURIComponent(cookieValue)}; expires=${expirationDate.toUTCString()};`; - if (domain) { - setCookieString += ` domain=${domain};`; - } - setCookieString += " path=/"; - this._akamiNativeRequest.storeCookie(setCookieString); - } -} diff --git a/src/bundle.json b/src/bundle.json deleted file mode 100644 index 96c53c8..0000000 --- a/src/bundle.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "edgeworker-version": "1.0", - "description" : "Queue-it Akamai Connector" -} diff --git a/src/integrationConfigProvider.js b/src/integrationConfigProvider.js deleted file mode 100644 index a834f1b..0000000 --- a/src/integrationConfigProvider.js +++ /dev/null @@ -1,46 +0,0 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -/*INLINE config*/ -const inlineIntegrationConfig = 'IF YOU ARE USING INLINE CONFIGURATION: GET YOUR INTEGRATION CONFIG IN JSON FORMAT FROM GO QUEUE-IT PLATFORM AND PASTE IT HERE'; -/*INLINE config*/ -import { httpRequest } from 'http-request'; -import { EdgeKV } from './lib/edgekv.js'; -export { IntegrationConfigProvider }; -class IntegrationConfigProvider { -} -IntegrationConfigProvider.getIntegrationConfig = function (configType, apiKey) { - return __awaiter(this, void 0, void 0, function* () { - switch (configType.toLowerCase()) { - case 'inline': - return inlineIntegrationConfig; - case 'cache': - return IntegrationConfigProvider.getIntegrationConfigFromCache(apiKey); - case 'edgekv': - return IntegrationConfigProvider.getIntegrationConfigFromEdgeKV(); - } - return ''; - }); -}; -IntegrationConfigProvider.getIntegrationConfigFromCache = function (apiKey) { - return __awaiter(this, void 0, void 0, function* () { - const options = {}; - options.method = "GET"; - options.headers = { "api-key": apiKey }; - options.timeout = 950; - return (yield httpRequest("/queueit/integrationconfig/", options)).text(); - }); -}; -IntegrationConfigProvider.getIntegrationConfigFromEdgeKV = function () { - return __awaiter(this, void 0, void 0, function* () { - let edgeKV = new EdgeKV("QueueIT", "integrations"); - let result = yield edgeKV.requestHandlerTemplate(() => edgeKV.getRequest({ namespace: 'QueueIT', group: 'integrations', item: 'integrationConfig' }), (response) => response.text(), (response) => __awaiter(this, void 0, void 0, function* () { return yield edgeKV.streamText(response.body); }), "GET JSON string", null); - return result; - }); -}; diff --git a/src/lib/edgekv.js b/src/lib/edgekv.js deleted file mode 100644 index 4474a10..0000000 --- a/src/lib/edgekv.js +++ /dev/null @@ -1,251 +0,0 @@ -/* -(c) Copyright 2020 Akamai Technologies, Inc. Licensed under Apache 2 license. -Version: 0.2 -Purpose: Provide a helper class to simplify the interaction with EdgeKV in an EdgeWorker. -Repo: https://github.com/akamai/edgeworkers-examples/tree/master/edgekv/lib -*/ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to set private field on non-instance"); - } - privateMap.set(receiver, value); - return value; -}; -var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) { - if (!privateMap.has(receiver)) { - throw new TypeError("attempted to get private field on non-instance"); - } - return privateMap.get(receiver); -}; -var _namespace, _group, _edgekv_uri, _token_override; -import { TextDecoderStream } from 'text-encode-transform'; -import { WritableStream } from 'streams'; -import { httpRequest } from 'http-request'; -/** - * You must include edgekv_tokens.js in your bundle for this class to function properly. - * edgekv_tokens.js must include all namespaces you are going to use in the bundle. - */ -import { edgekv_access_tokens } from './edgekv_tokens.js'; -export class EdgeKV { - /** - * Constructor to allow setting default namespace and group - * These defaults can be overriden when making individual GET, PUT, and DELETE operations - * @param {string} [namespace] the default namespace to use for all GET, PUT, and DELETE operations - * Namespace must be 32 characters or less, consisting of A-Z a-z 0-9 _ or - - * @param {string} [group] the default group to use for all GET, PUT, and DELETE operations - * Group must be 128 characters or less, consisting of A-Z a-z 0-9 _ or - - */ - constructor(namespace = "default", group = "default") { - _namespace.set(this, void 0); - _group.set(this, void 0); - _edgekv_uri.set(this, void 0); - _token_override.set(this, void 0); - if (typeof namespace === "object") { - __classPrivateFieldSet(this, _namespace, namespace.namespace || "default"); - __classPrivateFieldSet(this, _group, namespace.group || "default"); - __classPrivateFieldSet(this, _edgekv_uri, namespace.edgekv_uri || "https://edgekv.akamai-edge-svcs.net"); - __classPrivateFieldSet(this, _token_override, namespace.token_override || null); - } - else { - __classPrivateFieldSet(this, _namespace, namespace); - __classPrivateFieldSet(this, _group, group); - __classPrivateFieldSet(this, _edgekv_uri, "https://edgekv.akamai-edge-svcs.net"); - __classPrivateFieldSet(this, _token_override, null); - } - } - throwError(message, status, text) { - throw { - failed: message, - status: status, - body: text, - toString: function () { return JSON.stringify(this); } - }; - } - requestHandlerTemplate(response_provider, handler_200, handler_large_200, error_text, default_value) { - return __awaiter(this, void 0, void 0, function* () { - try { - let response = yield response_provider(); - switch (response.status) { - case 200: - // need to handle content length > 128000 bytes differently in EdgeWorkers - let contentLength = response.getHeader('Content-Length'); - if (!contentLength || contentLength.length == 0 || contentLength[0] >= 128000) { - return handler_large_200(response); - } - else { - return handler_200(response); - } - case 404: - return default_value; - default: - let text = ""; - try { - text = yield response.text(); - } - catch (error) { } - this.throwError(error_text, response.status, text); - } - } - catch (error) { - this.throwError(error_text + " FAILED", 0, error.toString()); - } - }); - } - validate({ namespace = null, group = null, item = null }) { - if (namespace && !/^[A-Za-z0-9_-]{1,32}$/.test(namespace)) { - throw "Namespace is not valid. Must be 32 characters or less, consisting of A-Z a-z 0-9 _ or -"; - } - if (group && !/^[A-Za-z0-9_-]{1,128}$/.test(group)) { - throw "Group is not valid. Must be 128 characters or less, consisting of A-Z a-z 0-9 _ or -"; - } - if (item && !/^[A-Za-z0-9_-]{1,512}$/.test(item)) { - throw "Item is not valid. Must be 512 characters or less, consisting of A-Z a-z 0-9 _ or -"; - } - } - getNamespaceToken(namespace) { - if (__classPrivateFieldGet(this, _token_override)) { - return __classPrivateFieldGet(this, _token_override); - } - let name = "namespace-" + namespace; - if (!(name in edgekv_access_tokens)) { - throw "MISSING ACCESS TOKEN. No EdgeKV Access Token defined for namespace '" + namespace + "'."; - } - return edgekv_access_tokens[name]["value"]; - } - addTimeout(options, timeout) { - if (timeout && (typeof timeout !== 'number' || !isFinite(timeout) || timeout <= 0)) { - throw "Timeout is not valid. Must be a number greater than 0."; - } - if (timeout) { - options.timeout = timeout; - } - return options; - } - streamText(response_body) { - return __awaiter(this, void 0, void 0, function* () { - let result = ""; - yield response_body - .pipeThrough(new TextDecoderStream()) - .pipeTo(new WritableStream({ - write(chunk) { - result += chunk; - } - })); - return result; - }); - } - putRequest({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, value, timeout = null }) { - this.validate({ namespace: namespace, group: group, item: item }); - let uri = __classPrivateFieldGet(this, _edgekv_uri) + "/api/v1/namespaces/" + namespace + "/groups/" + group + "/items/" + item; - return httpRequest(uri, this.addTimeout({ - method: "PUT", - body: typeof value === "object" ? JSON.stringify(value) : value, - headers: { "X-Akamai-EdgeDB-Auth": [this.getNamespaceToken(namespace)] } - }, timeout)); - } - /** - * async PUT text into an item in the EdgeKV. - * @param {string} [$0.namepsace=this.#namespace] specify a namespace other than the default - * @param {string} [$0.group=this.#group] specify a group other than the default - * @param {string} $0.item item key to put into the EdgeKV - * @param {string} $0.value text value to put into the EdgeKV - * @param {number} [$0.timeout=null] the maximum time, in milliseconds, to wait for the response - * @returns {string} if the operation was successful, the response from the EdgeKV - * @throws {object} if the operation was not successful, - * an object describing the non-200 response from the EdgeKV: {failed, status, body} - */ - putText({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, value, timeout = null }) { - return __awaiter(this, void 0, void 0, function* () { - return this.requestHandlerTemplate(() => this.putRequest({ namespace: namespace, group: group, item: item, value: value, timeout: timeout }), (response) => response.text(), (response) => this.streamText(response.body), "PUT", null); - }); - } - /** - * async PUT json into an item in the EdgeKV. - * @param {string} [$0.namepsace=this.#namespace] specify a namespace other than the default - * @param {string} [$0.group=this.#group] specify a group other than the default - * @param {string} $0.item item key to put into the EdgeKV - * @param {object} $0.value json value to put into the EdgeKV - * @param {number} [$0.timeout=null] the maximum time, in milliseconds, to wait for the response - * @returns {string} if the operation was successful, the response from the EdgeKV - * @throws {object} if the operation was not successful, - * an object describing the non-200 response from the EdgeKV: {failed, status, body} - */ - putJson({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, value, timeout = null }) { - return __awaiter(this, void 0, void 0, function* () { - return this.requestHandlerTemplate(() => this.putRequest({ namespace: namespace, group: group, item: item, value: JSON.stringify(value), timeout: timeout }), (response) => response.text(), (response) => this.streamText(response.body), "PUT", null); - }); - } - getRequest({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, timeout = null }) { - this.validate({ namespace: namespace, group: group, item: item }); - let uri = __classPrivateFieldGet(this, _edgekv_uri) + "/api/v1/namespaces/" + namespace + "/groups/" + group + "/items/" + item; - return httpRequest(uri, this.addTimeout({ - method: "GET", - headers: { "X-Akamai-EdgeDB-Auth": [this.getNamespaceToken(namespace)] } - }, timeout)); - } - /** - * async GET text from an item in the EdgeKV. - * @param {string} [$0.namepsace=this.#namespace] specify a namespace other than the default - * @param {string} [$0.group=this.#group] specify a group other than the default - * @param {string} $0.item item key to get from the EdgeKV - * @param {string} [$0.default_value=null] the default value to return if a 404 response is returned from EdgeKV - * @param {number} [$0.timeout=null] the maximum time, in milliseconds, to wait for the response - * @returns {string} if the operation was successful, the text response from the EdgeKV or the default_value on 404 - * @throws {object} if the operation was not successful, - * an object describing the non-200 and non-404 response from the EdgeKV: {failed, status, body} - */ - getText({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, default_value = null, timeout = null }) { - return __awaiter(this, void 0, void 0, function* () { - return this.requestHandlerTemplate(() => this.getRequest({ namespace: namespace, group: group, item: item, timeout: timeout }), (response) => response.text(), (response) => this.streamText(response.body), "GET TEXT", default_value); - }); - } - /** - * async GET json from an item in the EdgeKV. - * @param {string} [$0.namepsace=this.#namespace] specify a namespace other than the default - * @param {string} [$0.group=this.#group] specify a group other than the default - * @param {string} $0.item item key to get from the EdgeKV - * @param {object} [$0.default_value=null] the default value to return if a 404 response is returned from EdgeKV - * @param {number} [$0.timeout=null] the maximum time, in milliseconds, to wait for the response - * @returns {object} if the operation was successful, the json response from the EdgeKV or the default_value on 404 - * @throws {object} if the operation was not successful, - * an object describing the non-200 and non-404 response from the EdgeKV: {failed, status, body} - */ - getJson({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, default_value = null, timeout = null }) { - return __awaiter(this, void 0, void 0, function* () { - return this.requestHandlerTemplate(() => this.getRequest({ namespace: namespace, group: group, item: item, timeout: timeout }), (response) => response.json(), (response) => JSON.parse(this.streamText(response.body)), "GET JSON", default_value); - }); - } - deleteRequest({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, timeout = null }) { - this.validate({ namespace: namespace, group: group, item: item }); - let uri = __classPrivateFieldGet(this, _edgekv_uri) + "/api/v1/namespaces/" + namespace + "/groups/" + group + "/items/" + item; - return httpRequest(uri, this.addTimeout({ - method: "DELETE", - headers: { "X-Akamai-EdgeDB-Auth": [this.getNamespaceToken(namespace)] } - }, timeout)); - } - /** - * async DELETE an item in the EdgeKV. - * @param {string} [$0.namepsace=this.#namespace] specify a namespace other than the default - * @param {string} [$0.group=this.#group] specify a group other than the default - * @param {string} $0.item item key to delete from the EdgeKV - * @param {number} [$0.timeout=null] the maximum time, in milliseconds, to wait for the response - * @returns {string} if the operation was successful, the text response from the EdgeKV - * @throws {object} if the operation was not successful, - * an object describing the non-200 response from the EdgeKV: {failed, status, body} - */ - delete({ namespace = __classPrivateFieldGet(this, _namespace), group = __classPrivateFieldGet(this, _group), item, timeout = null }) { - return __awaiter(this, void 0, void 0, function* () { - return this.requestHandlerTemplate(() => this.deleteRequest({ namespace: namespace, group: group, item: item, timeout: timeout }), (response) => response.text(), (response) => this.streamText(response.body), "DELETE", null); - }); - } -} -_namespace = new WeakMap(), _group = new WeakMap(), _edgekv_uri = new WeakMap(), _token_override = new WeakMap(); diff --git a/src/lib/edgekv_tokens.js b/src/lib/edgekv_tokens.js deleted file mode 100644 index f56d9d6..0000000 --- a/src/lib/edgekv_tokens.js +++ /dev/null @@ -1,7 +0,0 @@ -var edgekv_access_tokens = { - "namespace-QueueIT" : { - "name": "Name of the token", - "value" : "Value of the token" - } -} -export { edgekv_access_tokens }; \ No newline at end of file diff --git a/src/lib/sha256.js b/src/lib/sha256.js deleted file mode 100644 index e6e67e0..0000000 --- a/src/lib/sha256.js +++ /dev/null @@ -1,504 +0,0 @@ -var crypto = {}; -/** - * [js-sha256]{@link https://github.com/emn178/js-sha256} - * - * @version 0.9.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2014-2017 - * @license MIT - */ -/*jslint bitwise: true */ -(function () { - 'use strict'; - var ERROR = 'input is invalid type'; - var WINDOW = typeof window === 'object'; - var root = WINDOW ? window : {}; - if (root.JS_SHA256_NO_WINDOW) { - WINDOW = false; - } - var WEB_WORKER = !WINDOW && typeof self === 'object'; - var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; - if (NODE_JS) { - root = global; - } - else if (WEB_WORKER) { - root = self; - } - var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === 'object' && module.exports; - var AMD = typeof define === 'function' && define.amd; - var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; - var HEX_CHARS = '0123456789abcdef'.split(''); - var EXTRA = [-2147483648, 8388608, 32768, 128]; - var SHIFT = [24, 16, 8, 0]; - var K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ]; - var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; - var blocks = []; - if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; - } - if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; - } - var createOutputMethod = function (outputType, is224) { - return function (message) { - return new Sha256(is224, true).update(message)[outputType](); - }; - }; - var createMethod = function (is224) { - var method = createOutputMethod('hex', is224); - if (NODE_JS) { - method = nodeWrap(method, is224); - } - method.create = function () { - return new Sha256(is224); - }; - method.update = function (message) { - return method.create().update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createOutputMethod(type, is224); - } - return method; - }; - var nodeWrap = function (method, is224) { - var crypto = eval("require('crypto')"); - var Buffer = eval("require('buffer').Buffer"); - var algorithm = is224 ? 'sha224' : 'sha256'; - var nodeMethod = function (message) { - if (typeof message === 'string') { - return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); - } - else { - if (message === null || message === undefined) { - throw new Error(ERROR); - } - else if (message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } - } - if (Array.isArray(message) || ArrayBuffer.isView(message) || - message.constructor === Buffer) { - return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex'); - } - else { - return method(message); - } - }; - return nodeMethod; - }; - var createHmacOutputMethod = function (outputType, is224) { - return function (key, message) { - return new HmacSha256(key, is224, true).update(message)[outputType](); - }; - }; - var createHmacMethod = function (is224) { - var method = createHmacOutputMethod('hex', is224); - method.create = function (key) { - return new HmacSha256(key, is224); - }; - method.update = function (key, message) { - return method.create(key).update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createHmacOutputMethod(type, is224); - } - return method; - }; - function Sha256(is224, sharedMemory) { - if (sharedMemory) { - blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - this.blocks = blocks; - } - else { - this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - } - if (is224) { - this.h0 = 0xc1059ed8; - this.h1 = 0x367cd507; - this.h2 = 0x3070dd17; - this.h3 = 0xf70e5939; - this.h4 = 0xffc00b31; - this.h5 = 0x68581511; - this.h6 = 0x64f98fa7; - this.h7 = 0xbefa4fa4; - } - else { // 256 - this.h0 = 0x6a09e667; - this.h1 = 0xbb67ae85; - this.h2 = 0x3c6ef372; - this.h3 = 0xa54ff53a; - this.h4 = 0x510e527f; - this.h5 = 0x9b05688c; - this.h6 = 0x1f83d9ab; - this.h7 = 0x5be0cd19; - } - this.block = this.start = this.bytes = this.hBytes = 0; - this.finalized = this.hashed = false; - this.first = true; - this.is224 = is224; - } - Sha256.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw new Error(ERROR); - } - else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } - else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw new Error(ERROR); - } - } - } - else { - throw new Error(ERROR); - } - notString = true; - } - var code, index = 0, i, length = message.length, blocks = this.blocks; - while (index < length) { - if (this.hashed) { - this.hashed = false; - blocks[0] = this.block; - blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - } - if (notString) { - for (i = this.start; index < length && i < 64; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } - else { - for (i = this.start; index < length && i < 64; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } - else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - this.bytes += i - this.start; - if (i >= 64) { - this.block = blocks[16]; - this.start = i - 64; - this.hash(); - this.hashed = true; - } - else { - this.start = i; - } - } - if (this.bytes > 4294967295) { - this.hBytes += this.bytes / 4294967296 << 0; - this.bytes = this.bytes % 4294967296; - } - return this; - }; - Sha256.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex; - blocks[16] = this.block; - blocks[i >> 2] |= EXTRA[i & 3]; - this.block = blocks[16]; - if (i >= 56) { - if (!this.hashed) { - this.hash(); - } - blocks[0] = this.block; - blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - } - blocks[14] = this.hBytes << 3 | this.bytes >>> 29; - blocks[15] = this.bytes << 3; - this.hash(); - }; - Sha256.prototype.hash = function () { - var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; - for (j = 16; j < 64; ++j) { - // rightrotate - t1 = blocks[j - 15]; - s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3); - t1 = blocks[j - 2]; - s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10); - blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; - } - bc = b & c; - for (j = 0; j < 64; j += 4) { - if (this.first) { - if (this.is224) { - ab = 300032; - t1 = blocks[0] - 1413257819; - h = t1 - 150054599 << 0; - d = t1 + 24177077 << 0; - } - else { - ab = 704751109; - t1 = blocks[0] - 210244248; - h = t1 - 1521486534 << 0; - d = t1 + 143694565 << 0; - } - this.first = false; - } - else { - s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); - s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); - ab = a & b; - maj = ab ^ (a & c) ^ bc; - ch = (e & f) ^ (~e & g); - t1 = h + s1 + ch + K[j] + blocks[j]; - t2 = s0 + maj; - h = d + t1 << 0; - d = t1 + t2 << 0; - } - s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10)); - s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7)); - da = d & a; - maj = da ^ (d & b) ^ ab; - ch = (h & e) ^ (~h & f); - t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; - t2 = s0 + maj; - g = c + t1 << 0; - c = t1 + t2 << 0; - s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10)); - s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7)); - cd = c & d; - maj = cd ^ (c & a) ^ da; - ch = (g & h) ^ (~g & e); - t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; - t2 = s0 + maj; - f = b + t1 << 0; - b = t1 + t2 << 0; - s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10)); - s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7)); - bc = b & c; - maj = bc ^ (b & d) ^ cd; - ch = (f & g) ^ (~f & h); - t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; - t2 = s0 + maj; - e = a + t1 << 0; - a = t1 + t2 << 0; - } - this.h0 = this.h0 + a << 0; - this.h1 = this.h1 + b << 0; - this.h2 = this.h2 + c << 0; - this.h3 = this.h3 + d << 0; - this.h4 = this.h4 + e << 0; - this.h5 = this.h5 + f << 0; - this.h6 = this.h6 + g << 0; - this.h7 = this.h7 + h << 0; - }; - Sha256.prototype.hex = function () { - this.finalize(); - var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7; - var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + - HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + - HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + - HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + - HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + - HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + - HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + - HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + - HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + - HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + - HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + - HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + - HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] + - HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + - HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + - HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + - HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] + - HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] + - HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] + - HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] + - HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] + - HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] + - HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] + - HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] + - HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] + - HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] + - HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] + - HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F]; - if (!this.is224) { - hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] + - HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] + - HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] + - HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F]; - } - return hex; - }; - Sha256.prototype.toString = Sha256.prototype.hex; - Sha256.prototype.digest = function () { - this.finalize(); - var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7; - var arr = [ - (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF, - (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF, - (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF, - (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF, - (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF, - (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF, - (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF - ]; - if (!this.is224) { - arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF); - } - return arr; - }; - Sha256.prototype.array = Sha256.prototype.digest; - Sha256.prototype.arrayBuffer = function () { - this.finalize(); - var buffer = new ArrayBuffer(this.is224 ? 28 : 32); - var dataView = new DataView(buffer); - dataView.setUint32(0, this.h0); - dataView.setUint32(4, this.h1); - dataView.setUint32(8, this.h2); - dataView.setUint32(12, this.h3); - dataView.setUint32(16, this.h4); - dataView.setUint32(20, this.h5); - dataView.setUint32(24, this.h6); - if (!this.is224) { - dataView.setUint32(28, this.h7); - } - return buffer; - }; - function HmacSha256(key, is224, sharedMemory) { - var i, type = typeof key; - if (type === 'string') { - var bytes = [], length = key.length, index = 0, code; - for (i = 0; i < length; ++i) { - code = key.charCodeAt(i); - if (code < 0x80) { - bytes[index++] = code; - } - else if (code < 0x800) { - bytes[index++] = (0xc0 | (code >> 6)); - bytes[index++] = (0x80 | (code & 0x3f)); - } - else if (code < 0xd800 || code >= 0xe000) { - bytes[index++] = (0xe0 | (code >> 12)); - bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); - bytes[index++] = (0x80 | (code & 0x3f)); - } - else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); - bytes[index++] = (0xf0 | (code >> 18)); - bytes[index++] = (0x80 | ((code >> 12) & 0x3f)); - bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); - bytes[index++] = (0x80 | (code & 0x3f)); - } - } - key = bytes; - } - else { - if (type === 'object') { - if (key === null) { - throw new Error(ERROR); - } - else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { - key = new Uint8Array(key); - } - else if (!Array.isArray(key)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { - throw new Error(ERROR); - } - } - } - else { - throw new Error(ERROR); - } - } - if (key.length > 64) { - key = (new Sha256(is224, true)).update(key).array(); - } - var oKeyPad = [], iKeyPad = []; - for (i = 0; i < 64; ++i) { - var b = key[i] || 0; - oKeyPad[i] = 0x5c ^ b; - iKeyPad[i] = 0x36 ^ b; - } - Sha256.call(this, is224, sharedMemory); - this.update(iKeyPad); - this.oKeyPad = oKeyPad; - this.inner = true; - this.sharedMemory = sharedMemory; - } - HmacSha256.prototype = new Sha256(); - HmacSha256.prototype.finalize = function () { - Sha256.prototype.finalize.call(this); - if (this.inner) { - this.inner = false; - var innerHash = this.array(); - Sha256.call(this, this.is224, this.sharedMemory); - this.update(this.oKeyPad); - this.update(innerHash); - Sha256.prototype.finalize.call(this); - } - }; - var exports = createMethod(); - exports.sha256 = exports; - exports.sha224 = createMethod(true); - exports.sha256.hmac = createHmacMethod(); - exports.sha224.hmac = createHmacMethod(true); - if (COMMON_JS) { - module.exports = exports; - } - else { - root.sha256 = exports.sha256; - root.sha224 = exports.sha224; - if (AMD) { - define(function () { - return exports; - }); - } - } - crypto.sha256 = exports.sha256; - crypto.sha224 = exports.sha224; -})(); -export default crypto; diff --git a/src/main.js b/src/main.js deleted file mode 100644 index bad1cae..0000000 --- a/src/main.js +++ /dev/null @@ -1,123 +0,0 @@ -/// -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -import { AkamaiHttpContextProvider } from './akamaiHttpContextProvider.js'; -import { KnownUser, Utils } from './sdk/queueitknownuser.bundle.js'; -import { QueueITHelper, SettingException } from './queueitHelpers.js'; -import { IntegrationConfigProvider } from './integrationConfigProvider.js'; -// @ts-ignore -import { logger } from 'log'; -const COOKIE_VARIABLE_NAME = 'PMUSER_QUEUEIT_C'; -const ERROR_VARIABLE_NAME = 'PMUSER_QUEUEIT_ER'; -const BIG_SET_COOKIE_VALUE = 'TOO_BIG_COOKIE'; -const QUEUEIT_CONNECTOR_EXECUTED_HEADERNAMRE = 'x-queueit-connector'; -const QUEUEIT_FAILED_HEADERNAME = 'x-queueit-failed'; -export function onClientRequest(request) { - return __awaiter(this, void 0, void 0, function* () { - try { - QueueITHelper.configureKnownUserHashing(Utils); - let httpContext = new AkamaiHttpContextProvider(request, { - storeCookie: function (cookieString) { - if (cookieString.length < 800) { - request.setVariable(COOKIE_VARIABLE_NAME, cookieString); - } - else { - request.setVariable(COOKIE_VARIABLE_NAME, BIG_SET_COOKIE_VALUE); - } - } - }); - let settings = QueueITHelper.getSettingsFromPMVariables(request); - let { queueitToken, requestUrlWithoutToken, validationResult } = yield validateRequest(httpContext, settings); - if (validationResult.doRedirect()) { - // Adding no cache headers to prevent browsers to cache requests - let headers = QueueITHelper.getNoCacheHeaders(); - if (validationResult.isAjaxResult) { - var headerName = validationResult.getAjaxQueueRedirectHeaderKey(); - // In case of ajax call send the user to the queue by sending a custom queue-it header and redirecting user to queue from javascript - headers[headerName] = [QueueITHelper.addKUPlatformVersion(validationResult.getAjaxRedirectUrl())]; - request.respondWith(200, headers, ""); - return; - } - else { - // Send the user to the queue - either because hash was missing or because is was invalid - let headers = QueueITHelper.getNoCacheHeaders(); - headers['Location'] = [QueueITHelper.addKUPlatformVersion(validationResult.redirectUrl)]; - request.respondWith(302, headers, ""); - return; - } - } - else { - // Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token - // Support mobile scenario adding the condition !validationResult.isAjaxResult - if (!validationResult.isAjaxResult && queueitToken && validationResult.actionType === "Queue") { - let headers = QueueITHelper.getNoCacheHeaders(); - headers['Location'] = [requestUrlWithoutToken]; - request.respondWith(302, headers, ""); - return; - } - } - } - catch (ex) { - if (ex instanceof SettingException) { - request.setVariable(ERROR_VARIABLE_NAME, 'request;setting:' + ex.Type); - } - else { - request.setVariable(ERROR_VARIABLE_NAME, 'request'); - } - logger.log('OnClientRequest Exception: %s', ex); - } - }); -} -export function onClientResponse(request, response) { - return __awaiter(this, void 0, void 0, function* () { - try { - response.addHeader(QUEUEIT_CONNECTOR_EXECUTED_HEADERNAMRE, 'akamai'); - let cookieString = request.getVariable(COOKIE_VARIABLE_NAME); - if (cookieString && cookieString !== BIG_SET_COOKIE_VALUE) { - response.addHeader('Set-Cookie', cookieString); - } - else if (cookieString == BIG_SET_COOKIE_VALUE) { - let httpContext = new AkamaiHttpContextProvider(request, { - storeCookie: function (cookieString) { - response.addHeader('Set-Cookie', cookieString); - } - }); - //cookie value was big so re-evaluating to be able to set the cookie on the response - let settings = QueueITHelper.getSettingsFromPMVariables(request); - yield validateRequest(httpContext, settings); - } - let error = request.getVariable(ERROR_VARIABLE_NAME); - if (request.getVariable(ERROR_VARIABLE_NAME)) { - response.addHeader(QUEUEIT_FAILED_HEADERNAME, error); - } - } - catch (ex) { - if (ex instanceof SettingException) { - response.addHeader(QUEUEIT_FAILED_HEADERNAME, 'response;setting:' + ex.Type); - } - else { - response.addHeader(QUEUEIT_FAILED_HEADERNAME, 'response'); - } - logger.log('OnClientRequest Exception: %s', ex); - } - }); -} -function validateRequest(httpContext, settings) { - return __awaiter(this, void 0, void 0, function* () { - var requestUrl = httpContext.getHttpRequest().getAbsoluteUri(); - let queueitToken = QueueITHelper.getParameterByName(KnownUser.QueueITTokenKey, requestUrl); - var requestUrlWithoutToken = requestUrl.replace(new RegExp("([\?&])(" + KnownUser.QueueITTokenKey + "=[^&]*)", 'i'), ""); - requestUrlWithoutToken = requestUrlWithoutToken.replace(new RegExp("[?]$"), ""); - let integrationConfig = yield IntegrationConfigProvider.getIntegrationConfig(settings.IntegrationConfigType, settings.ApiKey); - ; - let validationResult = KnownUser.validateRequestByIntegrationConfig(requestUrl, queueitToken, integrationConfig, settings.CustomerId, settings.SecretKey, httpContext); - return { queueitToken, requestUrlWithoutToken, validationResult }; - }); -} diff --git a/src/queueitHelpers.js b/src/queueitHelpers.js deleted file mode 100644 index 0fb74c6..0000000 --- a/src/queueitHelpers.js +++ /dev/null @@ -1,58 +0,0 @@ -import crypto from './lib/sha256.js'; -const AKAMAI_SDK_VERSION = "2.1.1"; -export class QueueITHelper { - static getParameterByName(name, url) { - name = name.replace(/[\[\]]/g, '\\$&'); - var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); - if (!results) - return null; - if (!results[2]) - return ''; - return results[2].replace(/\+/g, ' '); - } - static getNoCacheHeaders() { - return { - 'Cache-Control': ['no-cache, no-store, must-revalidate'], - 'Pragma': ['no-cache'], - 'Expires': ['Fri, 01 Jan 1990 00:00:00 GMT'] - }; - } - static getSettingsFromPMVariables(request) { - let setting = { - SecretKey: request.getVariable('PMUSER_QUEUEIT_SECRET_KEY'), - ApiKey: request.getVariable('PMUSER_QUEUEIT_API_KEY'), - CustomerId: request.getVariable('PMUSER_QUEUEIT_CUSTOMERID'), - IntegrationConfigType: request.getVariable('PMUSER_QUEUEIT_CONFIG_TYPE') - }; - if (!setting.CustomerId) { - let settingException = new SettingException(); - settingException.Type = "CustomerId"; - throw settingException; - } - if (!setting.SecretKey) { - let settingException = new SettingException(); - settingException.Type = "SecretKey"; - throw settingException; - } - if (!setting.IntegrationConfigType || - (setting.IntegrationConfigType.toLowerCase() != 'inline' && - setting.IntegrationConfigType.toLowerCase() != 'cache' && - setting.IntegrationConfigType.toLowerCase() != 'edgekv')) { - let settingException = new SettingException(); - settingException.Type = "ConfigType"; - throw settingException; - } - return setting; - } -} -QueueITHelper.addKUPlatformVersion = function (redirectQueueUrl) { - return redirectQueueUrl + "&kupver=akamai-" + AKAMAI_SDK_VERSION; -}; -QueueITHelper.configureKnownUserHashing = function (Utils) { - Utils.generateSHA256Hash = function (secretKey, stringToHash) { - const hash = crypto.sha256.hmac(secretKey, stringToHash); - return hash; - }; -}; -export class SettingException { -} diff --git a/src/sdk/queueitknownuser.bundle.js b/src/sdk/queueitknownuser.bundle.js deleted file mode 100644 index a9c481e..0000000 --- a/src/sdk/queueitknownuser.bundle.js +++ /dev/null @@ -1,1113 +0,0 @@ -var exportObject = {}; -(function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { - if (!e[i]) { - var c = "function" == typeof require && require; - if (!f && c) - return c(i, !0); - if (u) - return u(i, !0); - var a = new Error("Cannot find module '" + i + "'"); - throw a.code = "MODULE_NOT_FOUND", a; - } - var p = n[i] = { exports: {} }; - e[i][0].call(p.exports, function (r) { var n = e[i][1][r]; return o(n || r); }, p, p.exports, r, e, n, t); -} return n[i].exports; } for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) - o(t[i]); return o; } return r; })()({ 1: [function (require, module, exports) { - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); - }) : (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - o[k2] = m[k]; - })); - var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function (o, v) { - o["default"] = v; - }); - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) - for (var k in mod) - if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ComparisonOperatorHelper = exports.HttpHeaderValidatorHelper = exports.RequestBodyValidatorHelper = exports.UserAgentValidatorHelper = exports.CookieValidatorHelper = exports.UrlValidatorHelper = exports.IntegrationEvaluator = void 0; - var IntegrationModels = __importStar(require("./IntegrationConfigModel")); - var Models_1 = require("../Models"); - var IntegrationEvaluator = /** @class */ (function () { - function IntegrationEvaluator() { - } - IntegrationEvaluator.prototype.getMatchedIntegrationConfig = function (customerIntegration, currentPageUrl, request) { - if (!request) - throw new Models_1.KnownUserException("request is null"); - if (!customerIntegration) - throw new Models_1.KnownUserException("customerIntegration is null"); - for (var _i = 0, _a = customerIntegration.Integrations || []; _i < _a.length; _i++) { - var integration = _a[_i]; - for (var _b = 0, _c = integration.Triggers; _b < _c.length; _b++) { - var trigger = _c[_b]; - if (this.evaluateTrigger(trigger, currentPageUrl, request)) { - return integration; - } - } - } - return null; - }; - IntegrationEvaluator.prototype.evaluateTrigger = function (trigger, currentPageUrl, request) { - var part; - if (trigger.LogicalOperator === IntegrationModels.LogicalOperatorType.Or) { - for (var _i = 0, _a = trigger.TriggerParts; _i < _a.length; _i++) { - part = _a[_i]; - if (this.evaluateTriggerPart(part, currentPageUrl, request)) - return true; - } - return false; - } - else { - for (var _b = 0, _c = trigger.TriggerParts; _b < _c.length; _b++) { - part = _c[_b]; - if (!this.evaluateTriggerPart(part, currentPageUrl, request)) - return false; - } - return true; - } - }; - IntegrationEvaluator.prototype.evaluateTriggerPart = function (triggerPart, currentPageUrl, request) { - switch (triggerPart.ValidatorType) { - case IntegrationModels.ValidatorType.UrlValidator: - return UrlValidatorHelper.evaluate(triggerPart, currentPageUrl); - case IntegrationModels.ValidatorType.CookieValidator: - return CookieValidatorHelper.evaluate(triggerPart, request); - case IntegrationModels.ValidatorType.UserAgentValidator: - return UserAgentValidatorHelper.evaluate(triggerPart, request.getUserAgent()); - case IntegrationModels.ValidatorType.HttpHeaderValidator: - return HttpHeaderValidatorHelper.evaluate(triggerPart, request.getHeader(triggerPart.HttpHeaderName)); - case IntegrationModels.ValidatorType.RequestBodyValidator: - return RequestBodyValidatorHelper.evaluate(triggerPart, request.getRequestBodyAsString()); - default: - return false; - } - }; - return IntegrationEvaluator; - }()); - exports.IntegrationEvaluator = IntegrationEvaluator; - var UrlValidatorHelper = /** @class */ (function () { - function UrlValidatorHelper() { - } - UrlValidatorHelper.evaluate = function (triggerPart, url) { - return ComparisonOperatorHelper.evaluate(triggerPart.Operator, triggerPart.IsNegative, triggerPart.IsIgnoreCase, this.getUrlPart(triggerPart, url), triggerPart.ValueToCompare, triggerPart.ValuesToCompare); - }; - UrlValidatorHelper.getUrlPart = function (triggerPart, url) { - switch (triggerPart.UrlPart) { - case IntegrationModels.UrlPartType.PagePath: - return this.getPathFromUrl(url); - case IntegrationModels.UrlPartType.PageUrl: - return url; - case IntegrationModels.UrlPartType.HostName: - return this.getHostNameFromUrl(url); - default: - return ""; - } - }; - UrlValidatorHelper.getHostNameFromUrl = function (url) { - var urlMatcher = /^(([^:/\?#]+):)?(\/\/([^/\?#]*))?([^\?#]*)(\?([^#]*))?(#(.*))?/; - var match = urlMatcher.exec(url); - if (match && match[4]) - return match[4]; - return ""; - }; - UrlValidatorHelper.getPathFromUrl = function (url) { - var urlMatcher = /^(([^:/\?#]+):)?(\/\/([^/\?#]*))?([^\?#]*)(\?([^#]*))?(#(.*))?/; - var match = urlMatcher.exec(url); - if (match && match[5]) - return match[5]; - return ""; - }; - return UrlValidatorHelper; - }()); - exports.UrlValidatorHelper = UrlValidatorHelper; - var CookieValidatorHelper = /** @class */ (function () { - function CookieValidatorHelper() { - } - CookieValidatorHelper.evaluate = function (triggerPart, request) { - return ComparisonOperatorHelper.evaluate(triggerPart.Operator, triggerPart.IsNegative, triggerPart.IsIgnoreCase, this.getCookie(triggerPart.CookieName, request), triggerPart.ValueToCompare, triggerPart.ValuesToCompare); - }; - CookieValidatorHelper.getCookie = function (cookieName, request) { - var cookie = request.getCookieValue(cookieName); - if (!cookie) - return ""; - return cookie; - }; - return CookieValidatorHelper; - }()); - exports.CookieValidatorHelper = CookieValidatorHelper; - var UserAgentValidatorHelper = /** @class */ (function () { - function UserAgentValidatorHelper() { - } - UserAgentValidatorHelper.evaluate = function (triggerPart, userAgent) { - return ComparisonOperatorHelper.evaluate(triggerPart.Operator, triggerPart.IsNegative, triggerPart.IsIgnoreCase, userAgent, triggerPart.ValueToCompare, triggerPart.ValuesToCompare); - }; - return UserAgentValidatorHelper; - }()); - exports.UserAgentValidatorHelper = UserAgentValidatorHelper; - var RequestBodyValidatorHelper = /** @class */ (function () { - function RequestBodyValidatorHelper() { - } - RequestBodyValidatorHelper.evaluate = function (triggerPart, bodyString) { - return ComparisonOperatorHelper.evaluate(triggerPart.Operator, triggerPart.IsNegative, triggerPart.IsIgnoreCase, bodyString, triggerPart.ValueToCompare, triggerPart.ValuesToCompare); - }; - return RequestBodyValidatorHelper; - }()); - exports.RequestBodyValidatorHelper = RequestBodyValidatorHelper; - var HttpHeaderValidatorHelper = /** @class */ (function () { - function HttpHeaderValidatorHelper() { - } - HttpHeaderValidatorHelper.evaluate = function (triggerPart, headerValue) { - return ComparisonOperatorHelper.evaluate(triggerPart.Operator, triggerPart.IsNegative, triggerPart.IsIgnoreCase, headerValue, triggerPart.ValueToCompare, triggerPart.ValuesToCompare); - }; - return HttpHeaderValidatorHelper; - }()); - exports.HttpHeaderValidatorHelper = HttpHeaderValidatorHelper; - var ComparisonOperatorHelper = /** @class */ (function () { - function ComparisonOperatorHelper() { - } - ComparisonOperatorHelper.evaluate = function (opt, isNegative, isIgnoreCase, value, valueToCompare, valuesToCompare) { - value = value || ""; - valueToCompare = valueToCompare || ""; - valuesToCompare = valuesToCompare || []; - switch (opt) { - case IntegrationModels.ComparisonOperatorType.EqualS: - return ComparisonOperatorHelper.equalS(value, valueToCompare, isNegative, isIgnoreCase); - case IntegrationModels.ComparisonOperatorType.Contains: - return ComparisonOperatorHelper.contains(value, valueToCompare, isNegative, isIgnoreCase); - case IntegrationModels.ComparisonOperatorType.EqualsAny: - return ComparisonOperatorHelper.equalsAny(value, valuesToCompare, isNegative, isIgnoreCase); - case IntegrationModels.ComparisonOperatorType.ContainsAny: - return ComparisonOperatorHelper.containsAny(value, valuesToCompare, isNegative, isIgnoreCase); - default: - return false; - } - }; - ComparisonOperatorHelper.contains = function (value, valueToCompare, isNegative, ignoreCase) { - if (valueToCompare === "*" && value) - return true; - var evaluation = false; - if (ignoreCase) - evaluation = value.toUpperCase().indexOf(valueToCompare.toUpperCase()) !== -1; - else - evaluation = value.indexOf(valueToCompare) !== -1; - if (isNegative) - return !evaluation; - else - return evaluation; - }; - ComparisonOperatorHelper.equalS = function (value, valueToCompare, isNegative, ignoreCase) { - var evaluation = false; - if (ignoreCase) - evaluation = value.toUpperCase() === valueToCompare.toUpperCase(); - else - evaluation = value === valueToCompare; - if (isNegative) - return !evaluation; - else - return evaluation; - }; - ComparisonOperatorHelper.equalsAny = function (value, valuesToCompare, isNegative, isIgnoreCase) { - for (var _i = 0, valuesToCompare_1 = valuesToCompare; _i < valuesToCompare_1.length; _i++) { - var valueToCompare = valuesToCompare_1[_i]; - if (ComparisonOperatorHelper.equalS(value, valueToCompare, false, isIgnoreCase)) - return !isNegative; - } - return isNegative; - }; - ComparisonOperatorHelper.containsAny = function (value, valuesToCompare, isNegative, isIgnoreCase) { - for (var _i = 0, valuesToCompare_2 = valuesToCompare; _i < valuesToCompare_2.length; _i++) { - var valueToCompare = valuesToCompare_2[_i]; - if (ComparisonOperatorHelper.contains(value, valueToCompare, false, isIgnoreCase)) - return !isNegative; - } - return isNegative; - }; - return ComparisonOperatorHelper; - }()); - exports.ComparisonOperatorHelper = ComparisonOperatorHelper; - }, { "../Models": 4, "./IntegrationConfigModel": 2 }], 2: [function (require, module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ActionType = exports.LogicalOperatorType = exports.ComparisonOperatorType = exports.UrlPartType = exports.ValidatorType = exports.TriggerModel = exports.TriggerPart = exports.CustomerIntegration = exports.IntegrationConfigModel = void 0; - var IntegrationConfigModel = /** @class */ (function () { - function IntegrationConfigModel() { - } - return IntegrationConfigModel; - }()); - exports.IntegrationConfigModel = IntegrationConfigModel; - var CustomerIntegration = /** @class */ (function () { - function CustomerIntegration() { - this.Integrations = new Array(); - this.Version = -1; - } - return CustomerIntegration; - }()); - exports.CustomerIntegration = CustomerIntegration; - var TriggerPart = /** @class */ (function () { - function TriggerPart() { - } - return TriggerPart; - }()); - exports.TriggerPart = TriggerPart; - var TriggerModel = /** @class */ (function () { - function TriggerModel() { - this.TriggerParts = new Array(); - } - return TriggerModel; - }()); - exports.TriggerModel = TriggerModel; - var ValidatorType = /** @class */ (function () { - function ValidatorType() { - } - ValidatorType.UrlValidator = "UrlValidator"; - ValidatorType.CookieValidator = "CookieValidator"; - ValidatorType.UserAgentValidator = "UserAgentValidator"; - ValidatorType.HttpHeaderValidator = "HttpHeaderValidator"; - ValidatorType.RequestBodyValidator = "RequestBodyValidator"; - return ValidatorType; - }()); - exports.ValidatorType = ValidatorType; - var UrlPartType = /** @class */ (function () { - function UrlPartType() { - } - UrlPartType.HostName = "HostName"; - UrlPartType.PagePath = "PagePath"; - UrlPartType.PageUrl = "PageUrl"; - return UrlPartType; - }()); - exports.UrlPartType = UrlPartType; - var ComparisonOperatorType = /** @class */ (function () { - function ComparisonOperatorType() { - } - ComparisonOperatorType.EqualS = "Equals"; - ComparisonOperatorType.Contains = "Contains"; - ComparisonOperatorType.EqualsAny = "EqualsAny"; - ComparisonOperatorType.ContainsAny = "ContainsAny"; - return ComparisonOperatorType; - }()); - exports.ComparisonOperatorType = ComparisonOperatorType; - var LogicalOperatorType = /** @class */ (function () { - function LogicalOperatorType() { - } - LogicalOperatorType.Or = "Or"; - LogicalOperatorType.And = "And"; - return LogicalOperatorType; - }()); - exports.LogicalOperatorType = LogicalOperatorType; - var ActionType = /** @class */ (function () { - function ActionType() { - } - ActionType.IgnoreAction = "Ignore"; - ActionType.CancelAction = "Cancel"; - ActionType.QueueAction = "Queue"; - return ActionType; - }()); - exports.ActionType = ActionType; - }, {}], 3: [function (require, module, exports) { - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); - }) : (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - o[k2] = m[k]; - })); - var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function (o, v) { - o["default"] = v; - }); - var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) - for (var k in mod) - if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; - }; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.KnownUser = void 0; - var UserInQueueService_1 = require("./UserInQueueService"); - var UserInQueueStateCookieRepository_1 = require("./UserInQueueStateCookieRepository"); - var Models_1 = require("./Models"); - var QueueITHelpers_1 = require("./QueueITHelpers"); - var IntegrationConfigHelpers = __importStar(require("./IntegrationConfig/IntegrationConfigHelpers")); - var KnownUser = /** @class */ (function () { - function KnownUser() { - } - KnownUser.getUserInQueueService = function (httpContextProvider) { - if (!this.UserInQueueService) { - return new UserInQueueService_1.UserInQueueService(new UserInQueueStateCookieRepository_1.UserInQueueStateCookieRepository(httpContextProvider)); - } - return this.UserInQueueService; - }; - KnownUser.isQueueAjaxCall = function (httpContextProvider) { - return !!httpContextProvider.getHttpRequest().getHeader(this.QueueITAjaxHeaderKey); - }; - KnownUser.generateTargetUrl = function (originalTargetUrl, httpContextProvider) { - return !this.isQueueAjaxCall(httpContextProvider) ? - originalTargetUrl : - QueueITHelpers_1.Utils.decodeUrl(httpContextProvider.getHttpRequest().getHeader(this.QueueITAjaxHeaderKey)); - }; - KnownUser.logExtraRequestDetails = function (debugEntries, httpContextProvider) { - debugEntries["ServerUtcTime"] = (new Date()).toISOString().split('.')[0] + "Z"; - debugEntries["RequestIP"] = httpContextProvider.getHttpRequest().getUserHostAddress(); - debugEntries["RequestHttpHeader_Via"] = httpContextProvider.getHttpRequest().getHeader("Via"); - debugEntries["RequestHttpHeader_Forwarded"] = httpContextProvider.getHttpRequest().getHeader("Forwarded"); - debugEntries["RequestHttpHeader_XForwardedFor"] = httpContextProvider.getHttpRequest().getHeader("X-Forwarded-For"); - debugEntries["RequestHttpHeader_XForwardedHost"] = httpContextProvider.getHttpRequest().getHeader("X-Forwarded-Host"); - debugEntries["RequestHttpHeader_XForwardedProto"] = httpContextProvider.getHttpRequest().getHeader("X-Forwarded-Proto"); - }; - KnownUser.setDebugCookie = function (debugEntries, httpContextProvider) { - var cookieValue = ""; - for (var key in debugEntries) { - cookieValue += key + "=" + debugEntries[key] + "|"; - } - if (cookieValue.lastIndexOf("|") === cookieValue.length - 1) { - cookieValue = cookieValue.substring(0, cookieValue.length - 1); - } - if (!cookieValue) - return; - httpContextProvider.getHttpResponse().setCookie(this.QueueITDebugKey, cookieValue, null, QueueITHelpers_1.Utils.getCurrentTime() + 20 * 60); // now + 20 mins - }; - KnownUser._resolveQueueRequestByLocalConfig = function (targetUrl, queueitToken, queueConfig, customerId, secretKey, httpContextProvider, debugEntries, isDebug) { - if (isDebug) { - debugEntries["SdkVersion"] = UserInQueueService_1.UserInQueueService.SDK_VERSION; - debugEntries["TargetUrl"] = targetUrl; - debugEntries["QueueitToken"] = queueitToken; - debugEntries["OriginalUrl"] = httpContextProvider.getHttpRequest().getAbsoluteUri(); - debugEntries["QueueConfig"] = queueConfig !== null ? queueConfig.getString() : "NULL"; - this.logExtraRequestDetails(debugEntries, httpContextProvider); - } - if (!customerId) - throw new Models_1.KnownUserException("customerId can not be null or empty."); - if (!secretKey) - throw new Models_1.KnownUserException("secretKey can not be null or empty."); - if (!queueConfig) - throw new Models_1.KnownUserException("queueConfig can not be null."); - if (!queueConfig.eventId) - throw new Models_1.KnownUserException("queueConfig.eventId can not be null or empty."); - if (!queueConfig.queueDomain) - throw new Models_1.KnownUserException("queueConfig.queueDomain can not be null or empty."); - if (queueConfig.cookieValidityMinute <= 0) - throw new Models_1.KnownUserException("queueConfig.cookieValidityMinute should be integer greater than 0."); - var userInQueueService = this.getUserInQueueService(httpContextProvider); - var result = userInQueueService.validateQueueRequest(targetUrl, queueitToken, queueConfig, customerId, secretKey); - result.isAjaxResult = this.isQueueAjaxCall(httpContextProvider); - return result; - }; - KnownUser._cancelRequestByLocalConfig = function (targetUrl, queueitToken, cancelConfig, customerId, secretKey, httpContextProvider, debugEntries, isDebug) { - targetUrl = this.generateTargetUrl(targetUrl, httpContextProvider); - if (isDebug) { - debugEntries["SdkVersion"] = UserInQueueService_1.UserInQueueService.SDK_VERSION; - debugEntries["TargetUrl"] = targetUrl; - debugEntries["QueueitToken"] = queueitToken; - debugEntries["CancelConfig"] = cancelConfig !== null ? cancelConfig.getString() : "NULL"; - debugEntries["OriginalUrl"] = httpContextProvider.getHttpRequest().getAbsoluteUri(); - this.logExtraRequestDetails(debugEntries, httpContextProvider); - } - if (!targetUrl) - throw new Models_1.KnownUserException("targetUrl can not be null or empty."); - if (!customerId) - throw new Models_1.KnownUserException("customerId can not be null or empty."); - if (!secretKey) - throw new Models_1.KnownUserException("secretKey can not be null or empty."); - if (!cancelConfig) - throw new Models_1.KnownUserException("cancelConfig can not be null."); - if (!cancelConfig.eventId) - throw new Models_1.KnownUserException("cancelConfig.eventId can not be null or empty."); - if (!cancelConfig.queueDomain) - throw new Models_1.KnownUserException("cancelConfig.queueDomain can not be null or empty."); - var userInQueueService = this.getUserInQueueService(httpContextProvider); - var result = userInQueueService.validateCancelRequest(targetUrl, cancelConfig, customerId, secretKey); - result.isAjaxResult = this.isQueueAjaxCall(httpContextProvider); - return result; - }; - KnownUser.handleQueueAction = function (currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, matchedConfig, httpContextProvider, debugEntries, isDebug) { - var targetUrl = ""; - switch (matchedConfig.RedirectLogic) { - case "ForcedTargetUrl": - targetUrl = matchedConfig.ForcedTargetUrl; - break; - case "EventTargetUrl": - targetUrl = ""; - break; - default: - targetUrl = this.generateTargetUrl(currentUrlWithoutQueueITToken, httpContextProvider); - break; - } - var queueEventConfig = new Models_1.QueueEventConfig(matchedConfig.EventId, matchedConfig.LayoutName, matchedConfig.Culture, matchedConfig.QueueDomain, matchedConfig.ExtendCookieValidity, matchedConfig.CookieValidityMinute, matchedConfig.CookieDomain, customerIntegrationInfo.Version, matchedConfig.Name); - return this._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueEventConfig, customerId, secretKey, httpContextProvider, debugEntries, isDebug); - }; - KnownUser.handleCancelAction = function (currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, matchedConfig, httpContextProvider, debugEntries, isDebug) { - var cancelEventConfig = new Models_1.CancelEventConfig(matchedConfig.EventId, matchedConfig.QueueDomain, matchedConfig.CookieDomain, customerIntegrationInfo.Version, matchedConfig.Name); - var targetUrl = this.generateTargetUrl(currentUrlWithoutQueueITToken, httpContextProvider); - return this._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelEventConfig, customerId, secretKey, httpContextProvider, debugEntries, isDebug); - }; - KnownUser.handleIgnoreAction = function (httpContextProvider, actionName) { - var userInQueueService = this.getUserInQueueService(httpContextProvider); - var result = userInQueueService.getIgnoreResult(actionName); - result.isAjaxResult = this.isQueueAjaxCall(httpContextProvider); - return result; - }; - KnownUser.extendQueueCookie = function (eventId, cookieValidityMinute, cookieDomain, secretKey, httpContextProvider) { - if (!eventId) - throw new Models_1.KnownUserException("eventId can not be null or empty."); - if (!secretKey) - throw new Models_1.KnownUserException("secretKey can not be null or empty."); - if (cookieValidityMinute <= 0) - throw new Models_1.KnownUserException("cookieValidityMinute should be integer greater than 0."); - var userInQueueService = this.getUserInQueueService(httpContextProvider); - userInQueueService.extendQueueCookie(eventId, cookieValidityMinute, cookieDomain, secretKey); - }; - KnownUser.resolveQueueRequestByLocalConfig = function (targetUrl, queueitToken, queueConfig, customerId, secretKey, httpContextProvider) { - var debugEntries = {}; - var connectorDiagnostics = QueueITHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken); - if (connectorDiagnostics.hasError) - return connectorDiagnostics.validationResult; - try { - targetUrl = this.generateTargetUrl(targetUrl, httpContextProvider); - return this._resolveQueueRequestByLocalConfig(targetUrl, queueitToken, queueConfig, customerId, secretKey, httpContextProvider, debugEntries, connectorDiagnostics.isEnabled); - } - catch (e) { - if (connectorDiagnostics.isEnabled) - debugEntries["Exception"] = e.message; - throw e; - } - finally { - this.setDebugCookie(debugEntries, httpContextProvider); - } - }; - KnownUser.validateRequestByIntegrationConfig = function (currentUrlWithoutQueueITToken, queueitToken, integrationsConfigString, customerId, secretKey, httpContextProvider) { - var debugEntries = {}; - var customerIntegrationInfo; - var connectorDiagnostics = QueueITHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken); - if (connectorDiagnostics.hasError) - return connectorDiagnostics.validationResult; - try { - if (connectorDiagnostics.isEnabled) { - debugEntries["SdkVersion"] = UserInQueueService_1.UserInQueueService.SDK_VERSION; - debugEntries["PureUrl"] = currentUrlWithoutQueueITToken; - debugEntries["QueueitToken"] = queueitToken; - debugEntries["OriginalUrl"] = httpContextProvider.getHttpRequest().getAbsoluteUri(); - this.logExtraRequestDetails(debugEntries, httpContextProvider); - } - customerIntegrationInfo = JSON.parse(integrationsConfigString); - if (connectorDiagnostics.isEnabled) { - debugEntries["ConfigVersion"] = customerIntegrationInfo && customerIntegrationInfo.Version ? customerIntegrationInfo.Version.toString() : "NULL"; - } - if (!currentUrlWithoutQueueITToken) - throw new Models_1.KnownUserException("currentUrlWithoutQueueITToken can not be null or empty."); - if (!customerIntegrationInfo || !customerIntegrationInfo.Version) - throw new Models_1.KnownUserException("integrationsConfigString can not be null or empty."); - var configEvaluater = new IntegrationConfigHelpers.IntegrationEvaluator(); - var matchedConfig = configEvaluater.getMatchedIntegrationConfig(customerIntegrationInfo, currentUrlWithoutQueueITToken, httpContextProvider.getHttpRequest()); - if (connectorDiagnostics.isEnabled) { - debugEntries["MatchedConfig"] = matchedConfig ? matchedConfig.Name : "NULL"; - } - if (!matchedConfig) - return new Models_1.RequestValidationResult(null, null, null, null, null, null); - switch (matchedConfig.ActionType) { - case Models_1.ActionTypes.QueueAction: { - return this.handleQueueAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, matchedConfig, httpContextProvider, debugEntries, connectorDiagnostics.isEnabled); - } - case Models_1.ActionTypes.CancelAction: { - return this.handleCancelAction(currentUrlWithoutQueueITToken, queueitToken, customerIntegrationInfo, customerId, secretKey, matchedConfig, httpContextProvider, debugEntries, connectorDiagnostics.isEnabled); - } - default: { - return this.handleIgnoreAction(httpContextProvider, matchedConfig.Name); - } - } - } - catch (e) { - if (connectorDiagnostics.isEnabled) - debugEntries["Exception"] = e.message; - throw e; - } - finally { - this.setDebugCookie(debugEntries, httpContextProvider); - } - }; - KnownUser.cancelRequestByLocalConfig = function (targetUrl, queueitToken, cancelConfig, customerId, secretKey, httpContextProvider) { - var debugEntries = {}; - var connectorDiagnostics = QueueITHelpers_1.ConnectorDiagnostics.verify(customerId, secretKey, queueitToken); - if (connectorDiagnostics.hasError) - return connectorDiagnostics.validationResult; - try { - return this._cancelRequestByLocalConfig(targetUrl, queueitToken, cancelConfig, customerId, secretKey, httpContextProvider, debugEntries, connectorDiagnostics.isEnabled); - } - catch (e) { - if (connectorDiagnostics.isEnabled) - debugEntries["Exception"] = e.message; - throw e; - } - finally { - this.setDebugCookie(debugEntries, httpContextProvider); - } - }; - KnownUser.QueueITTokenKey = "queueittoken"; - KnownUser.QueueITDebugKey = "queueitdebug"; - KnownUser.QueueITAjaxHeaderKey = "x-queueit-ajaxpageurl"; - KnownUser.UserInQueueService = null; - return KnownUser; - }()); - exports.KnownUser = KnownUser; - }, { "./IntegrationConfig/IntegrationConfigHelpers": 1, "./Models": 4, "./QueueITHelpers": 5, "./UserInQueueService": 6, "./UserInQueueStateCookieRepository": 7 }], 4: [function (require, module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ActionTypes = exports.KnownUserException = exports.RequestValidationResult = exports.CancelEventConfig = exports.QueueEventConfig = void 0; - var QueueITHelpers_1 = require("./QueueITHelpers"); - var QueueEventConfig = /** @class */ (function () { - function QueueEventConfig(eventId, layoutName, culture, queueDomain, extendCookieValidity, cookieValidityMinute, cookieDomain, version, actionName) { - if (actionName === void 0) { - actionName = 'unspecified'; - } - this.eventId = eventId; - this.layoutName = layoutName; - this.culture = culture; - this.queueDomain = queueDomain; - this.extendCookieValidity = extendCookieValidity; - this.cookieValidityMinute = cookieValidityMinute; - this.cookieDomain = cookieDomain; - this.version = version; - this.actionName = actionName; - } - QueueEventConfig.prototype.getString = function () { - return "EventId:" + this.eventId + "&Version:" + this.version + "&ActionName:" + this.actionName + "&QueueDomain:" + this.queueDomain + - ("&CookieDomain:" + this.cookieDomain + "&ExtendCookieValidity:" + this.extendCookieValidity) + - ("&CookieValidityMinute:" + this.cookieValidityMinute + "&LayoutName:" + this.layoutName + "&Culture:" + this.culture); - }; - return QueueEventConfig; - }()); - exports.QueueEventConfig = QueueEventConfig; - var CancelEventConfig = /** @class */ (function () { - function CancelEventConfig(eventId, queueDomain, cookieDomain, version, actionName) { - if (actionName === void 0) { - actionName = 'unspecified'; - } - this.eventId = eventId; - this.queueDomain = queueDomain; - this.cookieDomain = cookieDomain; - this.version = version; - this.actionName = actionName; - } - CancelEventConfig.prototype.getString = function () { - return "EventId:" + this.eventId + "&Version:" + this.version + - ("&QueueDomain:" + this.queueDomain + "&CookieDomain:" + this.cookieDomain + "&ActionName:" + this.actionName); - }; - return CancelEventConfig; - }()); - exports.CancelEventConfig = CancelEventConfig; - var RequestValidationResult = /** @class */ (function () { - function RequestValidationResult(actionType, eventId, queueId, redirectUrl, redirectType, actionName) { - this.actionType = actionType; - this.eventId = eventId; - this.queueId = queueId; - this.redirectUrl = redirectUrl; - this.redirectType = redirectType; - this.actionName = actionName; - } - RequestValidationResult.prototype.doRedirect = function () { - return !!this.redirectUrl; - }; - RequestValidationResult.prototype.getAjaxQueueRedirectHeaderKey = function () { - return "x-queueit-redirect"; - }; - RequestValidationResult.prototype.getAjaxRedirectUrl = function () { - if (this.redirectUrl) { - return QueueITHelpers_1.Utils.encodeUrl(this.redirectUrl); - } - return ""; - }; - return RequestValidationResult; - }()); - exports.RequestValidationResult = RequestValidationResult; - var KnownUserException = /** @class */ (function () { - function KnownUserException(message) { - this.message = message; - } - return KnownUserException; - }()); - exports.KnownUserException = KnownUserException; - var ActionTypes = /** @class */ (function () { - function ActionTypes() { - } - ActionTypes.QueueAction = "Queue"; - ActionTypes.CancelAction = "Cancel"; - ActionTypes.IgnoreAction = "Ignore"; - return ActionTypes; - }()); - exports.ActionTypes = ActionTypes; - }, { "./QueueITHelpers": 5 }], 5: [function (require, module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ConnectorDiagnostics = exports.CookieHelper = exports.QueueParameterHelper = exports.QueueUrlParams = exports.Utils = void 0; - var Models_1 = require("./Models"); - var Utils = /** @class */ (function () { - function Utils() { - } - Utils.encodeUrl = function (url) { - if (!url) - return ""; - return encodeURIComponent(url).replace(/[!'()*]/g, function (c) { - // More stringent in adhering to RFC 3986 (which reserves!, ', (, ), and *) - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent - return '%' + c.charCodeAt(0).toString(16); - }); - }; - Utils.decodeUrl = function (url) { - return decodeURIComponent(url); - }; - Utils.generateSHA256Hash = function (secretKey, stringToHash) { - throw new Models_1.KnownUserException("Missing implementation for generateSHA256Hash"); - }; - Utils.endsWith = function (str, search) { - if (str === search) - return true; - if (!str || !search) - return false; - return str.substring(str.length - search.length, str.length) === search; - }; - Utils.getCurrentTime = function () { - return Math.floor(new Date().getTime() / 1000); - }; - return Utils; - }()); - exports.Utils = Utils; - var QueueUrlParams = /** @class */ (function () { - function QueueUrlParams() { - this.timeStamp = 0; - this.extendableCookie = false; - } - return QueueUrlParams; - }()); - exports.QueueUrlParams = QueueUrlParams; - var QueueParameterHelper = /** @class */ (function () { - function QueueParameterHelper() { - } - QueueParameterHelper.extractQueueParams = function (queueitToken) { - if (!queueitToken) { - return null; - } - var result = new QueueUrlParams(); - result.queueITToken = queueitToken; - var paramList = result.queueITToken.split(QueueParameterHelper.KeyValueSeparatorGroupChar); - for (var _i = 0, paramList_1 = paramList; _i < paramList_1.length; _i++) { - var paramKeyValue = paramList_1[_i]; - var keyValueArr = paramKeyValue.split(QueueParameterHelper.KeyValueSeparatorChar); - if (keyValueArr.length !== 2) { - continue; - } - switch (keyValueArr[0]) { - case QueueParameterHelper.HashKey: - result.hashCode = keyValueArr[1] || ""; - break; - case QueueParameterHelper.TimeStampKey: { - result.timeStamp = parseInt(keyValueArr[1]); - if (!result.timeStamp) { - result.timeStamp = 0; - } - break; - } - case QueueParameterHelper.CookieValidityMinutesKey: { - result.cookieValidityMinutes = parseInt(keyValueArr[1]); - if (!result.cookieValidityMinutes) { - result.cookieValidityMinutes = null; - } - break; - } - case QueueParameterHelper.EventIdKey: - result.eventId = keyValueArr[1] || ""; - break; - case QueueParameterHelper.ExtendableCookieKey: { - var extendCookie = (keyValueArr[1] || "false").toLowerCase(); - result.extendableCookie = extendCookie === "true"; - break; - } - case QueueParameterHelper.QueueIdKey: - result.queueId = keyValueArr[1] || ""; - break; - case QueueParameterHelper.RedirectTypeKey: - result.redirectType = keyValueArr[1] || ""; - break; - } - } - var hashWithPrefix = "" + QueueParameterHelper.KeyValueSeparatorGroupChar + QueueParameterHelper.HashKey + QueueParameterHelper.KeyValueSeparatorChar + result.hashCode; - result.queueITTokenWithoutHash = result.queueITToken.replace(hashWithPrefix, ""); - return result; - }; - QueueParameterHelper.TimeStampKey = "ts"; - QueueParameterHelper.ExtendableCookieKey = "ce"; - QueueParameterHelper.CookieValidityMinutesKey = "cv"; - QueueParameterHelper.HashKey = "h"; - QueueParameterHelper.EventIdKey = "e"; - QueueParameterHelper.QueueIdKey = "q"; - QueueParameterHelper.RedirectTypeKey = "rt"; - QueueParameterHelper.KeyValueSeparatorChar = '_'; - QueueParameterHelper.KeyValueSeparatorGroupChar = '~'; - return QueueParameterHelper; - }()); - exports.QueueParameterHelper = QueueParameterHelper; - var CookieHelper = /** @class */ (function () { - function CookieHelper() { - } - CookieHelper.toMapFromValue = function (cookieValue) { - try { - var result = {}; - var decoded = cookieValue; - var items = decoded.split('&'); - for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { - var item = items_1[_i]; - var keyValue = item.split('='); - result[keyValue[0]] = keyValue[1]; - } - return result; - } - catch (_a) { - return {}; - } - }; - CookieHelper.toValueFromKeyValueCollection = function (cookieValues) { - var values = new Array(); - for (var _i = 0, cookieValues_1 = cookieValues; _i < cookieValues_1.length; _i++) { - var keyVal = cookieValues_1[_i]; - values.push(keyVal.key + "=" + keyVal.value); - } - var result = values.join("&"); - return result; - }; - return CookieHelper; - }()); - exports.CookieHelper = CookieHelper; - var ConnectorDiagnostics = /** @class */ (function () { - function ConnectorDiagnostics() { - this.isEnabled = false; - this.hasError = false; - } - ConnectorDiagnostics.prototype.setStateWithTokenError = function (customerId, errorCode) { - this.hasError = true; - var redirectUrl = "https://" + customerId + ".api2.queue-it.net/" + customerId + "/diagnostics/connector/error/?code=" + errorCode; - this.validationResult = new Models_1.RequestValidationResult("ConnectorDiagnosticsRedirect", null, null, redirectUrl, null, null); - }; - ConnectorDiagnostics.prototype.setStateWithSetupError = function () { - this.hasError = true; - this.validationResult = new Models_1.RequestValidationResult("ConnectorDiagnosticsRedirect", null, null, "https://api2.queue-it.net/diagnostics/connector/error/?code=setup", null, null); - }; - ConnectorDiagnostics.verify = function (customerId, secretKey, queueitToken) { - var diagnostics = new ConnectorDiagnostics(); - var qParams = QueueParameterHelper.extractQueueParams(queueitToken); - if (qParams == null) - return diagnostics; - if (qParams.redirectType == null) - return diagnostics; - if (qParams.redirectType !== "debug") - return diagnostics; - if (!(customerId && secretKey)) { - diagnostics.setStateWithSetupError(); - return diagnostics; - } - if (Utils.generateSHA256Hash(secretKey, qParams.queueITTokenWithoutHash) != qParams.hashCode) { - diagnostics.setStateWithTokenError(customerId, "hash"); - return diagnostics; - } - if (qParams.timeStamp < Utils.getCurrentTime()) { - diagnostics.setStateWithTokenError(customerId, "timestamp"); - return diagnostics; - } - diagnostics.isEnabled = true; - return diagnostics; - }; - return ConnectorDiagnostics; - }()); - exports.ConnectorDiagnostics = ConnectorDiagnostics; - }, { "./Models": 4 }], 6: [function (require, module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.UserInQueueService = void 0; - var QueueITHelpers_1 = require("./QueueITHelpers"); - var Models_1 = require("./Models"); - var UserInQueueService = /** @class */ (function () { - function UserInQueueService(userInQueueStateRepository) { - this.userInQueueStateRepository = userInQueueStateRepository; - } - UserInQueueService.prototype.getValidTokenResult = function (config, queueParams, secretKey) { - this.userInQueueStateRepository.store(config.eventId, queueParams.queueId, queueParams.cookieValidityMinutes, config.cookieDomain, queueParams.redirectType, secretKey); - return new Models_1.RequestValidationResult(Models_1.ActionTypes.QueueAction, config.eventId, queueParams.queueId, null, queueParams.redirectType, config.actionName); - }; - UserInQueueService.prototype.getErrorResult = function (customerId, targetUrl, config, qParams, errorCode) { - var query = this.getQueryString(customerId, config.eventId, config.version, config.culture, config.layoutName, config.actionName) + - ("&queueittoken=" + qParams.queueITToken) + - ("&ts=" + QueueITHelpers_1.Utils.getCurrentTime()) + - (targetUrl ? "&t=" + QueueITHelpers_1.Utils.encodeUrl(targetUrl) : ""); - var uriPath = "error/" + errorCode + "/"; - var redirectUrl = this.generateRedirectUrl(config.queueDomain, uriPath, query); - return new Models_1.RequestValidationResult(Models_1.ActionTypes.QueueAction, config.eventId, null, redirectUrl, null, config.actionName); - }; - UserInQueueService.prototype.getQueueResult = function (targetUrl, config, customerId) { - var query = this.getQueryString(customerId, config.eventId, config.version, config.culture, config.layoutName, config.actionName) + - (targetUrl ? "&t=" + QueueITHelpers_1.Utils.encodeUrl(targetUrl) : ""); - var redirectUrl = this.generateRedirectUrl(config.queueDomain, "", query); - return new Models_1.RequestValidationResult(Models_1.ActionTypes.QueueAction, config.eventId, null, redirectUrl, null, config.actionName); - }; - UserInQueueService.prototype.getQueryString = function (customerId, eventId, configVersion, culture, layoutName, actionName) { - var queryStringList = new Array(); - queryStringList.push("c=" + QueueITHelpers_1.Utils.encodeUrl(customerId)); - queryStringList.push("e=" + QueueITHelpers_1.Utils.encodeUrl(eventId)); - queryStringList.push("ver=" + UserInQueueService.SDK_VERSION); - queryStringList.push("cver=" + configVersion); - queryStringList.push("man=" + QueueITHelpers_1.Utils.encodeUrl(actionName)); - if (culture) - queryStringList.push("cid=" + QueueITHelpers_1.Utils.encodeUrl(culture)); - if (layoutName) - queryStringList.push("l=" + QueueITHelpers_1.Utils.encodeUrl(layoutName)); - return queryStringList.join("&"); - }; - UserInQueueService.prototype.generateRedirectUrl = function (queueDomain, uriPath, query) { - if (!QueueITHelpers_1.Utils.endsWith(queueDomain, "/")) - queueDomain = queueDomain + "/"; - var redirectUrl = "https://" + queueDomain + uriPath + "?" + query; - return redirectUrl; - }; - UserInQueueService.prototype.validateQueueRequest = function (targetUrl, queueitToken, config, customerId, secretKey) { - var state = this.userInQueueStateRepository.getState(config.eventId, config.cookieValidityMinute, secretKey, true); - if (state.isValid) { - if (state.isStateExtendable() && config.extendCookieValidity) { - this.userInQueueStateRepository.store(config.eventId, state.queueId, null, config.cookieDomain, state.redirectType, secretKey); - } - return new Models_1.RequestValidationResult(Models_1.ActionTypes.QueueAction, config.eventId, state.queueId, null, state.redirectType, config.actionName); - } - var queueParams = QueueITHelpers_1.QueueParameterHelper.extractQueueParams(queueitToken); - var requestValidationResult = null; - var isTokenValid = false; - if (queueParams != null) { - var tokenValidationResult = this.validateToken(config, queueParams, secretKey); - isTokenValid = tokenValidationResult.isValid; - if (isTokenValid) { - requestValidationResult = this.getValidTokenResult(config, queueParams, secretKey); - } - else { - requestValidationResult = this.getErrorResult(customerId, targetUrl, config, queueParams, tokenValidationResult.errorCode); - } - } - else { - requestValidationResult = this.getQueueResult(targetUrl, config, customerId); - } - if (state.isFound && !isTokenValid) { - this.userInQueueStateRepository.cancelQueueCookie(config.eventId, config.cookieDomain); - } - return requestValidationResult; - }; - UserInQueueService.prototype.validateCancelRequest = function (targetUrl, config, customerId, secretKey) { - //we do not care how long cookie is valid while canceling cookie - var state = this.userInQueueStateRepository.getState(config.eventId, -1, secretKey, false); - if (state.isValid) { - this.userInQueueStateRepository.cancelQueueCookie(config.eventId, config.cookieDomain); - var query = this.getQueryString(customerId, config.eventId, config.version, null, null, config.actionName) + - (targetUrl ? "&r=" + QueueITHelpers_1.Utils.encodeUrl(targetUrl) : ""); - var uriPath = "cancel/" + customerId + "/" + config.eventId + "/"; - var redirectUrl = this.generateRedirectUrl(config.queueDomain, uriPath, query); - return new Models_1.RequestValidationResult(Models_1.ActionTypes.CancelAction, config.eventId, state.queueId, redirectUrl, state.redirectType, config.actionName); - } - else { - return new Models_1.RequestValidationResult(Models_1.ActionTypes.CancelAction, config.eventId, null, null, null, config.actionName); - } - }; - UserInQueueService.prototype.extendQueueCookie = function (eventId, cookieValidityMinutes, cookieDomain, secretKey) { - this.userInQueueStateRepository.reissueQueueCookie(eventId, cookieValidityMinutes, cookieDomain, secretKey); - }; - UserInQueueService.prototype.getIgnoreResult = function (actionName) { - return new Models_1.RequestValidationResult(Models_1.ActionTypes.IgnoreAction, null, null, null, null, actionName); - }; - UserInQueueService.prototype.validateToken = function (config, queueParams, secretKey) { - var calculatedHash = QueueITHelpers_1.Utils.generateSHA256Hash(secretKey, queueParams.queueITTokenWithoutHash); - if (calculatedHash !== queueParams.hashCode) - return new TokenValidationResult(false, "hash"); - if (queueParams.eventId !== config.eventId) - return new TokenValidationResult(false, "eventid"); - if (queueParams.timeStamp < QueueITHelpers_1.Utils.getCurrentTime()) - return new TokenValidationResult(false, "timestamp"); - return new TokenValidationResult(true, null); - }; - UserInQueueService.SDK_VERSION = "v3-javascript-" + "3.6.3"; - return UserInQueueService; - }()); - exports.UserInQueueService = UserInQueueService; - var TokenValidationResult = /** @class */ (function () { - function TokenValidationResult(isValid, errorCode) { - this.isValid = isValid; - this.errorCode = errorCode; - } - return TokenValidationResult; - }()); - }, { "./Models": 4, "./QueueITHelpers": 5 }], 7: [function (require, module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.StateInfo = exports.UserInQueueStateCookieRepository = void 0; - var QueueITHelpers_1 = require("./QueueITHelpers"); - var UserInQueueStateCookieRepository = /** @class */ (function () { - function UserInQueueStateCookieRepository(httpContextProvider) { - this.httpContextProvider = httpContextProvider; - } - UserInQueueStateCookieRepository.getCookieKey = function (eventId) { - return UserInQueueStateCookieRepository._QueueITDataKey + "_" + eventId; - }; - UserInQueueStateCookieRepository.prototype.store = function (eventId, queueId, fixedCookieValidityMinutes, cookieDomain, redirectType, secretKey) { - this.createCookie(eventId, queueId, fixedCookieValidityMinutes ? fixedCookieValidityMinutes.toString() : "", redirectType, cookieDomain, secretKey); - }; - UserInQueueStateCookieRepository.prototype.createCookie = function (eventId, queueId, fixedCookieValidityMinutes, redirectType, cookieDomain, secretKey) { - var cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); - var issueTime = QueueITHelpers_1.Utils.getCurrentTime().toString(); - var cookieValues = new Array(); - cookieValues.push({ key: UserInQueueStateCookieRepository._EventIdKey, value: eventId }); - cookieValues.push({ key: UserInQueueStateCookieRepository._QueueIdKey, value: queueId }); - if (fixedCookieValidityMinutes) { - cookieValues.push({ key: UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey, value: fixedCookieValidityMinutes }); - } - cookieValues.push({ key: UserInQueueStateCookieRepository._RedirectTypeKey, value: redirectType.toLowerCase() }); - cookieValues.push({ key: UserInQueueStateCookieRepository._IssueTimeKey, value: issueTime }); - cookieValues.push({ - key: UserInQueueStateCookieRepository._HashKey, - value: this.generateHash(eventId.toLowerCase(), queueId, fixedCookieValidityMinutes, redirectType.toLowerCase(), issueTime, secretKey) - }); - var tommorrow = new Date(); - tommorrow.setDate(tommorrow.getDate() + 1); - var expire = Math.floor(tommorrow.getTime() / 1000); - this.httpContextProvider.getHttpResponse().setCookie(cookieKey, QueueITHelpers_1.CookieHelper.toValueFromKeyValueCollection(cookieValues), cookieDomain, expire); - }; - UserInQueueStateCookieRepository.prototype.getState = function (eventId, cookieValidityMinutes, secretKey, validateTime) { - try { - var cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); - var cookie = this.httpContextProvider.getHttpRequest().getCookieValue(cookieKey); - if (!cookie) - return new StateInfo(false, false, "", null, ""); - var cookieValues = QueueITHelpers_1.CookieHelper.toMapFromValue(cookie); - if (!this.isCookieValid(secretKey, cookieValues, eventId, cookieValidityMinutes, validateTime)) - return new StateInfo(true, false, "", null, ""); - return new StateInfo(true, true, cookieValues[UserInQueueStateCookieRepository._QueueIdKey], cookieValues[UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey] - ? parseInt(cookieValues[UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey]) - : null, cookieValues[UserInQueueStateCookieRepository._RedirectTypeKey]); - } - catch (ex) { - return new StateInfo(true, false, "", null, ""); - } - }; - UserInQueueStateCookieRepository.prototype.isCookieValid = function (secretKey, cookieValueMap, eventId, cookieValidityMinutes, validateTime) { - try { - var storedHash = cookieValueMap[UserInQueueStateCookieRepository._HashKey] || ""; - var issueTimeString = cookieValueMap[UserInQueueStateCookieRepository._IssueTimeKey] || ""; - var queueId = cookieValueMap[UserInQueueStateCookieRepository._QueueIdKey] || ""; - var eventIdFromCookie = cookieValueMap[UserInQueueStateCookieRepository._EventIdKey] || ""; - var redirectType = cookieValueMap[UserInQueueStateCookieRepository._RedirectTypeKey] || ""; - var fixedCookieValidityMinutes = cookieValueMap[UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey] || ""; - var expectedHash = this.generateHash(eventIdFromCookie, queueId, fixedCookieValidityMinutes, redirectType, issueTimeString, secretKey); - if (expectedHash !== storedHash) - return false; - if (eventId.toLowerCase() !== eventIdFromCookie.toLowerCase()) - return false; - if (validateTime) { - var validity = fixedCookieValidityMinutes ? parseInt(fixedCookieValidityMinutes) : cookieValidityMinutes; - var expirationTime = parseInt(issueTimeString) + validity * 60; - if (expirationTime < QueueITHelpers_1.Utils.getCurrentTime()) - return false; - } - return true; - } - catch (_a) { - return false; - } - }; - UserInQueueStateCookieRepository.prototype.cancelQueueCookie = function (eventId, cookieDomain) { - var cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); - this.httpContextProvider.getHttpResponse().setCookie(cookieKey, "", cookieDomain, 0); - }; - UserInQueueStateCookieRepository.prototype.reissueQueueCookie = function (eventId, cookieValidityMinutes, cookieDomain, secretKey) { - var cookieKey = UserInQueueStateCookieRepository.getCookieKey(eventId); - var cookie = this.httpContextProvider.getHttpRequest().getCookieValue(cookieKey); - if (!cookie) - return; - var cookieValues = QueueITHelpers_1.CookieHelper.toMapFromValue(cookie); - if (!this.isCookieValid(secretKey, cookieValues, eventId, cookieValidityMinutes, true)) - return; - var fixedCookieValidityMinutes = ""; - if (cookieValues[UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey]) - fixedCookieValidityMinutes = cookieValues[UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey].toString(); - this.createCookie(eventId, cookieValues[UserInQueueStateCookieRepository._QueueIdKey], fixedCookieValidityMinutes, cookieValues[UserInQueueStateCookieRepository._RedirectTypeKey], cookieDomain, secretKey); - }; - UserInQueueStateCookieRepository.prototype.generateHash = function (eventId, queueId, fixedCookieValidityMinutes, redirectType, issueTime, secretKey) { - var valueToHash = eventId + queueId + fixedCookieValidityMinutes + redirectType + issueTime; - return QueueITHelpers_1.Utils.generateSHA256Hash(secretKey, valueToHash); - }; - UserInQueueStateCookieRepository._QueueITDataKey = "QueueITAccepted-SDFrts345E-V3"; - UserInQueueStateCookieRepository._HashKey = "Hash"; - UserInQueueStateCookieRepository._IssueTimeKey = "IssueTime"; - UserInQueueStateCookieRepository._QueueIdKey = "QueueId"; - UserInQueueStateCookieRepository._EventIdKey = "EventId"; - UserInQueueStateCookieRepository._RedirectTypeKey = "RedirectType"; - UserInQueueStateCookieRepository._FixedCookieValidityMinutesKey = "FixedValidityMins"; - return UserInQueueStateCookieRepository; - }()); - exports.UserInQueueStateCookieRepository = UserInQueueStateCookieRepository; - var StateInfo = /** @class */ (function () { - function StateInfo(isFound, isValid, queueId, fixedCookieValidityMinutes, redirectType) { - this.isFound = isFound; - this.isValid = isValid; - this.queueId = queueId; - this.fixedCookieValidityMinutes = fixedCookieValidityMinutes; - this.redirectType = redirectType; - } - StateInfo.prototype.isStateExtendable = function () { - return this.isValid && !this.fixedCookieValidityMinutes; - }; - return StateInfo; - }()); - exports.StateInfo = StateInfo; - }, { "./QueueITHelpers": 5 }], 8: [function (require, module, exports) { - "use strict"; - var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); - }) : (function (o, m, k, k2) { - if (k2 === undefined) - k2 = k; - o[k2] = m[k]; - })); - var __exportStar = (this && this.__exportStar) || function (m, exports) { - for (var p in m) - if (p !== "default" && !exports.hasOwnProperty(p)) - __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); - var KnownUser_1 = require("./KnownUser"); - Object.defineProperty(exports, "KnownUser", { enumerable: true, get: function () { return KnownUser_1.KnownUser; } }); - __exportStar(require("./Models"), exports); - var QueueITHelpers_1 = require("./QueueITHelpers"); - Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return QueueITHelpers_1.Utils; } }); - Object.defineProperty(exports, "QueueParameterHelper", { enumerable: true, get: function () { return QueueITHelpers_1.QueueParameterHelper; } }); - Object.defineProperty(exports, "QueueUrlParams", { enumerable: true, get: function () { return QueueITHelpers_1.QueueUrlParams; } }); - exportObject.KnownUser = KnownUser_1.KnownUser; - exportObject.Utils = QueueITHelpers_1.Utils; - }, { "./KnownUser": 3, "./Models": 4, "./QueueITHelpers": 5 }] }, {}, [8]); -var Utils = exportObject.Utils; -var KnownUser = exportObject.KnownUser; -export { KnownUser, Utils };