Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/suite-desktop-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"homepage": "https://trezor.io/",
"main": "src/app.ts",
"scripts": {
"build:scripts": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.scripts.json",
"build:scripts": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.scripts.json && find ./lib -name '*.js' -exec bash -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
Copy link
Copy Markdown
Contributor Author

@Lemonexe Lemonexe May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda hacky; what's going on here?
We have to indicate ESM to electron-builder somehow, it can't tell automatically.
Two ways to do that:

  • "type": "module" in suite-desktop/package.json
  • mjs extension, but tsconfig doesn't offer custom extension
    • so this bash script is a temporary measure to be removed when suite-desktop is entirely ESM
    • this shouldn't break Windows-native development because that's done only in Git Bash for Windows..

"build:core": "yarn g:rimraf dist && TS_NODE_PROJECT=\"tsconfig.json\" yarn webpack --config ./webpack/core.webpack.config.ts",
"type-check": "yarn g:tsc --build tsconfig.json",
"test:unit": "yarn g:jest",
Expand Down Expand Up @@ -57,7 +57,7 @@
"devDependencies": {
"@currents/playwright": "^1.11.3",
"@electron/fuses": "^1.8.0",
"@electron/notarize": "2.5.0",
"@electron/notarize": "3.0.1",
"@octokit/rest": "^21.1.1",
"@playwright/browser-chromium": "^1.51.0",
"@playwright/browser-firefox": "^1.51.0",
Expand Down
1 change: 0 additions & 1 deletion packages/suite-desktop-core/scripts/notarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const notarizeAfterSignHook: Hooks['afterSign'] = context => {
console.log(`notarizing ${appPath} ...`);

return notarize({
tool: 'notarytool',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'notarytool' is now the only tool, after 'legacy' tool was deprecated & removed in previous version.

appPath,
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEIDPASS,
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-desktop-core/scripts/setElectronFuses.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FuseV1Options, FuseVersion, flipFuses } from '@electron/fuses';
import type { Hooks } from 'app-builder-lib';
import path from 'path';
import path from 'node:path';

// copied from https://github.com/electron-userland/electron-builder/blob/04be5699c664e6a93e093b820a16ad516355b5c7/packages/app-builder-lib/src/platformPackager.ts#L430-L434
const binaryExtensionByPlaformNameMap = {
Expand Down
3 changes: 2 additions & 1 deletion packages/suite-desktop-core/scripts/sign-windows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CustomWindowsSign } from 'app-builder-lib';
import { execSync } from 'node:child_process';

// electron-builder TS requires the function to return Promise, but jsign MUST be called with execSync!
// eslint-disable-next-line require-await
Expand All @@ -15,7 +16,7 @@ const signWindows: CustomWindowsSign = async configuration => {
const CERTIFICATE_NAME = process.env.WINDOWS_SIGN_CERTIFICATE_NAME;
const TOKEN_PASSWORD = process.env.WINDOWS_SIGN_TOKEN_PASSWORD;

require('child_process').execSync(
execSync(
Copy link
Copy Markdown
Contributor Author

@Lemonexe Lemonexe May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I broke app update on Windows the last time I touched this, I tested now that the sha sums are correct with codesign windows build (locally self-signed):

$ shasum -a 512 ./Trezor-Suite-25.5.0-win-x64.exe | awk '{print $1}' | xxd -r -p | base64
tRQT0caKMhW0Tn90OXtaHsbXR4PJbUnVWcXTjaDYjF8M4PVZYoAuQYVXwN1gIJJEczE+rGQaTboi
nvgnhPVqRQ==
$ cat latest.yml | head -7 | tail -1
sha512: tRQT0caKMhW0Tn90OXtaHsbXR4PJbUnVWcXTjaDYjF8M4PVZYoAuQYVXwN1gIJJEczE+rGQaTboinvgnhPVqRQ==

Linux build just for completeness:

$ shasum -a 512 ./Trezor-Suite-25.5.0-linux-x86_64.AppImage  | awk '{print $1}' | xxd -r -p | base64
rKO5i6aVHMuOTV6maqwyI3xpXn3TcgYAZWnMKh0WoPS1ptm7hC0LAc2N+0UzYu0avhMMZrenc13P
LFXJ9lO0xw==
$ cat latest-linux.yml | head -4 | tail -1
    sha512: rKO5i6aVHMuOTV6maqwyI3xpXn3TcgYAZWnMKh0WoPS1ptm7hC0LAc2N+0UzYu0avhMMZrenc13PLFXJ9lO0xw==

`java -jar ../suite-desktop-core/scripts/jsign-6.0.jar --keystore ../suite-desktop-core/scripts/hardwareToken.cfg --storepass '${TOKEN_PASSWORD}' --storetype PKCS11 --tsaurl http://timestamp.digicert.com --alias "${CERTIFICATE_NAME}" "${configuration.path}"`,
{
stdio: 'inherit',
Expand Down
4 changes: 4 additions & 0 deletions packages/suite-desktop-core/tsconfig.scripts.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": "../../tsconfig.lib.json",
"compilerOptions": {
"module": "ESNext",
"declaration": false,
"sourceMap": false,
"declarationMap": false,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not emit .map.js, d.ts, .map.d.ts
It's not a library, the point of using TS is to just typecheck during transpilation & execute it right away.

"outDir": "lib"
},
"include": ["./scripts"],
Expand Down
8 changes: 5 additions & 3 deletions packages/suite-desktop/electron-builder-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ module.exports = {
target: ['nsis'],
signtoolOptions: {
publisherName: ['SatoshiLabs, s.r.o.', 'Trezor Company s.r.o.'],
sign: '../suite-desktop-core/lib/sign-windows.js',
// TODO #14482: when Electron-main is migrated to ESM, and we declare whole suite-desktop package as ESM, rename .mjs files back to .js
sign: '../suite-desktop-core/lib/sign-windows.mjs',
},
},
linux: {
Expand Down Expand Up @@ -162,6 +163,7 @@ module.exports = {
category: 'Utility',
target: ['AppImage'],
},
afterPack: '../suite-desktop-core/lib/setElectronFuses.js',
afterSign: '../suite-desktop-core/lib/notarize.js',
// TODO #14482: when Electron-main is migrated to ESM, and we declare whole suite-desktop package as ESM, rename .mjs files back to .js
afterPack: '../suite-desktop-core/lib/setElectronFuses.mjs',
afterSign: '../suite-desktop-core/lib/notarize.mjs',
};
2 changes: 1 addition & 1 deletion packages/suite-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@electron/fuses": "^1.8.0",
"@electron/notarize": "2.5.0",
"@electron/notarize": "3.0.1",
"electron": "35.1.2",
"electron-builder": "26.0.3",
"glob": "^10.3.10"
Expand Down
14 changes: 12 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,16 @@ __metadata:
languageName: node
linkType: hard

"@electron/notarize@npm:3.0.1":
version: 3.0.1
resolution: "@electron/notarize@npm:3.0.1"
dependencies:
debug: "npm:^4.4.0"
promise-retry: "npm:^2.0.1"
checksum: 10/d908dd1d5db9499072e65a518de722dd85b23b8dacc8992e48d37adf2ee9b92f589b08e105d46ffa574b0713efa5b25744ea4ef03c0de99398ee655029dec3bf
languageName: node
linkType: hard

"@electron/osx-sign@npm:1.3.1":
version: 1.3.1
resolution: "@electron/osx-sign@npm:1.3.1"
Expand Down Expand Up @@ -12255,7 +12265,7 @@ __metadata:
dependencies:
"@currents/playwright": "npm:^1.11.3"
"@electron/fuses": "npm:^1.8.0"
"@electron/notarize": "npm:2.5.0"
"@electron/notarize": "npm:3.0.1"
"@octokit/rest": "npm:^21.1.1"
"@playwright/browser-chromium": "npm:^1.51.0"
"@playwright/browser-firefox": "npm:^1.51.0"
Expand Down Expand Up @@ -12347,7 +12357,7 @@ __metadata:
resolution: "@trezor/suite-desktop@workspace:packages/suite-desktop"
dependencies:
"@electron/fuses": "npm:^1.8.0"
"@electron/notarize": "npm:2.5.0"
"@electron/notarize": "npm:3.0.1"
blake-hash: "npm:^2.0.0"
electron: "npm:35.1.2"
electron-builder: "npm:26.0.3"
Expand Down