jan/electron/sign.js
hiento09 96b00bd284
Fix auto update windows Bug (#1102)
* upgrade electron-updater and electron-builder for fixing windows autoupdater

* windows specific target build

* Add block map for windows nightly build

* content-type blocksize change to application/gzip

* content-type blocksize change to application/octet-stream

* remove content-type for windows

* add custom sign for windows

* correct exe file path for binary file

* Add windows codesign step to electron-builder

---------

Co-authored-by: Service Account <service@jan.ai>
Co-authored-by: Hien To <tominhhien97@gmail.com>
2023-12-19 16:33:53 +07:00

45 lines
1.3 KiB
JavaScript

const { exec } = require('child_process');
function sign({ path, name, certUrl, clientId, tenantId, clientSecret, certName, timestampServer, version }) {
return new Promise((resolve, reject) => {
const command = `azuresigntool.exe sign -kvu "${certUrl}" -kvi "${clientId}" -kvt "${tenantId}" -kvs "${clientSecret}" -kvc "${certName}" -tr "${timestampServer}" -v "${path}"`;
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error}`);
return reject(error);
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
resolve();
});
});
}
exports.default = async function(options) {
const certUrl = process.env.AZURE_KEY_VAULT_URI;
const clientId = process.env.AZURE_CLIENT_ID;
const tenantId = process.env.AZURE_TENANT_ID;
const clientSecret = process.env.AZURE_CLIENT_SECRET;
const certName = process.env.AZURE_CERT_NAME;
const timestampServer = 'http://timestamp.globalsign.com/tsa/r6advanced1';
await sign({
path: options.path,
name: "jan-win-x64",
certUrl,
clientId,
tenantId,
clientSecret,
certName,
timestampServer,
version: options.version
});
};