Skip to content

Commit 5aae542

Browse files
onlykeyonlykey
authored andcommitted
test
1 parent d47204b commit 5aae542

11 files changed

Lines changed: 116301 additions & 29 deletions

dev-new/bundle.859948db7d9b715a9705.js

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

dev-new/bundle.859948db7d9b715a9705.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-new/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.1a74f91abca795b5ab22.js"></script></body>
132+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
133133
<script>
134134
window.addEventListener("load", window.initok);
135135
</script>

dev-new/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.1a74f91abca795b5ab22.js"></script></body>
136+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
137137
<script>
138138
window.addEventListener("load", window.initok);
139139
</script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.1a74f91abca795b5ab22.js"></script></body>
137+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
138138
<script>
139139
window.addEventListener("load", window.initok);
140140
</script>

dev-new/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.1a74f91abca795b5ab22.js"></script></body>
129+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
130130
<script>
131131
window.addEventListener("load", window.initok);
132132
</script>

dev-new/encrypt-file-dev.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.1a74f91abca795b5ab22.js"></script></body>
137+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
138138
<script>
139139
window.addEventListener("load", window.initok);
140140
</script>

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

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<title>OnlyKey Apps - Encrypt & sign files using 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 ; connect-src 'self' https://sdk.virtru.com ; base-uri 'none'; form-action 'none';">
76
<link href="https://sdk.virtru.com/js/latest/auth-widget/index.css" rel="stylesheet"/>
87
<script src="https://sdk.virtru.com/js/latest/auth-widget/index.js"></script>
98
<script src="https://sdk.virtru.com/js/latest/virtru-sdk.min.js"></script>
@@ -105,9 +104,12 @@ <h1>
105104
</code>
106105
</div>
107106
<h4><font size="+2">Securely encrypt and sign files using
108-
<a href="https://onlykey.io" target="_blank">OnlyKey</a> and <a href="https://keybase.io/kbpgp" target="_blank">Keybase PGP</a></font></h4>
107+
<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>
108+
109109
<div id="container">
110+
<div id="virtru-auth-widget-mount"></div>
110111
<fieldset>
112+
<textarea placeholder="Email to send to..." rows="1" id="recipient-virtru"></textarea>
111113
<textarea placeholder="Your Keybase username or URL to your public pgp key or paste your key..." rows="1" id="pgpkeyurl2"></textarea>
112114
<textarea placeholder="Recipient's Keybase username or URL to their public PGP key or paste their key..." rows="1" id="pgpkeyurl"></textarea>
113115
<textarea placeholder="Enter a name to use for your encrypted files (optional)..." rows="1" id="filename"></textarea>
@@ -139,29 +141,40 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
139141
</code>
140142
</pre>
141143
</div>
142-
<div id="virtru-auth-widget-mount"></div>
143144
<script>
144145

145-
let sender_email;
146+
let client;
146147

148+
// Run all client code from here.
149+
// This will only be called when the user is successfully authenticated.
147150
async function afterAuth(email) {
148-
// Run all client code from here.
149-
// This will only be called when the user is successfully authenticated.
150-
// sender_email = email;
151-
// window.initok();
152-
const client = new Virtru.Client({email});
153-
const encryptParams = new Virtru.EncryptParamsBuilder()
154-
.withStringSource('Sokath, his eyes open!')
155-
.withDisplayFilename('darmok.txt')
156-
.build();
157-
ct = await client.encrypt(encryptParams);
158-
await ct.toFile('encrypted.html');
151+
152+
//TODO Enable Options fields after auth for user to set encrypted file expiration date etc.
153+
console.info('Virtru email ' + email);
154+
client = new Virtru.Client({email});
155+
console.info('Virtru client ' + client);
156+
}
157+
158+
// Encrypt or decrypt the file by using the support functions
159+
async function encryptOrDecryptFile(filedata, thisfilename, shouldEncrypt, completion) {
160+
if (shouldEncrypt) {
161+
const encrypted = await encrypt(filedata, thisfilename);
162+
await encrypted.toFile(thisfilename + '.tdf');
163+
} else {
164+
const decrypted = await decrypt(filedata);
165+
const finalfilename = buildDecryptFilename(thisfilename).trim();
166+
await decrypted.toFile(finalFilename);
167+
}
168+
169+
if (completion) {
170+
//completion();
171+
}
159172
}
160-
// Set up the auth widget.
161-
Virtru.AuthWidget('virtru-auth-widget-mount', {afterAuth});
162173

163174
// Handle filename parsing with parens involved
164175
function buildDecryptFilename(filename) {
176+
console.info('buildDecryptFilename');
177+
console.info(filename);
165178
const ext = filename.substr(-4);
166179
let finalFilename = filename;
167180

@@ -176,7 +189,8 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
176189

177190
// Decrypt the file by creating an object url (for now) and return the stream content
178191
async function decrypt(fileData) {
179-
const client = new Virtru.Client(sender_email);
192+
console.info('decrypt');
193+
console.info(fileData);
180194
const decryptParams = new Virtru.DecryptParamsBuilder()
181195
.withArrayBufferSource(fileData)
182196
.build();
@@ -187,19 +201,35 @@ <h3>Console Messages from OnlyKey Appear Below</h3>
187201

188202
// Encrypt the filedata and return the stream content and filename
189203
async function encrypt(fileData, filename) {
190-
const client = new Virtru.Client(sender_email);
204+
console.info('encrypt');
205+
console.info(filename);
206+
console.info(fileData);
207+
208+
//const encryptParams = new Virtru.EncryptParamsBuilder()
209+
// .withStringSource('Sokath, his eyes open!')
210+
// .withDisplayFilename('darmok.txt')
211+
// .build();
212+
//console.info(encryptParams);
213+
//ct = await client.encrypt(encryptParams);
214+
//await ct.toFile('encrypted.html');
191215

192216
//const policy = new Virtru.PolicyBuilder().build();
217+
var recipients = document.getElementById('recipient-virtru').value;
193218

194219
const encryptParams = new Virtru.EncryptParamsBuilder()
195220
.withArrayBufferSource(fileData)
196221
//.withPolicy(policy)
197-
//.withDisplayFilename(filename)
222+
.addUsersWithAccess([recipients])
223+
.withDisplayFilename(filename)
198224
.build();
199-
225+
console.info(encryptParams);
200226
const enc = await client.encrypt(encryptParams);
227+
console.info(enc);
201228
return enc;
202229
}
230+
231+
// Set up the auth widget.
232+
Virtru.AuthWidget('virtru-auth-widget-mount', {afterAuth});
203233
</script>
204-
<script type="text/javascript" src="bundle.1a74f91abca795b5ab22.js"></script></body>
234+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
205235
</html>

dev-new/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.1a74f91abca795b5ab22.js"></script></body>
126+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
127127
<script>
128128
window.addEventListener("load", window.initok);
129129
</script>

dev-new/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.1a74f91abca795b5ab22.js"></script></body>
309+
<script type="text/javascript" src="bundle.859948db7d9b715a9705.js"></script></body>
310310

311311
</html>

0 commit comments

Comments
 (0)