Skip to content

Commit

Permalink
Make callCert() rejectable (qzind#1172)
Browse files Browse the repository at this point in the history
* Make callCert() rejectable (not working)

Co-authored-by: Berenz <5912715+akberenz@users.noreply.github.com>
  • Loading branch information
tresf and akberenz authored Sep 4, 2023
1 parent 52cd71d commit e1b82dc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions js/qz-tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ 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) {
openPromise.reject(error);
} else {
sendCert(null);
}
});
},

Expand Down Expand Up @@ -579,6 +584,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 +2602,13 @@ 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;
_qz.security.rejectOnCertFailure = !!(options && options.rejectOnFailure);
},

/**
Expand Down

0 comments on commit e1b82dc

Please sign in to comment.