@@ -6,10 +6,17 @@ // If certificates were rejected by the API, log an error, for example. console.error(rejectedCerts.length + ' certificates were rejected.'); return; } +/* + * Optional features for CACKey + */ +var cackeyFeatures = { + customPINPrompt: true +}; + /* * Handle for the CACKey NaCl Target */ var cackeyHandle = null; var cackeyPCSCHandle = null; @@ -340,11 +347,11 @@ return; } pinWindowPreviousHandle = pinWindow; - + pinWindow.drawAttention(); pinWindow.focus(); /* * Register a handler to handle the window being closed without @@ -371,31 +378,40 @@ /* * Pass this message off to the other window so that it may resubmit the request. */ pinWindow.contentWindow.parentWindow = window; pinWindow.contentWindow.messageEvent = messageEvent; + + if (cackeyFeatures.customPINPrompt) { + pinWindow.contentWindow.pinprompt = messageEvent.data.pinprompt; + } return; }); } else { chrome.certificateProvider.requestPin({ signRequestId: messageEvent.data.originalrequest.signRequestId, requestType: "PIN" }, function(userInfo) { - chrome.certificateProvider.stopPinRequest({ - signRequestId: messageEvent.data.originalrequest.signRequestId - }, function() { - var pinValue = ""; - - pinWindowPreviousHandle = null; - - if (userInfo && userInfo.userInput) { - pinValue = userInfo.userInput; - } - - return(cackeyPINPromptCompleted(pinValue)); - }); + var destroyError; + var pinValue = ""; + + try { + chrome.certificateProvider.stopPinRequest({ + signRequestId: messageEvent.data.originalrequest.signRequestId + }, function() {}); + } catch (destroyError) { + /* Do nothing, we don't care if it fails really */ + } + + pinWindowPreviousHandle = null; + + if (userInfo && userInfo.userInput) { + pinValue = userInfo.userInput; + } + + return(cackeyPINPromptCompleted(pinValue)); }); } /* * We return here instead of break to avoid deleting the callback