forked from chatmail/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Desktop core #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Desktop core #4
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
312f4a9
Invite link changed
milinddeorepriv 2f81e98
Adding second device
milinddeorepriv 12823d3
@privitty/deltachat-rpc-server
milinddeorepriv 68b42ae
Merge branch 'main' into desktop-core
milinddeore 13c7d2a
fix in publish-privitty-deltachat-rpc-server.yml
milinddeorepriv 8ba6efd
more fix in publish-privitty-deltachat-rpc-server.yml
milinddeorepriv 1513501
minor fix in publish-privitty-deltachat-rpc-server.yml
milinddeorepriv ba24685
removed unsed imports
milinddeorepriv 9bc4c0e
Updated branch typo in publish-privitty-deltachat-rpc-server.yml
milinddeorepriv 729084b
Another branch typo in publish-privitty-deltachat-rpc-server.yml
milinddeorepriv 01cb117
Correct version is set publish-privitty-deltachat-rpc-server.yml
milinddeorepriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
182 changes: 182 additions & 0 deletions
182
.github/workflows/publish-privitty-deltachat-rpc-server.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| # Build deltachat-rpc-server from branch dekstop-core (Privitty/core) and publish to npm as @privitty/deltachat-rpc-server | ||
|
|
||
| name: Publish @privitty/deltachat-rpc-server | ||
|
|
||
| concurrency: | ||
| group: publish-privitty-rpc-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| push: | ||
| branches: [dekstop-core] | ||
| workflow_dispatch: | ||
| inputs: | ||
| branch: | ||
| description: "Branch to build from" | ||
| required: false | ||
| default: "dekstop-core" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| build_linux: | ||
| name: Linux | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [aarch64, armv7l, armv6l, i686, x86_64] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| ref: ${{ github.event.inputs.branch || github.ref }} | ||
| show-progress: false | ||
| persist-credentials: false | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| - name: Build deltachat-rpc-server binaries | ||
| run: nix build .#deltachat-rpc-server-${{ matrix.arch }}-linux | ||
| - name: Upload binary | ||
| uses: actions/upload-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-${{ matrix.arch }}-linux | ||
| path: result/bin/deltachat-rpc-server | ||
| if-no-files-found: error | ||
|
|
||
| build_windows: | ||
| name: Windows | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [win32, win64] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@6d28f1ea826946162388c29db5a29aca24037a | ||
|
|
||
| with: | ||
| ref: ${{ github.event.inputs.branch || github.ref }} | ||
| show-progress: false | ||
| persist-credentials: false | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
Check failureCode scanning / zizmor unpinned action reference Error
unpinned action reference
|
||
| - name: Build deltachat-rpc-server binaries | ||
| run: nix build .#deltachat-rpc-server-${{ matrix.arch }} | ||
| - name: Upload binary | ||
| uses: actions/upload-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-${{ matrix.arch }} | ||
| path: result/bin/deltachat-rpc-server.exe | ||
| if-no-files-found: error | ||
|
|
||
| build_macos: | ||
| name: macOS | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: [x86_64, aarch64] | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| ref: ${{ github.event.inputs.branch || github.ref }} | ||
| show-progress: false | ||
| persist-credentials: false | ||
| - name: Setup rust target | ||
| run: rustup target add ${{ matrix.arch }}-apple-darwin | ||
| - name: Build | ||
| run: cargo build --release --package deltachat-rpc-server --target ${{ matrix.arch }}-apple-darwin --features vendored | ||
| - name: Upload binary | ||
| uses: actions/upload-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-${{ matrix.arch }}-macos | ||
| path: target/${{ matrix.arch }}-apple-darwin/release/deltachat-rpc-server | ||
| if-no-files-found: error | ||
|
|
||
| publish_npm: | ||
| name: Pack and publish @privitty/deltachat-rpc-server | ||
| needs: [build_linux, build_windows, build_macos] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| ref: ${{ github.event.inputs.branch || github.ref }} | ||
| show-progress: false | ||
| persist-credentials: false | ||
| - uses: actions/setup-python@v5 | ||
Check failureCode scanning / zizmor unpinned action reference Error
unpinned action reference
|
||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Download Linux binaries | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-aarch64-linux | ||
| path: deltachat-rpc-server-aarch64-linux.d | ||
| - name: Download Linux armv7l | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-armv7l-linux | ||
| path: deltachat-rpc-server-armv7l-linux.d | ||
| - name: Download Linux armv6l | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-armv6l-linux | ||
| path: deltachat-rpc-server-armv6l-linux.d | ||
| - name: Download Linux i686 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-i686-linux | ||
| path: deltachat-rpc-server-i686-linux.d | ||
| - name: Download Linux x86_64 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-x86_64-linux | ||
| path: deltachat-rpc-server-x86_64-linux.d | ||
| - name: Download Win32 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-win32 | ||
| path: deltachat-rpc-server-win32.d | ||
| - name: Download Win64 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-win64 | ||
| path: deltachat-rpc-server-win64.d | ||
| - name: Download macOS x86_64 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-x86_64-macos | ||
| path: deltachat-rpc-server-x86_64-macos.d | ||
| - name: Download macOS aarch64 | ||
| uses: actions/download-artifact@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| name: deltachat-rpc-server-aarch64-macos | ||
| path: deltachat-rpc-server-aarch64-macos.d | ||
|
|
||
| - name: Make npm packages for @privitty/deltachat-rpc-server | ||
| run: | | ||
| cd deltachat-rpc-server/npm-package-privitty | ||
| python scripts/pack_binary_for_platform.py aarch64-unknown-linux-musl ../../deltachat-rpc-server-aarch64-linux.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py armv7-unknown-linux-musleabihf ../../deltachat-rpc-server-armv7l-linux.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py arm-unknown-linux-musleabihf ../../deltachat-rpc-server-armv6l-linux.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py i686-unknown-linux-musl ../../deltachat-rpc-server-i686-linux.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py x86_64-unknown-linux-musl ../../deltachat-rpc-server-x86_64-linux.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py i686-pc-windows-gnu ../../deltachat-rpc-server-win32.d/deltachat-rpc-server.exe | ||
| python scripts/pack_binary_for_platform.py x86_64-pc-windows-gnu ../../deltachat-rpc-server-win64.d/deltachat-rpc-server.exe | ||
| python scripts/pack_binary_for_platform.py x86_64-apple-darwin ../../deltachat-rpc-server-x86_64-macos.d/deltachat-rpc-server | ||
| python scripts/pack_binary_for_platform.py aarch64-apple-darwin ../../deltachat-rpc-server-aarch64-macos.d/deltachat-rpc-server | ||
| ls -la platform_package | ||
| for platform in ./platform_package/*; do npm pack "$platform"; done | ||
| npm pack | ||
| ls -la *.tgz | ||
|
|
||
| - uses: actions/setup-node@6d28f1ea826946162388c29db5a29aca24037adb | ||
| with: | ||
| node-version: 20 | ||
| registry-url: "https://registry.npmjs.org" | ||
|
|
||
| - name: Publish @privitty/deltachat-rpc-server to npm | ||
| working-directory: deltachat-rpc-server/npm-package-privitty | ||
| run: | | ||
| for f in *.tgz; do npm publish --provenance "$f" --access public; done | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| platform_package/* | ||
| scripts/ | ||
| *.tgz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # @privitty/deltachat-rpc-server | ||
|
|
||
| deltachat-rpc-server (stdio JSON-RPC server) from [Privitty/core](https://github.com/Privitty/core), built from the **dekstop-core** branch and published under **@privitty** on npm. | ||
|
|
||
| Same API as `@deltachat/stdio-rpc-server`. Use this when you want the server from the dekstop-core branch. | ||
|
|
||
| ```bash | ||
| npm i @privitty/deltachat-rpc-server @deltachat/jsonrpc-client | ||
| ``` | ||
|
|
||
| ```js | ||
| import { startDeltaChat } from "@privitty/deltachat-rpc-server"; | ||
|
|
||
| const dc = await startDeltaChat("deltachat-data"); | ||
| console.log(await dc.rpc.getSystemInfo()); | ||
| dc.close(); | ||
| ``` | ||
|
|
||
| Binary is resolved in this order: `DELTA_CHAT_RPC_SERVER` env, PATH (if `takeVersionFromPATH: true`), or platform prebuilds. Node >= 16. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { StdioDeltaChat } from "@deltachat/jsonrpc-client"; | ||
|
|
||
| export interface SearchOptions { | ||
| takeVersionFromPATH: boolean; | ||
| disableEnvPath: boolean; | ||
| } | ||
|
|
||
| export function getRPCServerPath( | ||
| options?: Partial<SearchOptions> | ||
| ): Promise<string>; | ||
|
|
||
| export type DeltaChatOverJsonRpcServer = StdioDeltaChat & { | ||
| readonly pathToServerBinary: string; | ||
| }; | ||
|
|
||
| export interface StartOptions { | ||
| muteStdErr: boolean; | ||
| } | ||
|
|
||
| export function startDeltaChat( | ||
| directory: string, | ||
| options?: Partial<SearchOptions & StartOptions> | ||
| ): Promise<DeltaChatOverJsonRpcServer>; | ||
|
|
||
| export namespace FnTypes { | ||
| export type getRPCServerPath = typeof getRPCServerPath; | ||
| export type startDeltaChat = typeof startDeltaChat; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| //@ts-check | ||
| import { spawn } from "node:child_process"; | ||
| import { stat } from "node:fs/promises"; | ||
| import os from "node:os"; | ||
| import process from "node:process"; | ||
| import { ENV_VAR_NAME, PATH_EXECUTABLE_NAME } from "./src/const.js"; | ||
| import { | ||
| ENV_VAR_LOCATION_NOT_FOUND, | ||
| FAILED_TO_START_SERVER_EXECUTABLE, | ||
| NPM_NOT_FOUND_SUPPORTED_PLATFORM_ERROR, | ||
| NPM_NOT_FOUND_UNSUPPORTED_PLATFORM_ERROR, | ||
| } from "./src/errors.js"; | ||
|
|
||
| import { createRequire } from "node:module"; | ||
|
|
||
| function findRPCServerInNodeModules() { | ||
| const arch = os.arch(); | ||
| const operating_system = process.platform; | ||
| const require = createRequire(import.meta.url); | ||
| const packageName = require("./package.json").name; | ||
| const package_name = `${packageName}-${operating_system}-${arch}`; | ||
| try { | ||
| const { resolve } = createRequire(import.meta.url); | ||
| return resolve(package_name); | ||
| } catch (error) { | ||
| console.debug("findRpcServerInNodeModules", error); | ||
| if ( | ||
| Object.keys(require("./package.json").optionalDependencies || {}).includes( | ||
| package_name | ||
| ) | ||
| ) { | ||
| throw new Error(NPM_NOT_FOUND_SUPPORTED_PLATFORM_ERROR(package_name)); | ||
| } else { | ||
| throw new Error(NPM_NOT_FOUND_UNSUPPORTED_PLATFORM_ERROR()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** @type {import("./index").FnTypes.getRPCServerPath} */ | ||
| export async function getRPCServerPath(options = {}) { | ||
| const { takeVersionFromPATH, disableEnvPath } = { | ||
| takeVersionFromPATH: false, | ||
| disableEnvPath: false, | ||
| ...options, | ||
| }; | ||
| if (process.env[ENV_VAR_NAME] && !disableEnvPath) { | ||
| try { | ||
| if (!(await stat(process.env[ENV_VAR_NAME])).isFile()) { | ||
| throw new Error( | ||
| `expected ${ENV_VAR_NAME} to point to the deltachat-rpc-server executable` | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| throw new Error(ENV_VAR_LOCATION_NOT_FOUND()); | ||
| } | ||
| return process.env[ENV_VAR_NAME]; | ||
| } | ||
| if (takeVersionFromPATH) { | ||
| return PATH_EXECUTABLE_NAME; | ||
| } | ||
| return findRPCServerInNodeModules(); | ||
| } | ||
|
|
||
| import { StdioDeltaChat } from "@deltachat/jsonrpc-client"; | ||
|
|
||
| /** @type {import("./index").FnTypes.startDeltaChat} */ | ||
| export async function startDeltaChat(directory, options = {}) { | ||
| const pathToServerBinary = await getRPCServerPath(options); | ||
| const server = spawn(pathToServerBinary, { | ||
| env: { | ||
| RUST_LOG: process.env.RUST_LOG, | ||
| DC_ACCOUNTS_PATH: directory, | ||
| }, | ||
| stdio: ["pipe", "pipe", options.muteStdErr ? "ignore" : "inherit"], | ||
| }); | ||
|
|
||
| server.on("error", (err) => { | ||
| throw new Error(FAILED_TO_START_SERVER_EXECUTABLE(pathToServerBinary, err)); | ||
| }); | ||
| let shouldClose = false; | ||
|
|
||
| server.on("exit", () => { | ||
| if (shouldClose) return; | ||
| throw new Error("Server quit"); | ||
| }); | ||
|
|
||
| /** @type {import('./index').DeltaChatOverJsonRpcServer} */ | ||
| //@ts-expect-error | ||
| const dc = new StdioDeltaChat(server.stdin, server.stdout, true); | ||
|
|
||
| dc.close = () => { | ||
| shouldClose = true; | ||
| if (!server.kill()) console.log("server termination failed"); | ||
| }; | ||
|
|
||
| //@ts-expect-error | ||
| dc.pathToServerBinary = pathToServerBinary; | ||
|
|
||
| return dc; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "@privitty/deltachat-rpc-server", | ||
| "version": "1.160.0", | ||
| "license": "MPL-2.0", | ||
| "main": "index.js", | ||
| "types": "index.d.ts", | ||
| "type": "module", | ||
| "optionalDependencies": {}, | ||
| "peerDependencies": { | ||
| "@deltachat/jsonrpc-client": "*" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/Privitty/core.git", | ||
| "directory": "deltachat-rpc-server" | ||
| }, | ||
| "scripts": { | ||
| "prepack": "node scripts/update_optional_dependencies_and_version.js" | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
deltachat-rpc-server/npm-package-privitty/scripts/pack_binary_for_platform.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import subprocess | ||
| import sys | ||
| from os import path, makedirs, chdir, chmod | ||
| from shutil import copy | ||
|
|
||
| # run from npm-package-privitty/ | ||
| chdir(path.join(path.dirname(path.abspath(__file__)), "../")) | ||
|
|
||
| if len(sys.argv) < 3: | ||
| print("Usage: pack_binary_for_platform.py <cargo-target> <binary_path>") | ||
| sys.exit(1) | ||
|
|
||
| target = sys.argv[1].strip() | ||
| binary_path = sys.argv[2].strip() | ||
|
|
||
| out = subprocess.run(["rustc", "--print", "target-list"], capture_output=True, check=True) | ||
| if target not in out.stdout.decode("utf-8"): | ||
| print("Unknown target:", target) | ||
| sys.exit(1) | ||
|
|
||
| makedirs("platform_package", exist_ok=True) | ||
| platform_path = "platform_package/" + target | ||
| makedirs(platform_path, exist_ok=True) | ||
|
|
||
| binary_name = path.basename(binary_path) | ||
| dest = platform_path + "/" + binary_name | ||
| copy(binary_path, dest) | ||
| chmod(dest, 0o555) | ||
|
|
||
| from src.make_package import write_package_json | ||
| write_package_json(platform_path, target, binary_name) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / zizmor
unpinned action reference Error