Skip to content

Commit a0c75c2

Browse files
onlykeyonlykey
authored andcommitted
test
1 parent ced11b0 commit a0c75c2

13 files changed

Lines changed: 116496 additions & 18 deletions

dev-vir/bundle.54a29c09d8140fc71c64.js

Lines changed: 116238 additions & 0 deletions
Large diffs are not rendered by default.

dev-vir/bundle.54a29c09d8140fc71c64.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-vir/decrypt-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
129129
</code>
130130
</pre>
131131
</div>
132-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
132+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
133133
<script>
134134
window.addEventListener("load", window.initok);
135135
</script>

dev-vir/decrypt-file-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
133133
</code>
134134
</pre>
135135
</div>
136-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
136+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
137137
<script>
138138
window.addEventListener("load", window.initok);
139139
</script>

dev-vir/decrypt-file-vir-dev.html

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<html>
22

33
<head>
4-
<title>OnlyKey Apps - Decrypt & verify files in your browser using Keybase PGP and Virtru</title>
4+
<title>OnlyKey Apps - Decrypt & verify files using Onlykey, Keybase PGP, and Virtru</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
6-
<META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none' ; script-src 'self' 'sha256-P1WP1KTz9iiHN5Bfeec+pIgBDay5qWNQZh9HujWa94o=' 'sha256-pBDNHyFUtn3XsRvFveaLkaEupq1l96neUvZm5/c1PmQ='; style-src 'self' 'sha256-ujVZuuvwuQ+epdwqO8AhlbOQSx68+ci+dDIwrFrzI+Q=' 'sha256-zsMKYSOY0gzTtULlMRDwkny+ocnOJuA+B49b0BIIQXU='; img-src 'self' ; font-src 'self' ; connect-src 'self' https://keybase.io ; base-uri 'none'; form-action 'none';">
76
<!-- CSSNormalize, CSSGrids-Responsive, CSSForm, CSSTable, CSSList (v3.9.1) -->
87
<link rel="stylesheet" href="css/gallerycss-csstable-min.css">
98
<link rel="stylesheet" href="css/gallerycss-csslist-min.css">
@@ -17,6 +16,9 @@
1716
<link href="css/ShareTechMono.css" rel="stylesheet">
1817
<link href="css/font-awesome.min.css" rel="stylesheet">
1918
<link href="css/style.css" rel="stylesheet">
19+
<link href="https://sdk.virtru.com/js/latest/auth-widget/index.css" rel="stylesheet"/>
20+
<script src="https://sdk.virtru.com/js/latest/auth-widget/index.js"></script>
21+
<script src="https://sdk.virtru.com/js/latest/virtru-sdk.min.js"></script>
2022
<!-- Modify header colors here to customize the look and feel of the site-->
2123
<style>
2224
.header {
@@ -101,12 +103,15 @@ <h1>
101103
</code>
102104
</div>
103105
<h4><font size="+2">Securely decrypt and verify files using
104-
<a href="https://onlykey.io" target="_blank">OnlyKey</a> and <a href="https://keybase.io/kbpgp" target="_blank">Keybase PGP</a></font></h4>
106+
<a href="https://onlykey.io" target="_blank">OnlyKey</a>, <a href="https://keybase.io/kbpgp" target="_blank">Keybase PGP</a>, and <a href="https://keybase.io/kbpgp" target="_blank">Virtru</a></font></h4>
105107
<div id="container">
106108
<fieldset>
107-
<textarea placeholder="Sender's Keybase username or URL to their public pgp key or paste their key..." rows="1" id="pgpkeyurl"></textarea>
109+
<textarea placeholder="Sender's Keybase username..." rows="1" id="pgpkeyurl"></textarea>
108110
<form name="fileform">
109111
<div id="block">
112+
<div id="virtru-auth-widget-mount" align="left" style="overflow: hidden; text-overflow: ellipsis; text-align:left; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-content: left; align-content: left;">
113+
<label for="virtru-auth-widget-mount" id="virtru-auth-widget-mount_label">Confirm your email below to decrypt TDF</label>
114+
</div>
110115
<h3>Choose the file to decrypt</h3>
111116
<input type="file" id="file" name="file" /><br />
112117
<p id="filedetails"></p>
@@ -134,7 +139,121 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
134139
</code>
135140
</pre>
136141
</div>
137-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
142+
<script>
143+
144+
145+
let client;
146+
// Start with these hidden until the user selects to expire messages
147+
document.getElementById('virtru-auth-widget-mount').style.display = "none";
148+
document.getElementById('virtru-auth-widget-mount_label').style.display = "none";
149+
file = document.getElementById('file');
150+
151+
file.addEventListener('change', e => {
152+
console.info(document.getElementById('file').value);
153+
if (document.getElementById('file').value.includes('.TDF') == true) {
154+
document.getElementById('virtru-auth-widget-mount').style.display = "initial";
155+
document.getElementById('virtru-auth-widget-mount_label').style.display = "initial";
156+
} else {
157+
document.getElementById('virtru-auth-widget-mount').style.display = "none";
158+
document.getElementById('virtru-auth-widget-mount_label').style.display = "none";
159+
}
160+
});
161+
162+
// Run all client code from here.
163+
// This will only be called when the user is successfully authenticated.
164+
async function afterAuth(email) {
165+
166+
//TODO Enable Options fields after auth for user to set encrypted file expiration date etc.
167+
console.info('Virtru email ' + email);
168+
client = new Virtru.Client({email});
169+
console.info('Virtru client ' + client);
170+
}
171+
172+
// Encrypt or decrypt the file by using the support functions
173+
async function encryptOrDecryptFile(filedata, thisfilename, shouldEncrypt, completion) {
174+
if (shouldEncrypt) {
175+
const encrypted = await encrypt(filedata, thisfilename);
176+
await encrypted.toFile(thisfilename + '.tdf');
177+
} else {
178+
const decrypted = await decrypt(filedata);
179+
const finalfilename = buildDecryptFilename(thisfilename).trim();
180+
await decrypted.toFile(finalFilename);
181+
}
182+
183+
if (completion) {
184+
//completion();
185+
}
186+
}
187+
188+
// Handle filename parsing with parens involved
189+
function buildDecryptFilename(filename) {
190+
console.info('buildDecryptFilename');
191+
console.info(filename);
192+
const ext = filename.substr(-4);
193+
let finalFilename = filename;
194+
195+
if (ext === '.tdf') {
196+
finalFilename = finalFilename.replace(ext, '');
197+
}
198+
199+
finalFilename = finalFilename.replace(/\([^.]*\)$/, '');
200+
201+
return finalFilename;
202+
}
203+
204+
// Decrypt the file by creating an object url (for now) and return the stream content
205+
async function decrypt(fileData) {
206+
console.info('decrypt');
207+
console.info(fileData);
208+
const decryptParams = new Virtru.DecryptParamsBuilder()
209+
.withArrayBufferSource(fileData)
210+
.build();
211+
212+
const decrypted = await client.decrypt(decryptParams);
213+
return decrypted;
214+
}
215+
216+
// Encrypt the filedata and return the stream content and filename
217+
async function encrypt(fileData, filename) {
218+
console.info('encrypt');
219+
console.info(filename);
220+
console.info(fileData);
221+
222+
var recipients = document.getElementById('recipient-virtru').value;
223+
224+
if (document.getElementById('expire').checked == true) {
225+
const policy = new Virtru.PolicyBuilder()
226+
.enableExpirationDeadlineFromNow((document.getElementById('expire_seconds').value)*3600)
227+
.build();
228+
const encryptParams = new Virtru.EncryptParamsBuilder()
229+
.withArrayBufferSource(fileData)
230+
.withPolicy(policy)
231+
.withUsersWithAccess([recipients])
232+
.withDisplayFilename(filename)
233+
//.withZipFormat() // Generate TDF in zip format
234+
.build();
235+
const enc = await client.encrypt(encryptParams);
236+
console.info(encryptParams);
237+
return enc;
238+
} else {
239+
const encryptParams = new Virtru.EncryptParamsBuilder()
240+
.withArrayBufferSource(fileData)
241+
//.withPolicy(policy)
242+
.withUsersWithAccess([recipients])
243+
.withDisplayFilename(filename)
244+
//.withZipFormat() // Generate TDF in zip format
245+
.build();
246+
const enc = await client.encrypt(encryptParams);
247+
console.info(encryptParams);
248+
return enc;
249+
}
250+
}
251+
252+
// Set up the auth widget.
253+
Virtru.AuthWidget('virtru-auth-widget-mount', {afterAuth});
254+
255+
</script>
256+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
138257
<script>
139258
window.addEventListener("load", window.initok);
140259
</script>

dev-vir/encrypt-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
126126
</code>
127127
</pre>
128128
</div>
129-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
129+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
130130
<script>
131131
window.addEventListener("load", window.initok);
132132
</script>

dev-vir/encrypt-file-dev.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22

33
<head>
4-
<title>OnlyKey Apps - Encrypt & sign files using Keybase PGP</title>
4+
<title>OnlyKey Apps - Encrypt & sign files using Onlykey, Keybase PGP, and Virtru</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
66
<META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none' ; script-src 'self' 'sha256-P1WP1KTz9iiHN5Bfeec+pIgBDay5qWNQZh9HujWa94o=' 'sha256-pBDNHyFUtn3XsRvFveaLkaEupq1l96neUvZm5/c1PmQ='; style-src 'self' 'sha256-ujVZuuvwuQ+epdwqO8AhlbOQSx68+ci+dDIwrFrzI+Q=' 'sha256-zsMKYSOY0gzTtULlMRDwkny+ocnOJuA+B49b0BIIQXU='; img-src 'self' ; font-src 'self' ; connect-src 'self' https://keybase.io ; base-uri 'none'; form-action 'none';">
77
<!-- CSSNormalize, CSSGrids-Responsive, CSSForm, CSSTable, CSSList (v3.9.1) -->
@@ -134,7 +134,7 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
134134
</code>
135135
</pre>
136136
</div>
137-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
137+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
138138
<script>
139139
window.addEventListener("load", window.initok);
140140
</script>

dev-vir/encrypt-file-vir-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,5 +283,5 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
283283
Virtru.AuthWidget('virtru-auth-widget-mount', {afterAuth});
284284

285285
</script>
286-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
286+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
287287
</html>

dev-vir/index-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h3>Looking for the <a href="https://apps.crp.to/beta7" target="_blank">old Webc
123123
</code>
124124
</pre>
125125
</div>
126-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
126+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
127127
<script>
128128
window.addEventListener("load", window.initok);
129129
</script>

dev-vir/search-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,6 @@ <h3>Search results go here...</h3>
306306
</div>
307307
</fieldset>
308308
</div>
309-
<script type="text/javascript" src="bundle.b4c367785a0f927bb9d4.js"></script></body>
309+
<script type="text/javascript" src="bundle.54a29c09d8140fc71c64.js"></script></body>
310310

311311
</html>

0 commit comments

Comments
 (0)