Updated WebCrypto-shim library

v1.0.4-work
Giulio Cesare Solaroli 2017-09-16 09:41:03 +02:00
parent bc92cbce63
commit 58e89852c3
1 changed files with 5 additions and 4 deletions

View File

@ -19,8 +19,9 @@
_SubtleCrypto = global.SubtleCrypto || _subtle.constructor || Object, _SubtleCrypto = global.SubtleCrypto || _subtle.constructor || Object,
_CryptoKey = global.CryptoKey || global.Key || Object; _CryptoKey = global.CryptoKey || global.Key || Object;
var isIE = !!global.msCrypto, var isEdge = global.navigator.userAgent.indexOf('Edge/') > -1;
isWebkit = !!_crypto.webkitSubtle; var isIE = !!global.msCrypto && !isEdge;
var isWebkit = !_crypto.subtle && !!_crypto.webkitSubtle;
if ( !isIE && !isWebkit ) return; if ( !isIE && !isWebkit ) return;
function s2a ( s ) { function s2a ( s ) {
@ -360,7 +361,7 @@
keys[0].alg = keys[1].alg = jwkAlg(ka); keys[0].alg = keys[1].alg = jwkAlg(ka);
keys[0].key_ops = ku.filter(isPubKeyUse), keys[1].key_ops = ku.filter(isPrvKeyUse); keys[0].key_ops = ku.filter(isPubKeyUse), keys[1].key_ops = ku.filter(isPrvKeyUse);
return Promise.all([ return Promise.all([
_subtle.importKey( 'jwk', keys[0], ka, kx, keys[0].key_ops ), _subtle.importKey( 'jwk', keys[0], ka, true, keys[0].key_ops ),
_subtle.importKey( 'jwk', keys[1], ka, kx, keys[1].key_ops ), _subtle.importKey( 'jwk', keys[1], ka, kx, keys[1].key_ops ),
]); ]);
}) })
@ -594,4 +595,4 @@
global.SubtleCrypto = _SubtleCrypto; global.SubtleCrypto = _SubtleCrypto;
global.CryptoKey = CryptoKey; global.CryptoKey = CryptoKey;
} }
}(this); }( typeof window === 'undefined' ? typeof self === 'undefined' ? this : self : window );