-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontactme.html
220 lines (207 loc) · 9.84 KB
/
contactme.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
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="untracked/aws-sdk-2.1048.0.min.js"></script>
<script src="untracked/decrypt.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
<style type="text/css">
.title-primary {
font-size: 225%;
font-weight: bold;
}
.title-secondary {
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
font-size: 175%;
font-weight: bold;
}
textarea {
resize: none;
}
</style>
<script id="config">
AWS.config.update({region: keys["region"]});
AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: keys["cognito_pool_id"]});
if (AWS.config.credentials.expired == true) {
AWS.config.credentials.get();
}
var SQS = new AWS.SQS({region: keys["region"], apiVersion: '2012-11-05'});
let publickeypem = keys["public_key"];
function base64ToArrayBuffer(b64) {
var byteString = window.atob(b64);
var byteArray = new Uint8Array(byteString.length);
for(var i=0; i < byteString.length; i++) {
byteArray[i] = byteString.charCodeAt(i);
}
return byteArray;
}
var pubkey = "";
(async function() {
pubkey = await crypto.subtle.importKey(
"spki",
base64ToArrayBuffer(publickeypem),
{
name: "RSA-OAEP",
hash: {
name: "SHA-256"
}
},
true,
["encrypt"]
)
})();
function getMessageEncoded(plaintext) {
let message = plaintext;
let enc = new TextEncoder();
return enc.encode(message);
}
function getMessageDecoded(arraybuffer) {
let enc = new TextDecoder();
return enc.decode(arraybuffer);
}
function encryptAndSend(plaintext, pubkey) {
let encoded = getMessageEncoded(plaintext);
let ciphertext = window.crypto.subtle.encrypt(
{
name: "RSA-OAEP"
},
pubkey,
encoded
).then(invokeSQS);
}
function invokeSQS(ciphertext) {
var sendtext = btoa(String.fromCharCode.apply(null, new Uint8Array(ciphertext)));
var params = {
MessageBody: sendtext,
QueueUrl: keys["sqs_queue"],
DelaySeconds: 0,
};
SQS.sendMessage(params, function(err, data) {
if (err) {
alert("Unsuccessful");
console.log(err, err.stack);
}
else {
alert("Successful");
console.log(data);
}
});
document.getElementById("contact-form").reset();
}
function submitToSQS(e) {
e.preventDefault();
var Namere = /[A-Za-z ]+/;
if (!Namere.test($("#name-input").val())) {
alert("No non-alphabetic characters in Name");
return;
}
var mobilere = /[0-9]{10}/;
if (!mobilere.test($("#phone-input").val())) {
alert("Please enter valid mobile number");
return;
}
var emailinput = $("#email-username").val() + "@" + $("#email-domain").val() + "." + $("#email-tld").val()
if (!($("#email-username").val()=="" || $("#email-domain").val()=="" || $("#email-tld").val()=="")) {
var reemail = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/;
if (!reemail.test(emailinput.val())) {
alert("Please enter valid email address");
return;
}
}
else {
emailinput = ""
}
if (($("#description-input").val() == "")) {
alert("Can't message me without a message");
return;
}
var name = $("#name-input").val();
var phone = $("#phone-input").val();
var email = emailinput;
var desc = $("#description-input").val();
var data = {
name : name,
phone : phone,
email : email,
desc : desc
};
encryptAndSend(JSON.stringify(data), pubkey);
}
</script>
</head>
<body class="bg-dark bg-gradient">
<div class="py-5">
<div class="container bg-white bg-gradient">
<div class="row">
<div class="my-5 col">
<div class="text-center">
<div class="title-primary">Contact</div>
<div class="title-secondary"><em>Emperor Irritant, the Oddly Successful</em></div>
</div>
<div class="px-5 py-4">
<form id="contact-form" method="">
<h4 class="text-dark font-weight-bold">Name</h4>
<input type="text"" id="name-input" placeholder="Feel free to make up any name, Miste...tres... errr You-Who-Shall-Be-Named-As-You-Choose!" class="form-control" style="width:100%;" /><br/>
<h4 class="text-dark font-weight-bold">Phone</h4>
<input type="phone"" id="phone-input" placeholder="Nope. Don't want it. Do you?" class="form-control" style="width:100%;"/><br/>
<h4 class="text-dark font-weight-bold">Email</h4>
<div class="input-group">
<div class="w-25 input-group">
<span class="input-group">
<input type="text" id="email-username" placeholder="username" class="form-control">
</span>
</div>
<div class="input-group-append">
<span class="input-group-text">@</span>
</div>
<div class="w-25 input-group-append">
<span class="input-group">
<input type="text" id="email-domain" class="form-control" placeholder="domain">
</span>
</div>
<div class="input-group-append">
<span class="input-group-text">.</span>
</div>
<div class="w-25 input-group-append">
<span class="w-50 input-group">
<input type="text" id="email-tld" class="form-control" placeholder="tld">
</span>
</div>
</div>
<br/>
<h4 class="text-dark font-weight-bold">Your message for me</h4>
<textarea id="description-input" rows="3" placeholder="Take your spammer bots and fingers, scanner bots and fingers, trolling fingers (do we have trolling bots, yet?) and aim them elsewhere. Please?" class="form-control" style="width:100%;"></textarea><br/>
<div class="text-center py-5">
<button type="button" onClick="submitToSQS(event)" class="btn btn-lg btn-danger btn-gradient">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<footer class="text-center text-lg-start bg-light text-muted">
<section class="d-flex justify-content-center justify-content-lg-between p-4 border-bottom">
<div class="me-5 d-none d-lg-block">
<span>Get connected with us on social networks:</span>
</div>
<div>
<a href="" class="me-4 text-reset">
<i class="fab fa-github"></i>
</a>
</div>
</section>
<section>
<div class="p-4">
Disclaimer:
</div>
</section>
<div class="text-center p-4" style="background-color: rgba(0, 0, 0, 0.05);">
© 2021 Copyright
<a class="text-reset fw-bold" href="https://github.com/EmperorIrritant/">Emperor Irritant</a>
</div>
</footer>
</body>
</html>