This repository was archived by the owner on Mar 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ var hwcrypto = (function hwcrypto() {
58
58
// Important constants
59
59
var digidoc_mime = 'application/x-digidoc' ;
60
60
var digidoc_chrome = 'TokenSigning' ;
61
+ var EXTENSION_CHECK_TIMEOUT = 1000 ;
61
62
// Some error strings
62
63
var USER_CANCEL = "user_cancel" ;
63
64
var NO_CERTIFICATES = "no_certificates" ;
@@ -187,8 +188,21 @@ var hwcrypto = (function hwcrypto() {
187
188
}
188
189
// FIXME: remove this from content script!
189
190
p = new window [ digidoc_chrome ] ( ) ;
191
+
190
192
if ( p ) {
191
- resolve ( true ) ;
193
+ // The global TokenSigning function can be defined either by
194
+ // the extension or, to workaround a CSP issue, by the website.
195
+ // Requesting the extension version to make sure the extension is installed.
196
+ var versionCheckTimeout = new Promise ( function ( resolve , reject ) {
197
+ setTimeout ( reject , EXTENSION_CHECK_TIMEOUT ) ;
198
+ } ) ;
199
+
200
+ resolve (
201
+ Promise
202
+ . race ( [ p . getVersion ( ) , versionCheckTimeout ] )
203
+ . then ( function ( ) { return true ; } )
204
+ . catch ( function ( ) { return false ; } )
205
+ ) ;
192
206
} else {
193
207
resolve ( false ) ;
194
208
}
You can’t perform that action at this time.
0 commit comments