ec4w_validator 0.0.1001111221 → 0.0.1001111223
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.Docker.md +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -25
- package/dist/index.umd.cjs +1 -1
- package/dist/vite.svg +0 -0
- package/package.json +6 -3
package/README.Docker.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Docker usage
|
|
2
|
+
|
|
3
|
+
Docker container may be used, configurations are for:
|
|
4
|
+
* for development purpose only,
|
|
5
|
+
* to setup a development environment in a container
|
|
6
|
+
|
|
7
|
+
commands to run:
|
|
8
|
+
```bash
|
|
9
|
+
docker compose down --remove-orphans \
|
|
10
|
+
# remove any leftover stopped container
|
|
11
|
+
&& \
|
|
12
|
+
# build image and then run it, auto remove when done and on exit
|
|
13
|
+
docker compose run --rm --build app
|
|
14
|
+
# you are in container now --sh--
|
|
15
|
+
# enter `exit` to exit from container's sh
|
|
16
|
+
|
|
17
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function l(n) {
|
|
2
|
+
const e = { ...n }, t = Object.getPrototypeOf(n);
|
|
3
|
+
return Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([r, s]) => {
|
|
4
|
+
typeof s.get == "function" && (e[r] = n[r]);
|
|
5
|
+
}), e;
|
|
6
|
+
}
|
|
7
|
+
class h {
|
|
2
8
|
/** @type {SentRequest[]} */
|
|
3
9
|
#t = [];
|
|
4
10
|
/** @param {SentRequest[]} requestList */
|
|
@@ -11,17 +17,17 @@ class c {
|
|
|
11
17
|
for (const r of this.#t) {
|
|
12
18
|
if (!r.url) continue;
|
|
13
19
|
const s = new URL(r.url);
|
|
14
|
-
|
|
20
|
+
u.canBe(r.method, s) ? e.push(new u(r.method, s)) : c.canBe(r.method, s) && e.push(new c(r.method, s));
|
|
15
21
|
}
|
|
16
22
|
if (e.length < 1) throw new Error("no ( sentRequest ) detected");
|
|
17
23
|
const t = [];
|
|
18
24
|
{
|
|
19
25
|
let r = null;
|
|
20
26
|
for (const s of e)
|
|
21
|
-
s instanceof
|
|
27
|
+
s instanceof u ? r = s : s instanceof c && t.push(new m(r, s));
|
|
22
28
|
}
|
|
23
29
|
if (t.length < 1) throw new Error("no ( UPDE | EC4w ) requests detected");
|
|
24
|
-
return new
|
|
30
|
+
return new g(t);
|
|
25
31
|
}
|
|
26
32
|
/** @param {string} em */
|
|
27
33
|
static emIsValid(e) {
|
|
@@ -30,23 +36,26 @@ class c {
|
|
|
30
36
|
if (r < 2) return !1;
|
|
31
37
|
for (let s = 1; s < r; ++s) {
|
|
32
38
|
if (t[s] === "") return !1;
|
|
33
|
-
const [
|
|
34
|
-
if (!
|
|
39
|
+
const [f, d] = t[s].split(".");
|
|
40
|
+
if (!f || !d) return !1;
|
|
35
41
|
}
|
|
36
42
|
return !0;
|
|
37
43
|
}
|
|
44
|
+
toJSON() {
|
|
45
|
+
return l(this);
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
48
|
const a = Object.freeze({
|
|
40
49
|
em_validInConversion: "valid `em` in Conversion payload",
|
|
41
50
|
em_validInUPDE: "valid `em` in UPDE payload"
|
|
42
|
-
}),
|
|
51
|
+
}), o = Object.freeze({
|
|
43
52
|
em_invalidInConversion: "invalid `em` in Conversion payload",
|
|
44
53
|
em_invalidInUPDE: "invalid `em` in UPDE payload",
|
|
45
54
|
ecsid_mismatch: "mismatch `ecsid` between UPDE and Conversion payload",
|
|
46
55
|
conversionId_mismatch: "mismatch `Conversion ID` between UPDE and Conversion payload",
|
|
47
56
|
noEC4W_request: "no valid EC4W requests detected at all"
|
|
48
57
|
});
|
|
49
|
-
class
|
|
58
|
+
class m {
|
|
50
59
|
#t = null;
|
|
51
60
|
#e;
|
|
52
61
|
/**
|
|
@@ -56,27 +65,30 @@ class f {
|
|
|
56
65
|
this.#t = e, this.#e = t;
|
|
57
66
|
}
|
|
58
67
|
get result() {
|
|
59
|
-
return !this.#t && !this.#e ? new
|
|
68
|
+
return !this.#t && !this.#e ? new i(!1, o.noEC4W_request) : this.#s() === !1 ? new i(!1, o.ecsid_mismatch) : this.#r();
|
|
60
69
|
}
|
|
61
70
|
#s() {
|
|
62
71
|
return this.#e === null ? !1 : this.#t === null ? !0 : !(!this.#t.ecsid || !this.#e.ecsid || this.#t.ecsid !== this.#e.ecsid);
|
|
63
72
|
}
|
|
64
73
|
#r() {
|
|
65
74
|
if (this.#e === null)
|
|
66
|
-
return new
|
|
75
|
+
return new i(!1, o.em_invalidInConversion);
|
|
67
76
|
if (this.#t === null) {
|
|
68
77
|
const t = this.#e.emIsValid();
|
|
69
|
-
return t ? new
|
|
78
|
+
return t ? new i(t, a.em_validInConversion) : new i(t, o.em_invalidInConversion);
|
|
70
79
|
}
|
|
71
80
|
if (this.#e.em === null) {
|
|
72
81
|
const t = this.#t.emIsValid();
|
|
73
|
-
return t ? new
|
|
82
|
+
return t ? new i(t, a.em_validInUPDE) : new i(t, o.em_invalidInUPDE);
|
|
74
83
|
}
|
|
75
84
|
const e = this.#e.emIsValid();
|
|
76
|
-
return e ? new
|
|
85
|
+
return e ? new i(e, a.em_validInConversion) : new i(e, o.em_invalidInConversion);
|
|
86
|
+
}
|
|
87
|
+
toJSON() {
|
|
88
|
+
return l(this);
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
class
|
|
91
|
+
class i {
|
|
80
92
|
#t;
|
|
81
93
|
get isGood() {
|
|
82
94
|
return this.#t;
|
|
@@ -90,8 +102,14 @@ class n {
|
|
|
90
102
|
constructor(e, t) {
|
|
91
103
|
this.#t = e, this.#e = t;
|
|
92
104
|
}
|
|
105
|
+
toJSON() {
|
|
106
|
+
return {
|
|
107
|
+
isGood: this.#t,
|
|
108
|
+
message: this.#e
|
|
109
|
+
};
|
|
110
|
+
}
|
|
93
111
|
}
|
|
94
|
-
class
|
|
112
|
+
class u {
|
|
95
113
|
/**
|
|
96
114
|
* @param {string} method
|
|
97
115
|
* @param {URL} Url */
|
|
@@ -119,10 +137,13 @@ class o {
|
|
|
119
137
|
return this.#e.searchParams.get("ecsid");
|
|
120
138
|
}
|
|
121
139
|
emIsValid() {
|
|
122
|
-
return
|
|
140
|
+
return h.emIsValid(this.em);
|
|
141
|
+
}
|
|
142
|
+
toJSON() {
|
|
143
|
+
return l(this);
|
|
123
144
|
}
|
|
124
145
|
}
|
|
125
|
-
class
|
|
146
|
+
class c {
|
|
126
147
|
/**
|
|
127
148
|
* @param {string} method
|
|
128
149
|
* @param {URL} Url */
|
|
@@ -150,10 +171,13 @@ class u {
|
|
|
150
171
|
return this.#e.searchParams.get("ecsid");
|
|
151
172
|
}
|
|
152
173
|
emIsValid() {
|
|
153
|
-
return
|
|
174
|
+
return h.emIsValid(this.em);
|
|
175
|
+
}
|
|
176
|
+
toJSON() {
|
|
177
|
+
return l(this);
|
|
154
178
|
}
|
|
155
179
|
}
|
|
156
|
-
class
|
|
180
|
+
class g {
|
|
157
181
|
/** @type {EC4W_Request[]} */
|
|
158
182
|
EC4W_Requests = [];
|
|
159
183
|
// errors = [];
|
|
@@ -185,6 +209,9 @@ class m {
|
|
|
185
209
|
// }
|
|
186
210
|
// return summary;
|
|
187
211
|
// }
|
|
212
|
+
toJSON() {
|
|
213
|
+
return l(this);
|
|
214
|
+
}
|
|
188
215
|
}
|
|
189
216
|
class v {
|
|
190
217
|
url = "https://";
|
|
@@ -192,14 +219,17 @@ class v {
|
|
|
192
219
|
constructor(e, t) {
|
|
193
220
|
this.url = e, this.method = t;
|
|
194
221
|
}
|
|
222
|
+
toJSON() {
|
|
223
|
+
return l(this);
|
|
224
|
+
}
|
|
195
225
|
}
|
|
196
226
|
export {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
227
|
+
c as Conversion_Request,
|
|
228
|
+
o as EC4W_ErrorMessages,
|
|
229
|
+
m as EC4W_Request,
|
|
230
|
+
g as EC4W_Result,
|
|
201
231
|
a as EC4W_ValidMessages,
|
|
202
|
-
|
|
232
|
+
h as EC4W_Validator,
|
|
203
233
|
v as SentRequest,
|
|
204
|
-
|
|
234
|
+
u as UPDE_Request
|
|
205
235
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(r=typeof globalThis<"u"?globalThis:r||self,i(r.fafafa={}))})(this,(function(r){"use strict";function i(o){const e={...o},t=Object.getPrototypeOf(o);return Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([n,s])=>{typeof s.get=="function"&&(e[n]=o[n])}),e}class d{#t=[];constructor(e){this.#t=e}conclude(){const e=[];for(const n of this.#t){if(!n.url)continue;const s=new URL(n.url);c.canBe(n.method,s)?e.push(new c(n.method,s)):f.canBe(n.method,s)&&e.push(new f(n.method,s))}if(e.length<1)throw new Error("no ( sentRequest ) detected");const t=[];{let n=null;for(const s of e)s instanceof c?n=s:s instanceof f&&t.push(new h(n,s))}if(t.length<1)throw new Error("no ( UPDE | EC4w ) requests detected");return new m(t)}static emIsValid(e){if(!e||e.startsWith("tv.1")===!1||e==="tv.1"||/^tv\.1~e[0-9]/.test(e))return!1;const t=e.split("~"),n=t.length;if(n<2)return!1;for(let s=1;s<n;++s){if(t[s]==="")return!1;const[v,E]=t[s].split(".");if(!v||!E)return!1}return!0}toJSON(){return i(this)}}const u=Object.freeze({em_validInConversion:"valid `em` in Conversion payload",em_validInUPDE:"valid `em` in UPDE payload"}),l=Object.freeze({em_invalidInConversion:"invalid `em` in Conversion payload",em_invalidInUPDE:"invalid `em` in UPDE payload",ecsid_mismatch:"mismatch `ecsid` between UPDE and Conversion payload",conversionId_mismatch:"mismatch `Conversion ID` between UPDE and Conversion payload",noEC4W_request:"no valid EC4W requests detected at all"});class h{#t=null;#e;constructor(e,t){this.#t=e,this.#e=t}get result(){return!this.#t&&!this.#e?new a(!1,l.noEC4W_request):this.#s()===!1?new a(!1,l.ecsid_mismatch):this.#n()}#s(){return this.#e===null?!1:this.#t===null?!0:!(!this.#t.ecsid||!this.#e.ecsid||this.#t.ecsid!==this.#e.ecsid)}#n(){if(this.#e===null)return new a(!1,l.em_invalidInConversion);if(this.#t===null){const t=this.#e.emIsValid();return t?new a(t,u.em_validInConversion):new a(t,l.em_invalidInConversion)}if(this.#e.em===null){const t=this.#t.emIsValid();return t?new a(t,u.em_validInUPDE):new a(t,l.em_invalidInUPDE)}const e=this.#e.emIsValid();return e?new a(e,u.em_validInConversion):new a(e,l.em_invalidInConversion)}toJSON(){return i(this)}}class a{#t;get isGood(){return this.#t}#e;get message(){return this.#e}constructor(e,t){this.#t=e,this.#e=t}toJSON(){return{isGood:this.#t,message:this.#e}}}class c{static canBe(e,t){return!(e!=="GET"||t.toString().startsWith("https://www.google.com/ccm/form-data/")===!1||t.searchParams.get("em")===null)}#t;get method(){return this.#t}#e;get url(){return this.#e.toString()}constructor(e,t){this.#t=e,this.#e=t}get em(){return this.#e.searchParams.get("em")}get ecsid(){return this.#e.searchParams.get("ecsid")}emIsValid(){return d.emIsValid(this.em)}toJSON(){return i(this)}}class f{static canBe(e,t){return!(e!=="GET"||t.toString().startsWith("https://www.googleadservices.com/ccm/conversion/")===!1||t.searchParams.get("label")===null)}#t;get method(){return this.#t}#e;get url(){return this.#e.toString()}constructor(e,t){this.#t=e,this.#e=t}get em(){return this.#e.searchParams.get("em")}get ecsid(){return this.#e.searchParams.get("ecsid")}emIsValid(){return d.emIsValid(this.em)}toJSON(){return i(this)}}class m{EC4W_Requests=[];messages=[];constructor(e){if(!e||e.length<1)throw new Error("no requests detected");this.EC4W_Requests=e}get invalidRequest(){for(const e of this.EC4W_Requests)if(e.result.isGood===!1)return e;return null}get validRequest(){for(const e of this.EC4W_Requests)if(e.result.isGood)return e;return null}toJSON(){return i(this)}}class g{url="https://";method="GET";constructor(e,t){this.url=e,this.method=t}toJSON(){return i(this)}}r.Conversion_Request=f,r.EC4W_ErrorMessages=l,r.EC4W_Request=h,r.EC4W_Result=m,r.EC4W_ValidMessages=u,r.EC4W_Validator=d,r.SentRequest=g,r.UPDE_Request=c,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/vite.svg
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ec4w_validator",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1001111223",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"test-watch": "vitest",
|
|
12
12
|
"test-coverage": "vitest run --coverage"
|
|
13
13
|
},
|
|
14
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"./dist/"
|
|
16
|
+
],
|
|
15
17
|
"main": "./dist/index.umd.cjs",
|
|
16
18
|
"module": "./dist/index.js",
|
|
17
19
|
"exports": {
|
|
@@ -27,6 +29,7 @@
|
|
|
27
29
|
"globals": "^17.2.0",
|
|
28
30
|
"jsdom": "^27.4.0",
|
|
29
31
|
"vite": "^7.2.4",
|
|
32
|
+
"vite-plugin-dts": "^4.5.4",
|
|
30
33
|
"vitest": "^4.0.18"
|
|
31
34
|
}
|
|
32
|
-
}
|
|
35
|
+
}
|