Browse Source

fixed types for array buffer.

jared/typescript-5.x
Jared McCannon 6 days ago
parent
commit
92a47b9037
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
  1. 1
      .eslintignore
  2. 2
      jslib/common/src/misc/nodeUtils.ts
  3. 34
      jslib/common/src/misc/utils.ts
  4. 6
      jslib/common/src/models/domain/encString.ts
  5. 28
      jslib/common/src/models/domain/symmetricCryptoKey.ts
  6. 1
      jslib/common/src/models/request/identityToken/passwordTokenRequest.ts
  7. 51
      jslib/common/src/services/crypto.service.ts
  8. 14
      jslib/node/spec/services/nodeCryptoFunction.service.spec.ts
  9. 7
      jslib/node/src/services/nodeCryptoFunction.service.ts
  10. 6
      scripts/notarize.js
  11. 4
      scripts/sign.js
  12. 3
      src/app/main.ts

1
.eslintignore

@ -1,6 +1,7 @@
dist dist
build build
build-cli build-cli
coverage
webpack.cli.js webpack.cli.js
webpack.main.js webpack.main.js
webpack.renderer.js webpack.renderer.js

2
jslib/common/src/misc/nodeUtils.ts

@ -29,6 +29,6 @@ export class NodeUtils {
// https://stackoverflow.com/a/31394257 // https://stackoverflow.com/a/31394257
static bufferToArrayBuffer(buf: Buffer): ArrayBuffer { static bufferToArrayBuffer(buf: Buffer): ArrayBuffer {
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) as ArrayBuffer;
} }
} }

34
jslib/common/src/misc/utils.ts

@ -1,11 +1,13 @@
/* eslint-disable no-useless-escape */ /* eslint-disable no-useless-escape */
import url from "url";
import { I18nService } from "../abstractions/i18n.service"; import { I18nService } from "../abstractions/i18n.service";
import * as tldjs from "tldjs"; import * as tldjs from "tldjs";
const nodeURL = typeof window === "undefined" ? require("url") : null; const nodeURL = typeof window === "undefined" ? url : null;
export class Utils { class Utils {
static inited = false; static inited = false;
static isNode = false; static isNode = false;
static isBrowser = true; static isBrowser = true;
@ -34,9 +36,11 @@ export class Utils {
Utils.global = Utils.isNode && !Utils.isBrowser ? global : window; Utils.global = Utils.isNode && !Utils.isBrowser ? global : window;
} }
static fromB64ToArray(str: string): Uint8Array { static fromB64ToArray(str: string): Uint8Array<ArrayBuffer> {
if (Utils.isNode) { if (Utils.isNode) {
return new Uint8Array(Buffer.from(str, "base64")); const buffer = Buffer.from(str, "base64");
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) as Uint8Array<ArrayBuffer>;
} else { } else {
const binaryString = window.atob(str); const binaryString = window.atob(str);
const bytes = new Uint8Array(binaryString.length); const bytes = new Uint8Array(binaryString.length);
@ -47,7 +51,7 @@ export class Utils {
} }
} }
static fromUrlB64ToArray(str: string): Uint8Array { static fromUrlB64ToArray(str: string): Uint8Array<ArrayBuffer> {
return Utils.fromB64ToArray(Utils.fromUrlB64ToB64(str)); return Utils.fromB64ToArray(Utils.fromUrlB64ToB64(str));
} }
@ -63,9 +67,11 @@ export class Utils {
} }
} }
static fromUtf8ToArray(str: string): Uint8Array { static fromUtf8ToArray(str: string): Uint8Array<ArrayBuffer> {
if (Utils.isNode) { if (Utils.isNode) {
return new Uint8Array(Buffer.from(str, "utf8")); const buffer = Buffer.from(str, "utf8");
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) as Uint8Array<ArrayBuffer>;
} else { } else {
const strUtf8 = unescape(encodeURIComponent(str)); const strUtf8 = unescape(encodeURIComponent(str));
const arr = new Uint8Array(strUtf8.length); const arr = new Uint8Array(strUtf8.length);
@ -84,12 +90,12 @@ export class Utils {
return arr; return arr;
} }
static fromBufferToB64(buffer: ArrayBuffer): string { static fromBufferToB64(buffer: BufferSource): string {
if (Utils.isNode) { if (Utils.isNode) {
return Buffer.from(buffer).toString("base64"); return Buffer.from(buffer as ArrayBuffer).toString("base64");
} else { } else {
let binary = ""; let binary = "";
const bytes = new Uint8Array(buffer); const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);
for (let i = 0; i < bytes.byteLength; i++) { for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]); binary += String.fromCharCode(bytes[i]);
} }
@ -97,7 +103,7 @@ export class Utils {
} }
} }
static fromBufferToUrlB64(buffer: ArrayBuffer): string { static fromBufferToUrlB64(buffer: BufferSource): string {
return Utils.fromB64toUrlB64(Utils.fromBufferToB64(buffer)); return Utils.fromB64toUrlB64(Utils.fromBufferToB64(buffer));
} }
@ -247,7 +253,7 @@ export class Utils {
const urlDomain = const urlDomain =
tldjs != null && tldjs.getDomain != null ? tldjs.getDomain(url.hostname) : null; tldjs != null && tldjs.getDomain != null ? tldjs.getDomain(url.hostname) : null;
return urlDomain != null ? urlDomain : url.hostname; return urlDomain != null ? urlDomain : url.hostname;
} catch (e) { } catch {
// Invalid domain, try another approach below. // Invalid domain, try another approach below.
} }
} }
@ -395,7 +401,7 @@ export class Utils {
anchor.href = uriString; anchor.href = uriString;
return anchor as any; return anchor as any;
} }
} catch (e) { } catch {
// Ignore error // Ignore error
} }
@ -403,4 +409,6 @@ export class Utils {
} }
} }
export default Utils;
Utils.init(); Utils.init();

