electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

Notarize failed with 24.13.3 after upgrade from 24.12.0 with app specific password

Open KillerCodeMonkey opened this issue 1 year ago • 10 comments

  • Electron-Builder Version: 24.13.3
  • Node Version: 18.18.2
  • Electron Version: 28.2.5
  • Electron Type (current, beta, nightly): stable
  • Target: macos-12 dmg darwin-64

I upgraded electron builder from 24.12.0 to 24.13.3 and notarizing failed with

Cannot destructure property 'appBundleId' of 'options' as it is undefined. 

I am using APPLE_ID and APPLE_APP_SPECIFIC_PASSWORD approach for authorization. Since i did not find out what changed, i tried to force new notarytool.

I checked the code how notarize options are build. And it should be possible to set

{
  mac: {
    notarize: {
      teamId: "TEAM_ID"
    }
  }
}

even when using apple id and app specific password for authorization. the new notarytool should be used following the source code in https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/macPackager.ts#L566. But when setting the team id i get this:

-> Options related to how build macOS targets.
   Details:
    * configuration.mac.notarize has an unknown property 'teamId'. These properties are valid:
      object { appBundleId?, ascProvider? }
    * configuration.mac.notarize has an unknown property 'tool'. These properties are valid:
      object { appBundleId?, ascProvider? }
    * configuration.mac.notarize has an unknown property 'tool'. These properties are valid:
      object { teamId }
    * configuration.mac.notarize misses the property 'teamId'. Should be:
      string
      -> The team ID you want to notarize under for when using `notarytool`

So what did i miss in the version update that notarizing is not working anymore?

Thank you!

EDIT: Downgraded to 24.12.0 again and removed the notarize key from the builder config. and it is working again.

KillerCodeMonkey avatar Mar 06 '24 09:03 KillerCodeMonkey

I switched to api keys to get things working with latest builder version. but i guess the issue is still valid

KillerCodeMonkey avatar Mar 07 '24 11:03 KillerCodeMonkey

I also had to downgrade to get things rolling again.

It seems that in v24.13.3, notarize is being called somewhere while disregarding the script specified by afterSign.

The error I was getting: Cannot destructure property 'appBundleId' of 'options' as it is undefined. failedTask=build stackTrace=TypeError: Cannot destructure property 'appBundleId' of 'options' as it is undefined..

It seems like this "other" notarize is being called based on a trigger other than the afterSign config.

brianpetro avatar Mar 23 '24 23:03 brianpetro

I hit the same issue that reported here.

Newer electron-builder has a built-in notarize option that works out of the box as @KillerCodeMonkey mentioned. On the other hand, the old way that uses the afterSign option to invoke a script to manually call electron-notarize doesn't work well with electron-builder 24.13.3.

I removed the afterSign option in my script and added the following config to package.json and now everything works without issues. I'm still using APPLE_APP_SPECIFIC_PASSWORD, but it looks that's just fine.

...under mac..
     "notarize": {
        "teamId": "YOUR_TEAM_ID"
      }

yudai avatar Mar 27 '24 21:03 yudai

If you have the following env variables, it will try to notarize automatically

  1. APPLE_API_KEY, APPLE_API_KEY_ID and APPLE_API_ISSUER.
  2. APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, and APPLE_TEAM_ID
  3. APPLE_KEYCHAIN and APPLE_KEYCHAIN_PROFILE

sandeep1995 avatar Apr 15 '24 11:04 sandeep1995

the afterSign option to invoke a script to manually call electron-notarize doesn't work well with electron-builder 24.13.3

How so?

I am still using this approach and it works fine. Just ensure to set build.mac.notarize to false in package.json, to avoid attempting it twice.

Here is my afterSign.js file, set in build.afterSign. Note that I load the credentials from a file using dotenv; I do not pass them via runtime environment variables:

