Skip to content

Commit

Permalink
Try to make callCert() rejectable (not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Aug 31, 2023
1 parent 52cd71d commit 0ffb3cd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/qz-tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ var qz = (function() {

_qz.security.callCert().then(sendCert).catch(function(error) {
_qz.log.warn("Failed to get certificate:", error);
sendCert(null);
if(_qz.security.rejectOnCertFailure) {
return _qz.tools.reject(error);
} else {
sendCert(null);
}
});
},

Expand Down Expand Up @@ -579,6 +583,8 @@ var qz = (function() {
/** Signing algorithm used on signatures */
signAlgorithm: "SHA1",

rejectOnCertFailure: false,

needsSigned: function(callName) {
const undialoged = [
"printers.getStatus",
Expand Down Expand Up @@ -2595,11 +2601,15 @@ var qz = (function() {
*
* @param {Function|AsyncFunction|Promise<string>} promiseHandler Either a function that will be used as a promise resolver (of format <code>Function({function} resolve, {function}reject)</code>),
* an async function, or a promise. Any of which should return the public certificate via their respective <code>resolve</code> call.
*
* @param {Object} [options] Configuration options for the certificate resolver
* @param {boolean} [options.rejectOnFailure=[false]] Overrides default behavior to call resolve with a blank certificate on failure.
* @memberof qz.security
*/
setCertificatePromise: function(promiseHandler) {
setCertificatePromise: function(promiseHandler, options) {
_qz.security.certHandler = promiseHandler;
if(options && options.rejectOnFailure) {
_qz.security.rejectOnCertFailure = options.rejectOnFailure;
}
},

/**
Expand Down

0 comments on commit 0ffb3cd

Please sign in to comment.