Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: bump engines requirement to Node 22 #222

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # tag: v4.1.0
with:
node-version: lts/*
node-version: '22.12.x'
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build API documentation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20.x
node-version: '22.12.x'
cache: 'yarn'
- name: Install
run: yarn install --frozen-lockfile
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,18 @@ jobs:
strategy:
matrix:
node-version:
- '20.9'
- '18.17'
- '16.20'
- '14.16'
- '22.12.x'
runs-on: macos-latest
steps:
- name: Install Rosetta
if: ${{ matrix.node-version == '14.16' }}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: "${{ matrix.node-version }}"
cache: 'yarn'
architecture: ${{ matrix.node-version == '14.16' && 'x64' || env.RUNNER_ARCH }}
- name: Install (Node.js v16+)
if : ${{ matrix.node-version != '14.16' }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install (Node.js < v16)
if : ${{ matrix.node-version == '14.16' }}
run: yarn install --frozen-lockfile --ignore-engines
- name: Lint
run: yarn lint
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,25 @@
"lib"
],
"engines": {
"node": ">= 10.0.0"
"node": ">= 22.12.0"
},
"publishConfig": {
"provenance": true
},
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.1",
"@types/debug": "^4.1.12",
"@types/jest": "^29.0.0",
"@types/node": "^13.7.7",
"@types/node": "~22.10.7",
"@types/promise-retry": "^1.1.3",
"jest": "^29.0.0",
"prettier": "^3.4.2",
"ts-jest": "^29.0.0",
"typedoc": "~0.25.13",
"typedoc-plugin-missing-exports": "^2.2.0",
"typescript": "4.9.3"
"typescript": "~5.4.5"
},
"dependencies": {
"debug": "^4.1.1",
"fs-extra": "^9.0.1",
"debug": "^4.4.0",
"promise-retry": "^2.0.1"
}
}
11 changes: 6 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import debug from 'debug';
import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';

import * as fs from 'node:fs/promises';
import * as os from 'node:os';
import * as path from 'node:path';

const d = debug('electron-notarize:helpers');

Expand All @@ -13,11 +14,11 @@ export async function withTempDir<T>(fn: (dir: string) => Promise<T>) {
result = await fn(dir);
} catch (err) {
d('work failed');
await fs.remove(dir);
await fs.rm(dir, { recursive: true, force: true });
throw err;
}
d('work succeeded');
await fs.remove(dir);
await fs.rm(dir, { recursive: true, force: true });
return result;
}

Expand Down
21 changes: 3 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import retry from 'promise-retry';
import { checkSignatures } from './check-signature';
import { isNotaryToolAvailable, notarizeAndWaitForNotaryTool } from './notarytool';
import { stapleApp } from './staple';
import {
NotarizeOptions,
NotaryToolStartOptions,
NotarizeOptionsLegacy,
NotarizeOptionsNotaryTool,
} from './types';
import { NotarizeOptions } from './types';

const d = debug('electron-notarize');

Expand All @@ -28,19 +23,9 @@ export { validateNotaryToolAuthorizationArgs as validateAuthorizationArgs } from
* @param args Options for notarization
* @returns The Promise resolves once notarization is complete. Note that this may take a few minutes.
*/
async function notarize(args: NotarizeOptionsNotaryTool): Promise<void>;
/**
* @deprecated
*/
async function notarize(args: NotarizeOptionsLegacy): Promise<void>;
async function notarize(args: NotarizeOptions): Promise<void>;

async function notarize({ appPath, ...otherOptions }: NotarizeOptions) {
if (otherOptions.tool === 'legacy') {
throw new Error(
'Notarization with the legacy altool system was decommisioned as of November 2023',
);
}

await checkSignatures({ appPath });

d('notarizing using notarytool');
Expand All @@ -53,7 +38,7 @@ async function notarize({ appPath, ...otherOptions }: NotarizeOptions) {
await notarizeAndWaitForNotaryTool({
appPath,
...otherOptions,
} as NotaryToolStartOptions);
} as NotarizeOptions);

await retry(() => stapleApp({ appPath }), {
retries: 3,
Expand Down
18 changes: 0 additions & 18 deletions src/legacy.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
isNotaryToolPasswordCredentials,
isNotaryToolApiKeyCredentials,
} from './validate-args';
import { NotaryToolCredentials, NotaryToolStartOptions } from './types';
import { NotarizeOptions, NotaryToolCredentials } from './types';

const d = debug('electron-notarize:notarytool');

Expand Down Expand Up @@ -47,7 +47,7 @@ function authorizationArgs(rawOpts: NotaryToolCredentials): string[] {
}
}

