Upload via GUI (7543 Dateien)
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/* auto-generated by NAPI-RS */
|
||||||
|
/* eslint-disable */
|
||||||
|
export declare function extract(zipPath: string, opts: ExtractOptions): Promise<void>
|
||||||
|
|
||||||
|
export interface ExtractOptions {
|
||||||
|
/** Destination directory. Must be an absolute path. */
|
||||||
|
dir: string
|
||||||
|
}
|
||||||
+629
@@ -0,0 +1,629 @@
|
|||||||
|
// prettier-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
// @ts-nocheck
|
||||||
|
/* auto-generated by NAPI-RS */
|
||||||
|
|
||||||
|
import { createRequire } from 'node:module'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
const __dirname = new URL('.', import.meta.url).pathname
|
||||||
|
|
||||||
|
const { readFileSync } = require('node:fs')
|
||||||
|
let nativeBinding = null
|
||||||
|
const loadErrors = []
|
||||||
|
|
||||||
|
const isMusl = () => {
|
||||||
|
let musl = false
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
musl = isMuslFromFilesystem()
|
||||||
|
if (musl === null) {
|
||||||
|
musl = isMuslFromReport()
|
||||||
|
}
|
||||||
|
if (musl === null) {
|
||||||
|
musl = isMuslFromChildProcess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return musl
|
||||||
|
}
|
||||||
|
|
||||||
|
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
||||||
|
|
||||||
|
const isMuslFromFilesystem = () => {
|
||||||
|
try {
|
||||||
|
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const isMuslFromReport = () => {
|
||||||
|
let report = null
|
||||||
|
if (typeof process.report?.getReport === 'function') {
|
||||||
|
process.report.excludeNetwork = true
|
||||||
|
report = process.report.getReport()
|
||||||
|
}
|
||||||
|
if (!report) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
if (report.header && report.header.glibcVersionRuntime) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (Array.isArray(report.sharedObjects)) {
|
||||||
|
if (report.sharedObjects.some(isFileMusl)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const isMuslFromChildProcess = () => {
|
||||||
|
try {
|
||||||
|
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
||||||
|
} catch (e) {
|
||||||
|
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireNative() {
|
||||||
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
||||||
|
try {
|
||||||
|
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
||||||
|
} catch (err) {
|
||||||
|
loadErrors.push(err)
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'android') {
|
||||||
|
if (process.arch === 'arm64') {
|
||||||
|
try {
|
||||||
|
return require('./index.android-arm64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-android-arm64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-android-arm64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm') {
|
||||||
|
try {
|
||||||
|
return require('./index.android-arm-eabi.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-android-arm-eabi is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-android-arm-eabi/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
|
if (process.arch === 'x64') {
|
||||||
|
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
|
||||||
|
try {
|
||||||
|
return require('./index.win32-x64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-x64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-x64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.win32-x64-msvc.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-x64-msvc is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-x64-msvc/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'ia32') {
|
||||||
|
try {
|
||||||
|
return require('./index.win32-ia32-msvc.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-ia32-msvc is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-ia32-msvc/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm64') {
|
||||||
|
try {
|
||||||
|
return require('./index.win32-arm64-msvc.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-arm64-msvc is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-win32-arm64-msvc/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'darwin') {
|
||||||
|
try {
|
||||||
|
return require('./index.darwin-universal.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-universal is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-universal/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
if (process.arch === 'x64') {
|
||||||
|
try {
|
||||||
|
return require('./index.darwin-x64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-x64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-x64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm64') {
|
||||||
|
try {
|
||||||
|
return require('./index.darwin-arm64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-arm64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-darwin-arm64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'freebsd') {
|
||||||
|
if (process.arch === 'x64') {
|
||||||
|
try {
|
||||||
|
return require('./index.freebsd-x64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-freebsd-x64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-freebsd-x64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm64') {
|
||||||
|
try {
|
||||||
|
return require('./index.freebsd-arm64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-freebsd-arm64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-freebsd-arm64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'linux') {
|
||||||
|
if (process.arch === 'x64') {
|
||||||
|
if (isMusl()) {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-x64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-x64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return require('./index.linux-x64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-x64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm64') {
|
||||||
|
if (isMusl()) {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-arm64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-arm64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return require('./index.linux-arm64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm') {
|
||||||
|
if (isMusl()) {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-arm-musleabihf.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm-musleabihf is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm-musleabihf/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-arm-gnueabihf.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm-gnueabihf is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-arm-gnueabihf/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'loong64') {
|
||||||
|
if (isMusl()) {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-loong64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-loong64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-loong64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-loong64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-loong64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-loong64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'riscv64') {
|
||||||
|
if (isMusl()) {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-riscv64-musl.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-riscv64-musl is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-riscv64-musl/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-riscv64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-riscv64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-riscv64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'ppc64') {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-ppc64-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-ppc64-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-ppc64-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 's390x') {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-s390x-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-s390x-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-s390x-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'ia32') {
|
||||||
|
try {
|
||||||
|
return require('./index.linux-ia32-gnu.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-ia32-gnu is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-linux-ia32-gnu/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'openharmony') {
|
||||||
|
if (process.arch === 'arm64') {
|
||||||
|
try {
|
||||||
|
return require('./index.openharmony-arm64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-arm64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-arm64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'x64') {
|
||||||
|
try {
|
||||||
|
return require('./index.openharmony-x64.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-x64 is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-x64/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else if (process.arch === 'arm') {
|
||||||
|
try {
|
||||||
|
return require('./index.openharmony-arm.node')
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const binding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-arm is intentionally not published)') })()
|
||||||
|
const bindingPackageVersion = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-openharmony-arm/package.json is intentionally not published)') })().version
|
||||||
|
if (bindingPackageVersion !== '0.0.0-development' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||||
|
throw new Error(`Native binding package version mismatch, expected 0.0.0-development but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||||
|
}
|
||||||
|
return binding
|
||||||
|
} catch (e) {
|
||||||
|
loadErrors.push(e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeBinding = requireNative()
|
||||||
|
|
||||||
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
||||||
|
let wasiBinding = null
|
||||||
|
let wasiBindingError = null
|
||||||
|
try {
|
||||||
|
wasiBinding = require('./index.wasi.cjs')
|
||||||
|
nativeBinding = wasiBinding
|
||||||
|
} catch (err) {
|
||||||
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||||
|
wasiBindingError = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
||||||
|
try {
|
||||||
|
wasiBinding = (() => { throw new Error('prebuild for this platform is not bundled (and @electron-internal/extract-zip-wasm32-wasi is intentionally not published)') })()
|
||||||
|
nativeBinding = wasiBinding
|
||||||
|
} catch (err) {
|
||||||
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||||
|
if (!wasiBindingError) {
|
||||||
|
wasiBindingError = err
|
||||||
|
} else {
|
||||||
|
wasiBindingError.cause = err
|
||||||
|
}
|
||||||
|
loadErrors.push(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
||||||
|
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
||||||
|
error.cause = wasiBindingError
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nativeBinding) {
|
||||||
|
if (loadErrors.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Cannot find native binding. ` +
|
||||||
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
||||||
|
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
||||||
|
{
|
||||||
|
cause: loadErrors.reduce((err, cur) => {
|
||||||
|
cur.cause = err
|
||||||
|
return cur
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new Error(`Failed to load native binding`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const { extract } = nativeBinding
|
||||||
|
export { extract }
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
export interface ExtractOptions {
|
||||||
|
/** Destination directory. Must be an absolute path. */
|
||||||
|
dir: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare function extract(zipPath: string, opts: ExtractOptions): Promise<void>;
|
||||||
|
|
||||||
|
export default extract;
|
||||||
BIN
Binary file not shown.
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import path from 'node:path';
|
||||||
|
import { extract as nativeExtract } from './binding.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a zip archive to a directory.
|
||||||
|
*
|
||||||
|
* await extract(source, { dir: '/abs/path' })
|
||||||
|
*
|
||||||
|
* @param {string} zipPath
|
||||||
|
* @param {import('./index.js').ExtractOptions} opts
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
export async function extract(zipPath, opts) {
|
||||||
|
if (!opts || typeof opts.dir !== 'string') {
|
||||||
|
throw new TypeError('extract: opts.dir is required');
|
||||||
|
}
|
||||||
|
if (!path.isAbsolute(opts.dir)) {
|
||||||
|
throw new TypeError('extract: opts.dir must be an absolute path');
|
||||||
|
}
|
||||||
|
return nativeExtract(zipPath, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default extract;
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+23
@@ -0,0 +1,23 @@
|
|||||||
|
Copyright (c) Felix Rieseberg
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
+262
@@ -0,0 +1,262 @@
|
|||||||
|
# @electron/windows-sign [![npm][npm_img]][npm_url]
|
||||||
|
|
||||||
|
Codesign your app for Windows. Made for [Electron][electron] but really supports any folder with binary files. `electron-windows-sign` scans a folder for [signable files](#file-types) and codesigns them with both SHA-1 and SHA-256. It can be highly customized and used either programmatically or on the command line.
|
||||||
|
|
||||||
|
This tool is particularly useful if you want to code sign Electron or other Windows binaries with an EV certificate or an HSM setup (like DigiCert KeyLocker, AWS CloudHSM, Azure Key Vault HSM, Google Cloud Key Management Service HSM, and other similar services). For more details on how you'd exactly do that, please see [Use with Cloud HSM Providers](#use-with-cloud-hsm-providers) below.
|
||||||
|
|
||||||
|
# Requirements
|
||||||
|
|
||||||
|
By default, this module spawns `signtool.exe` and needs to run on Windows. If you're building an Electron app and care enough to codesign them, I would heavily recommend that you build and test your apps on the platforms you're building for.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
Most developers of Electron apps will likely not use this module directly - and instead use it indirectly
|
||||||
|
instead. If you are one of those developers who is using a module like `@electron/forge` or `@electron/packager`, you can configure this module with global environment variables. If that describes
|
||||||
|
you, you can skip ahead to your use case:
|
||||||
|
|
||||||
|
- [With a certificate file and password](#with-a-certificate-file-and-password)
|
||||||
|
- [With a custom binary or custom parameters](#with-a-custom-signtoolexe-or-custom-parameters)
|
||||||
|
- [With a completely custom hook](#with-a-custom-hook-function)
|
||||||
|
|
||||||
|
## Direct Usage
|
||||||
|
|
||||||
|
`@electron/windows-codesign` is built to both esm and cjs and can be used both as a module as well as directly from the command line.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { sign } from "@electron/windows-sign"
|
||||||
|
// or const { sign } = require("@electron/windows-sign")
|
||||||
|
|
||||||
|
await sign(signOptions)
|
||||||
|
```
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
electron-windows-sign $PATH_TO_APP_DIRECTORY [options ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
## With a certificate file and password
|
||||||
|
|
||||||
|
This is the "traditional" way to codesign Electron apps on Windows. You pass in a certificate file
|
||||||
|
(like a .pfx) and a password, which will then be passed to a built-in version of `signtool.exe` taken
|
||||||
|
directly from the Windows SDK.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await sign({
|
||||||
|
appDirectory: "C:\\Path\\To\\App",
|
||||||
|
// or process.env.WINDOWS_CERTIFICATE_FILE
|
||||||
|
certificateFile: "C:\\Cert.pfx",
|
||||||
|
// or process.env.WINDOWS_CERTIFICATE_PASSWORD
|
||||||
|
certificatePassword: "hunter99"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
electron-windows-sign $PATH_TO_APP_DIRECTORY --certificate-file=$PATH_TO_CERT --certificate-password=$CERT-PASSWORD
|
||||||
|
```
|
||||||
|
|
||||||
|
### Full configuration
|
||||||
|
```ts
|
||||||
|
// Path to a timestamp server. Defaults to http://timestamp.digicert.com
|
||||||
|
// Can also be passed as process.env.WINDOWS_TIMESTAMP_SERVER
|
||||||
|
timestampServer = "http://timestamp.digicert.com"
|
||||||
|
// Description of the signed content. Will be passed to signtool.exe as /d
|
||||||
|
// Can also be passed as process.env.WINDOWS_SIGN_DESCRIPTION
|
||||||
|
description = "My content"
|
||||||
|
// URL of the signed content. Will be passed to signtool.exe as /du
|
||||||
|
// Can also be passed as process.env.WINDOWS_SIGN_WEBSITE
|
||||||
|
website = "https://mywebsite.com"
|
||||||
|
// If enabled, attempt to sign .js JavaScript files. Disabled by default
|
||||||
|
signJavaScript = true
|
||||||
|
// If unspecified, both sha1 and sha256 signatures will be appended. Will be passed to signtool.exe as the /fd option.
|
||||||
|
hashes = ["sha256"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## With a custom signtool.exe or custom parameters
|
||||||
|
|
||||||
|
Sometimes, you need to specify specific signing parameters or use a different version
|
||||||
|
of `signtool.exe`. In this mode, `@electron/windows-sign` will call the provided binary
|
||||||
|
with the provided parameters for each file to sign.
|
||||||
|
|
||||||
|
If you only provide `signToolPath`, the default parameters will be used.
|
||||||
|
If you only provide `signWithParams`, the default `signtool.exe` will be used.
|
||||||
|
|
||||||
|
All the [additional configuration](#additional-configuration) mentioned above is also
|
||||||
|
available here, but only used if you do not provide your own parameters.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await sign({
|
||||||
|
appDirectory: "C:\\Path\\To\\App",
|
||||||
|
// or process.env.WINDOWS_CERTIFICATE_FILE
|
||||||
|
certificateFile: "C:\\Cert.pfx",
|
||||||
|
// or process.env.WINDOWS_CERTIFICATE_PASSWORD
|
||||||
|
certificatePassword: "hunter99",
|
||||||
|
// or process.env.WINDOWS_SIGNTOOL_PATH
|
||||||
|
signToolPath: "C:\\Path\\To\\my-custom-tool.exe",
|
||||||
|
// or process.env.WINDOWS_SIGN_WITH_PARAMS
|
||||||
|
signWithParams: "--my=custom --parameters"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
electron-windows-sign $PATH_TO_APP_DIRECTORY --sign-tool-path=$PATH_TO_TOOL --sign-with-params="--my=custom --parameters"
|
||||||
|
```
|
||||||
|
|
||||||
|
## With a custom hook function
|
||||||
|
|
||||||
|
Sometimes, you just want all modules depending on `@electron/windows-sign` to call
|
||||||
|
your completely custom logic. You can either specify a `hookFunction` (if you're calling
|
||||||
|
this module yourself) or a `hookModulePath`, which this module will attempt to require.
|
||||||
|
|
||||||
|
Using the `hookModulePath` has the benefit that you can override how any other users
|
||||||
|
of this module (like `@electron/packager`) codesign your app.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await sign({
|
||||||
|
// A function with the following signature:
|
||||||
|
// (fileToSign: string) => void | Promise<void>
|
||||||
|
//
|
||||||
|
// This function will be called sequentially for each file that
|
||||||
|
// @electron/windows-sign wants to sign.
|
||||||
|
hookFunction: myHookFunction
|
||||||
|
// Path to a hook module.
|
||||||
|
hookModulePath: "C:\\Path\\To\\my-hook-module.js",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Your hook module should either directly export a function or
|
||||||
|
export a `default` function.
|
||||||
|
```js
|
||||||
|
// Good:
|
||||||
|
module.exports = function (filePath) {
|
||||||
|
console.log(`Path to file to sign: ${filePath}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Good:
|
||||||
|
module.exports = async function (filePath) {
|
||||||
|
console.log(`Path to file to sign: ${filePath}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Good:
|
||||||
|
export default async function (filePath) {
|
||||||
|
console.log(`Path to file to sign: ${filePath}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bad:
|
||||||
|
module.exports = {
|
||||||
|
myCustomHookName: function (filePath) {
|
||||||
|
console.log(`Path to file to sign: ${filePath}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bad:
|
||||||
|
export async function myCustomHookName(filePath) {
|
||||||
|
console.log(`Path to file to sign: ${filePath}`)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
SYNOPSIS
|
||||||
|
electron-windows-sign app [options ...]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
app
|
||||||
|
Path to the application to sign. It must be a directory.
|
||||||
|
|
||||||
|
certificate-file
|
||||||
|
Path to the certificate file (.pfx) to use for signing. Uses
|
||||||
|
environment variable WINDOWS_CERTIFICATE_FILE if not provided.
|
||||||
|
|
||||||
|
certificate-password
|
||||||
|
Password to use for the certificate. Uses environment variable
|
||||||
|
WINDOWS_CERTIFICATE_PASSWORD if not provided.
|
||||||
|
|
||||||
|
sign-tool-path
|
||||||
|
Path to the signtool.exe binary. If not specified, the tool will attempt
|
||||||
|
use a built-in version.
|
||||||
|
|
||||||
|
timestamp-server
|
||||||
|
URL of the timestamp server to use. If not specified, the tool will
|
||||||
|
attempt to use a built-in server (http://timestamp.digicert.com)
|
||||||
|
|
||||||
|
description
|
||||||
|
Description to use for the signed files. Passed as /d to signtool.exe.
|
||||||
|
|
||||||
|
website
|
||||||
|
URL of the website to use for the signed files. Passed as /du to
|
||||||
|
signtool.exe.
|
||||||
|
|
||||||
|
sign-with-params
|
||||||
|
Additional parameters to pass to signtool.exe. This can be used to
|
||||||
|
specify additional certificates to use for cross-signing.
|
||||||
|
|
||||||
|
automatically-select-certificate
|
||||||
|
Automatically select the best certificate to use for signing. On by default.
|
||||||
|
|
||||||
|
help
|
||||||
|
Print this usage information.
|
||||||
|
|
||||||
|
debug
|
||||||
|
Print additional debug information.
|
||||||
|
```
|
||||||
|
|
||||||
|
# File Types
|
||||||
|
This tool will aggressively attempt to sign all files that _can_
|
||||||
|
be signed, excluding scripts.
|
||||||
|
|
||||||
|
- [Portable executable files][pe] (.exe, .dll, .sys, .efi, .scr, .node)
|
||||||
|
- Microsoft installers (.msi)
|
||||||
|
- APPX/MSIX packages (.appx, .appxbundle, .msix, .msixbundle)
|
||||||
|
- Catalog files (.cat)
|
||||||
|
- Cabinet files (.cab)
|
||||||
|
- Silverlight applications (.xap)
|
||||||
|
- Scripts (.vbs, .wsf, .ps1)
|
||||||
|
|
||||||
|
If you do want to sign JavaScript, please enable it with the `signJavaScript`
|
||||||
|
parameter. As far as we are aware, there are no benefits to signing
|
||||||
|
JavaScript files, so we do not by default.
|
||||||
|
|
||||||
|
# Use with Cloud HSM Providers
|
||||||
|
|
||||||
|
Since 2023, Microsoft requires that Windows software be signed with an extended validation (EV) certificate in order to avoid a Windows Defender popup. This presents a challenge for developers who are used to building and signing in the cloud or some continuous integration setup like GitHub Actions, CircleCI, Travis CI, or AppVeyor because EV certificates require a Hardware Security Module (HSM). Or, in simpler words: If you want to code sign your Windows software so that your customers don't see a scary Windows Defender dialog, you need to code sign on a computer with a USB device plugged in.
|
||||||
|
|
||||||
|
The industry has an answer to this problem: Services like DigiCert KeyLocker, AWS CloudHSM, Azure Key Vault HSM, or Google Cloud Key Management Service HSM allow code signing binaries with an Extended Validation (EV) certificate from the cloud. `@electron/windows-sign` is compatible with all of these services.
|
||||||
|
|
||||||
|
## Custom signtool parameters
|
||||||
|
|
||||||
|
Most services allow signing your code with Microsoft's `signtool.exe`. Let's take DigiCert KeyLocker as an example. [DigiCert's documentation](https://docs.digicert.com/en/digicert-keylocker/signing-tools/sign-authenticode-files-with-signtool-on-windows.html) explains the steps necessary to setup your signing machine. Once done, you can sign with the following call:
|
||||||
|
|
||||||
|
```
|
||||||
|
signtool.exe sign /csp "DigiCert Signing Manager KSP" /kc <keypair_alias> /f <certificate_file> /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 <file_to_be_signed>
|
||||||
|
```
|
||||||
|
|
||||||
|
To sign with `@electron/windows-sign` using those instructions, you would take the parameters and add them to `signWithParams`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
await sign({
|
||||||
|
signWithParams: "/csp \"DigiCert Signing Manager KSP\" /kc <keypair_alias> /f <certificate_file> /tr http://timestamp.digicert.com /td SHA256 /fd SHA256"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Both Google's and Amazon's solutions similarly allow you to sign with Microsoft's SignTool. Documentation for [Google can be found here](https://cloud.google.com/kms/docs/reference/cng-signtool), [Amazon's lives here](https://docs.aws.amazon.com/cloudhsm/latest/userguide/signtool.html).
|
||||||
|
|
||||||
|
## Custom signtool.exe
|
||||||
|
|
||||||
|
Some providers provide drop-in replacements for `signtool.exe`. If that's the case, simply pass the path to that replacement:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
await sign({
|
||||||
|
// or process.env.WINDOWS_SIGNTOOL_PATH
|
||||||
|
signToolPath: "C:\\Path\\To\\my-custom-tool.exe",
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## Fully custom process
|
||||||
|
|
||||||
|
If your HSM provider has a more complex setup, you might have to call a custom file with custom parameters. If that's the case, use a hook function or hook module, which allows you to completely customize what to do with each file that `@electron/windows-sign` wants to sign. More documentation about this option can be found in the ["Signing with a custom hook function" section above](#with-a-custom-hook-function).
|
||||||
|
|
||||||
|
# License
|
||||||
|
BSD 2-Clause "Simplified". Please see LICENSE for details.
|
||||||
|
|
||||||
|
[electron]: https://github.com/electron/electron
|
||||||
|
[npm_img]: https://img.shields.io/npm/v/@electron/windows-sign.svg
|
||||||
|
[npm_url]: https://npmjs.org/package/@electron/windows-sign
|
||||||
|
[pe]: https://en.wikipedia.org/wiki/Portable_Executable
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export declare function enableDebugging(): void;
|
||||||
|
export declare const log: import("debug").Debugger;
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { debug as debugModule } from 'debug';
|
||||||
|
export function enableDebugging() {
|
||||||
|
debugModule.enable('electron-windows-sign');
|
||||||
|
}
|
||||||
|
export const log = debugModule('electron-windows-sign');
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Tries to parse an process.env string to a boolean.
|
||||||
|
* Will understand undefined as the default value
|
||||||
|
* Will understand "false", "False", "fAlse", or "0" as `false`
|
||||||
|
* Will understand everything else as true
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} name
|
||||||
|
* @return {*} {boolean}
|
||||||
|
*/
|
||||||
|
export declare function booleanFromEnv(name: string): boolean | undefined;
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Tries to parse an process.env string to a boolean.
|
||||||
|
* Will understand undefined as the default value
|
||||||
|
* Will understand "false", "False", "fAlse", or "0" as `false`
|
||||||
|
* Will understand everything else as true
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} name
|
||||||
|
* @return {*} {boolean}
|
||||||
|
*/
|
||||||
|
export function booleanFromEnv(name) {
|
||||||
|
const value = process.env[name];
|
||||||
|
if (value === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (value.toLowerCase() === 'false' || value === '0') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !!value;
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"name": "@electron/windows-sign",
|
||||||
|
"version": "1.2.2",
|
||||||
|
"description": "Codesign Electron Windows apps",
|
||||||
|
"main": "dist/cjs/index.js",
|
||||||
|
"module": "dist/esm/index.js",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"entitlements",
|
||||||
|
"README.md",
|
||||||
|
"LICENSE",
|
||||||
|
"bin",
|
||||||
|
"vendor"
|
||||||
|
],
|
||||||
|
"bin": {
|
||||||
|
"electron-windows-sign": "bin/electron-windows-sign.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/electron/windows-sign.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Felix Rieseberg",
|
||||||
|
"email": "felix@felixrieseberg.com"
|
||||||
|
},
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/electron/windows-sign/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/electron/windows-sign",
|
||||||
|
"publishConfig": {
|
||||||
|
"provenance": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cross-dirname": "^0.1.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"fs-extra": "^11.1.1",
|
||||||
|
"minimist": "^1.2.8",
|
||||||
|
"postject": "^1.0.0-alpha.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/debug": "^4.1.10",
|
||||||
|
"@types/fs-extra": "^11.0.3",
|
||||||
|
"@types/node": "^18.18.7",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
|
"eslint": "^8.52.0",
|
||||||
|
"eslint-config-eslint": "^9.0.0",
|
||||||
|
"eslint-config-standard": "^17.1.0",
|
||||||
|
"eslint-plugin-import": "^2.29.0",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-promise": "^6.1.1",
|
||||||
|
"globstar": "^1.0.0",
|
||||||
|
"standard": "^17.1.0",
|
||||||
|
"tsx": "^3.14.0",
|
||||||
|
"typedoc": "~0.25.13",
|
||||||
|
"typescript": "^5.2.2"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc && tsc -p tsconfig.esm.json",
|
||||||
|
"docs": "npx typedoc",
|
||||||
|
"lint": "eslint --ext .ts,.js src bin test",
|
||||||
|
"test:loader": "globstar -- node --loader tsx --test \"test/**/*.spec.ts\"",
|
||||||
|
"test": "globstar -- node --import tsx --test \"test/**/*.spec.ts\"",
|
||||||
|
"prepublishOnly": "yarn build"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.14"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
Reference in New Issue
Block a user