UNPKG

signing-enclave

Version:

A code signing and notarization tool for macOS and Windows applications. Uses Azure Key Vault for secret and certificate management.

51 lines 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNotarizationSecretsFromHSM = getNotarizationSecretsFromHSM; exports.notarizeWithTimeout = notarizeWithTimeout; const notarize_1 = require("@electron/notarize"); const secretClient_1 = require("./secretClient"); const NOTARIZE_TIMEOUT = 2700000; // 45 minutes async function getNotarizationSecretsFromHSM(credentialsWithoutSecret) { if ("$appSpecificPassword" in credentialsWithoutSecret) { const appSpecificPassword = await (0, secretClient_1.getSecret)(credentialsWithoutSecret.$appSpecificPassword); return { ...credentialsWithoutSecret, appleIdPassword: appSpecificPassword, }; } else if ("$appleApiKey" in credentialsWithoutSecret) { const appleApiKey = await (0, secretClient_1.getSecret)(credentialsWithoutSecret.$appleApiKey); return { ...credentialsWithoutSecret, appleApiKey, }; } else { throw new Error("Invalid credentials"); } } async function notarizeWithTimeout(credentialsWithoutSecret, appPath) { const hrstart = process.hrtime(); const credentials = await getNotarizationSecretsFromHSM(credentialsWithoutSecret); const initTime = process.hrtime(hrstart); console.debug(`Notarization secrets retrieved in ${initTime[0]}s ${(initTime[1] / 1000000).toFixed(0)}ms`); const hrsignstart = process.hrtime(); console.log(credentials, appPath); let timeoutId; await Promise.race([ (0, notarize_1.notarize)({ ...credentials, appPath, tool: "notarytool", }).then(() => { clearTimeout(timeoutId); const signTime = process.hrtime(hrsignstart); console.debug(`Notarized in ${signTime[0]}s ${(signTime[1] / 1000000).toFixed(0)}ms`); }), // throws timeout error if notarize() not resolved after 45 mins new Promise((_, reject) => { timeoutId = setTimeout(() => reject(new Error("Mac notarization timed out")), NOTARIZE_TIMEOUT); }), ]); } //# sourceMappingURL=macOSNotarization.js.map