Skip to content
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

IndexedDB support for wasm/browser environments #414

Merged
merged 119 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
8a2732a
first steps
gnunicorn Nov 15, 2021
b8af613
big batch
gnunicorn Nov 17, 2021
5bba24c
activating browser tests
gnunicorn Nov 17, 2021
e7ec861
generic tests passing'
gnunicorn Nov 17, 2021
e603496
implement custom value
gnunicorn Nov 18, 2021
a2b80f0
move and unify usage of store_key
gnunicorn Nov 18, 2021
3e11e0d
fixing style
gnunicorn Nov 18, 2021
7df36e3
first attempt at creating a CI job for wasm tests
gnunicorn Nov 18, 2021
b16c660
fixing typo
gnunicorn Nov 18, 2021
3fcfe98
minor clippy fixes
gnunicorn Nov 18, 2021
10d4fe5
clarify API
gnunicorn Nov 18, 2021
76454e6
style fix
gnunicorn Nov 18, 2021
917e901
clean up API and corresponding docs
gnunicorn Nov 19, 2021
9e83bcb
fixing browser test
gnunicorn Nov 19, 2021
94d3ffa
infrastructure for indexeddb cryptostore
gnunicorn Nov 19, 2021
4c0bbeb
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Nov 24, 2021
5cf56ad
Adding result-signature support for wasm32 async-test-macro
gnunicorn Nov 25, 2021
4268016
fix up CI test
gnunicorn Nov 25, 2021
4c60db9
Implement helper for wasm32 MilliSecondsSinceUnixEpoch
gnunicorn Nov 25, 2021
32a8ec7
minor wasm32 fixes
gnunicorn Nov 25, 2021
47dff21
update trait impl of indexeddb
gnunicorn Nov 25, 2021
6d9920c
various minor cleanups of unused imports
gnunicorn Nov 25, 2021
229a81b
Implement saving
gnunicorn Nov 26, 2021
b42b04e
account loading and saving
gnunicorn Nov 26, 2021
47168ca
implement saving user
gnunicorn Nov 29, 2021
fe257ef
properly open encrypted state db
gnunicorn Nov 29, 2021
8338026
implement devices saving and deleting
gnunicorn Nov 29, 2021
41faa59
implement keyrequests
gnunicorn Nov 29, 2021
c9a1035
implement olm_hashes
gnunicorn Nov 29, 2021
85dde94
implement sessions
gnunicorn Nov 29, 2021
d509eaa
implement tracked user
gnunicorn Nov 29, 2021
59e3baf
cover more inbound_group_session functions
gnunicorn Nov 30, 2021
1e654ac
backup and reset for inbound_groups
gnunicorn Nov 30, 2021
e3c6282
test and impl for outbound
gnunicorn Nov 30, 2021
954cce4
make cryptostore tests reusable
gnunicorn Nov 30, 2021
9f0fe18
fix async_test for non-wasm32 envs
gnunicorn Nov 30, 2021
f185aa2
reuse cryptostore for sled
gnunicorn Nov 30, 2021
968f80c
minor fix
gnunicorn Nov 30, 2021
9b7c1d7
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Nov 30, 2021
9a0cf2b
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Nov 30, 2021
97d675f
fix formatting
gnunicorn Nov 30, 2021
c5e7ca0
undo my olm-sys-hack
gnunicorn Nov 30, 2021
4fdada5
fixing typo
gnunicorn Nov 30, 2021
1a20e62
remove trouble causing unnecessary ref-clone
gnunicorn Nov 30, 2021
a1b62a1
allow helper to be unused
gnunicorn Nov 30, 2021
c7a9fc6
syntax fix
gnunicorn Dec 1, 2021
9d5c1fc
move store tests into separate reusable macro, too
gnunicorn Dec 1, 2021
4b12260
move store implementations into files
gnunicorn Dec 1, 2021
b150dea
fix style
gnunicorn Dec 1, 2021
afaeae8
unify indexeddb-features and improve example build
gnunicorn Dec 1, 2021
293700c
checking all crates for wasm32
gnunicorn Dec 1, 2021
787f826
fixing CI
gnunicorn Dec 1, 2021
8ab5df4
remove appservice, as it won't support wasm for a while
gnunicorn Dec 1, 2021
6b3f008
ensure Instant::now is working properly
gnunicorn Dec 1, 2021
2ee7a95
(now really) ensure Instant::now is working properly
gnunicorn Dec 1, 2021
f548508
limit test execution to platforms that support it
gnunicorn Dec 1, 2021
470c81b
be specific with dead_code
gnunicorn Dec 1, 2021
ac2771b
add docs
gnunicorn Dec 1, 2021
d039590
activate available tests for wasm32
gnunicorn Dec 1, 2021
7e6ac42
cleaning up store
gnunicorn Dec 1, 2021
d155f9a
can work on wasm32
gnunicorn Dec 1, 2021
1bbe38e
compiling matrix-sdk for wasm
gnunicorn Dec 1, 2021
d0838d6
fixing style
gnunicorn Dec 1, 2021
53ad581
typo fixes
gnunicorn Dec 1, 2021
652ef6e
sled store needs tokio
gnunicorn Dec 1, 2021
aab1fd2
fixing ci job
gnunicorn Dec 1, 2021
9883ca0
[CI] parallel and the correct crates
gnunicorn Dec 1, 2021
10e2753
fix CI format
gnunicorn Dec 1, 2021
4e18286
remove another dependency
gnunicorn Dec 1, 2021
5734afc
[CI] fixing test syntax
gnunicorn Dec 2, 2021
8952324
fixing main sdk wasm testing
gnunicorn Dec 2, 2021
2ccb1d2
don't pickle
gnunicorn Dec 8, 2021
3de6f60
remove unneccessary imports and compiler flags
gnunicorn Dec 8, 2021
a6dbd6b
escaped characters for indexeddb keys
gnunicorn Dec 10, 2021
007b7e2
outsource SafeEncode helper
gnunicorn Dec 10, 2021
186bd97
reuse SafeEncode for indexeddb_cryptostore
gnunicorn Dec 10, 2021
bf9ad7a
fix typo
gnunicorn Dec 10, 2021
e02407e
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Dec 10, 2021
35f2a00
style and docs fixes
gnunicorn Dec 10, 2021
3f9b551
activate IdbKeyRange feature on web-sys dependency
gnunicorn Dec 10, 2021
2982741
minor style fix
gnunicorn Dec 10, 2021
7fc040d
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Dec 13, 2021
678527e
libolm is fixed, so should our code be
gnunicorn Dec 13, 2021
fa00cba
fixing style
gnunicorn Dec 13, 2021
4f93e73
fixing typo
gnunicorn Dec 13, 2021
71bc043
extended testing for wasm example
gnunicorn Dec 16, 2021
7ad5bc7
version listing
gnunicorn Dec 16, 2021
8feab72
[CI] dynamic node version
gnunicorn Dec 16, 2021
9d4d866
latest and node
gnunicorn Dec 16, 2021
afe7d05
[ci] fix syntax
gnunicorn Dec 16, 2021
1a206ff
let them all run out
gnunicorn Dec 16, 2021
e619cc1
don't combine
gnunicorn Dec 22, 2021
8dda7ea
please consider all includes
gnunicorn Dec 22, 2021
1f5a084
don't fail fast
gnunicorn Dec 22, 2021
5748933
refine wasm tests
gnunicorn Dec 22, 2021
98beff4
resolve clippy complaints
gnunicorn Dec 22, 2021
cbd4aa0
disable test failing on macosx
gnunicorn Dec 22, 2021
3cde28a
trying older emscripten
gnunicorn Dec 27, 2021
15cdaea
fix broken now call
gnunicorn Dec 27, 2021
9ff4609
testing emcc versions
gnunicorn Dec 27, 2021
8ce622d
fixin style
gnunicorn Dec 27, 2021
3468773
create sync token store
gnunicorn Dec 27, 2021
e1ad8fe
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Jan 7, 2022
0937c2e
[fix ci] remove unused import
gnunicorn Jan 7, 2022
278d934
fix broken merge
gnunicorn Jan 7, 2022
fb81ebf
fixing style again
gnunicorn Jan 7, 2022
92044ce
fixing style again
gnunicorn Jan 7, 2022
a0f2e38
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Feb 1, 2022
93c75c1
fixing build warnings and clippy lints
gnunicorn Feb 1, 2022
e2c6dc3
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Feb 2, 2022
ea959a1
Merge remote-tracking branch 'upstream/main' into ben-wasm-store
gnunicorn Feb 2, 2022
b4d5ad9
fixing style
gnunicorn Feb 2, 2022
c07c284
fixing docs for await
gnunicorn Feb 2, 2022
7e008d0
fixing linux tests
gnunicorn Feb 2, 2022
666bec4
fixing indexeddb types merge
gnunicorn Feb 2, 2022
b8d93d0
implementing room removal for indexeddb
gnunicorn Feb 2, 2022
64709f1
fixing style
gnunicorn Feb 2, 2022
990b897
switch tokio:test to async_test
gnunicorn Feb 2, 2022
fa60881
disable broken test
gnunicorn Feb 2, 2022
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
160 changes: 151 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,40 @@ jobs:
args: --all-targets --no-default-features --features native-tls,warp -- -D warnings

