mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-20 20:17:38 +00:00
Fix for Safari support using webkit prefix
This commit is contained in:
parent
2a8e4842c3
commit
64b12776b8
@ -43,7 +43,7 @@ $(function() {
|
|||||||
|
|
||||||
if (!roomId) return;
|
if (!roomId) return;
|
||||||
|
|
||||||
if ((!window.crypto && !window.msCrypto) || !window.crypto.subtle) {
|
if (!window.crypto || (!window.crypto.subtle && !window.crypto.webkitSubtle)) {
|
||||||
$('#no-crypto').modal({
|
$('#no-crypto').modal({
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
show: false,
|
show: false,
|
||||||
@ -54,6 +54,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var crypto = window.crypto;
|
var crypto = window.crypto;
|
||||||
|
var cryptoSubtle = window.crypto.subtle || window.crypto.webkitSubtle;
|
||||||
|
|
||||||
let socket = io(roomId);
|
let socket = io(roomId);
|
||||||
$('#roomIdKey').text(roomId.replace('/', ''));
|
$('#roomIdKey').text(roomId.replace('/', ''));
|
||||||
@ -579,25 +580,25 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createKey(password) {
|
function createKey(password) {
|
||||||
return crypto.subtle.digest({
|
return cryptoSubtle.digest({
|
||||||
name: "SHA-256"
|
name: "SHA-256"
|
||||||
}, convertStringToArrayBufferView(password))
|
}, convertStringToArrayBufferView(password))
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
return window.crypto.subtle.importKey("raw", result, {
|
return cryptoSubtle.importKey("raw", result, {
|
||||||
name: "AES-CBC"
|
name: "AES-CBC"
|
||||||
}, false, ["encrypt", "decrypt"]);
|
}, false, ["encrypt", "decrypt"]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function encryptData(data, key, vector) {
|
function encryptData(data, key, vector) {
|
||||||
return crypto.subtle.encrypt({
|
return cryptoSubtle.encrypt({
|
||||||
name: "AES-CBC",
|
name: "AES-CBC",
|
||||||
iv: vector
|
iv: vector
|
||||||
}, key, convertStringToArrayBufferView(data));
|
}, key, convertStringToArrayBufferView(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
function decryptData(data, key, vector) {
|
function decryptData(data, key, vector) {
|
||||||
return crypto.subtle.decrypt({
|
return cryptoSubtle.decrypt({
|
||||||
name: "AES-CBC",
|
name: "AES-CBC",
|
||||||
iv: vector
|
iv: vector
|
||||||
}, key, data);
|
}, key, data);
|
||||||
|
@ -188,7 +188,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Your browser does not support the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto" target="_blank">Crypto Web API</a>.</p>
|
<p>Your browser does not support the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto" target="_blank">Crypto Web API</a>.</p>
|
||||||
<p>Try using the lastest version of Chrome or Firefox.</p>
|
<p>Try using the lastest version of Chrome, Firefox or Safari.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user