Sign And Notarize ElectronJS App – Generate One Time Password

Sign And Notarize ElectronJS App – Generate One Time Password

This article will discuss how to notarize an ElectronJS I will add to this article it is mainly for me.

First login to you apple members account and create your app identifier.

https://developer.apple.com/account/resources/identifiers/list

You will be using this in your notarize.js file and package.json

You also need to generate a APP-SPECIFIC PASSWORD in your account and add this to a .env file in the root of your project.

Generate your APP-SPECIFIC PASSWORD here.
https://appleid.apple.com/account/manage

You .env file will look like this.

APPLEID=mail@example.co.uk
APPLEIDPASS=ihmk-0000-zagl-0000

You can then update you package.json build section like this.

"build": {
    "appId": "com.example.test",
    "afterSign": "notarize.js",
    "dmg": {
        "sign": true
    },
    "mac": {
        "hardenedRuntime": true,
        "gatekeeperAssess": false,
        "entitlements": "build/entitlements.mac.plist",
        "entitlementsInherit": "build/entitlements.mac.plist",
        "icon": "build/icon.png",
        "category": "public.app-category.video"
    },
    "files": [
        "!notarize.js",
        "!.env"
    ]
},

Now you want to add this code to your notarize.js file.

require('dotenv').config();

const {
    notarize
} = require('electron-notarize');

exports.default = async function notarizing(context) {

    const {
        electronPlatformName,
        appOutDir
    } = context;

    if (electronPlatformName !== 'darwin') {

        return;
    }

    const appName = context.packager.appInfo.productFilename;

    return await notarize({
        appBundleId: 'com.example.test',
        appPath: `${appOutDir}/${appName}.app`,
        appleId: process.env.APPLEID,
        appleIdPassword: process.env.APPLEIDPASS,
        ascProvider: '0000000000',
    });

};

Hopefully now your app should sign successfully.

Leave a comment