And I have some test code which works very nicely to test reading a USB scale. It's in the ngOnInit() section of a particular component. This works fine, although the security dialog pops up 3 times as each function is called.
qz.websocket.connect().then(function() {
let deviceInfo = {"vendorId" : "0x0d8f", "productId" : "0x0200", "usagePage" : "0x008d"};
return qz.hid.claimDevice(deviceInfo);
}).then(function() {
//console.log("scale device claimed!!");
}).then(function() {
let deviceInfo = {"vendorId" : "0x0d8f", "productId" : "0x0200", "usagePage" : "0x008d", "responseSize" : 20};
return qz.hid.readData(deviceInfo);
}).then(function(data) {
console.log(data);
// }).then(function() {
// return qz.websocket.disconnect();
}).catch(function(err) {
console.error(err);
});
Because I purchased premium support, I was able to use this
https://qz.io/wiki/generate-certificate as a guide and quick generate my private & public key along with the signed certificate on the QZ website (very slick BTW).
But now I'm a bit confused on how and where to add this cryptographic subsystem.
1. When the trusted certificate is properly installed, does it just popup once for a given browser session? Suppose I move back and forth to other components/pages? Or will the "allow" feature stay enabled between sessions provides cookies are not cleared?
2. Am I correct in assuming that all the required keys and certs are installed as part of the Angular code and does not involve the server-side? I plan to monitor a local USB scale and print label ZPL payload which is received from our server to a local printer So I'm assuming that I don't need to install any of the QZ crypto on in our docker containers or any other server-based systems.
3. It appears like I would add the code below ahead of my code above with this format:
qz.security.setCertificatePromise(function(resolve, reject) { $.ajax({ url: "path/to/digital-certificate.txt", cache: false, dataType: "text" }).then(resolve, reject);});
where my path might reflect my project directory, e.g. app/assets/certs/digital-certification.txt.
I am a bit confused about the $.ajax -- I haven't used any ajax libraries in Angular thus far -- I suspect they are more known to JS programmers.
Let me stop here before moving on to Signatures.
Thanks for reading!
Harry