signing-enclave
Version:
A code signing and notarization tool for macOS and Windows applications. Uses Azure Key Vault for secret and certificate management.
86 lines • 3.56 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.windowsSign = windowsSign;
const path_1 = require("path");
const execa_1 = __importDefault(require("execa"));
const os_1 = __importDefault(require("os"));
const path_2 = __importDefault(require("path"));
const keyVaultCredentials_1 = require("./keyVaultCredentials");
const dotenv = __importStar(require("dotenv"));
dotenv.config();
async function windowsSign(pathToSign, certName) {
const credentials = (0, keyVaultCredentials_1.getKeyVaultCredentials)();
const slash = (await Promise.resolve().then(() => __importStar(require("slash")))).default;
const shellCompatiblePath = slash(pathToSign);
const hrstart = process.hrtime();
try {
// TODO: would be nice to do this in JS instead of relying on `azuresigntool`
await (0, execa_1.default)("azuresigntool", [
"sign",
shellCompatiblePath,
"--file-digest",
"sha256",
"--timestamp-rfc3161",
"http://timestamp.digicert.com",
"--timestamp-digest",
"sha256",
"--azure-key-vault-url",
credentials.url,
"--azure-key-vault-client-id",
credentials.id,
"--azure-key-vault-client-secret",
credentials.secret,
"--azure-key-vault-certificate",
certName,
"--azure-key-vault-tenant-id",
credentials.tenantId,
"--verbose",
], {
cwd: __dirname,
env: {
// add ~/.dotnet/tools to PATH
PATH: [
process.env.PATH,
path_2.default.join(os_1.default.homedir(), ".dotnet", "tools"),
].join(";"),
},
});
}
catch (err) {
const errorMessage = (err instanceof Error ? err.message : String(err))
.replace(credentials.secret, "***")
.replace(credentials.url, "***")
.replace(credentials.id, "***");
console.error("azuresigntool error", errorMessage);
throw new Error("Failed to codesign the Windows build");
}
const [secs, nanosecs] = process.hrtime(hrstart);
console.debug(`Signed in ${secs}s ${nanosecs / 1000000}ms: ${(0, path_1.basename)(shellCompatiblePath)}`);
}
//# sourceMappingURL=windowsSigning.js.map