check-wasm:
name: linux / WASM
needs: [clippy]
name: checking WASM builds
runs-on: ubuntu-latest

strategy:
# fail-fast: true

matrix:
name:
- matrix-qrcode
- matrix-sdk (no-default, wasm-flags)
- matrix-sdk-base
- matrix-sdk-common
- matrix-sdk-crypto
- matrix-sdk-base / indexeddb_state_store
- matrix-sdk-crypto / indexeddb_cryptostore

include:
- name: matrix-qrcode
cargo_args: --package matrix-qrcode
- name: matrix-sdk (no-default, wasm-flags)
cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk
- name: matrix-sdk-base
cargo_args: --package matrix-sdk-base
- name: matrix-sdk-common
cargo_args: --package matrix-sdk-common
- name: matrix-sdk-crypto
cargo_args: --package matrix-sdk-crypto

# special check for specific features
- name: matrix-sdk-base / indexeddb_state_store
cargo_args: --package matrix-sdk-base --features indexeddb_state_store
- name: matrix-sdk-crypto / indexeddb_cryptostore
cargo_args: --package matrix-sdk-crypto --features indexeddb_cryptostore

steps:
- name: Checkout the repo
uses: actions/checkout@v2
Expand All @@ -111,20 +141,132 @@ jobs:
profile: minimal
override: true

