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

Commit 3f3f0f7

Browse files
committed
Allow CryptoKey to be recognized even when provided by minified applications
1 parent b9b66ef commit 3f3f0f7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
coverage/
2+
node_modules
3+
.idea

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)