@queue-it/fastly 2.0.0 → 2.0.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +4 -7
- package/src/contextProvider.ts +14 -6
- package/src/helper.ts +1 -8
- package/src/requestResponseHandler.ts +1 -3
- package/src/sdk/HttpContextProvider.ts +0 -23
- package/src/sdk/IntegrationConfig/CustomerIntegrationDecodingHandler.ts +0 -57
- package/src/sdk/IntegrationConfig/IntegrationConfigHelpers.ts +0 -230
- package/src/sdk/IntegrationConfig/IntegrationConfigModel.ts +0 -93
- package/src/sdk/KnownUser.ts +0 -393
- package/src/sdk/Models.ts +0 -105
- package/src/sdk/QueueITHelpers.ts +0 -267
- package/src/sdk/UserInQueueService.ts +0 -245
- package/src/sdk/UserInQueueStateCookieRepository.ts +0 -188
- package/src/sdk/helpers/Uri.ts +0 -4
- /package/src/{sdk/helpers → helpers}/crypto.ts +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# KnownUser.V3.Fastly
|
|
2
2
|
|
|
3
3
|
The Queue-it Security Framework ensures that end-users are not able to access your online application without first
|
|
4
|
-
going through the queue for any and all
|
|
4
|
+
going through the queue for any and all `protected` areas and paths on your sites. The queue system is implemented by
|
|
5
5
|
adding a server-side (request-level) integration that protects your online application by redirecting users to a waiting
|
|
6
6
|
room according to web traffic settings in the Queue-it GO Platform. After the integration is complete, queue system
|
|
7
|
-
behavior and operations are managed in Queue-it
|
|
7
|
+
behavior and operations are managed in Queue-it's Go Platform and/or via the Queue-it Admin API.
|
|
8
8
|
|
|
9
|
-
This Fastly Queue-it Connector SDK (aka, Queue-it
|
|
9
|
+
This Fastly Queue-it Connector SDK (aka, Queue-it's server-side KnownUser connector) uses a Compute@Edge service to
|
|
10
10
|
integrate Queue-it's functionality into Fastly's network.
|
|
11
11
|
|
|
12
12
|
A Wasm service is required to utilize this connector.
|
|
@@ -52,7 +52,7 @@ There are two methods of installation:
|
|
|
52
52
|
- You can verify that the `Config store` has been linked by going to your service and see it in the section `Config stores`
|
|
53
53
|
- Download the latest package from the releases page and unarchive it.
|
|
54
54
|
- Edit the `fastly.toml` file and copy the ID of your service (you can see this by opening up the service in Fastly) and
|
|
55
|
-
replace
|
|
55
|
+
replace **{YourServiceId}** with it.
|
|
56
56
|
- Archive the directory in the same format (tar.gz).
|
|
57
57
|
- Go to `Package` in the Fastly service page and upload the package.
|
|
58
58
|
- To finish up and deploy your service click on the **Activate** button.
|
|
@@ -61,9 +61,9 @@ There are two methods of installation:
|
|
|
61
61
|
|
|
62
62
|
- Go to the Fastly services page and create a new **Wasm** service and copy it's ID.
|
|
63
63
|
- Clone this repository and edit the fastly.toml file, make sure to set the `service_id` field to the ID you copied.
|
|
64
|
-
- Then click on *Origins* and add a new host that has the hostname of your origin server.
|
|
64
|
+
- Then click on *Origins* and add a new host that has the hostname of your origin server.
|
|
65
65
|
You can name the host **origin** or whatever you choose.
|
|
66
|
-
- Create a host that has the hostname of `{yourCustomerId}.queue-it.net` and name it **queue-it**.
|
|
66
|
+
- Create a host that has the hostname of `{yourCustomerId}.queue-it.net` and name it **queue-it**.
|
|
67
67
|
Edit the host, go to advanced options and fill in the same hostname in **Override host**
|
|
68
68
|
- Go to **Resources -> Config stores** and create a new config store named `IntegrationConfiguration`.
|
|
69
69
|
- Add the following items in the config store (you can find these values in the Go Queue-It self-service platform):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@queue-it/fastly",
|
|
3
|
-
"version": "2.0.0",
|
|
3
|
+
"version": "2.0.3-beta.0",
|
|
4
4
|
"description": "Queue-it connector for Fastly",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"author": "devs@queue-it.com",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"package.json",
|
|
11
11
|
"README.md",
|
|
12
|
-
"src/
|
|
12
|
+
"src/helpers",
|
|
13
13
|
"src/contextProvider.ts",
|
|
14
14
|
"src/helper.ts",
|
|
15
15
|
"src/integrationConfigProvider.ts",
|
|
@@ -17,19 +17,16 @@
|
|
|
17
17
|
"src/index.ts"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"test": "jest",
|
|
21
20
|
"bundle": "esbuild src/index.ts --bundle --outfile=bin/index.js --platform=node --target=es2022 && js-compute-runtime bin/index.js bin/main.wasm",
|
|
22
21
|
"build": "fastly compute build",
|
|
23
22
|
"deploy": "fastly compute deploy"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@fastly/js-compute": "^3.0.0"
|
|
25
|
+
"@fastly/js-compute": "^3.0.0",
|
|
26
|
+
"@queue-it/connector-javascript": "^5.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/jest": "^29.5.0",
|
|
30
29
|
"esbuild": "^0.27.3",
|
|
31
|
-
"jest": "^29.5.0",
|
|
32
|
-
"ts-jest": "^29.1.0",
|
|
33
30
|
"typescript": "^5.4.0"
|
|
34
31
|
}
|
|
35
32
|
}
|
package/src/contextProvider.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IConnectorContextProvider, IHttpRequest, IHttpResponse } from '@queue-it/connector-javascript';
|
|
2
|
+
import { FastlyCryptoProvider } from './fastlyCryptoProvider';
|
|
3
3
|
|
|
4
4
|
export function getHttpHandler(req: Request): FastlyHttpContextProvider {
|
|
5
5
|
return new FastlyHttpContextProvider(req);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export class FastlyHttpContextProvider implements
|
|
8
|
+
export class FastlyHttpContextProvider implements IConnectorContextProvider {
|
|
9
9
|
isError: boolean = false;
|
|
10
10
|
private readonly req: FastlyHttpRequest;
|
|
11
11
|
private readonly res: FastlyHttpResponse;
|
|
@@ -22,6 +22,14 @@ export class FastlyHttpContextProvider implements IHttpContextProvider {
|
|
|
22
22
|
getHttpResponse(): IHttpResponse {
|
|
23
23
|
return this.res;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
getCryptoProvider(): FastlyCryptoProvider {
|
|
27
|
+
return new FastlyCryptoProvider();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getEnqueueTokenProvider(): null {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
export class FastlyHttpRequest implements IHttpRequest {
|
|
@@ -64,11 +72,11 @@ export class FastlyHttpRequest implements IHttpRequest {
|
|
|
64
72
|
return this.baseReq.url;
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
getCookieValue(cookieKey: string): string {
|
|
75
|
+
getCookieValue(cookieKey: string): string | undefined {
|
|
68
76
|
if (this.parsedCookieDic.size == 0) {
|
|
69
77
|
this.parseCookies(this.getHeader('cookie'))
|
|
70
78
|
}
|
|
71
|
-
if (!this.parsedCookieDic.has(cookieKey)) return
|
|
79
|
+
if (!this.parsedCookieDic.has(cookieKey)) return undefined;
|
|
72
80
|
const cookieVal = this.parsedCookieDic.get(cookieKey)!;
|
|
73
81
|
try {
|
|
74
82
|
return decodeURIComponent(cookieVal);
|
|
@@ -110,7 +118,7 @@ export class FastlyHttpResponse implements IHttpResponse {
|
|
|
110
118
|
this.headers = new Headers();
|
|
111
119
|
}
|
|
112
120
|
|
|
113
|
-
setCookie(cookieName: string, cookieValue: string, domain: string, expiration: number): void {
|
|
121
|
+
setCookie(cookieName: string, cookieValue: string, domain: string, expiration: number, _isHttpOnly: boolean, _isSecure: boolean): void {
|
|
114
122
|
const expirationDate = new Date(expiration * 1000);
|
|
115
123
|
let setCookieString = cookieName + "=" + encodeURIComponent(cookieValue) + "; expires=" + expirationDate.toUTCString() + ";";
|
|
116
124
|
if (domain != "") {
|
package/src/helper.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { Utils } from "./sdk/QueueITHelpers";
|
|
2
|
-
import { hmacString } from "./sdk/helpers/crypto";
|
|
3
|
-
|
|
4
1
|
export class QueueITHelper {
|
|
5
|
-
static readonly KUP_VERSION: string = "fastly-2.0.0";
|
|
6
|
-
|
|
7
|
-
static configureKnownUserHashing(): void {
|
|
8
|
-
Utils.generateSHA256Hash = hmacString;
|
|
9
|
-
}
|
|
2
|
+
static readonly KUP_VERSION: string = "fastly-2.0.3-beta.0";
|
|
10
3
|
|
|
11
4
|
static addKUPlatformVersion(redirectQueueUrl: string): string {
|
|
12
5
|
return redirectQueueUrl + "&kupver=" + QueueITHelper.KUP_VERSION;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnownUser } from "
|
|
1
|
+
import { KnownUser, Utils } from "@queue-it/connector-javascript";
|
|
2
2
|
import { QueueITHelper } from "./helper";
|
|
3
3
|
import { FastlyHttpContextProvider, getHttpHandler } from "./contextProvider";
|
|
4
4
|
import {
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
IntegrationDetails,
|
|
8
8
|
QueueItIntegrationEndpointProvider,
|
|
9
9
|
} from "./integrationConfigProvider";
|
|
10
|
-
import { Utils } from "./sdk/QueueITHelpers";
|
|
11
10
|
|
|
12
11
|
const QUEUEIT_FAILED_HEADERNAME = "x-queueit-failed";
|
|
13
12
|
let httpProvider: FastlyHttpContextProvider | null = null;
|
|
@@ -30,7 +29,6 @@ export async function onQueueITRequest(
|
|
|
30
29
|
conf.provider == null
|
|
31
30
|
? new QueueItIntegrationEndpointProvider()
|
|
32
31
|
: conf.provider;
|
|
33
|
-
QueueITHelper.configureKnownUserHashing();
|
|
34
32
|
httpProvider = getHttpHandler(req);
|
|
35
33
|
|
|
36
34
|
let integrationConfigJson = await getIntegrationConfig(conf, integrationProvider);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface IHttpRequest {
|
|
3
|
-
getUserAgent(): string;
|
|
4
|
-
getHeader(name: string): string;
|
|
5
|
-
getAbsoluteUri(): string;
|
|
6
|
-
getUserHostAddress(): string;
|
|
7
|
-
getCookieValue(cookieKey: string): string;
|
|
8
|
-
getRequestBodyAsString(): string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface IHttpResponse {
|
|
12
|
-
setCookie(cookieName: string, cookieValue: string, domain: string, expiration: number): void;
|
|
13
|
-
getHeaders(): Headers;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IHttpContextProvider {
|
|
17
|
-
getHttpRequest(): IHttpRequest;
|
|
18
|
-
getHttpResponse(): IHttpResponse;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface IDateTimeProvider {
|
|
22
|
-
getCurrentTime(): Date
|
|
23
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CustomerIntegration,
|
|
3
|
-
IntegrationConfigModel,
|
|
4
|
-
TriggerModel,
|
|
5
|
-
TriggerPart
|
|
6
|
-
} from "./IntegrationConfigModel";
|
|
7
|
-
|
|
8
|
-
export class CustomerIntegrationDecodingHandler {
|
|
9
|
-
static deserialize(integrationsConfigString: string): CustomerIntegration {
|
|
10
|
-
const result = new CustomerIntegration();
|
|
11
|
-
if (!integrationsConfigString) return result;
|
|
12
|
-
|
|
13
|
-
const parsed = JSON.parse(integrationsConfigString);
|
|
14
|
-
result.Version = parsed.Version ?? 0;
|
|
15
|
-
result.Description = parsed.Description ?? '';
|
|
16
|
-
|
|
17
|
-
if (Array.isArray(parsed.Integrations)) {
|
|
18
|
-
result.Integrations = parsed.Integrations.map((item: any) => {
|
|
19
|
-
const model = new IntegrationConfigModel();
|
|
20
|
-
model.Name = item.Name ?? '';
|
|
21
|
-
model.EventId = item.EventId ?? '';
|
|
22
|
-
model.CookieDomain = item.CookieDomain ?? '';
|
|
23
|
-
model.LayoutName = item.LayoutName ?? '';
|
|
24
|
-
model.Culture = item.Culture ?? '';
|
|
25
|
-
model.ExtendCookieValidity = item.ExtendCookieValidity ?? false;
|
|
26
|
-
model.CookieValidityMinute = item.CookieValidityMinute ?? 0;
|
|
27
|
-
model.QueueDomain = item.QueueDomain ?? '';
|
|
28
|
-
model.RedirectLogic = item.RedirectLogic ?? '';
|
|
29
|
-
model.ForcedTargetUrl = item.ForcedTargetUrl ?? '';
|
|
30
|
-
model.ActionType = item.ActionType ?? '';
|
|
31
|
-
|
|
32
|
-
model.Triggers = (item.Triggers ?? []).map((trigger: any) => {
|
|
33
|
-
const t = new TriggerModel();
|
|
34
|
-
t.LogicalOperator = trigger.LogicalOperator ?? '';
|
|
35
|
-
t.TriggerParts = (trigger.TriggerParts ?? []).map((part: any) => {
|
|
36
|
-
const tp = new TriggerPart();
|
|
37
|
-
tp.ValidatorType = part.ValidatorType ?? '';
|
|
38
|
-
tp.Operator = part.Operator ?? '';
|
|
39
|
-
tp.ValueToCompare = part.ValueToCompare ?? '';
|
|
40
|
-
tp.ValuesToCompare = part.ValuesToCompare ?? [];
|
|
41
|
-
tp.IsNegative = part.IsNegative ?? false;
|
|
42
|
-
tp.IsIgnoreCase = part.IsIgnoreCase ?? false;
|
|
43
|
-
tp.UrlPart = part.UrlPart ?? '';
|
|
44
|
-
tp.CookieName = part.CookieName ?? '';
|
|
45
|
-
tp.HttpHeaderName = part.HttpHeaderName ?? '';
|
|
46
|
-
return tp;
|
|
47
|
-
});
|
|
48
|
-
return t;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return model;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import * as IntegrationModels from './IntegrationConfigModel'
|
|
2
|
-
import {KnownUserException} from '../Models'
|
|
3
|
-
import {IHttpRequest} from '../HttpContextProvider'
|
|
4
|
-
|
|
5
|
-
export interface IIntegrationEvaluator {
|
|
6
|
-
getMatchedIntegrationConfig(
|
|
7
|
-
customerIntegration: IntegrationModels.CustomerIntegration,
|
|
8
|
-
currentPageUrl: string,
|
|
9
|
-
request: IHttpRequest): IntegrationModels.IntegrationConfigModelResult | null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class IntegrationEvaluator implements IIntegrationEvaluator {
|
|
13
|
-
public getMatchedIntegrationConfig(
|
|
14
|
-
customerIntegration: IntegrationModels.CustomerIntegration,
|
|
15
|
-
currentPageUrl: string,
|
|
16
|
-
request: IHttpRequest | null): IntegrationModels.IntegrationConfigModelResult | null {
|
|
17
|
-
|
|
18
|
-
if (request == null)
|
|
19
|
-
return new IntegrationModels.IntegrationConfigModelResult(null, new KnownUserException("request is null"));
|
|
20
|
-
|
|
21
|
-
if (customerIntegration == null)
|
|
22
|
-
return new IntegrationModels.IntegrationConfigModelResult(null, new KnownUserException("customerIntegration is null"));
|
|
23
|
-
|
|
24
|
-
for (let i = 0; i < customerIntegration.Integrations.length; i++) {
|
|
25
|
-
let integration = customerIntegration.Integrations[i];
|
|
26
|
-
for (let t = 0; t < integration.Triggers.length; t++) {
|
|
27
|
-
let trigger = integration.Triggers[t];
|
|
28
|
-
if (this.evaluateTrigger(trigger, currentPageUrl, request)) {
|
|
29
|
-
return new IntegrationModels.IntegrationConfigModelResult(integration, null);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private evaluateTrigger(trigger: IntegrationModels.TriggerModel, currentPageUrl: string, request: IHttpRequest): boolean {
|
|
37
|
-
if (trigger.LogicalOperator == IntegrationModels.LogicalOperatorType.Or) {
|
|
38
|
-
for (let i = 0; i < trigger.TriggerParts.length; i++) {
|
|
39
|
-
let part = trigger.TriggerParts[i];
|
|
40
|
-
if (this.evaluateTriggerPart(part, currentPageUrl, request))
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
} else {
|
|
45
|
-
for (let i = 0; i < trigger.TriggerParts.length; i++) {
|
|
46
|
-
let part = trigger.TriggerParts[i];
|
|
47
|
-
let matched = this.evaluateTriggerPart(part, currentPageUrl, request);
|
|
48
|
-
if (!matched)
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private evaluateTriggerPart(triggerPart: IntegrationModels.TriggerPart, currentPageUrl: string, request: IHttpRequest): boolean {
|
|
56
|
-
if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.UrlValidator) {
|
|
57
|
-
return UrlValidatorHelper.evaluate(triggerPart, currentPageUrl);
|
|
58
|
-
} else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.CookieValidator) {
|
|
59
|
-
return CookieValidatorHelper.evaluate(triggerPart, request);
|
|
60
|
-
} else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.UserAgentValidator) {
|
|
61
|
-
return UserAgentValidatorHelper.evaluate(triggerPart, request.getUserAgent());
|
|
62
|
-
} else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.HttpHeaderValidator) {
|
|
63
|
-
return HttpHeaderValidatorHelper.evaluate(triggerPart, request.getHeader(triggerPart.HttpHeaderName));
|
|
64
|
-
} else if (triggerPart.ValidatorType == IntegrationModels.ValidatorType.RequestBodyValidator) {
|
|
65
|
-
return RequestBodyValidatorHelper.evaluate(triggerPart, request.getRequestBodyAsString());
|
|
66
|
-
} else {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export class UrlValidatorHelper {
|
|
73
|
-
public static evaluate(triggerPart: IntegrationModels.TriggerPart, url: string): boolean {
|
|
74
|
-
let urlpart = this.getUrlPart(triggerPart, url);
|
|
75
|
-
return ComparisonOperatorHelper.evaluate(
|
|
76
|
-
triggerPart.Operator,
|
|
77
|
-
triggerPart.IsNegative,
|
|
78
|
-
triggerPart.IsIgnoreCase,
|
|
79
|
-
urlpart,
|
|
80
|
-
triggerPart.ValueToCompare,
|
|
81
|
-
triggerPart.ValuesToCompare);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private static getUrlPart(triggerPart: IntegrationModels.TriggerPart, url: string): string {
|
|
85
|
-
if (triggerPart.UrlPart == IntegrationModels.UrlPartType.PagePath) {
|
|
86
|
-
return this.getPathFromUrl(url);
|
|
87
|
-
} else if (triggerPart.UrlPart == IntegrationModels.UrlPartType.PageUrl) {
|
|
88
|
-
return url;
|
|
89
|
-
} else if (triggerPart.UrlPart == IntegrationModels.UrlPartType.HostName) {
|
|
90
|
-
return this.getHostNameFromUrl(url);
|
|
91
|
-
} else {
|
|
92
|
-
return "";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public static getHostNameFromUrl(url: string): string {
|
|
97
|
-
let urlx = new URL(url);
|
|
98
|
-
return urlx.host;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public static getPathFromUrl(url: string): string {
|
|
102
|
-
let urlx = new URL(url);
|
|
103
|
-
return urlx.pathname;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export class CookieValidatorHelper {
|
|
108
|
-
public static evaluate(triggerPart: IntegrationModels.TriggerPart, request: IHttpRequest): boolean {
|
|
109
|
-
return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
|
|
110
|
-
triggerPart.IsNegative,
|
|
111
|
-
triggerPart.IsIgnoreCase,
|
|
112
|
-
this.getCookie(triggerPart.CookieName, request),
|
|
113
|
-
triggerPart.ValueToCompare,
|
|
114
|
-
triggerPart.ValuesToCompare);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private static getCookie(cookieName: string, request: IHttpRequest): string {
|
|
118
|
-
return request.getCookieValue(cookieName);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export class UserAgentValidatorHelper {
|
|
123
|
-
public static evaluate(triggerPart: IntegrationModels.TriggerPart, userAgent: string): boolean {
|
|
124
|
-
|
|
125
|
-
return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
|
|
126
|
-
triggerPart.IsNegative,
|
|
127
|
-
triggerPart.IsIgnoreCase,
|
|
128
|
-
userAgent,
|
|
129
|
-
triggerPart.ValueToCompare,
|
|
130
|
-
triggerPart.ValuesToCompare);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export class RequestBodyValidatorHelper {
|
|
135
|
-
public static evaluate(triggerPart: IntegrationModels.TriggerPart, bodyString: string): boolean {
|
|
136
|
-
|
|
137
|
-
return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
|
|
138
|
-
triggerPart.IsNegative,
|
|
139
|
-
triggerPart.IsIgnoreCase,
|
|
140
|
-
bodyString,
|
|
141
|
-
triggerPart.ValueToCompare,
|
|
142
|
-
triggerPart.ValuesToCompare);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export class HttpHeaderValidatorHelper {
|
|
147
|
-
public static evaluate(triggerPart: IntegrationModels.TriggerPart, headerValue: string): boolean {
|
|
148
|
-
return ComparisonOperatorHelper.evaluate(triggerPart.Operator,
|
|
149
|
-
triggerPart.IsNegative,
|
|
150
|
-
triggerPart.IsIgnoreCase,
|
|
151
|
-
headerValue,
|
|
152
|
-
triggerPart.ValueToCompare,
|
|
153
|
-
triggerPart.ValuesToCompare);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export class ComparisonOperatorHelper {
|
|
158
|
-
public static evaluate(opt: string,
|
|
159
|
-
isNegative: boolean,
|
|
160
|
-
isIgnoreCase: boolean,
|
|
161
|
-
value: string,
|
|
162
|
-
valueToCompare: string,
|
|
163
|
-
valuesToCompare: Array<string> | null): boolean {
|
|
164
|
-
if (valuesToCompare == null) {
|
|
165
|
-
valuesToCompare = new Array<string>();
|
|
166
|
-
}
|
|
167
|
-
if (opt == IntegrationModels.ComparisonOperatorType.EqualS) {
|
|
168
|
-
return ComparisonOperatorHelper.equalS(value, valueToCompare, isNegative, isIgnoreCase);
|
|
169
|
-
} else if (opt == IntegrationModels.ComparisonOperatorType.Contains) {
|
|
170
|
-
return ComparisonOperatorHelper.contains(value, valueToCompare, isNegative, isIgnoreCase);
|
|
171
|
-
} else if (opt == IntegrationModels.ComparisonOperatorType.EqualsAny) {
|
|
172
|
-
return ComparisonOperatorHelper.equalsAny(value, valuesToCompare, isNegative, isIgnoreCase);
|
|
173
|
-
} else if (opt == IntegrationModels.ComparisonOperatorType.ContainsAny) {
|
|
174
|
-
return ComparisonOperatorHelper.containsAny(value, valuesToCompare, isNegative, isIgnoreCase);
|
|
175
|
-
} else {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private static contains(value: string, valueToCompare: string, isNegative: boolean, ignoreCase: boolean): boolean {
|
|
181
|
-
if (valueToCompare == "*" && value != "")
|
|
182
|
-
return true;
|
|
183
|
-
|
|
184
|
-
let evaluation = false;
|
|
185
|
-
|
|
186
|
-
if (ignoreCase)
|
|
187
|
-
evaluation = value.toUpperCase().indexOf(valueToCompare.toUpperCase()) != -1;
|
|
188
|
-
else
|
|
189
|
-
evaluation = value.indexOf(valueToCompare) != -1;
|
|
190
|
-
|
|
191
|
-
if (isNegative)
|
|
192
|
-
return !evaluation;
|
|
193
|
-
else
|
|
194
|
-
return evaluation;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private static equalS(value: string, valueToCompare: string, isNegative: boolean, ignoreCase: boolean): boolean {
|
|
198
|
-
let evaluation = false;
|
|
199
|
-
|
|
200
|
-
if (ignoreCase)
|
|
201
|
-
evaluation = value.toUpperCase() == valueToCompare.toUpperCase();
|
|
202
|
-
else
|
|
203
|
-
evaluation = value == valueToCompare;
|
|
204
|
-
|
|
205
|
-
if (isNegative)
|
|
206
|
-
return !evaluation;
|
|
207
|
-
else
|
|
208
|
-
return evaluation;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private static equalsAny(value: string, valuesToCompare: Array<string>, isNegative: boolean, isIgnoreCase: boolean): boolean {
|
|
212
|
-
for (let i = 0; i < valuesToCompare.length; i++) {
|
|
213
|
-
let valueToCompare = valuesToCompare[i];
|
|
214
|
-
if (ComparisonOperatorHelper.equalS(value, valueToCompare, false, isIgnoreCase))
|
|
215
|
-
return !isNegative;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return isNegative;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private static containsAny(value: string, valuesToCompare: Array<string>, isNegative: boolean, isIgnoreCase: boolean): boolean {
|
|
222
|
-
for (let i = 0; i < valuesToCompare.length; i++) {
|
|
223
|
-
let valueToCompare = valuesToCompare[i];
|
|
224
|
-
if (ComparisonOperatorHelper.contains(value, valueToCompare, false, isIgnoreCase))
|
|
225
|
-
return !isNegative;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return isNegative;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {KnownUserException, Tuple} from "../Models";
|
|
2
|
-
|
|
3
|
-
export class IntegrationConfigModelResult extends Tuple<IntegrationConfigModel | null, KnownUserException | null> {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class IntegrationConfigModel {
|
|
7
|
-
Name: string = "";
|
|
8
|
-
EventId: string = "";
|
|
9
|
-
CookieDomain: string = "";
|
|
10
|
-
LayoutName: string = "";
|
|
11
|
-
Culture: string = "";
|
|
12
|
-
ExtendCookieValidity: boolean = false;
|
|
13
|
-
CookieValidityMinute: number = 0;
|
|
14
|
-
QueueDomain: string = "";
|
|
15
|
-
RedirectLogic: string = "";
|
|
16
|
-
ForcedTargetUrl: string = "";
|
|
17
|
-
ActionType: string = "";
|
|
18
|
-
Triggers: Array<TriggerModel>;
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.Triggers = new Array<TriggerModel>();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class CustomerIntegration {
|
|
26
|
-
Integrations: Array<IntegrationConfigModel>;
|
|
27
|
-
Version: number;
|
|
28
|
-
Description: string;
|
|
29
|
-
|
|
30
|
-
constructor() {
|
|
31
|
-
this.Integrations = new Array<IntegrationConfigModel>();
|
|
32
|
-
this.Version = 0;
|
|
33
|
-
this.Description = "";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export class TriggerPart {
|
|
38
|
-
ValidatorType: string = "";
|
|
39
|
-
Operator: string = "";
|
|
40
|
-
ValueToCompare: string = "";
|
|
41
|
-
ValuesToCompare: Array<string>;
|
|
42
|
-
IsNegative: boolean = false;
|
|
43
|
-
IsIgnoreCase: boolean = false;
|
|
44
|
-
UrlPart: string = ""; // UrlValidator
|
|
45
|
-
CookieName: string = ""; // CookieValidator
|
|
46
|
-
HttpHeaderName: string = ""; // HttpHeaderValidator
|
|
47
|
-
|
|
48
|
-
constructor() {
|
|
49
|
-
this.ValuesToCompare = new Array<string>();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class TriggerModel {
|
|
54
|
-
constructor() {
|
|
55
|
-
this.TriggerParts = new Array<TriggerPart>();
|
|
56
|
-
this.LogicalOperator = "";
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
TriggerParts: Array<TriggerPart>;
|
|
60
|
-
LogicalOperator: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class ValidatorType {
|
|
64
|
-
public static readonly UrlValidator: string = "UrlValidator";
|
|
65
|
-
public static readonly CookieValidator: string = "CookieValidator";
|
|
66
|
-
public static readonly UserAgentValidator: string = "UserAgentValidator";
|
|
67
|
-
public static readonly HttpHeaderValidator: string = "HttpHeaderValidator";
|
|
68
|
-
public static readonly RequestBodyValidator: string = "RequestBodyValidator";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class UrlPartType {
|
|
72
|
-
static readonly HostName: string = "HostName";
|
|
73
|
-
static readonly PagePath: string = "PagePath";
|
|
74
|
-
static readonly PageUrl: string = "PageUrl";
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export class ComparisonOperatorType {
|
|
78
|
-
static readonly EqualS: string = "Equals";
|
|
79
|
-
static readonly Contains: string = "Contains";
|
|
80
|
-
static readonly EqualsAny: string = "EqualsAny";
|
|
81
|
-
static readonly ContainsAny: string = "ContainsAny";
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export class LogicalOperatorType {
|
|
85
|
-
public static readonly Or: string = "Or";
|
|
86
|
-
public static readonly And: string = "And";
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class ActionType {
|
|
90
|
-
public static readonly IgnoreAction: string = "Ignore";
|
|
91
|
-
public static readonly CancelAction: string = "Cancel";
|
|
92
|
-
public static readonly QueueAction: string = "Queue";
|
|
93
|
-
}
|