# needed for libolm-sys compilation
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v7
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ matrix.emcc_version || 'latest' }}

- name: check
uses: actions-rs/cargo@v1
with:
command: check
args: --target wasm32-unknown-unknown ${{ matrix.cargo_args }}

test-wasm:
# building wasm is not enough, we've seen runtime errors before,
# hence the tests
name: ${{ matrix.name }} WASM test
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will still turn our CI state into a ❌, oh well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, github actions don't have a proper ignore-failure switch ... what I could offer is to comment the specific test (which would also mean we don't waste these resources every time) until we have it fixed up ...?!?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, sounds good.


strategy:
matrix:
include:
- name: "matrix-sdk-crypto @Node14 emcc2.0"
experimental: false
emcc_version: 2.0.27
base_dir: matrix-sdk-crypto
cargo_args: --features indexeddb_cryptostore
- name: matrix-sdk-base
experimental: false
base_dir: matrix-sdk-base
cargo_args: --features indexeddb_state_store,indexeddb_cryptostore
- name: matrix-sdk
experimental: false
base_dir: matrix-sdk
# FIXME: we have to skip all examples b/c of https://github.com/rustwasm/wasm-pack/issues/666
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib
- name: "matrix-sdk-example-wasm_command_bot @Node14"
experimental: false
emcc_version: 2.0.27
node_version: '14'
# known to work
base_dir: matrix-sdk/examples/wasm_command_bot
cmd: |
npm install
npm test
wasm-pack test --firefox --headless

