ec4w_validator 0.0.10011111 → 0.0.1001111221

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/dist/index.js ADDED
@@ -0,0 +1,205 @@
1
+ class c {
2
+ /** @type {SentRequest[]} */
3
+ #t = [];
4
+ /** @param {SentRequest[]} requestList */
5
+ constructor(e) {
6
+ this.#t = e;
7
+ }
8
+ /** @returns {EC4W_Result} */
9
+ conclude() {
10
+ const e = [];
11
+ for (const r of this.#t) {
12
+ if (!r.url) continue;
13
+ const s = new URL(r.url);
14
+ o.canBe(r.method, s) ? e.push(new o(r.method, s)) : u.canBe(r.method, s) && e.push(new u(r.method, s));
15
+ }
16
+ if (e.length < 1) throw new Error("no ( sentRequest ) detected");
17
+ const t = [];
18
+ {
19
+ let r = null;
20
+ for (const s of e)
21
+ s instanceof o ? r = s : s instanceof u && t.push(new f(r, s));
22
+ }
23
+ if (t.length < 1) throw new Error("no ( UPDE | EC4w ) requests detected");
24
+ return new m(t);
25
+ }
26
+ /** @param {string} em */
27
+ static emIsValid(e) {
28
+ if (!e || e.startsWith("tv.1") === !1 || e === "tv.1" || /^tv\.1~e[0-9]/.test(e)) return !1;
29
+ const t = e.split("~"), r = t.length;
30
+ if (r < 2) return !1;
31
+ for (let s = 1; s < r; ++s) {
32
+ if (t[s] === "") return !1;
33
+ const [h, d] = t[s].split(".");
34
+ if (!h || !d) return !1;
35
+ }
36
+ return !0;
37
+ }
38
+ }
39
+ const a = Object.freeze({
40
+ em_validInConversion: "valid `em` in Conversion payload",
41
+ em_validInUPDE: "valid `em` in UPDE payload"
42
+ }), l = Object.freeze({
43
+ em_invalidInConversion: "invalid `em` in Conversion payload",
44
+ em_invalidInUPDE: "invalid `em` in UPDE payload",
45
+ ecsid_mismatch: "mismatch `ecsid` between UPDE and Conversion payload",
46
+ conversionId_mismatch: "mismatch `Conversion ID` between UPDE and Conversion payload",
47
+ noEC4W_request: "no valid EC4W requests detected at all"
48
+ });
49
+ class f {
50
+ #t = null;
51
+ #e;
52
+ /**
53
+ * @param {UPDE_Request?} UPDE_Request
54
+ * @param {Conversion_Request} Conversion_Request */
55
+ constructor(e, t) {
56
+ this.#t = e, this.#e = t;
57
+ }
58
+ get result() {
59
+ return !this.#t && !this.#e ? new n(!1, l.noEC4W_request) : this.#s() === !1 ? new n(!1, l.ecsid_mismatch) : this.#r();
60
+ }
61
+ #s() {
62
+ return this.#e === null ? !1 : this.#t === null ? !0 : !(!this.#t.ecsid || !this.#e.ecsid || this.#t.ecsid !== this.#e.ecsid);
63
+ }
64
+ #r() {
65
+ if (this.#e === null)
66
+ return new n(!1, l.em_invalidInConversion);
67
+ if (this.#t === null) {
68
+ const t = this.#e.emIsValid();
69
+ return t ? new n(t, a.em_validInConversion) : new n(t, l.em_invalidInConversion);
70
+ }
71
+ if (this.#e.em === null) {
72
+ const t = this.#t.emIsValid();
73
+ return t ? new n(t, a.em_validInUPDE) : new n(t, l.em_invalidInUPDE);
74
+ }
75
+ const e = this.#e.emIsValid();
76
+ return e ? new n(e, a.em_validInConversion) : new n(e, l.em_invalidInConversion);
77
+ }
78
+ }
79
+ class n {
80
+ #t;
81
+ get isGood() {
82
+ return this.#t;
83
+ }
84
+ #e;
85
+ get message() {
86
+ return this.#e;
87
+ }
88
+ /** @param {boolean} isGood
89
+ * @param {string} message */
90
+ constructor(e, t) {
91
+ this.#t = e, this.#e = t;
92
+ }
93
+ }
94
+ class o {
95
+ /**
96
+ * @param {string} method
97
+ * @param {URL} Url */
98
+ static canBe(e, t) {
99
+ return !(e !== "GET" || t.toString().startsWith("https://www.google.com/ccm/form-data/") === !1 || t.searchParams.get("em") === null);
100
+ }
101
+ #t;
102
+ get method() {
103
+ return this.#t;
104
+ }
105
+ #e;
106
+ get url() {
107
+ return this.#e.toString();
108
+ }
109
+ /**
110
+ * @param {string} method
111
+ * @param {URL} Url */
112
+ constructor(e, t) {
113
+ this.#t = e, this.#e = t;
114
+ }
115
+ get em() {
116
+ return this.#e.searchParams.get("em");
117
+ }
118
+ get ecsid() {
119
+ return this.#e.searchParams.get("ecsid");
120
+ }
121
+ emIsValid() {
122
+ return c.emIsValid(this.em);
123
+ }
124
+ }
125
+ class u {
126
+ /**
127
+ * @param {string} method
128
+ * @param {URL} Url */
129
+ static canBe(e, t) {
130
+ return !(e !== "GET" || t.toString().startsWith("https://www.googleadservices.com/ccm/conversion/") === !1 || t.searchParams.get("label") === null);
131
+ }
132
+ #t;
133
+ get method() {
134
+ return this.#t;
135
+ }
136
+ #e;
137
+ get url() {
138
+ return this.#e.toString();
139
+ }
140
+ /**
141
+ * @param {string} method
142
+ * @param {URL} Url */
143
+ constructor(e, t) {
144
+ this.#t = e, this.#e = t;
145
+ }
146
+ get em() {
147
+ return this.#e.searchParams.get("em");
148
+ }
149
+ get ecsid() {
150
+ return this.#e.searchParams.get("ecsid");
151
+ }
152
+ emIsValid() {
153
+ return c.emIsValid(this.em);
154
+ }
155
+ }
156
+ class m {
157
+ /** @type {EC4W_Request[]} */
158
+ EC4W_Requests = [];
159
+ // errors = [];
160
+ messages = [];
161
+ /**
162
+ * @param {EC4W_Request[]} EC4W_Requests
163
+ * */
164
+ constructor(e) {
165
+ if (!e || e.length < 1) throw new Error("no requests detected");
166
+ this.EC4W_Requests = e;
167
+ }
168
+ get invalidRequest() {
169
+ for (const e of this.EC4W_Requests)
170
+ if (e.result.isGood === !1) return e;
171
+ return null;
172
+ }
173
+ get validRequest() {
174
+ for (const e of this.EC4W_Requests)
175
+ if (e.result.isGood) return e;
176
+ return null;
177
+ }
178
+ // get summary() {
179
+ // const summary = [], EC4W_Requests = this.EC4W_Requests;
180
+ // for (const EC4W_Request of EC4W_Requests) {
181
+ // summary.push({
182
+ // EC4W_Request: EC4W_Request,
183
+ // result: EC4W_Request.result,
184
+ // });
185
+ // }
186
+ // return summary;
187
+ // }
188
+ }
189
+ class v {
190
+ url = "https://";
191
+ method = "GET";
192
+ constructor(e, t) {
193
+ this.url = e, this.method = t;
194
+ }
195
+ }
196
+ export {
197
+ u as Conversion_Request,
198
+ l as EC4W_ErrorMessages,
199
+ f as EC4W_Request,
200
+ m as EC4W_Result,
201
+ a as EC4W_ValidMessages,
202
+ c as EC4W_Validator,
203
+ v as SentRequest,
204
+ o as UPDE_Request
205
+ };
@@ -0,0 +1 @@
1
+ (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.fafafa={}))})(this,(function(n){"use strict";class a{#t=[];constructor(e){this.#t=e}conclude(){const e=[];for(const i of this.#t){if(!i.url)continue;const s=new URL(i.url);d.canBe(i.method,s)?e.push(new d(i.method,s)):f.canBe(i.method,s)&&e.push(new f(i.method,s))}if(e.length<1)throw new Error("no ( sentRequest ) detected");const t=[];{let i=null;for(const s of e)s instanceof d?i=s:s instanceof f&&t.push(new c(i,s))}if(t.length<1)throw new Error("no ( UPDE | EC4w ) requests detected");return new h(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("~"),i=t.length;if(i<2)return!1;for(let s=1;s<i;++s){if(t[s]==="")return!1;const[g,v]=t[s].split(".");if(!g||!v)return!1}return!0}}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 c{#t=null;#e;constructor(e,t){this.#t=e,this.#e=t}get result(){return!this.#t&&!this.#e?new r(!1,l.noEC4W_request):this.#s()===!1?new r(!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 r(!1,l.em_invalidInConversion);if(this.#t===null){const t=this.#e.emIsValid();return t?new r(t,u.em_validInConversion):new r(t,l.em_invalidInConversion)}if(this.#e.em===null){const t=this.#t.emIsValid();return t?new r(t,u.em_validInUPDE):new r(t,l.em_invalidInUPDE)}const e=this.#e.emIsValid();return e?new r(e,u.em_validInConversion):new r(e,l.em_invalidInConversion)}}class r{#t;get isGood(){return this.#t}#e;get message(){return this.#e}constructor(e,t){this.#t=e,this.#e=t}}class d{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 a.emIsValid(this.em)}}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 a.emIsValid(this.em)}}class h{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}}class m{url="https://";method="GET";constructor(e,t){this.url=e,this.method=t}}n.Conversion_Request=f,n.EC4W_ErrorMessages=l,n.EC4W_Request=c,n.EC4W_Result=h,n.EC4W_ValidMessages=u,n.EC4W_Validator=a,n.SentRequest=m,n.UPDE_Request=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ec4w_validator",
3
3
  "private": false,
4
- "version": "0.0.10011111",
4
+ "version": "0.0.1001111221",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -11,6 +11,9 @@
11
11
  "test-watch": "vitest",
12
12
  "test-coverage": "vitest run --coverage"
13
13
  },
14
+ "files": ["dist"],
15
+ "main": "./dist/index.umd.cjs",
16
+ "module": "./dist/index.js",
14
17
  "exports": {
15
18
  ".": {
16
19
  "import": "./dist/index.js",
package/.idx/dev.nix DELETED
@@ -1,34 +0,0 @@
1
- { pkgs }: {
2
- channel = "stable-25.05";
3
- packages = [
4
- pkgs.nodejs_24
5
- # pkgs.deno
6
- ];
7
- env = { };
8
- idx.extensions = [
9
- # "vscodevim.vim"
10
- "ms-vscode.js-debug"
11
- "usernamehw.errorlens"
12
- "dbaeumer.vscode-eslint"
13
- "formulahendry.auto-rename-tag"
14
- "esbenp.prettier-vscode"
15
- "mermaidchart.vscode-mermaid-chart"
16
- "google.gemini-cli-vscode-ide-companion"
17
- ];
18
- idx = {
19
- workspace = {
20
- # Runs when a workspace is first created
21
- onCreate = {
22
- # Example: install JS dependencies from NPM
23
- # npm-install = "npm install";
24
- # Open editors for the following files by default, if they exist:
25
- # default.openFiles = [ "style.css" "main.js" "index.html" ];
26
- };
27
- # Runs when the workspace is (re)started
28
- onStart = {
29
- # Example: start a background task to watch and re-build backend code
30
- # watch-backend = "npm run watch-backend";
31
- };
32
- };
33
- };
34
- }
@@ -1,168 +0,0 @@
1
- // Place your key bindings in this file to override the defaultsauto[]
2
- [
3
- {
4
- "key": "ctrl+t",
5
- "command": "workbench.action.files.newUntitledFile"
6
- },
7
- {
8
- "key": "ctrl+n",
9
- "command": "-workbench.action.files.newUntitledFile"
10
- },
11
- {
12
- "key": "ctrl+n",
13
- "command": "explorer.newFile"
14
- },
15
- {
16
- "key": "ctrl+shift+alt+/",
17
- "command": "workbench.action.openSettings"
18
- },
19
- {
20
- "key": "ctrl+,",
21
- "command": "-workbench.action.openSettings"
22
- },
23
- {
24
- "key": "alt+9",
25
- "command": "-workbench.action.openEditorAtIndex9"
26
- },
27
- {
28
- "key": "alt+8",
29
- "command": "-workbench.action.openEditorAtIndex8"
30
- },
31
- {
32
- "key": "alt+7",
33
- "command": "-workbench.action.openEditorAtIndex7"
34
- },
35
- {
36
- "key": "alt+6",
37
- "command": "-workbench.action.openEditorAtIndex6"
38
- },
39
- {
40
- "key": "alt+5",
41
- "command": "-workbench.action.openEditorAtIndex5"
42
- },
43
- {
44
- "key": "alt+4",
45
- "command": "-workbench.action.openEditorAtIndex4"
46
- },
47
- {
48
- "key": "alt+3",
49
- "command": "-workbench.action.openEditorAtIndex3"
50
- },
51
- {
52
- "key": "alt+2",
53
- "command": "-workbench.action.openEditorAtIndex2"
54
- },
55
- {
56
- "key": "alt+1",
57
- "command": "-workbench.action.openEditorAtIndex1"
58
- },
59
- {
60
- "key": "shift+pageup",
61
- "command": "editor.action.insertCursorAbove",
62
- "when": "editorTextFocus"
63
- },
64
- {
65
- "key": "ctrl+shift+up",
66
- "command": "-editor.action.insertCursorAbove",
67
- "when": "editorTextFocus"
68
- },
69
- {
70
- "key": "shift+pagedown",
71
- "command": "editor.action.insertCursorBelow",
72
- "when": "editorTextFocus"
73
- },
74
- {
75
- "key": "ctrl+shift+down",
76
- "command": "-editor.action.insertCursorBelow",
77
- "when": "editorTextFocus"
78
- },
79
- {
80
- "key": "pagedown",
81
- "command": "editor.action.moveLinesDownAction",
82
- "when": "editorTextFocus && !editorReadonly"
83
- },
84
- {
85
- "key": "alt+down",
86
- "command": "-editor.action.moveLinesDownAction",
87
- "when": "editorTextFocus && !editorReadonly"
88
- },
89
- {
90
- "key": "pageup",
91
- "command": "editor.action.moveLinesUpAction",
92
- "when": "editorTextFocus && !editorReadonly"
93
- },
94
- {
95
- "key": "alt+up",
96
- "command": "-editor.action.moveLinesUpAction",
97
- "when": "editorTextFocus && !editorReadonly"
98
- },
99
- {
100
- "key": "shift+alt+f",
101
- "command": "editor.action.formatDocument",
102
- "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
103
- },
104
- {
105
- "key": "ctrl+shift+i",
106
- "command": "-editor.action.formatDocument",
107
- "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
108
- },
109
- {
110
- "key": "shift+alt+f",
111
- "command": "editor.action.formatDocument.none",
112
- "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly"
113
- },
114
- {
115
- "key": "ctrl+shift+i",
116
- "command": "-editor.action.formatDocument.none",
117
- "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly"
118
- },
119
- {
120
- "key": "ctrl+shift+i",
121
- "command": "editor.action.formatSelection.multiple"
122
- },
123
- {
124
- "key": "ctrl+shift+alt+c",
125
- "command": "-copyRelativeFilePath",
126
- "when": "!editorFocus"
127
- },
128
- {
129
- "key": "ctrl+k ctrl+shift+alt+c",
130
- "command": "-copyRelativeFilePath",
131
- "when": "editorFocus"
132
- },
133
- {
134
- "key": "ctrl+alt+c",
135
- "command": "-search.action.copyPath",
136
- "when": "fileMatchOrFolderMatchWithResourceFocus"
137
- },
138
- {
139
- "key": "ctrl+alt+c",
140
- "command": "-copyFilePath",
141
- "when": "!editorFocus"
142
- },
143
- {
144
- "key": "ctrl+k ctrl+alt+c",
145
- "command": "-copyFilePath",
146
- "when": "editorFocus"
147
- },
148
- {
149
- "key": "ctrl+v",
150
- "command": "-notebook.cell.paste",
151
- "when": "notebookEditorFocused && !inputFocus"
152
- },
153
- {
154
- "key": "ctrl+v",
155
- "command": "-filesExplorer.paste",
156
- "when": "filesExplorerFocus && foldersViewVisible && !explorerResourceReadonly && !inputFocus"
157
- },
158
- {
159
- "key": "ctrl+v",
160
- "command": "editor.action.clipboardPasteAction",
161
- "when": "editorTextFocus && !editorReadonly"
162
- },
163
- {
164
- "key": "ctrl+v",
165
- "command": "filesExplorer.paste",
166
- "when": "filesExplorerFocus && !inputFocus"
167
- }
168
- ]
@@ -1,32 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "debug tests",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "cwd": "${workspaceFolder}",
15
- "runtimeExecutable": "deno",
16
- "runtimeArgs": [
17
- "test",
18
- "--inspect-brk"
19
- ],
20
- "attachSimplePort": 9229
21
- },
22
- {
23
- "type": "node",
24
- "request": "launch",
25
- "name": "Launch Program",
26
- "skipFiles": [
27
- "<node_internals>/**"
28
- ],
29
- "program": "${workspaceFolder}/src/ec4w_validator.js"
30
- }
31
- ]
32
- }
package/eslint.config.js DELETED
@@ -1,34 +0,0 @@
1
- import js from "@eslint/js";
2
- import globals from "globals";
3
- import { defineConfig } from "eslint/config";
4
-
5
- export default defineConfig([
6
- {
7
- files: ["**/*.{js,mjs,cjs}"],
8
- plugins: { js },
9
- extends: ["js/recommended"],
10
- languageOptions: {
11
- globals: {
12
- ...globals.browser,
13
- // ...globals.webextensions,
14
- },
15
- ecmaVersion: 'latest',
16
- },
17
- rules: {
18
- 'no-unused-vars': 'off',
19
- 'no-undef': 'error',
20
- 'no-unreachable': 'warn',
21
- // 'no-case-declarations': 'off',
22
- 'no-empty': 'warn',
23
- 'no-invalid-this': 'error',
24
- 'no-redeclare': 'warn',
25
-
26
- // 'semi': ['warn', 'always'],
27
- // 'eqeqeq': 'warn'
28
- // 'quotes': ['off', 'single'],
29
- },
30
- // env: { // deprecated settings
31
- // "chrome": true,
32
- // },
33
- },
34
- ]);
package/index.html DELETED
@@ -1,16 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- <title>ec4w_validator</title>
9
- </head>
10
-
11
- <body>
12
- <div id="app"></div>
13
- <script type="module" src="/src/main.js"></script>
14
- </body>
15
-
16
- </html>
package/jsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "es2022",
4
- "target": "es2024",
5
- "moduleResolution": "bundler",
6
- "baseUrl": "./",
7
- "paths": {
8
- "/src/*": [
9
- "./src/*"
10
- ],
11
- "@/*": [
12
- "./src/*"
13
- ]
14
- },
15
- "checkJs": true
16
- },
17
- "include": [
18
- "./src/**/*.js",
19
- "./src/**/*.mjs",
20
- ],
21
- "exclude": [
22
- "./node_modules/",
23
- "./**/*.md"
24
- ],
25
- }