6
jslib/common/src/models/domain/encString.ts

@ -1,6 +1,6 @@
import { CryptoService } from "../../abstractions/crypto.service"; import { CryptoService } from "../../abstractions/crypto.service";
import { EncryptionType } from "../../enums/encryptionType"; import { EncryptionType } from "../../enums/encryptionType";
import { Utils } from "../../misc/utils"; import Utils from "../../misc/utils";
import { SymmetricCryptoKey } from "./symmetricCryptoKey"; import { SymmetricCryptoKey } from "./symmetricCryptoKey";
@ -53,7 +53,7 @@ export class EncString {
try { try {
this.encryptionType = parseInt(headerPieces[0], null); this.encryptionType = parseInt(headerPieces[0], null);
encPieces = headerPieces[1].split("|"); encPieces = headerPieces[1].split("|");
} catch (e) { } catch {
return; return;
} }
} else { } else {
@ -114,7 +114,7 @@ export class EncString {
key = await cryptoService.getOrgKey(orgId); key = await cryptoService.getOrgKey(orgId);
} }
this.decryptedValue = await cryptoService.decryptToUtf8(this, key); this.decryptedValue = await cryptoService.decryptToUtf8(this, key);
} catch (e) { } catch {
this.decryptedValue = "[error: cannot decrypt]"; this.decryptedValue = "[error: cannot decrypt]";
} }
return this.decryptedValue; return this.decryptedValue;

28
jslib/common/src/models/domain/symmetricCryptoKey.ts

