Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit e505e6b

Browse files
Merge pull request #50 from rapropos/loosencryptokey
Allow CryptoKey to be recognized even when provided by minified applications
2 parents 9a68e0d + 3f3f0f7 commit e505e6b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/jose-utils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,5 +367,15 @@ Utils.sha256 = function(str) {
367367
Utils.isCryptoKey = function(rsa_key) {
368368
// Some browsers don't expose the CryptoKey as an object, so we need to check
369369
// the constructor's name.
370-
return rsa_key.constructor.name == 'CryptoKey';
370+
if (rsa_key.constructor.name == 'CryptoKey') {
371+
return true;
372+
}
373+
374+
// In the presence of minifiers, relying on class names can be problematic,
375+
// so let's also allow objects that have an 'algorithm' property.
376+
if (rsa_key.hasOwnProperty('algorithm')) {
377+
return true;
378+
}
379+
380+
return false;
371381
};

0 commit comments

Comments
 (0)