Skip to content

Commit

Permalink
chore: delete code for deprecated altool strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Jan 17, 2025
1 parent 99d0cbe commit 1b04111
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 254 deletions.
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
73 changes: 0 additions & 73 deletions test/validate-args.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"Core",
"Credential Strategies",
"Utility Types",
"Legacy"
]
}

0 comments on commit 1b04111

Please sign in to comment.