mirror of
https://github.com/tutao/tutanota.git
synced 2025-12-08 06:09:50 +00:00
WIP tsgo
Co-authored-by: ivk <ivk@tutao.de>
This commit is contained in:
parent
6294845462
commit
61a8348761
7 changed files with 148 additions and 9 deletions
|
|
@ -54,7 +54,7 @@ export async function runDevBuild({ stage, host, desktop, clean, networkDebuggin
|
||||||
const version = await getTutanotaAppVersion()
|
const version = await getTutanotaAppVersion()
|
||||||
|
|
||||||
await runStep("Types", async () => {
|
await runStep("Types", async () => {
|
||||||
await sh`npx tsc --project ${tsConfig} --incremental ${true} --noEmit true`
|
await sh`npx tsgo --project ${tsConfig} --incremental ${true} --noEmit true`
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
118
package-lock.json
generated
118
package-lock.json
generated
|
|
@ -64,6 +64,7 @@
|
||||||
"@tutao/tutanota-test-utils": "315.251125.0",
|
"@tutao/tutanota-test-utils": "315.251125.0",
|
||||||
"@types/express": "5.0.3",
|
"@types/express": "5.0.3",
|
||||||
"@types/pako": "^2.0.3",
|
"@types/pako": "^2.0.3",
|
||||||
|
"@typescript/native-preview": "latest",
|
||||||
"body-parser": "2.2.0",
|
"body-parser": "2.2.0",
|
||||||
"commander": "14.0.0",
|
"commander": "14.0.0",
|
||||||
"electron-builder": "26.0.17",
|
"electron-builder": "26.0.17",
|
||||||
|
|
@ -4572,6 +4573,123 @@
|
||||||
"url": "https://opencollective.com/eslint"
|
"url": "https://opencollective.com/eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@typescript/native-preview": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview/-/native-preview-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-nyMp0ybgJVZFtDOWmcKDqaRqtj8dOg65+fDxbjIrnZuMWIqlOUGH+imFwofqlW+KndAA7KtAio2YSZMMZB25WA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"tsgo": "bin/tsgo.js"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@typescript/native-preview-darwin-arm64": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-darwin-x64": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-linux-arm": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-linux-arm64": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-linux-x64": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-win32-arm64": "7.0.0-dev.20251204.1",
|
||||||
|
"@typescript/native-preview-win32-x64": "7.0.0-dev.20251204.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-darwin-arm64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-arm64/-/native-preview-darwin-arm64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-CgIzuO/LFRufdVjJmll6x7jnejYqqLo4kJwrsUxQipJ/dcGeP0q2XMcxNBzT7F9L4Sd5dphRPOZFXES4kS0lig==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-darwin-x64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-x64/-/native-preview-darwin-x64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-X76oQeDMQHJiukkPPbk7STrfu97pfPe5ixwiN6nXzSGXLE+tzrXRecNkYhz4XWeAW2ASNmGwDJJ2RAU5l8MbgQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-linux-arm": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm/-/native-preview-linux-arm-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-3zl/Jj5rzkK9Oo5KVSIW+6bzRligoI+ZnA1xLpg0BBH2sk27a8Vasj7ZaGPlFvlSegvcaJdIjSt7Z8nBtiF9Ww==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-linux-arm64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm64/-/native-preview-linux-arm64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-+1as+h6ZNpc9TqlHwvDkBP7jg0FoCMUf6Rrc9/Mkllau6etznfVsWMADWT4t76gkGZKUIXOZqsl2Ya3uaBrCBQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-linux-x64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-x64/-/native-preview-linux-x64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-YD//l6yv7iPNlKn9OZDzBxrI+QGLN6d4RV3dSucsyq/YNZUulcywGztbZiaQxdUzKPwj70G+LVb9WCgf5ITOIQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-win32-arm64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-arm64/-/native-preview-win32-arm64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-eDXYR5qfPFA8EfQ0d9SbWGLn02VbAaeTM9jQ5VeLlPLcBP81nGRaGQ9Quta5zeEHev1S9iCdyRj5BqCRtl0ohw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@typescript/native-preview-win32-x64": {
|
||||||
|
"version": "7.0.0-dev.20251204.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-x64/-/native-preview-win32-x64-7.0.0-dev.20251204.1.tgz",
|
||||||
|
"integrity": "sha512-CRWI2OPdqXbzOU52R2abWMb3Ie2Wp6VPrCFzR3pzP53JabTAe8+XoBWlont9bw/NsqbPKp2aQbdfbLQX5RI44g==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@webgpu/types": {
|
"node_modules/@webgpu/types": {
|
||||||
"version": "0.1.38",
|
"version": "0.1.38",
|
||||||
"resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.38.tgz",
|
"resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.38.tgz",
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,8 @@
|
||||||
"typescript-eslint": "8.34.0",
|
"typescript-eslint": "8.34.0",
|
||||||
"xhr2": "0.2.1",
|
"xhr2": "0.2.1",
|
||||||
"zx": "8.5.5",
|
"zx": "8.5.5",
|
||||||
"wasm-pack": "git+https://github.com/tutao/wasm-pack.git#b1e0e982fee26803ba6b8a8c29197d2a8cdd93f3"
|
"wasm-pack": "git+https://github.com/tutao/wasm-pack.git#b1e0e982fee26803ba6b8a8c29197d2a8cdd93f3",
|
||||||
|
"@typescript/native-preview": "latest"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"./packages/*"
|
"./packages/*"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// @ts-ignore[untyped-import]
|
// @ts-ignore[untyped-import]
|
||||||
import { BigInteger, parseBigInt, RSAKey } from "../internal/crypto-jsbn-2012-08-09_1.js"
|
import { BigInteger as BigIntegerNew, parseBigInt, RSAKey as RSAKeyNew } from "../internal/crypto-jsbn-2012-08-09_1.js"
|
||||||
import type { Base64, Hex } from "@tutao/tutanota-utils"
|
import type { Base64, Hex } from "@tutao/tutanota-utils"
|
||||||
import { base64ToHex, base64ToUint8Array, concat, hexToUint8Array, int8ArrayToBase64, uint8ArrayToHex } from "@tutao/tutanota-utils"
|
import { base64ToHex, base64ToUint8Array, concat, hexToUint8Array, int8ArrayToBase64, uint8ArrayToHex } from "@tutao/tutanota-utils"
|
||||||
import type { RawRsaPublicKey, RsaPrivateKey, RsaPublicKey } from "./RsaKeyPair.js"
|
import type { RawRsaPublicKey, RsaPrivateKey, RsaPublicKey } from "./RsaKeyPair.js"
|
||||||
|
|
@ -10,11 +10,32 @@ import { KeyPairType } from "./AsymmetricKeyPair.js"
|
||||||
const RSA_KEY_LENGTH_BITS = 2048
|
const RSA_KEY_LENGTH_BITS = 2048
|
||||||
const RSA_PUBLIC_EXPONENT = 65537
|
const RSA_PUBLIC_EXPONENT = 65537
|
||||||
|
|
||||||
|
interface BigInteger {
|
||||||
|
clone(): BigInteger
|
||||||
|
toByteArray(): Uint8Array
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RSAKey {
|
||||||
|
n: BigInteger
|
||||||
|
d: BigInteger
|
||||||
|
p: BigInteger
|
||||||
|
q: BigInteger
|
||||||
|
dmp1: BigInteger
|
||||||
|
dmq1: BigInteger
|
||||||
|
coeff: BigInteger
|
||||||
|
e: number
|
||||||
|
doPublic(bigInt: BigInteger): BigInteger
|
||||||
|
doPrivate(bigInt: BigInteger): BigInteger
|
||||||
|
}
|
||||||
|
|
||||||
|
const RSAKey = RSAKeyNew as unknown as { new (): RSAKey }
|
||||||
|
const BigInteger = BigIntegerNew as unknown as { new (array: Int8Array): BigInteger }
|
||||||
|
|
||||||
export function rsaEncrypt(publicKey: RsaPublicKey, bytes: Uint8Array, seed: Uint8Array): Uint8Array {
|
export function rsaEncrypt(publicKey: RsaPublicKey, bytes: Uint8Array, seed: Uint8Array): Uint8Array {
|
||||||
const rsa = new RSAKey()
|
const rsa = new RSAKey()
|
||||||
// we have double conversion from bytes to hex to big int because there is no direct conversion from bytes to big int
|
// we have double conversion from bytes to hex to big int because there is no direct conversion from bytes to big int
|
||||||
// BigInteger of JSBN uses a signed byte array and we convert to it by using Int8Array
|
// BigInteger of JSBN uses a signed byte array and we convert to it by using Int8Array
|
||||||
rsa.n = new BigInteger(new Int8Array(base64ToUint8Array(publicKey.modulus)))
|
rsa.n = new (BigInteger as unknown as { new (array: Int8Array): BigInteger })(new Int8Array(base64ToUint8Array(publicKey.modulus)))
|
||||||
rsa.e = publicKey.publicExponent
|
rsa.e = publicKey.publicExponent
|
||||||
const paddedBytes = oaepPad(bytes, publicKey.keyLength, seed)
|
const paddedBytes = oaepPad(bytes, publicKey.keyLength, seed)
|
||||||
const paddedHex = uint8ArrayToHex(paddedBytes)
|
const paddedHex = uint8ArrayToHex(paddedBytes)
|
||||||
|
|
@ -284,7 +305,7 @@ function _clear(array: Uint8Array | null | undefined) {
|
||||||
export function mgf1(seed: Uint8Array, length: number): Uint8Array {
|
export function mgf1(seed: Uint8Array, length: number): Uint8Array {
|
||||||
let C: Uint8Array | null = null
|
let C: Uint8Array | null = null
|
||||||
let counter = 0
|
let counter = 0
|
||||||
let T = new Uint8Array(0)
|
let T: Uint8Array = new Uint8Array(0)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
C = i2osp(counter)
|
C = i2osp(counter)
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"build": "node make && tsc -b",
|
"build": "node make && tsgo -b",
|
||||||
"test": "tsc -b test && cd build && node test/Suite.js"
|
"test": "tsgo -b test && cd build && node test/Suite.js"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ export type Base64Url = string
|
||||||
export type Hex = string
|
export type Hex = string
|
||||||
|
|
||||||
// TODO rename methods according to their JAVA counterparts (e.g. Uint8Array == bytes, Utf8Uint8Array == bytes...)
|
// TODO rename methods according to their JAVA counterparts (e.g. Uint8Array == bytes, Utf8Uint8Array == bytes...)
|
||||||
export function uint8ArrayToArrayBuffer(uint8Array: Uint8Array): ArrayBuffer {
|
export function uint8ArrayToArrayBuffer(uint8Array: Uint8Array): ArrayBufferLike {
|
||||||
if (uint8Array.byteLength === uint8Array.buffer.byteLength) {
|
if (uint8Array.byteLength === uint8Array.buffer.byteLength) {
|
||||||
return uint8Array.buffer
|
return uint8Array.buffer
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
"strictBindCallApply": true,
|
"strictBindCallApply": true,
|
||||||
"strictFunctionTypes": false,
|
"strictFunctionTypes": false,
|
||||||
"strictPropertyInitialization": true,
|
"strictPropertyInitialization": true,
|
||||||
"noStrictGenericChecks": false,
|
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
"types": ["node"]
|
"types": ["node"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue