-
Notifications
You must be signed in to change notification settings - Fork 1
/
alert-webhook.html
458 lines (406 loc) · 18.3 KB
/
alert-webhook.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<head>
<meta charset="utf-8">
<title>XposedOrNot: Webhook Configuration</title>
<link rel="dns-prefetch" href="cdnjs.cloudflare.com">
<link rel="dns-prefetch" href="static.hotjar.com">
<link rel="shortcut icon" type="image/ico" href="favicon.ico" />
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Poppins%3A300%2C400%2C500%2C600%2C700%2C900&subset"
type="text/css" media="all">
<link href="/static/css/style.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css"
integrity="sha512-rt/SrQ4UNIaGfDyEXZtNcyWvQeOq0QLygHluFQcSjaGB04IxWhal71tKuzP6K8eYXYB6vJV4pHkXcmFGGQ1/0w=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css"
integrity="sha256-BtbhCIbtfeVWGsqxk1vOHEYXS6qcvQvLMZqjtpWUEx8=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<script src="/static/scripts/utils.js"></script>
<link href="/static/css/style2.css" type="text/css" rel="stylesheet" defer>
<link href="/static/css/xon-report.css" type="text/css" rel="stylesheet" defer>
<meta name="viewport" content="width=device-width, maximum-scale=5.0, initial-scale=1.0">
<meta name="description" content="XposedOrNot: Get alerts using custom webhook">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="author" content="Devanand Premkumar">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.5.3/js/bootstrapValidator.js"></script>
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<style>
body {
background-color: #f5f5f5;
}
.navbar {
margin-bottom: 20px;
}
.card {
box-shadow: 0px 0px 15px 0px rgba(50, 50, 50, 0.2);
}
h3 {
color: #007bff;
}
.benefit-card {
border: none;
border-radius: 10px;
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.1);
}
.benefit-card:nth-child(even) {
background: #007bff;
color: #fff;
}
.benefit-card:nth-child(odd) {
background: #fff;
color: #007bff;
}
.benefit-card .card-title {
font-weight: 700;
font-size: 1.2em;
}
.benefit-card .card-text {
font-size: 1em;
}
.main-container {
max-width: 1000px;
margin: 0 auto;
}
.config-section {
padding: 20px;
border-radius: 5px;
margin-bottom: 20px;
background-color: #fff;
display: none;
}
.active-step {
display: block;
}
.section-heading {
margin-bottom: 15px;
color: #0056b3;
}
.alert {
margin-top: 15px;
}
.helper-column {
position: fixed;
right: 0;
top: 100px;
width: 300px;
padding: 40px;
background-color: #f8f9fa;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
max-height: 90vh;
overflow-y: auto;
}
.helper-column h4 {
color: #0056b3;
}
.helper-column ul {
list-style-type: none;
padding: 0;
}
.helper-column li {
margin-bottom: 10px;
}
.main-container {
max-width: 1000px;
margin: 0 auto;
padding-top: 40px;
}
.form-group .input-group {
display: flex;
align-items: center;
flex-grow: 1;
}
.form-group .input-group input {
flex-grow: 1;
min-width: 0;
}
.form-group .input-group span {
margin-left: 4px;
flex-shrink: 0;
}
</style>
<script src="/static/scripts/other-libraries.js" defer></script>
</head>
<body>
<div class="mobileheader-area">
<div class="container">
<div class="row">
<div class="col-lg-12">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="index.html">
<p>XposedorNot</p>
</a>
<button class="hamburger hamburger--squeeze navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="hamburger-box">
<span class="hamburger-inner"></span>
</span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"></ul>
<div class="main-menu-part">
<ul>
<li>
<a href="password.html">Password</a>
</li>
<li>
<a href="faq.html">FAQ</a>
</li>
<li>
<a target="_blank" rel="noopener noreferrer"
href="https://blog.xposedornot.com/">Blog</a>
</li>
<li>
<a target="_blank" rel="noopener noreferrer"
href="https://twitter.com/XposedOrNot">
<em class="fab fa-twitter"></em>
</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
</div>
</div>
<header class="header-area">
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-3">
<div class="header-left">
<a href="https://XposedOrNot.com">
<p>XposedorNot</p>
</a>
</div>
</div>
<div class="col-lg-9 col-md-9">
<div class="header-right">
<ul>
<li>
<a href="password.html">Password</a>
</li>
<li>
<a href="faq.html">FAQ</a>
</li>
<li>
<a target="_blank" rel="noopener noreferrer"
href="https://blog.xposedornot.com/">Blog</a>
</li>
<li>
<a target="_blank" rel="noopener noreferrer" href="https://twitter.com/XposedOrNot">
<em class="fab fa-twitter"></em>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div class="main-container">
<div class="config-section active-step" id="step1">
<h2 class="section-heading">Step 1: Enter Custom Webhook Details</h2>
<form>
<div class="form-group">
<label for="webhookUrl">Webhook URL</label>
<input type="text" class="form-control" id="webhookUrl" placeholder="Enter Webhook URL">
<span id="webhookUrl-status"></span>
</div>
<div class="form-group">
<label for="token">Token</label>
<input type="text" class="form-control" id="token" placeholder="Enter Token" readonly>
<span id="token-status"></span>
</div>
<div class="form-group">
<label for="domain">Domain</label>
<input type="text" class="form-control" id="domain" placeholder="Enter Domain" readonly>
<span id="domain-status"></span>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="initBtn"
onclick="initiateConfiguration()">Initiate Configuration</button>
<button type="button" class="btn btn-secondary" onclick="cancelConfiguration()">Cancel
Config</button>
</div>
</form>
</div>
<div class="config-section" id="step2">
<h2 class="section-heading">Step 2: Verify Configuration</h2>
<form>
<div class="form-group">
<label for="reviewWebhookUrl">Webhook URL</label>
<input type="text" class="form-control" id="reviewWebhookUrl" placeholder="Webhook URL" readonly>
</div>
<div class="form-group">
<label for="reviewToken">Token</label>
<input type="text" class="form-control" id="reviewToken" placeholder="Token" readonly>
</div>
<div class="form-group">
<label for="reviewDomain">Domain</label>
<input type="text" class="form-control" id="reviewDomain" placeholder="Domain" readonly>
</div>
<div class="form-group">
<label for="verifyToken">Verification Token</label>
<input type="text" class="form-control" id="verifyToken" placeholder="Enter Verification Token">
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="verifyBtn" onclick="verifyConfiguration()">Verify
Configuration</button>
<button type="button" class="btn btn-secondary" id="backToDashboardBtn"
onclick="goBackToDashboard()">Go Back to Dashboard</button>
</div>
</form>
</div>
<div class="alert" id="apiResponse" role="alert" style="display:none;"></div>
</div>
<div class="helper-column">
<h4>Helpful Steps</h4>
<ul id="helpful-steps-content">
<li><strong>Creating a Webhook:</strong> Your webhook and related information</li>
<li><strong>Obtaining a Webhook URL:</strong> Your webhook location.</li>
</ul>
</div>
<script>
// Global variables
let globalWebhookUrl, token, domain, email, secret;
// Event listener for DOMContentLoaded
document.addEventListener('DOMContentLoaded', function () {
initialize();
}, false);
function initialize() {
const queryParams = new URLSearchParams(window.location.search);
email = queryParams.get('email');
domain = queryParams.get('domain');
token = queryParams.get('token');
if (!email || !domain || !token) {
updateApiResponse('Missing required query parameters: email, domain, token', 'danger');
return;
}
fetchWebhookConfig();
updateHelpfulSteps('step1');
}
function fetchWebhookConfig() {
const apiUrl = `https://api.xposedornot.com/v1/webhook-config?email=${encodeURIComponent(email)}&domain=${encodeURIComponent(domain)}&token=${encodeURIComponent(token)}`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data && data.data) {
document.getElementById('webhookUrl').value = data.data.webhook_url;
document.getElementById('domain').value = data.data.domain;
globalWebhookUrl = data.data.webhook_url;
displayConfigFetched();
} else {
throw new Error('Invalid data format');
}
})
.catch(error => {
updateApiResponse('Webhook configuration not found for this domain', 'info');
});
}
function initiateConfiguration() {
globalWebhookUrl = document.getElementById('webhookUrl').value;
secret = prompt("Please enter your webhook secret", "");
if (!globalWebhookUrl || !secret) {
updateApiResponse('Webhook URL and secret are required.', 'danger');
return;
}
let data = {
token: token,
domain: domain,
webhook: globalWebhookUrl,
secret: secret,
action: "init"
};
sendApiRequest(data, 'initBtn', (responseData) => {
if (responseData.status === 'initiated') {
switchStep('step1', 'step2');
document.getElementById('verifyToken').value = responseData.verify_token;
}
});
}
function verifyConfiguration() {
let verifyToken = document.getElementById('verifyToken').value;
if (!verifyToken) {
updateApiResponse('Verification token is required.', 'danger');
return;
}
let data = {
token: token,
domain: domain,
webhook: globalWebhookUrl,
secret: secret,
verify_token: verifyToken,
action: "verify"
};
sendApiRequest(data, 'verifyBtn', (responseData) => {
if (responseData.status === 'success') {
document.getElementById('verifyBtn').disabled = true;
document.getElementById('backToDashboardBtn').classList.remove('btn-secondary');
document.getElementById('backToDashboardBtn').classList.add('btn-primary');
updateApiResponse(responseData.message, 'success');
}
});
}
function sendApiRequest(data, btnId, onSuccess) {
let btn = document.getElementById(btnId);
btn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Processing...';
btn.disabled = true;
const setupUrl = `https://xon-api-test.xposedornot.com/v1/webhook-setup`;
fetch(setupUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(responseData => {
btn.textContent = btnId === 'initBtn' ? 'Initiate Configuration' : 'Verify Configuration';
btn.disabled = false;
if (responseData.status === 'success' || responseData.status === 'initiated') {
if (responseData.message) {
updateApiResponse(responseData.message, 'success');
}
if (onSuccess) {
onSuccess(responseData);
}
} else {
updateApiResponse(responseData.message || 'An error occurred', 'danger');
}
})
.catch(error => {
btn.textContent = btnId === 'initBtn' ? 'Initiate Configuration' : 'Verify Configuration';
btn.disabled = false;
updateApiResponse('An error occurred', 'danger');
});
}
function switchStep(currentStep, nextStep) {
document.getElementById(currentStep).classList.remove('active-step');
document.getElementById(nextStep).classList.add('active-step');
updateHelpfulSteps(nextStep);
if (nextStep === 'step2') {
document.getElementById('reviewWebhookUrl').value = globalWebhookUrl;
document.getElementById('reviewToken').value = token;
document.getElementById('reviewDomain').value = domain;
}
}
function updateApiResponse(message, type) {
let responseDiv = document.getElementById('apiResponse');
responseDiv.style.display = 'block';
responseDiv.className = 'alert alert-' + type;
responseDiv.textContent = message;
}
function updateHelpfulSteps(step) {
let stepsContent = document.getElementById('helpful-steps-content');
}
function cancelConfiguration() {
const dashboardUrl = `breach-dashboard.html?email=${encodeURIComponent(email)}&token=${encodeURIComponent(token)}`;
window.location.href = dashboardUrl;
}
</script>
</body>