async function getNotarizationLogs(opts: NotaryToolStartOptions, id: string) {
async function getNotarizationLogs(opts: NotarizeOptions, id: string) {
try {
const logResult = await runNotaryTool(
['log', id, ...authorizationArgs(opts)],
Expand All @@ -70,7 +70,7 @@ export async function isNotaryToolAvailable(notarytoolPath?: string) {
}
}

export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions) {
export async function notarizeAndWaitForNotaryTool(opts: NotarizeOptions) {
d('starting notarize process for app:', opts.appPath);
return await withTempDir(async (dir) => {
const fileExt = path.extname(opts.appPath);
Expand Down
85 changes: 1 addition & 84 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export interface LegacyNotarizePasswordCredentials {
appleId: string;
appleIdPassword: string;
}

/**
* You can generate an [app-specific password](https://support.apple.com/en-us/102654) for your Apple ID
* to notarize your Electron applications.
Expand Down Expand Up @@ -36,15 +27,6 @@ export interface NotaryToolPasswordCredentials {
teamId: string;
}

/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export interface LegacyNotarizeApiKeyCredentials {
appleApiKey: string;
appleApiIssuer: string;
}

/**
* Credentials required for JSON Web Token (JWT) notarization using App Store Connect API keys.
*
Expand Down Expand Up @@ -90,14 +72,6 @@ export interface NotaryToolKeychainCredentials {
keychain?: string;
}

/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export type LegacyNotarizeCredentials =
| LegacyNotarizePasswordCredentials
| LegacyNotarizeApiKeyCredentials;

/**
* Credential options for authenticating `notarytool`. There are three valid stategies available:
*
Expand All @@ -111,15 +85,6 @@ export type NotaryToolCredentials =
| NotaryToolApiKeyCredentials
| NotaryToolKeychainCredentials;

/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export interface LegacyNotarizeAppOptions {
appPath: string;
appBundleId: string;
}

/**
* Non-credential options for notarizing your application with `notarytool`.
* @category Core
Expand All @@ -132,56 +97,8 @@ export interface NotaryToolNotarizeAppOptions {
notarytoolPath?: string;
}

/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
interface TransporterOptions {
ascProvider?: string;
}

/**
* @deprecated This interface was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
interface NotarizeResult {
uuid: string;
}

/**
* @deprecated This type was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export type LegacyNotarizeStartOptions = LegacyNotarizeAppOptions &
LegacyNotarizeCredentials &
TransporterOptions;

/**
* @deprecated This type was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export type LegacyNotarizeWaitOptions = NotarizeResult & LegacyNotarizeCredentials;

/**
* @deprecated This type was used for Apple's `altool`, which was sunset in 2023 and no longer works.
* @category Legacy
*/
export type NotarizeOptionsLegacy = { tool: 'legacy' } & LegacyNotarizeStartOptions;

/**
* Options for notarizing your Electron app with `notarytool`.
* @category Core
*/
export type NotaryToolStartOptions = NotaryToolNotarizeAppOptions & NotaryToolCredentials;

/**
* Helper type that specifies that `@electron/notarize` is using the `notarytool` strategy.
* @category Utility Types
*/
export type NotarizeOptionsNotaryTool = { tool?: 'notarytool' } & NotaryToolStartOptions;

/**
* Options accepted by the `notarize` method.
* @internal
*/
export type NotarizeOptions = NotarizeOptionsLegacy | NotarizeOptionsNotaryTool;
export type NotarizeOptions = NotaryToolNotarizeAppOptions & NotaryToolCredentials;
57 changes: 0 additions & 57 deletions src/validate-args.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,10 @@
import {
LegacyNotarizeApiKeyCredentials,
LegacyNotarizeCredentials,
LegacyNotarizePasswordCredentials,
NotaryToolApiKeyCredentials,
NotaryToolCredentials,
NotaryToolKeychainCredentials,
NotaryToolPasswordCredentials,
} from './types';

/** @deprecated */
export function isLegacyPasswordCredentials(
opts: LegacyNotarizeCredentials,
): opts is LegacyNotarizePasswordCredentials {
const creds = opts as LegacyNotarizePasswordCredentials;
return creds.appleId !== undefined || creds.appleIdPassword !== undefined;
}

/** @deprecated */
export function isLegacyApiKeyCredentials(
opts: LegacyNotarizeCredentials,
): opts is LegacyNotarizeApiKeyCredentials {
const creds = opts as LegacyNotarizeApiKeyCredentials;
return creds.appleApiKey !== undefined || creds.appleApiIssuer !== undefined;
}

/** @deprecated */
export function validateLegacyAuthorizationArgs(
opts: LegacyNotarizeCredentials,
): LegacyNotarizeCredentials {
const isPassword = isLegacyPasswordCredentials(opts);
const isApiKey = isLegacyApiKeyCredentials(opts);
if (isPassword && isApiKey) {
throw new Error('Cannot use both password credentials and API key credentials at once');
}
if (isPassword) {
const passwordCreds = opts as LegacyNotarizePasswordCredentials;
if (!passwordCreds.appleId) {
throw new Error(
'The appleId property is required when using notarization with appleIdPassword',
);
} else if (!passwordCreds.appleIdPassword) {
throw new Error(
'The appleIdPassword property is required when using notarization with appleId',
);
}
return passwordCreds;
}
if (isApiKey) {
const apiKeyCreds = opts as LegacyNotarizeApiKeyCredentials;
if (!apiKeyCreds.appleApiKey) {
throw new Error(
'The appleApiKey property is required when using notarization with appleApiIssuer',
);
} else if (!apiKeyCreds.appleApiIssuer) {
throw new Error(
'The appleApiIssuer property is required when using notarization with appleApiKey',
);
}
return apiKeyCreds;
}
throw new Error('No authentication properties provided (e.g. appleId, appleApiKey)');
}

export function isNotaryToolPasswordCredentials(
opts: NotaryToolCredentials,
): opts is NotaryToolPasswordCredentials {
Expand Down
Loading
Loading