cyperful 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/public/frame-agent.js +109 -105
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f8d3ff27a617e78c9574d35c85d0f02dc0273de2e90c7773da683cd8750f5e
|
4
|
+
data.tar.gz: 2fb3db663142fcbc88cdd6961983f8c1a3df8f623dc5fbf8ed73e4a7256a6c1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2887f50bf26d411114cd9152e233f9bc81f66425c173ed2550e19e867c0d4f2abe3811626f2918bc731d810e4ca2e683bf1d0144ae5f1cf13d324afd1ed45cfd
|
7
|
+
data.tar.gz: 74f2680a4ec70a3fe89291e84f81f3a682b5a6e7c2c1dd40f0031df3fb5720f0654d42b2e4eaf833f32913a3c5a381b1c2a66a58b0705f485e20abf4dc595932
|
data/public/frame-agent.js
CHANGED
@@ -5,168 +5,172 @@ function L() {
|
|
5
5
|
return m;
|
6
6
|
}
|
7
7
|
let _ = 0;
|
8
|
-
const
|
9
|
-
const { CYPERFUL_ORIGIN:
|
10
|
-
let
|
8
|
+
const u = (e, n, i = null) => {
|
9
|
+
const { CYPERFUL_ORIGIN: o } = L();
|
10
|
+
let r = null;
|
11
11
|
try {
|
12
|
-
const
|
13
|
-
if ("url" in
|
12
|
+
const t = Date.now(), a = `${t}-${_++}`;
|
13
|
+
if ("url" in n && n.url != null)
|
14
14
|
try {
|
15
|
-
const
|
16
|
-
if (
|
17
|
-
|
15
|
+
const s = new URL(n.url, window.location.origin);
|
16
|
+
if (s.origin === o) return null;
|
17
|
+
s.origin === window.location.origin && (n.url = s.pathname + s.search + s.hash);
|
18
18
|
} catch {
|
19
19
|
}
|
20
|
-
|
21
|
-
type:
|
22
|
-
data:
|
23
|
-
id:
|
24
|
-
timestamp:
|
25
|
-
start_id:
|
26
|
-
}, window.parent.postMessage(
|
20
|
+
r = {
|
21
|
+
type: e,
|
22
|
+
data: n,
|
23
|
+
id: a,
|
24
|
+
timestamp: t,
|
25
|
+
start_id: i ? i.id : void 0
|
26
|
+
}, window.parent.postMessage(r, o);
|
27
27
|
} catch {
|
28
28
|
}
|
29
|
-
return
|
29
|
+
return r;
|
30
30
|
};
|
31
|
-
function
|
31
|
+
function q(e) {
|
32
32
|
try {
|
33
|
-
if (typeof
|
33
|
+
if (typeof e == "string") return JSON.parse(e);
|
34
34
|
} catch {
|
35
|
-
return
|
35
|
+
return e;
|
36
36
|
}
|
37
37
|
}
|
38
|
-
function
|
39
|
-
const
|
40
|
-
for (const [
|
41
|
-
|
42
|
-
return
|
38
|
+
function R(e) {
|
39
|
+
const n = {};
|
40
|
+
for (const [i, o] of e.entries())
|
41
|
+
o instanceof Blob ? n[i] = `[[ Blob: ${o.size} bytes ]]` : n[i] = o.toString();
|
42
|
+
return n;
|
43
|
+
}
|
44
|
+
const H = (e) => e instanceof ArrayBuffer;
|
45
|
+
function g(e, n) {
|
46
|
+
return e == null ? e : e instanceof FormData ? R(e) : e instanceof Blob ? `[[ ${e.constructor.name}: ${e.size} bytes ]]` : H(e) ? `[[ ${e.constructor.name}: ${e.byteLength} bytes ]]` : e instanceof URLSearchParams ? e.toString() : typeof e == "object" || typeof e == "function" ? `[[ ${e.constructor.name} ]]` : typeof e == "string" && (n != null && n.match(/[+/]json\b/)) ? q(e) : e;
|
43
47
|
}
|
44
|
-
const
|
45
|
-
const
|
46
|
-
window.fetch = (...
|
47
|
-
var
|
48
|
-
const [
|
49
|
-
let
|
48
|
+
const $ = () => {
|
49
|
+
const e = window.fetch;
|
50
|
+
window.fetch = (...n) => {
|
51
|
+
var y;
|
52
|
+
const [i, o = {}] = typeof n[0] == "string" || n[0] instanceof URL ? [n[0], n[1]] : [n[0].url, n[0]], r = ((y = o.method) == null ? void 0 : y.toUpperCase()) ?? "GET", t = o.body, s = new Headers(o.headers).get("content-type") || void 0;
|
53
|
+
let l;
|
50
54
|
try {
|
51
|
-
|
55
|
+
l = g(t, s);
|
52
56
|
} catch {
|
53
57
|
}
|
54
|
-
const
|
55
|
-
method:
|
56
|
-
url:
|
57
|
-
body:
|
58
|
-
bodyType:
|
59
|
-
}),
|
60
|
-
return
|
61
|
-
const
|
62
|
-
let
|
58
|
+
const p = u("fetch", {
|
59
|
+
method: r,
|
60
|
+
url: i.toString(),
|
61
|
+
body: l,
|
62
|
+
bodyType: s
|
63
|
+
}), h = e(...n);
|
64
|
+
return h.then(async (f) => {
|
65
|
+
const c = f.headers.get("content-type") || void 0, S = f.headers.get("content-length") || void 0;
|
66
|
+
let d;
|
63
67
|
try {
|
64
|
-
const w =
|
65
|
-
|
68
|
+
const w = f.clone();
|
69
|
+
c != null && c.match(/\bform-data|\bapplication\/x-www-form-urlencoded\b/) && (d = R(await w.formData())), c != null && c.match(/[+/]json\b/) ? d = await w.json() : c != null && c.match(/\btext[+/]/) ? d = await w.text() : d = `[[ Unhandled content-type ${c || "<empty>"} (size: ${S ?? "<unknown>"} bytes) ]]`;
|
66
70
|
} catch {
|
67
71
|
}
|
68
|
-
|
72
|
+
p && u(
|
69
73
|
"fetch:finished",
|
70
74
|
{
|
71
|
-
status:
|
72
|
-
responseType:
|
73
|
-
response:
|
75
|
+
status: f.status,
|
76
|
+
responseType: c,
|
77
|
+
response: d
|
74
78
|
},
|
75
|
-
|
79
|
+
p
|
76
80
|
);
|
77
|
-
}).catch((
|
78
|
-
|
81
|
+
}).catch((f) => {
|
82
|
+
p && u(
|
79
83
|
"fetch:finished",
|
80
84
|
{
|
81
85
|
status: 0,
|
82
|
-
response: `[caught error] ${
|
86
|
+
response: `[caught error] ${f.message || "Unknown error"}`
|
83
87
|
},
|
84
|
-
|
88
|
+
p
|
85
89
|
);
|
86
|
-
}),
|
90
|
+
}), h;
|
87
91
|
};
|
88
|
-
},
|
89
|
-
const
|
90
|
-
window.XMLHttpRequest.prototype.open = function(...
|
92
|
+
}, B = () => {
|
93
|
+
const e = window.XMLHttpRequest.prototype.open, n = window.XMLHttpRequest.prototype.send, i = window.XMLHttpRequest.prototype.setRequestHeader;
|
94
|
+
window.XMLHttpRequest.prototype.open = function(...r) {
|
91
95
|
return this._requestMeta = {
|
92
|
-
method:
|
93
|
-
url:
|
96
|
+
method: r[0],
|
97
|
+
url: r[1].toString(),
|
94
98
|
headers: {}
|
95
|
-
},
|
96
|
-
}, window.XMLHttpRequest.prototype.setRequestHeader = function(
|
97
|
-
const
|
98
|
-
return
|
99
|
-
}, window.XMLHttpRequest.prototype.send = function(
|
100
|
-
const
|
101
|
-
let
|
99
|
+
}, e.apply(this, r);
|
100
|
+
}, window.XMLHttpRequest.prototype.setRequestHeader = function(r, t) {
|
101
|
+
const a = this._requestMeta;
|
102
|
+
return a && (a.headers[r.toLowerCase()] = t), i.apply(this, [r, t]);
|
103
|
+
}, window.XMLHttpRequest.prototype.send = function(r) {
|
104
|
+
const t = this._requestMeta, a = t == null ? void 0 : t.headers["content-type"];
|
105
|
+
let s;
|
102
106
|
try {
|
103
|
-
|
107
|
+
s = g(r, a);
|
104
108
|
} catch {
|
105
109
|
}
|
106
|
-
const
|
107
|
-
method:
|
108
|
-
url:
|
109
|
-
body:
|
110
|
-
bodyType:
|
110
|
+
const l = t ? u("xhr", {
|
111
|
+
method: t.method,
|
112
|
+
url: t.url,
|
113
|
+
body: s,
|
114
|
+
bodyType: a
|
111
115
|
}) : null;
|
112
116
|
return this.addEventListener("load", async () => {
|
113
|
-
if (!
|
114
|
-
const
|
115
|
-
let
|
117
|
+
if (!l) return;
|
118
|
+
const p = this.getResponseHeader("content-type") || void 0;
|
119
|
+
let h;
|
116
120
|
try {
|
117
|
-
|
121
|
+
h = g(this.response, p);
|
118
122
|
} catch {
|
119
123
|
}
|
120
|
-
|
124
|
+
u(
|
121
125
|
"xhr:finished",
|
122
126
|
{
|
123
127
|
status: this.status,
|
124
|
-
response:
|
125
|
-
responseType:
|
128
|
+
response: h,
|
129
|
+
responseType: p
|
126
130
|
},
|
127
|
-
|
131
|
+
l
|
128
132
|
);
|
129
133
|
}), this.addEventListener("error", () => {
|
130
|
-
|
134
|
+
l && u(
|
131
135
|
"xhr:finished",
|
132
136
|
{
|
133
137
|
status: 0,
|
134
138
|
response: `[caught error] ${this.status ?? 0} - ${this.statusText || "Unknown error"}`
|
135
139
|
},
|
136
|
-
|
140
|
+
l
|
137
141
|
);
|
138
|
-
}),
|
142
|
+
}), n.apply(this, [r]);
|
139
143
|
};
|
140
|
-
},
|
144
|
+
}, C = () => {
|
141
145
|
if (window.__cyperfulAgentInitialized) return;
|
142
146
|
window.__cyperfulAgentInitialized = !0;
|
143
|
-
const
|
144
|
-
|
145
|
-
const { CYPERFUL_ORIGIN:
|
146
|
-
if (window.location.origin ===
|
147
|
-
|
147
|
+
const e = console.log, n = (...t) => e("[Cyperful Agent]", ...t);
|
148
|
+
n("Loading...");
|
149
|
+
const { CYPERFUL_ORIGIN: i } = L();
|
150
|
+
if (window.location.origin === i) {
|
151
|
+
n("Ignoring parent frame (Why are we here?)");
|
148
152
|
return;
|
149
153
|
}
|
150
|
-
|
151
|
-
|
152
|
-
}), window.addEventListener("unhandledrejection", (
|
153
|
-
|
154
|
+
$(), B(), window.addEventListener("error", (t) => {
|
155
|
+
u("global_error", { message: t.error.toString() });
|
156
|
+
}), window.addEventListener("unhandledrejection", (t) => {
|
157
|
+
u("unhandledrejection", { message: t.reason.toString() });
|
154
158
|
});
|
155
|
-
const
|
156
|
-
history.pushState = (...
|
157
|
-
|
159
|
+
const o = history.pushState;
|
160
|
+
history.pushState = (...t) => {
|
161
|
+
o.apply(history, t), u("client_navigate", {
|
158
162
|
url: location.href,
|
159
163
|
replace: !1
|
160
164
|
});
|
161
165
|
};
|
162
|
-
const
|
163
|
-
history.replaceState = (...
|
164
|
-
|
166
|
+
const r = history.replaceState;
|
167
|
+
history.replaceState = (...t) => {
|
168
|
+
r.apply(history, t), u("client_navigate", {
|
165
169
|
url: location.href,
|
166
170
|
replace: !0
|
167
171
|
});
|
168
172
|
};
|
169
|
-
for (const
|
173
|
+
for (const t of [
|
170
174
|
"log",
|
171
175
|
"error",
|
172
176
|
"warn",
|
@@ -174,15 +178,15 @@ const S = () => {
|
|
174
178
|
"dir",
|
175
179
|
"debug"
|
176
180
|
]) {
|
177
|
-
const
|
178
|
-
|
179
|
-
|
181
|
+
const a = console[t];
|
182
|
+
a && (console[t] = (...s) => {
|
183
|
+
a.apply(console, s), u("log", { level: t, args: s });
|
180
184
|
});
|
181
185
|
}
|
182
|
-
|
186
|
+
n("Loaded.");
|
183
187
|
};
|
184
188
|
try {
|
185
|
-
|
186
|
-
} catch (
|
187
|
-
console.error("Cyperful Agent failed to load",
|
189
|
+
C();
|
190
|
+
} catch (e) {
|
191
|
+
console.error("Cyperful Agent failed to load", e);
|
188
192
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyperful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wyatt Ades
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|