const path = require('path');
require('dotenv').config();
require('dotenv').config({ path: path.resolve(__dirname, '..', '..', '.credentials') });
const { spawnSync } = require('child_process');
const { notarize } = require('@electron/notarize');

async function notarizeMacos(context) {
  const { appOutDir } = context;

  const {
    APPLE_ID,
    APPLE_APP_SPECIFIC_PASSWORD,
    APPLE_TEAM_ID,
  } = process.env;

  if (!(APPLE_ID && APPLE_APP_SPECIFIC_PASSWORD && APPLE_TEAM_ID)) {
    console.log('Skipping notarizing step. APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, and APPLE_TEAM_ID env variables must be set');
    return;
  }

  if (process.env.SKIP_NOTARIZE !== undefined) {
    console.warn('Skipping notarizing step. SKIP_NOTARIZE env variable is set.');
    return;
  }

  const appName = context.packager.appInfo.productFilename;

  console.log('Notarizing macOS app...');
  await notarize({
    // appBundleId: build.appId,
    appPath: `${appOutDir}/${appName}.app`,
    appleId: APPLE_ID,
    appleIdPassword: APPLE_APP_SPECIFIC_PASSWORD,
    teamId: APPLE_TEAM_ID,
  });
}

exports.default = async function notarizeOrSign(context) {
  const { electronPlatformName } = context;
  if (electronPlatformName === 'darwin') {
    await notarizeMacos(context);
  } else {
    console.log(`No notarization or signing for platform ${electronPlatformName}`);
  }
};

slhck avatar Apr 25 '24 10:04 slhck

I hit the same issue that reported here.

Newer electron-builder has a built-in notarize option that works out of the box as @KillerCodeMonkey mentioned. On the other hand, the old way that uses the afterSign option to invoke a script to manually call electron-notarize doesn't work well with electron-builder 24.13.3.

I removed the afterSign option in my script and added the following config to package.json and now everything works without issues. I'm still using APPLE_APP_SPECIFIC_PASSWORD, but it looks that's just fine.

...under mac..
     "notarize": {
        "teamId": "YOUR_TEAM_ID"
      }

It works! Thank you!

shangzhenyang avatar Apr 26 '24 20:04 shangzhenyang

@sandeep1995

  • APPLE_ID, APPLE_APP_SPECIFIC_PASSWORD, and APPLE_TEAM_ID

This is not working for me

[email protected] APPLE_TEAM_ID=W00ABCDEFG APPLE_APP_SPECIFIC_PASSWORD=xxxx-yyyy-zzzz-wwww ....

The teamId property is required when using notarization with password credentials failedTask=build stackTrace=Error: The teamId property is required when using notarization with password credentials

"electron-builder": "^24.13.3"

I don't have an afterSign script.

greggman avatar May 28 '24 13:05 greggman

"notarize": { "teamId": "YOUR_TEAM_ID" }

It works! Thanks!

nunyvega avatar Jun 07 '24 11:06 nunyvega

I hit the same issue that reported here.

Newer electron-builder has a built-in notarize option that works out of the box as @KillerCodeMonkey mentioned. On the other hand, the old way that uses the afterSign option to invoke a script to manually call electron-notarize doesn't work well with electron-builder 24.13.3.

I removed the afterSign option in my script and added the following config to package.json and now everything works without issues. I'm still using APPLE_APP_SPECIFIC_PASSWORD, but it looks that's just fine.

...under mac..
     "notarize": {
        "teamId": "YOUR_TEAM_ID"
      }

I added it in my electron-builder.ts

also set the envs APPLE_ID & APPLE_APP_SPECIFIC_PASSWORD and it is working again.

Note: If you have an older afterSign script, you will probably want to turn that off as electron-builder will now try to automatically notarize the app for you

talhaibnmahmud avatar Jun 10 '24 13:06 talhaibnmahmud

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Aug 10 '24 00:08 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Sep 09 '24 00:09 github-actions[bot]