@ -1,5 +1,5 @@
import { EncryptionType } from "../../enums/encryptionType"; import { EncryptionType } from "../../enums/encryptionType";
import { Utils } from "../../misc/utils"; import Utils from "../../misc/utils";
export class SymmetricCryptoKey { export class SymmetricCryptoKey {
key: ArrayBuffer; key: ArrayBuffer;
@ -13,33 +13,35 @@ export class SymmetricCryptoKey {
meta: any; meta: any;
constructor(key: ArrayBuffer, encType?: EncryptionType) { constructor(key: BufferSource, encType?: EncryptionType) {
if (key == null) { if (key == null) {
throw new Error("Must provide key"); throw new Error("Must provide key");
} }
const keyBuffer = ArrayBuffer.isView(key) ? key.buffer.slice(key.byteOffset, key.byteOffset + key.byteLength) : key;
if (encType == null) { if (encType == null) {
if (key.byteLength === 32) { if (keyBuffer.byteLength === 32) {
encType = EncryptionType.AesCbc256_B64; encType = EncryptionType.AesCbc256_B64;
} else if (key.byteLength === 64) { } else if (keyBuffer.byteLength === 64) {
encType = EncryptionType.AesCbc256_HmacSha256_B64; encType = EncryptionType.AesCbc256_HmacSha256_B64;
} else { } else {
throw new Error("Unable to determine encType."); throw new Error("Unable to determine encType.");
} }
} }
this.key = key; this.key = keyBuffer;
this.encType = encType; this.encType = encType;
if (encType === EncryptionType.AesCbc256_B64 && key.byteLength === 32) { if (encType === EncryptionType.AesCbc256_B64 && keyBuffer.byteLength === 32) {
this.encKey = key; this.encKey = keyBuffer;
this.macKey = null; this.macKey = null;
} else if (encType === EncryptionType.AesCbc128_HmacSha256_B64 && key.byteLength === 32) { } else if (encType === EncryptionType.AesCbc128_HmacSha256_B64 && keyBuffer.byteLength === 32) {
this.encKey = key.slice(0, 16); this.encKey = keyBuffer.slice(0, 16);
this.macKey = key.slice(16, 32); this.macKey = keyBuffer.slice(16, 32);
} else if (encType === EncryptionType.AesCbc256_HmacSha256_B64 && key.byteLength === 64) { } else if (encType === EncryptionType.AesCbc256_HmacSha256_B64 && keyBuffer.byteLength === 64) {
this.encKey = key.slice(0, 32); this.encKey = keyBuffer.slice(0, 32);
this.macKey = key.slice(32, 64); this.macKey = keyBuffer.slice(32, 64);
} else { } else {
throw new Error("Unsupported encType/key length."); throw new Error("Unsupported encType/key length.");
} }

1
jslib/common/src/models/request/identityToken/passwordTokenRequest.ts

@ -1,5 +1,4 @@
import { ClientType } from "../../../enums/clientType"; import { ClientType } from "../../../enums/clientType";
import { Utils } from "../../../misc/utils";
import { CaptchaProtectedRequest } from "../captchaProtectedRequest"; import { CaptchaProtectedRequest } from "../captchaProtectedRequest";
import { DeviceRequest } from "../deviceRequest"; import { DeviceRequest } from "../deviceRequest";

51
jslib/common/src/services/crypto.service.ts

@ -10,7 +10,7 @@ import { HashPurpose } from "../enums/hashPurpose";
import { KdfType } from "../enums/kdfType"; import { KdfType } from "../enums/kdfType";
import { KeySuffixOptions } from "../enums/keySuffixOptions"; import { KeySuffixOptions } from "../enums/keySuffixOptions";
import { sequentialize } from "../misc/sequentialize"; import { sequentialize } from "../misc/sequentialize";
import { Utils } from "../misc/utils"; import Utils from "../misc/utils";
import { EEFLongWordList } from "../misc/wordlist"; import { EEFLongWordList } from "../misc/wordlist";
import { EncArrayBuffer } from "../models/domain/encArrayBuffer"; import { EncArrayBuffer } from "../models/domain/encArrayBuffer";
import { EncString } from "../models/domain/encString"; import { EncString } from "../models/domain/encString";
@ -109,7 +109,7 @@ export class CryptoService implements CryptoServiceAbstraction {
): Promise<SymmetricCryptoKey> { ): Promise<SymmetricCryptoKey> {
const key = await this.retrieveKeyFromStorage(keySuffix, userId); const key = await this.retrieveKeyFromStorage(keySuffix, userId);
if (key != null) { if (key != null) {
const symmetricKey = new SymmetricCryptoKey(Utils.fromB64ToArray(key).buffer); const symmetricKey = new SymmetricCryptoKey(Utils.fromB64ToArray(key));
if (!(await this.validateKey(symmetricKey))) { if (!(await this.validateKey(symmetricKey))) {
this.logService.warning("Wrong key, throwing away stored key"); this.logService.warning("Wrong key, throwing away stored key");
@ -335,9 +335,11 @@ export class CryptoService implements CryptoServiceAbstraction {
} }
async clearStoredKey(keySuffix: KeySuffixOptions) { async clearStoredKey(keySuffix: KeySuffixOptions) {
keySuffix === KeySuffixOptions.Auto if (keySuffix === KeySuffixOptions.Auto) {
? await this.stateService.setCryptoMasterKeyAuto(null) await this.stateService.setCryptoMasterKeyAuto(null);
: await this.stateService.setCryptoMasterKeyBiometric(null); } else {
await this.stateService.setCryptoMasterKeyBiometric(null);
}
} }
async clearKeyHash(userId?: string): Promise<any> { async clearKeyHash(userId?: string): Promise<any> {
@ -508,9 +510,9 @@ export class CryptoService implements CryptoServiceAbstraction {
return Promise.resolve(null); return Promise.resolve(null);
} }
let plainBuf: ArrayBuffer; let plainBuf: BufferSource;
if (typeof plainValue === "string") { if (typeof plainValue === "string") {
plainBuf = Utils.fromUtf8ToArray(plainValue).buffer; plainBuf = Utils.fromUtf8ToArray(plainValue);
} else { } else {
plainBuf = plainValue; plainBuf = plainValue;
} }
@ -583,7 +585,8 @@ export class CryptoService implements CryptoServiceAbstraction {
throw new Error("encPieces unavailable."); throw new Error("encPieces unavailable.");
} }
const data = Utils.fromB64ToArray(encPieces[0]).buffer; const dataArray = Utils.fromB64ToArray(encPieces[0]);
const data = dataArray.buffer as ArrayBuffer;
const privateKey = privateKeyValue ?? (await this.getPrivateKey()); const privateKey = privateKeyValue ?? (await this.getPrivateKey());
if (privateKey == null) { if (privateKey == null) {
throw new Error("No private key."); throw new Error("No private key.");
@ -606,9 +609,12 @@ export class CryptoService implements CryptoServiceAbstraction {
} }
async decryptToBytes(encString: EncString, key?: SymmetricCryptoKey): Promise<ArrayBuffer> { async decryptToBytes(encString: EncString, key?: SymmetricCryptoKey): Promise<ArrayBuffer> {
const iv = Utils.fromB64ToArray(encString.iv).buffer; const ivArray = Utils.fromB64ToArray(encString.iv);
const data = Utils.fromB64ToArray(encString.data).buffer; const iv = ivArray.buffer as ArrayBuffer;
const mac = encString.mac ? Utils.fromB64ToArray(encString.mac).buffer : null; const dataArray = Utils.fromB64ToArray(encString.data);
const data = dataArray.buffer as ArrayBuffer;
const macArray = encString.mac ? Utils.fromB64ToArray(encString.mac) : null;
const mac = macArray ? (macArray.buffer as ArrayBuffer) : null;
const decipher = await this.aesDecryptToBytes(encString.encryptionType, data, iv, mac, key); const decipher = await this.aesDecryptToBytes(encString.encryptionType, data, iv, mac, key);
if (decipher == null) { if (decipher == null) {
return null; return null;
@ -665,9 +671,9 @@ export class CryptoService implements CryptoServiceAbstraction {
return await this.aesDecryptToBytes( return await this.aesDecryptToBytes(
encType, encType,
ctBytes.buffer, ctBytes.buffer as ArrayBuffer,
ivBytes.buffer, ivBytes.buffer as ArrayBuffer,
macBytes != null ? macBytes.buffer : null, macBytes != null ? (macBytes.buffer as ArrayBuffer) : null,
key, key,
); );
} }
@ -717,7 +723,7 @@ export class CryptoService implements CryptoServiceAbstraction {
const privateKey = await this.decryptToBytes(new EncString(encPrivateKey), encKey); const privateKey = await this.decryptToBytes(new EncString(encPrivateKey), encKey);
await this.cryptoFunctionService.rsaExtractPublicKey(privateKey); await this.cryptoFunctionService.rsaExtractPublicKey(privateKey);
} catch (e) { } catch {
return false; return false;
} }
@ -754,17 +760,24 @@ export class CryptoService implements CryptoServiceAbstraction {
: await this.stateService.getCryptoMasterKeyBiometric({ userId: userId }); : await this.stateService.getCryptoMasterKeyBiometric({ userId: userId });
} }
private async aesEncrypt(data: ArrayBuffer, key: SymmetricCryptoKey): Promise<EncryptedObject> { private async aesEncrypt(data: BufferSource, key: SymmetricCryptoKey): Promise<EncryptedObject> {
const obj = new EncryptedObject(); const obj = new EncryptedObject();
obj.key = await this.getKeyForEncryption(key); obj.key = await this.getKeyForEncryption(key);
obj.iv = await this.cryptoFunctionService.randomBytes(16); obj.iv = await this.cryptoFunctionService.randomBytes(16);
obj.data = await this.cryptoFunctionService.aesEncrypt(data, obj.iv, obj.key.encKey);
const dataBuffer = ArrayBuffer.isView(data)
? (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength
? data.buffer as ArrayBuffer
: data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer)
: data;
obj.data = await this.cryptoFunctionService.aesEncrypt(dataBuffer, obj.iv, obj.key.encKey);
if (obj.key.macKey != null) { if (obj.key.macKey != null) {
const macData = new Uint8Array(obj.iv.byteLength + obj.data.byteLength); const macData = new Uint8Array(obj.iv.byteLength + obj.data.byteLength);
macData.set(new Uint8Array(obj.iv), 0); macData.set(new Uint8Array(obj.iv), 0);
macData.set(new Uint8Array(obj.data), obj.iv.byteLength); macData.set(new Uint8Array(obj.data), obj.iv.byteLength);
obj.mac = await this.cryptoFunctionService.hmac(macData.buffer, obj.key.macKey, "sha256");
obj.mac = await this.cryptoFunctionService.hmac(macData.buffer as ArrayBuffer, obj.key.macKey, "sha256");
} }
return obj; return obj;
@ -830,7 +843,7 @@ export class CryptoService implements CryptoServiceAbstraction {
macData.set(new Uint8Array(iv), 0); macData.set(new Uint8Array(iv), 0);
macData.set(new Uint8Array(data), iv.byteLength); macData.set(new Uint8Array(data), iv.byteLength);
const computedMac = await this.cryptoFunctionService.hmac( const computedMac = await this.cryptoFunctionService.hmac(
macData.buffer, macData.buffer as ArrayBuffer,
theKey.macKey, theKey.macKey,
"sha256", "sha256",
); );

14
jslib/node/spec/services/nodeCryptoFunction.service.spec.ts

@ -1,4 +1,4 @@
import { Utils } from "@/jslib/common/src/misc/utils"; import Utils from "@/jslib/common/src/misc/utils";
import { SymmetricCryptoKey } from "@/jslib/common/src/models/domain/symmetricCryptoKey"; import { SymmetricCryptoKey } from "@/jslib/common/src/models/domain/symmetricCryptoKey";
import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service"; import { NodeCryptoFunctionService } from "@/jslib/node/src/services/nodeCryptoFunction.service";
@ -93,8 +93,9 @@ describe("NodeCrypto Function Service", () => {
it("should fail with prk too small", async () => { it("should fail with prk too small", async () => {
const cryptoFunctionService = new NodeCryptoFunctionService(); const cryptoFunctionService = new NodeCryptoFunctionService();
const prk = Utils.fromB64ToArray(prk16Byte);
const f = cryptoFunctionService.hkdfExpand( const f = cryptoFunctionService.hkdfExpand(
Utils.fromB64ToArray(prk16Byte), prk.buffer as ArrayBuffer,
"info", "info",
32, 32,
"sha256", "sha256",
@ -104,8 +105,9 @@ describe("NodeCrypto Function Service", () => {
it("should fail with outputByteSize is too large", async () => { it("should fail with outputByteSize is too large", async () => {
const cryptoFunctionService = new NodeCryptoFunctionService(); const cryptoFunctionService = new NodeCryptoFunctionService();
const prk = Utils.fromB64ToArray(prk32Byte);
const f = cryptoFunctionService.hkdfExpand( const f = cryptoFunctionService.hkdfExpand(
Utils.fromB64ToArray(prk32Byte), prk.buffer as ArrayBuffer,
"info", "info",
8161, 8161,
"sha256", "sha256",
@ -341,7 +343,8 @@ function testHkdf(
utf8Key: string, utf8Key: string,
unicodeKey: string, unicodeKey: string,
) { ) {
const ikm = Utils.fromB64ToArray("criAmKtfzxanbgea5/kelQ=="); const ikmArray = Utils.fromB64ToArray("criAmKtfzxanbgea5/kelQ==");
const ikm = ikmArray.buffer as ArrayBuffer;
const regularSalt = "salt"; const regularSalt = "salt";
const utf8Salt = "üser_salt"; const utf8Salt = "üser_salt";
@ -392,8 +395,9 @@ function testHkdfExpand(
it("should create valid " + algorithm + " " + outputByteSize + " byte okm", async () => { it("should create valid " + algorithm + " " + outputByteSize + " byte okm", async () => {
const cryptoFunctionService = new NodeCryptoFunctionService(); const cryptoFunctionService = new NodeCryptoFunctionService();
const prk = Utils.fromB64ToArray(b64prk);
const okm = await cryptoFunctionService.hkdfExpand( const okm = await cryptoFunctionService.hkdfExpand(
Utils.fromB64ToArray(b64prk), prk.buffer as ArrayBuffer,
info, info,
outputByteSize, outputByteSize,
algorithm, algorithm,

7
jslib/node/src/services/nodeCryptoFunction.service.ts

@ -3,7 +3,7 @@ import * as crypto from "crypto";
import * as forge from "node-forge"; import * as forge from "node-forge";
import { CryptoFunctionService } from "@/jslib/common/src/abstractions/cryptoFunction.service"; import { CryptoFunctionService } from "@/jslib/common/src/abstractions/cryptoFunction.service";
import { Utils } from "@/jslib/common/src/misc/utils"; import Utils from "@/jslib/common/src/misc/utils";
import { DecryptParameters } from "@/jslib/common/src/models/domain/decryptParameters"; import { DecryptParameters } from "@/jslib/common/src/models/domain/decryptParameters";
import { SymmetricCryptoKey } from "@/jslib/common/src/models/domain/symmetricCryptoKey"; import { SymmetricCryptoKey } from "@/jslib/common/src/models/domain/symmetricCryptoKey";
@ -215,7 +215,8 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
const publicKeyAsn1 = forge.pki.publicKeyToAsn1(forgePublicKey); const publicKeyAsn1 = forge.pki.publicKeyToAsn1(forgePublicKey);
const publicKeyByteString = forge.asn1.toDer(publicKeyAsn1).data; const publicKeyByteString = forge.asn1.toDer(publicKeyAsn1).data;
const publicKeyArray = Utils.fromByteStringToArray(publicKeyByteString); const publicKeyArray = Utils.fromByteStringToArray(publicKeyByteString);
return Promise.resolve(publicKeyArray.buffer);
return Promise.resolve(publicKeyArray.buffer as ArrayBuffer);
} }
async rsaGenerateKeyPair(length: 1024 | 2048 | 4096): Promise<[ArrayBuffer, ArrayBuffer]> { async rsaGenerateKeyPair(length: 1024 | 2048 | 4096): Promise<[ArrayBuffer, ArrayBuffer]> {
@ -241,7 +242,7 @@ export class NodeCryptoFunctionService implements CryptoFunctionService {
const privateKeyByteString = forge.asn1.toDer(privateKeyPkcs8).getBytes(); const privateKeyByteString = forge.asn1.toDer(privateKeyPkcs8).getBytes();
const privateKey = Utils.fromByteStringToArray(privateKeyByteString); const privateKey = Utils.fromByteStringToArray(privateKeyByteString);
resolve([publicKey.buffer, privateKey.buffer]); resolve([publicKey.buffer as ArrayBuffer, privateKey.buffer as ArrayBuffer]);
}, },
); );
}); });

6
scripts/notarize.js

@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
require("dotenv").config(); import { notarize } from "@electron/notarize";
const { notarize } = require("@electron/notarize"); import { config } from "dotenv";
config();
exports.default = async function notarizing(context) { exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context; const { electronPlatformName, appOutDir } = context;

4
scripts/sign.js

@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires, no-console */ /* eslint-disable @typescript-eslint/no-var-requires, no-console */
import { execSync } from "child_process";
exports.default = async function (configuration) { exports.default = async function (configuration) {
if (parseInt(process.env.ELECTRON_BUILDER_SIGN) === 1 && configuration.path.slice(-4) == ".exe") { if (parseInt(process.env.ELECTRON_BUILDER_SIGN) === 1 && configuration.path.slice(-4) == ".exe") {
console.log(`[*] Signing file: ${configuration.path}`); console.log(`[*] Signing file: ${configuration.path}`);
require("child_process").execSync( execSync(
`azuresigntool sign ` + `azuresigntool sign ` +
`-kvu ${process.env.SIGNING_VAULT_URL} ` + `-kvu ${process.env.SIGNING_VAULT_URL} ` +
`-kvi ${process.env.SIGNING_CLIENT_ID} ` + `-kvi ${process.env.SIGNING_CLIENT_ID} ` +

3
src/app/main.ts

@ -3,8 +3,7 @@ import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { isDev } from "@/jslib/electron/src/utils"; import { isDev } from "@/jslib/electron/src/utils";
// tslint:disable-next-line import "../scss/styles.scss";
require("../scss/styles.scss");
import { AppModule } from "./app.module"; import { AppModule } from "./app.module";

Loading…
Cancel
Save