Skip to content
This repository was archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Bring in nodejs crypto bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Feb 7, 2022
1 parent c00a522 commit 72b8b7e
Show file tree
Hide file tree
Showing 33 changed files with 1,863 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[doc.extern-map.registries]
crates-io = "https://docs.rs/"
138 changes: 138 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: CI

on:
push:
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
style:
name: Check style
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
profile: minimal
override: true

- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

typos:
name: Spell Check with Typos
needs: [style]
runs-on: ubuntu-latest

steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Check the spelling of the files in our repo
uses: crate-ci/typos@master

clippy:
name: Run clippy
needs: [style]
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v2

- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
profile: minimal
override: true

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings

- name: Clippy without default features
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --no-default-features --features native-tls,warp -- -D warnings

test:
name: ${{ matrix.name }}

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: true
matrix:
name:
- linux / stable
- linux / beta
- macOS / stable

include:
- name: linux / stable

- name: linux / beta
rust: beta

- name: macOS / stable
os: macOS-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust || 'stable' }}
target: ${{ matrix.target }}
profile: minimal
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
50 changes: 50 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Code coverage

on:
push:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
code_coverage:
name: Code Coverage
runs-on: "ubuntu-latest"

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Install tarpaulin
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-tarpaulin

- name: Run tarpaulin
uses: actions-rs/cargo@v1
with:
command: tarpaulin
args: --ignore-config --exclude-files "crates/matrix-sdk/examples/*,crates/matrix-sdk-common,crates/matrix-sdk-test" --out Xml

- name: Upload to codecov.io
uses: codecov/codecov-action@v1
48 changes: 48 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: docs

on:
push:
branches: [main]
pull_request:

jobs:
docs:
name: docs
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Build docs
uses: actions-rs/cargo@v1
env:
RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
with:
command: doc
args: --no-deps --workspace --features docs -Zrustdoc-map

- name: Deploy docs
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc/
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cargo.lock
target
master.zip
emsdk-*
.idea/
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: local
hooks:
- id: fmt
name: fmt
language: system
types: [file, rust]
entry: cargo fmt -- --check

- id: clippy
name: clippy
language: system
types: [file, rust]
entry: cargo clippy --all-targets --all
pass_filenames: false

- id: test
name: test
language: system
files: '\.rs$'
entry: cargo test --lib
pass_filenames: false
7 changes: 7 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
edition = "2018"
max_width = 100
comment_width = 80
wrap_comments = true
imports_granularity = "Crate"
use_small_heuristics = "Max"
group_imports = "StdExternalCrate"
11 changes: 11 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[default.extend-words]
# Remove this once base64 gets correctly ignored by typos
# Or if we're able to ignore certain lines.
Fo = "Fo"
BA = "BA"
UE = "UE"

[files]
# Our json files contain a bunch of base64 encoded ed25519 keys which aren't
# automatically ignored, we ignore them here.
extend-exclude = ["*.json"]
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[workspace]
members = [
"crates/matrix-sdk-crypto-nodejs",
]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# matrix-rust-sdk-bindings
Language bindings for matrix-rust-sdk


**Work in progress**
6 changes: 6 additions & 0 deletions crates/matrix-sdk-crypto-nodejs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
napi-module.js
napi-module.d.ts
yarn-error.log
/sled
/lib
62 changes: 62 additions & 0 deletions crates/matrix-sdk-crypto-nodejs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[package]
authors = ["Travis Ralston <[email protected]>"]
description = "matrix-sdk-crypto crate for Node JS"
edition = "2021"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma", "nio"]
license = "Apache-2.0"
name = "matrix-sdk-crypto-nodejs"
readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk-bindings"
rust-version = "1.56"
version = "0.1.0"

[lib]
crate-type=["cdylib"]

[dependencies]
napi-derive = { version = "2.0.0", features = ["full"] }
napi = { version = "2.0.0", features = ["full"] }
serde = "1"
serde_derive = "1"
serde_json = "1"
http = "0.2.4"

# For some reason the futures lib is missing in published builds, so copy the dep from
# the matrix-sdk-crypto crate.
futures = { version = "0.3.15", default-features = false, features = ["executor"] }

[dependencies.matrix-sdk-crypto]
version = "0.4.1"
default_features = false
features = ["sled_cryptostore", "backups_v1"]

# use git for release mode
git = "https://github.com/matrix-org/matrix-rust-sdk"
rev = "59d21d9683cd83196b6b4de6c605fb611d20d384"

# use path in local development mode
#path = "../matrix-sdk-crypto"

[dependencies.matrix-sdk-common]
version = "0.4.1"

# use git for release mode
git = "https://github.com/matrix-org/matrix-rust-sdk"
rev = "59d21d9683cd83196b6b4de6c605fb611d20d384"

# use path in local development mode
#path = "../matrix-sdk-common"

[dependencies.ruma]
git = "https://github.com/ruma/ruma/"
rev = "37095f88553b311e7a70adaaabe39976fb8ff71c"
features = ["client-api-c"]

[dependencies.tokio]
version = "1.7.1"
default_features = false
features = ["rt-multi-thread"]

[build-dependencies]
napi-build = "1.2.1"
Loading

0 comments on commit 72b8b7e

Please sign in to comment.