# these are _known_ broken on latest node
# - name: matrix-sdk-crypto
# experimental: true
# base_dir: matrix-sdk-crypto
- name: matrix-sdk-example-wasm_command_bot
base_dir: matrix-sdk/examples/wasm_command_bot
# this might fail
experimental: true
cmd: |
npm install
npm test
wasm-pack test --firefox --headless

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: stable
target: wasm32-unknown-unknown
profile: minimal
override: true

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version || 'lts/*' }}

- name: Install emscripten
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ matrix.emcc_version || 'latest' }}

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Verify versions
run: |
echo "> node --version"
node --version
echo "> npm --version"
npm --version
echo "> wasm-pack --version"
wasm-pack --version
echo "> emcc -v"
emcc -v

- name: Default wasm-pack tests
if: ${{!matrix.cmd}}
run: |
cd crates/${{matrix.base_dir}}
wasm-pack test --node -- ${{ matrix.cargo_args }}
wasm-pack test --firefox --headless -- --features ${{ matrix.cargo_args }}

- name: Check
- name: Testing with custom command
if: ${{matrix.cmd}}
run: |
cd crates/matrix-sdk/examples/wasm_command_bot
cargo check --target wasm32-unknown-unknown
cd crates/${{matrix.base_dir}}
${{matrix.cmd}}

test-appservice:
name: ${{ matrix.name }}
needs: [clippy]

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: true
matrix:
name:
- linux / appservice / stable / warp
Expand Down Expand Up @@ -181,10 +323,10 @@ jobs:

test-features:
name: ${{ matrix.name }}
needs: [clippy]

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: true
matrix:
name:
- linux / features-no-encryption
Expand Down Expand Up @@ -258,10 +400,10 @@ jobs:

test:
name: ${{ matrix.name }}
needs: [clippy]

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: true
matrix:
name:
- linux / stable
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-appservice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl AppService {
};

let client =
Client::new_with_config(self.homeserver_url.clone(), config.appservice_mode())?;
Client::new_with_config(self.homeserver_url.clone(), config.appservice_mode()).await?;

let session = Session {
access_token: self.registration.as_token.clone(),
Expand Down
16 changes: 11 additions & 5 deletions crates/matrix-sdk-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ encryption = ["matrix-sdk-crypto"]
qrcode = ["matrix-sdk-crypto/qrcode"]
sled_state_store = [
"sled",
"tokio",
"pbkdf2",
"hmac",
"sha2",
Expand All @@ -29,6 +30,9 @@ sled_state_store = [
]
sled_cryptostore = ["matrix-sdk-crypto/sled_cryptostore"]

indexeddb_state_store = ["indexed_db_futures", "wasm-bindgen", "pbkdf2", "hmac", "sha2", "rand", "chacha20poly1305"]
gnunicorn marked this conversation as resolved.
Show resolved Hide resolved
indexeddb_cryptostore = ["matrix-sdk-crypto/indexeddb_cryptostore"]

[dependencies]
chacha20poly1305 = { version = "0.9.0", optional = true }
dashmap = "4.0.2"
Expand All @@ -48,16 +52,18 @@ thiserror = "1.0.25"
tracing = "0.1.26"
zeroize = { version = "1.3.0", features = ["zeroize_derive"] }

## Feature sled_state_store
tokio = { version = "1.7.1", optional = true, default-features = false, features = ["sync", "fs"] }

## Feature indexeddb-state-store
indexed_db_futures = { version = "0.2.0", optional = true }
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }

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

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "1.7.1"
default-features = false
features = ["sync", "fs"]

[dev-dependencies]
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
http = "0.2.4"
Expand Down
Loading