Merge branch 'v1' into feat/stronghold/argon2-kdf

pull/449/head
Lucas Nogueira 2 years ago
commit eb6d7f1677
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

@ -45,6 +45,8 @@ jobs:
- name: build - name: build
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features
- uses: dtolnay/rust-toolchain@1.65.0
- name: build sql:sqlite - name: build sql:sqlite
run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite

@ -48,7 +48,7 @@ https.get(url, options, (response) => {
console.log(versions.length ? versions[0].num : "0.0.0"); console.log(versions.length ? versions[0].num : "0.0.0");
} else if (kind === "npm") { } else if (kind === "npm") {
const versions = Object.keys(data.versions).filter((v) => const versions = Object.keys(data.versions).filter((v) =>
v.startsWith(target) v.startsWith(target),
); );
console.log(versions[versions.length - 1] || "0.0.0"); console.log(versions[versions.length - 1] || "0.0.0");
} }

390
Cargo.lock generated

@ -40,9 +40,9 @@ dependencies = [
[[package]] [[package]]
name = "aes-gcm" name = "aes-gcm"
version = "0.9.2" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc3be92e19a7ef47457b8e6f90707e12b6ac5d20c6f3866584fa3be0787d839f" checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6"
dependencies = [ dependencies = [
"aead", "aead",
"aes", "aes",
@ -70,6 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"getrandom 0.2.10",
"once_cell", "once_cell",
"version_check", "version_check",
] ]
@ -291,9 +292,9 @@ dependencies = [
[[package]] [[package]]
name = "atoi" name = "atoi"
version = "1.0.0" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528"
dependencies = [ dependencies = [
"num-traits", "num-traits",
] ]
@ -397,6 +398,9 @@ name = "bitflags"
version = "2.3.3" version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "blake2" name = "blake2"
@ -732,9 +736,9 @@ dependencies = [
[[package]] [[package]]
name = "const-oid" name = "const-oid"
version = "0.7.1" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747"
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
@ -856,16 +860,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crypto-bigint"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21"
dependencies = [
"generic-array",
"subtle",
]
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.6" version = "0.1.6"
@ -915,9 +909,9 @@ dependencies = [
[[package]] [[package]]
name = "ctr" name = "ctr"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a232f92a03f37dd7d7dd2adc67166c77e9cd88de5b019b9a9eecfaeaf7bfd481" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea"
dependencies = [ dependencies = [
"cipher", "cipher",
] ]
@ -978,13 +972,13 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "der" name = "der"
version = "0.5.1" version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c"
dependencies = [ dependencies = [
"const-oid", "const-oid",
"crypto-bigint",
"pem-rfc7468", "pem-rfc7468",
"zeroize",
] ]
[[package]] [[package]]
@ -1046,6 +1040,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [ dependencies = [
"block-buffer 0.10.4", "block-buffer 0.10.4",
"const-oid",
"crypto-common", "crypto-common",
"subtle", "subtle",
] ]
@ -1143,6 +1138,9 @@ name = "either"
version = "1.9.0" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "embed_plist" name = "embed_plist"
@ -1207,6 +1205,17 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "etcetera"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
dependencies = [
"cfg-if",
"home",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "event-listener" name = "event-listener"
version = "2.5.3" version = "2.5.3"
@ -1384,13 +1393,13 @@ dependencies = [
[[package]] [[package]]
name = "futures-intrusive" name = "futures-intrusive"
version = "0.4.2" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"lock_api", "lock_api",
"parking_lot 0.11.2", "parking_lot",
] ]
[[package]] [[package]]
@ -1868,6 +1877,15 @@ dependencies = [
"digest 0.10.7", "digest 0.10.7",
] ]
[[package]]
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "html5ever" name = "html5ever"
version = "0.25.2" version = "0.25.2"
@ -2137,9 +2155,9 @@ dependencies = [
[[package]] [[package]]
name = "iota-crypto" name = "iota-crypto"
version = "0.21.2" version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d22b9d6f6b7601c3fcff97cdf6298cbfdd6fb44812b4e6f82a016152be1c891" checksum = "c5d5a986d972c3a703d48ced24fdc0bf16fb2d02959ff4b152fa77b9132f6fb0"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@ -2374,9 +2392,9 @@ dependencies = [
[[package]] [[package]]
name = "libsqlite3-sys" name = "libsqlite3-sys"
version = "0.24.2" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326"
dependencies = [ dependencies = [
"cc", "cc",
"pkg-config", "pkg-config",
@ -2711,17 +2729,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "num-bigint"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]] [[package]]
name = "num-bigint-dig" name = "num-bigint-dig"
version = "0.8.4" version = "0.8.4"
@ -2961,17 +2968,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e"
[[package]]
name = "parking_lot"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
dependencies = [
"instant",
"lock_api",
"parking_lot_core 0.8.6",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.1" version = "0.12.1"
@ -2979,21 +2975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [ dependencies = [
"lock_api", "lock_api",
"parking_lot_core 0.9.8", "parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall 0.2.16",
"smallvec",
"winapi",
] ]
[[package]] [[package]]
@ -3026,9 +3008,9 @@ dependencies = [
[[package]] [[package]]
name = "pem-rfc7468" name = "pem-rfc7468"
version = "0.3.1" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01de5d978f34aa4b2296576379fcc416034702fd94117c56ffd8a1a767cefb30" checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412"
dependencies = [ dependencies = [
"base64ct", "base64ct",
] ]
@ -3171,24 +3153,23 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkcs1" name = "pkcs1"
version = "0.3.3" version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a78f66c04ccc83dd4486fd46c33896f4e17b24a7a3a6400dedc48ed0ddd72320" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
dependencies = [ dependencies = [
"der", "der",
"pkcs8", "pkcs8",
"zeroize", "spki",
] ]
[[package]] [[package]]
name = "pkcs8" name = "pkcs8"
version = "0.8.0" version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
dependencies = [ dependencies = [
"der", "der",
"spki", "spki",
"zeroize",
] ]
[[package]] [[package]]
@ -3575,11 +3556,12 @@ dependencies = [
[[package]] [[package]]
name = "rsa" name = "rsa"
version = "0.6.1" version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cf22754c49613d2b3b119f0e5d46e34a2c628a937e3024b8762de4e7d8c710b" checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"const-oid",
"digest 0.10.7", "digest 0.10.7",
"num-bigint-dig", "num-bigint-dig",
"num-integer", "num-integer",
@ -3588,7 +3570,8 @@ dependencies = [
"pkcs1", "pkcs1",
"pkcs8", "pkcs8",
"rand_core 0.6.4", "rand_core 0.6.4",
"smallvec", "signature",
"spki",
"subtle", "subtle",
"zeroize", "zeroize",
] ]
@ -3655,14 +3638,13 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.20.8" version = "0.21.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb"
dependencies = [ dependencies = [
"log",
"ring", "ring",
"rustls-webpki",
"sct", "sct",
"webpki",
] ]
[[package]] [[package]]
@ -3674,6 +3656,16 @@ dependencies = [
"base64 0.21.2", "base64 0.21.2",
] ]
[[package]]
name = "rustls-webpki"
version = "0.101.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.14" version = "1.0.14"
@ -3983,6 +3975,16 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "signature"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500"
dependencies = [
"digest 0.10.7",
"rand_core 0.6.4",
]
[[package]] [[package]]
name = "simd-adler32" name = "simd-adler32"
version = "0.3.7" version = "0.3.7"
@ -4065,9 +4067,9 @@ dependencies = [
[[package]] [[package]]
name = "spki" name = "spki"
version = "0.5.4" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a"
dependencies = [ dependencies = [
"base64ct", "base64ct",
"der", "der",
@ -4086,104 +4088,204 @@ dependencies = [
[[package]] [[package]]
name = "sqlx" name = "sqlx"
version = "0.6.3" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721"
dependencies = [ dependencies = [
"sqlx-core", "sqlx-core",
"sqlx-macros", "sqlx-macros",
"sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
] ]
[[package]] [[package]]
name = "sqlx-core" name = "sqlx-core"
version = "0.6.3" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53"
dependencies = [ dependencies = [
"ahash 0.7.6", "ahash 0.8.3",
"atoi", "atoi",
"base64 0.13.1",
"bitflags 1.3.2",
"byteorder", "byteorder",
"bytes 1.4.0", "bytes 1.4.0",
"crc", "crc",
"crossbeam-queue", "crossbeam-queue",
"digest 0.10.7",
"dirs",
"dotenvy", "dotenvy",
"either", "either",
"event-listener", "event-listener",
"flume",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-executor",
"futures-intrusive", "futures-intrusive",
"futures-io",
"futures-util", "futures-util",
"generic-array",
"hashlink", "hashlink",
"hex", "hex",
"hkdf", "indexmap 2.0.0",
"hmac",
"indexmap 1.9.3",
"itoa 1.0.9",
"libc",
"libsqlite3-sys",
"log", "log",
"md-5",
"memchr", "memchr",
"num-bigint",
"once_cell", "once_cell",
"paste", "paste",
"percent-encoding", "percent-encoding",
"rand 0.8.5",
"rsa",
"rustls", "rustls",
"rustls-pemfile", "rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"sha1",
"sha2 0.10.7", "sha2 0.10.7",
"smallvec", "smallvec",
"sqlformat", "sqlformat",
"sqlx-rt",
"stringprep",
"thiserror", "thiserror",
"time 0.3.25", "time 0.3.25",
"tokio",
"tokio-stream", "tokio-stream",
"tracing",
"url", "url",
"webpki-roots", "webpki-roots",
"whoami",
] ]
[[package]] [[package]]
name = "sqlx-macros" name = "sqlx-macros"
version = "0.6.3" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2"
dependencies = [
"proc-macro2",
"quote",
"sqlx-core",
"sqlx-macros-core",
"syn 1.0.109",
]
[[package]]
name = "sqlx-macros-core"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc"
dependencies = [ dependencies = [
"dotenvy", "dotenvy",
"either", "either",
"heck 0.4.1", "heck 0.4.1",
"hex",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"serde",
"serde_json", "serde_json",
"sha2 0.10.7", "sha2 0.10.7",
"sqlx-core", "sqlx-core",
"sqlx-rt", "sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
"syn 1.0.109", "syn 1.0.109",
"tempfile",
"tokio",
"url", "url",
] ]
[[package]] [[package]]
name = "sqlx-rt" name = "sqlx-mysql"
version = "0.6.3" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482"
dependencies = [ dependencies = [
"atoi",
"base64 0.21.2",
"bitflags 2.3.3",
"byteorder",
"bytes 1.4.0",
"crc",
"digest 0.10.7",
"dotenvy",
"either",
"futures-channel",
"futures-core",
"futures-io",
"futures-util",
"generic-array",
"hex",
"hkdf",
"hmac",
"itoa 1.0.9",
"log",
"md-5",
"memchr",
"once_cell", "once_cell",
"tokio", "percent-encoding",
"tokio-rustls", "rand 0.8.5",
"rsa",
"serde",
"sha1",
"sha2 0.10.7",
"smallvec",
"sqlx-core",
"stringprep",
"thiserror",
"time 0.3.25",
"tracing",
"whoami",
]
[[package]]
name = "sqlx-postgres"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e"
dependencies = [
"atoi",
"base64 0.21.2",
"bitflags 2.3.3",
"byteorder",
"crc",
"dotenvy",
"etcetera",
"futures-channel",
"futures-core",
"futures-io",
"futures-util",
"hex",
"hkdf",
"hmac",
"home",
"itoa 1.0.9",
"log",
"md-5",
"memchr",
"once_cell",
"rand 0.8.5",
"serde",
"serde_json",
"sha1",
"sha2 0.10.7",
"smallvec",
"sqlx-core",
"stringprep",
"thiserror",
"time 0.3.25",
"tracing",
"whoami",
]
[[package]]
name = "sqlx-sqlite"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2"
dependencies = [
"atoi",
"flume",
"futures-channel",
"futures-core",
"futures-executor",
"futures-intrusive",
"futures-util",
"libsqlite3-sys",
"log",
"percent-encoding",
"serde",
"sqlx-core",
"time 0.3.25",
"tracing",
"url",
] ]
[[package]] [[package]]
@ -4215,7 +4317,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"
dependencies = [ dependencies = [
"new_debug_unreachable", "new_debug_unreachable",
"once_cell", "once_cell",
"parking_lot 0.12.1", "parking_lot",
"phf_shared 0.10.0", "phf_shared 0.10.0",
"precomputed-hash", "precomputed-hash",
"serde", "serde",
@ -4309,9 +4411,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "subtle" name = "subtle"
version = "2.5.0" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
[[package]] [[package]]
name = "syn" name = "syn"
@ -4397,7 +4499,7 @@ dependencies = [
"ndk-sys", "ndk-sys",
"objc", "objc",
"once_cell", "once_cell",
"parking_lot 0.12.1", "parking_lot",
"png", "png",
"raw-window-handle", "raw-window-handle",
"scopeguard", "scopeguard",
@ -4606,7 +4708,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-persisted-scope" name = "tauri-plugin-persisted-scope"
version = "0.1.1" version = "0.1.3"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"bincode", "bincode",
@ -4673,7 +4775,7 @@ name = "tauri-plugin-stronghold"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"hex", "hex",
"iota-crypto 0.21.2", "iota-crypto 0.23.0",
"iota_stronghold", "iota_stronghold",
"log", "log",
"rand 0.8.5", "rand 0.8.5",
@ -4957,17 +5059,6 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tokio-rustls"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"rustls",
"tokio",
"webpki",
]
[[package]] [[package]]
name = "tokio-stream" name = "tokio-stream"
version = "0.1.14" version = "0.1.14"
@ -4981,9 +5072,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"log", "log",
@ -5063,6 +5154,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"log",
"pin-project-lite", "pin-project-lite",
"tracing-attributes", "tracing-attributes",
"tracing-core", "tracing-core",
@ -5135,9 +5227,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]] [[package]]
name = "tungstenite" name = "tungstenite"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"bytes 1.4.0", "bytes 1.4.0",
@ -5221,9 +5313,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e"
[[package]] [[package]]
name = "universal-hash" name = "universal-hash"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05"
dependencies = [ dependencies = [
"generic-array", "generic-array",
"subtle", "subtle",
@ -5492,23 +5584,13 @@ dependencies = [
"system-deps 6.1.1", "system-deps 6.1.1",
] ]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.22.6" version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888"
dependencies = [ dependencies = [
"webpki", "rustls-webpki",
] ]
[[package]] [[package]]
@ -5554,10 +5636,6 @@ name = "whoami"
version = "1.4.1" version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50"
dependencies = [
"wasm-bindgen",
"web-sys",
]
[[package]] [[package]]
name = "winapi" name = "winapi"

@ -10,23 +10,27 @@
"format-check": "prettier --check ." "format-check": "prettier --check ."
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-node-resolve": "15.1.0",
"@rollup/plugin-terser": "^0.4.1", "@rollup/plugin-terser": "0.4.3",
"@rollup/plugin-typescript": "^11.1.0", "@rollup/plugin-typescript": "11.1.2",
"@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/eslint-plugin": "6.2.1",
"@typescript-eslint/parser": "^5.58.0", "@typescript-eslint/parser": "6.2.1",
"eslint": "^8.38.0", "eslint": "8.46.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "9.0.0",
"eslint-config-standard-with-typescript": "^35.0.0", "eslint-config-standard-with-typescript": "37.0.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "2.28.0",
"eslint-plugin-n": "^16.0.0", "eslint-plugin-n": "16.0.1",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "6.1.1",
"eslint-plugin-security": "^1.7.1", "eslint-plugin-security": "1.7.1",
"prettier": "^2.8.7", "prettier": "3.0.1",
"rollup": "^3.20.4", "rollup": "3.27.2",
"typescript": "^5.0.4" "typescript": "5.1.6"
},
"resolutions": {
"semver": ">=7.5.2",
"optionator": ">=0.9.3"
}, },
"engines": { "engines": {
"pnpm": ">=7.33.0" "pnpm": ">=7.33.1"
} }
} }

@ -76,7 +76,7 @@ const r2 = await auth.verifyRegistration(
challenge, challenge,
app, app,
registerResult.registerData, registerResult.registerData,
registerResult.clientData registerResult.clientData,
); );
const j2 = JSON.parse(r2); const j2 = JSON.parse(r2);
@ -91,7 +91,7 @@ const counter = await auth.verifySignature(
signData.signData, signData.signData,
clientData, clientData,
keyHandle, keyHandle,
pubkey pubkey,
); );
if (counter && counter > 0) { if (counter && counter > 0) {

@ -17,7 +17,7 @@ export class Authenticator {
challenge: string, challenge: string,
application: string, application: string,
registerData: string, registerData: string,
clientData: string clientData: string,
): Promise<string> { ): Promise<string> {
return await invoke("plugin:authenticator|verify_registration", { return await invoke("plugin:authenticator|verify_registration", {
challenge, challenge,
@ -30,7 +30,7 @@ export class Authenticator {
async sign( async sign(
challenge: string, challenge: string,
application: string, application: string,
keyHandle: string keyHandle: string,
): Promise<string> { ): Promise<string> {
return await invoke("plugin:authenticator|sign", { return await invoke("plugin:authenticator|sign", {
timeout: 10000, timeout: 10000,
@ -46,7 +46,7 @@ export class Authenticator {
signData: string, signData: string,
clientData: string, clientData: string,
keyHandle: string, keyHandle: string,
pubkey: string pubkey: string,
): Promise<number> { ): Promise<number> {
return await invoke("plugin:authenticator|verify_signature", { return await invoke("plugin:authenticator|verify_signature", {
challenge, challenge,

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -24,9 +24,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -57,17 +57,17 @@ import { watch, watchImmediate } from "tauri-plugin-fs-watch-api";
const stopWatching = await watch( const stopWatching = await watch(
"/path/to/something", "/path/to/something",
(event) => { (event) => {
const { type, payload } = event; const { kind, path } = event;
}, },
{ recursive: true } { recursive: true },
); );
const stopRawWatcher = await watchImmediate( const stopRawWatcher = await watchImmediate(
["/path/a", "/path/b"], ["/path/a", "/path/b"],
(event) => { (event) => {
const { path, operation, cookie } = event; const { type, paths, attrs } = event;
}, },
{} {},
); );
``` ```

@ -45,7 +45,7 @@ async function unwatch(id: number): Promise<void> {
export async function watch( export async function watch(
paths: string | string[], paths: string | string[],
cb: (event: DebouncedEvent) => void, cb: (event: DebouncedEvent) => void,
options: DebouncedWatchOptions = {} options: DebouncedWatchOptions = {},
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const opts = { const opts = {
recursive: false, recursive: false,
@ -71,7 +71,7 @@ export async function watch(
`watcher://debounced-event/${id}`, `watcher://debounced-event/${id}`,
(event) => { (event) => {
cb(event.payload); cb(event.payload);
} },
); );
return () => { return () => {
@ -83,7 +83,7 @@ export async function watch(
export async function watchImmediate( export async function watchImmediate(
paths: string | string[], paths: string | string[],
cb: (event: RawEvent) => void, cb: (event: RawEvent) => void,
options: WatchOptions = {} options: WatchOptions = {},
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
const opts = { const opts = {
recursive: false, recursive: false,
@ -109,7 +109,7 @@ export async function watchImmediate(
`watcher://raw-event/${id}`, `watcher://raw-event/${id}`,
(event) => { (event) => {
cb(event.payload); cb(event.payload);
} },
); );
return () => { return () => {

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -43,7 +43,7 @@ enum LogLevel {
async function log( async function log(
level: LogLevel, level: LogLevel,
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
const traces = new Error().stack?.split("\n").map((line) => line.split("@")); const traces = new Error().stack?.split("\n").map((line) => line.split("@"));
@ -86,7 +86,7 @@ async function log(
*/ */
export async function error( export async function error(
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
await log(LogLevel.Error, message, options); await log(LogLevel.Error, message, options);
} }
@ -108,7 +108,7 @@ export async function error(
*/ */
export async function warn( export async function warn(
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
await log(LogLevel.Warn, message, options); await log(LogLevel.Warn, message, options);
} }
@ -130,7 +130,7 @@ export async function warn(
*/ */
export async function info( export async function info(
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
await log(LogLevel.Info, message, options); await log(LogLevel.Info, message, options);
} }
@ -152,7 +152,7 @@ export async function info(
*/ */
export async function debug( export async function debug(
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
await log(LogLevel.Debug, message, options); await log(LogLevel.Debug, message, options);
} }
@ -174,7 +174,7 @@ export async function debug(
*/ */
export async function trace( export async function trace(
message: string, message: string,
options?: LogOptions options?: LogOptions,
): Promise<void> { ): Promise<void> {
await log(LogLevel.Trace, message, options); await log(LogLevel.Trace, message, options);
} }
@ -193,7 +193,7 @@ export async function attachConsole(): Promise<UnlistenFn> {
// TODO: Investigate security/detect-unsafe-regex // TODO: Investigate security/detect-unsafe-regex
// eslint-disable-next-line no-control-regex, security/detect-unsafe-regex // eslint-disable-next-line no-control-regex, security/detect-unsafe-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
"" "",
); );
switch (payload.level) { switch (payload.level) {

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -1,5 +1,15 @@
# Changelog # Changelog
## \[0.1.3]
- Split up fs and asset scopes. **This will reset the asset protocol scope once!**
- [ad30286](https://github.com/tauri-apps/plugins-workspace/commit/ad3028646c96ed213a2f483823ffdc3c17b5fc1e) fix(persisted-scope): separately save asset protocol patterns ([#459](https://github.com/tauri-apps/plugins-workspace/pull/459)) on 2023-07-10
## \[0.1.2]
- Fix usage of directory patterns by removing glob asterisks at the end before allowing/forbidding them. This was causing them to be escaped, and so undesirable paths were allowed/forbidden while polluting the `.persisted_scope` file.
- [9174b80](https://github.com/tauri-apps/plugins-workspace/commit/9174b808dc37154999c119fcc3f31258a9c5a3fb) \[persisted scope] fix: handle recursive directory correctly ([#455](https://github.com/tauri-apps/plugins-workspace/pull/455)) on 2023-06-29
## \[0.1.1] ## \[0.1.1]
- The MSRV was raised to 1.64! - The MSRV was raised to 1.64!

@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-persisted-scope" name = "tauri-plugin-persisted-scope"
version = "0.1.1" version = "0.1.3"
description = "Save filesystem and asset scopes and restore them when the app is reopened." description = "Save filesystem and asset scopes and restore them when the app is reopened."
authors.workspace = true authors.workspace = true
license.workspace = true license.workspace = true

@ -6,7 +6,7 @@ use aho_corasick::AhoCorasick;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tauri::{ use tauri::{
plugin::{Builder, TauriPlugin}, plugin::{Builder, TauriPlugin},
AppHandle, FsScopeEvent, Manager, Runtime, FsScope, FsScopeEvent, Manager, Runtime,
}; };
use std::{ use std::{
@ -15,7 +15,10 @@ use std::{
path::Path, path::Path,
}; };
// Using 2 separate files so that we don't have to think about write conflicts and not break backwards compat.
const SCOPE_STATE_FILENAME: &str = ".persisted-scope"; const SCOPE_STATE_FILENAME: &str = ".persisted-scope";
#[cfg(feature = "protocol-asset")]
const ASSET_SCOPE_STATE_FILENAME: &str = ".persisted-scope-asset";
// Most of these patterns are just added to try to fix broken files in the wild. // Most of these patterns are just added to try to fix broken files in the wild.
// After a while we can hopefully reduce it to something like [r"[?]", r"[*]", r"\\?\\\?\"] // After a while we can hopefully reduce it to something like [r"[?]", r"[*]", r"\\?\\\?\"]
@ -42,6 +45,14 @@ enum Error {
Bincode(#[from] Box<bincode::ErrorKind>), Bincode(#[from] Box<bincode::ErrorKind>),
} }
#[derive(Debug, Default, Deserialize, Serialize, Eq, PartialEq, Hash)]
enum TargetType {
#[default]
File,
Directory,
RecursiveDirectory,
}
#[derive(Debug, Default, Deserialize, Serialize)] #[derive(Debug, Default, Deserialize, Serialize)]
struct Scope { struct Scope {
allowed_paths: Vec<String>, allowed_paths: Vec<String>,
@ -58,16 +69,74 @@ fn fix_pattern(ac: &AhoCorasick, s: &str) -> String {
s s
} }
fn save_scopes<R: Runtime>(app: &AppHandle<R>, app_dir: &Path, scope_state_path: &Path) { const RESURSIVE_DIRECTORY_SUFFIX: &str = "**";
let fs_scope = app.fs_scope(); const DIRECTORY_SUFFIX: &str = "*";
fn detect_scope_type(scope_state_path: &str) -> TargetType {
if scope_state_path.ends_with(RESURSIVE_DIRECTORY_SUFFIX) {
TargetType::RecursiveDirectory
} else if scope_state_path.ends_with(DIRECTORY_SUFFIX) {
TargetType::Directory
} else {
TargetType::File
}
}
fn fix_directory(path_str: &str) -> &Path {
let mut path = Path::new(path_str);
if path.ends_with(DIRECTORY_SUFFIX) || path.ends_with(RESURSIVE_DIRECTORY_SUFFIX) {
path = match path.parent() {
Some(value) => value,
None => return path,
};
}
path
}
fn allow_path(scope: &FsScope, path: &str) {
let target_type = detect_scope_type(path);
match target_type {
TargetType::File => {
let _ = scope.allow_file(path);
}
TargetType::Directory => {
// We remove the '*' at the end of it, else it will be escaped by the pattern.
let _ = scope.allow_directory(fix_directory(path), false);
}
TargetType::RecursiveDirectory => {
// We remove the '**' at the end of it, else it will be escaped by the pattern.
let _ = scope.allow_directory(fix_directory(path), true);
}
}
}
fn forbid_path(scope: &FsScope, path: &str) {
let target_type = detect_scope_type(path);
match target_type {
TargetType::File => {
let _ = scope.forbid_file(path);
}
TargetType::Directory => {
let _ = scope.forbid_directory(fix_directory(path), false);
}
TargetType::RecursiveDirectory => {
let _ = scope.forbid_directory(fix_directory(path), true);
}
}
}
fn save_scopes(scope: &FsScope, app_dir: &Path, scope_state_path: &Path) {
let scope = Scope { let scope = Scope {
allowed_paths: fs_scope allowed_paths: scope
.allowed_patterns() .allowed_patterns()
.into_iter() .into_iter()
.map(|p| p.to_string()) .map(|p| p.to_string())
.collect(), .collect(),
forbidden_patterns: fs_scope forbidden_patterns: scope
.forbidden_patterns() .forbidden_patterns()
.into_iter() .into_iter()
.map(|p| p.to_string()) .map(|p| p.to_string())
@ -93,46 +162,74 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
let app_dir = app.path_resolver().app_data_dir(); let app_dir = app.path_resolver().app_data_dir();
if let Some(app_dir) = app_dir { if let Some(app_dir) = app_dir {
let scope_state_path = app_dir.join(SCOPE_STATE_FILENAME); let fs_scope_state_path = app_dir.join(SCOPE_STATE_FILENAME);
#[cfg(feature = "protocol-asset")]
let asset_scope_state_path = app_dir.join(ASSET_SCOPE_STATE_FILENAME);
let _ = fs_scope.forbid_file(&scope_state_path); let _ = fs_scope.forbid_file(&fs_scope_state_path);
#[cfg(feature = "protocol-asset")] #[cfg(feature = "protocol-asset")]
let _ = asset_protocol_scope.forbid_file(&scope_state_path); let _ = asset_protocol_scope.forbid_file(&asset_scope_state_path);
// We're trying to fix broken .persisted-scope files seamlessly, so we'll be running this on the values read on the saved file. // We're trying to fix broken .persisted-scope files seamlessly, so we'll be running this on the values read on the saved file.
// We will still save some semi-broken values because the scope events are quite spammy and we don't want to reduce runtime performance any further. // We will still save some semi-broken values because the scope events are quite spammy and we don't want to reduce runtime performance any further.
let ac = AhoCorasick::new(PATTERNS).unwrap(/* This should be impossible to fail since we're using a small static input */); let ac = AhoCorasick::new(PATTERNS).unwrap(/* This should be impossible to fail since we're using a small static input */);
if scope_state_path.exists() { if fs_scope_state_path.exists() {
let scope: Scope = tauri::api::file::read_binary(&scope_state_path) let scope: Scope = tauri::api::file::read_binary(&fs_scope_state_path)
.map_err(Error::from) .map_err(Error::from)
.and_then(|scope| bincode::deserialize(&scope).map_err(Into::into)) .and_then(|scope| bincode::deserialize(&scope).map_err(Into::into))
.unwrap_or_default(); .unwrap_or_default();
for allowed in &scope.allowed_paths { for allowed in &scope.allowed_paths {
let allowed = fix_pattern(&ac, allowed); let allowed = fix_pattern(&ac, allowed);
allow_path(&fs_scope, &allowed);
let _ = fs_scope.allow_file(&allowed);
#[cfg(feature = "protocol-asset")]
let _ = asset_protocol_scope.allow_file(&allowed);
} }
for forbidden in &scope.forbidden_patterns { for forbidden in &scope.forbidden_patterns {
let forbidden = fix_pattern(&ac, forbidden); let forbidden = fix_pattern(&ac, forbidden);
forbid_path(&fs_scope, &forbidden);
}
// Manually save the fixed scopes to disk once.
// This is needed to fix broken .peristed-scope files in case the app doesn't update the scope itself.
save_scopes(&fs_scope, &app_dir, &fs_scope_state_path);
}
let _ = fs_scope.forbid_file(&forbidden);
#[cfg(feature = "protocol-asset")] #[cfg(feature = "protocol-asset")]
let _ = asset_protocol_scope.forbid_file(&forbidden); if asset_scope_state_path.exists() {
let scope: Scope = tauri::api::file::read_binary(&asset_scope_state_path)
.map_err(Error::from)
.and_then(|scope| bincode::deserialize(&scope).map_err(Into::into))
.unwrap_or_default();
for allowed in &scope.allowed_paths {
let allowed = fix_pattern(&ac, allowed);
allow_path(&asset_protocol_scope, &allowed);
}
for forbidden in &scope.forbidden_patterns {
let forbidden = fix_pattern(&ac, forbidden);
forbid_path(&asset_protocol_scope, &forbidden);
} }
// Manually save the fixed scopes to disk once. // Manually save the fixed scopes to disk once.
// This is needed to fix broken .peristed-scope files in case the app doesn't update the scope itself. save_scopes(&asset_protocol_scope, &app_dir, &asset_scope_state_path);
save_scopes(&app, &app_dir, &scope_state_path);
} }
#[cfg(feature = "protocol-asset")]
let app_dir_ = app_dir.clone();
let fs_scope_ = fs_scope.clone();
fs_scope.listen(move |event| { fs_scope.listen(move |event| {
if let FsScopeEvent::PathAllowed(_) = event { if let FsScopeEvent::PathAllowed(_) = event {
save_scopes(&app, &app_dir, &scope_state_path); save_scopes(&fs_scope_, &app_dir, &fs_scope_state_path);
} }
}); });
#[cfg(feature = "protocol-asset")]
{
let asset_protocol_scope_ = asset_protocol_scope.clone();
asset_protocol_scope.listen(move |event| {
if let FsScopeEvent::PathAllowed(_) = event {
save_scopes(&asset_protocol_scope_, &app_dir_, &asset_scope_state_path);
}
});}
} }
Ok(()) Ok(())
}) })

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -9,6 +9,6 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^1.2.3" "@tauri-apps/cli": "1.4.0"
} }
} }

@ -1,106 +0,0 @@
lockfileVersion: 5.4
specifiers:
'@tauri-apps/cli': ^1.0.0
dependencies:
'@tauri-apps/cli': 1.0.2
packages:
/@tauri-apps/cli-darwin-arm64/1.0.2:
resolution: {integrity: sha512-Ahd951yoYon1+WLNBg6xsx6Bb7+GJt7WwC1FllHZ2/iLCbrtWCS2qfeLS0L4ngBqCuWyL35JC/M2LIr9mcUzrg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-darwin-x64/1.0.2:
resolution: {integrity: sha512-8wo+SN1zWoXFQVa/iyEt3Cs0vNMjxDXqVe3Srm4UNpgKboFN5mIgbugwqvM+aJKnEZAH8h8n+ZJUHzc4wtPGHA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-linux-arm-gnueabihf/1.0.2:
resolution: {integrity: sha512-PGQghMn0adt9PTnyi2K2o/CLG3tWbOyZvwQjam5cfQbK757WmMgPErC1VqsxiQc+PItWYvqoE9gjANiFc2MpAQ==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-linux-arm64-gnu/1.0.2:
resolution: {integrity: sha512-Uc+XNlWelrnRh7DYrdxBi8Oam9JAQM1GzgEwjupF6Pv7BwlODN7s0HImGPQOKrEkqzpfmYw7KpfgWiiEjS5/3Q==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-linux-arm64-musl/1.0.2:
resolution: {integrity: sha512-lVwCG1QzQs2zWP32H4+Dw8NKgJ6hBox2X+bmawGfV9Ce+K4P84bnqfNgpdaSAncjeiTjrO+g7yT9gJFQCOrjlQ==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-linux-x64-gnu/1.0.2:
resolution: {integrity: sha512-G2XmGxvufW9sgGhA3rx+HehcifVTUo8zyISd8DpvGwtpp6Z4WakbivzKFyGiNnnok0nvj/WUrLgBxtUbfdSY+A==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-linux-x64-musl/1.0.2:
resolution: {integrity: sha512-/eX536p+KXSmkFuINGeU6EQmYiQEXj6JXbmetmJmkXN0297HbtH3rS3wlyVDCnobRzh1hMeOJEnV+XA20GghMA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-win32-ia32-msvc/1.0.2:
resolution: {integrity: sha512-ZvnaKkCABqUbyUKlNk4RdxKyfOte30D5BxN1pj6iZNeKAwXEuTcgP6iPzOovdeaDirkIjcWCEZymwtZDXN4Rvg==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli-win32-x64-msvc/1.0.2:
resolution: {integrity: sha512-uMcQyQQD7nyxps34HyYBYUYzFwH26lP58/qdT/GZWvBL1Sv2rqkQXuxHT7xtp4g7nTs0fGRWOtfcnvYIr/1wDw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@tauri-apps/cli/1.0.2:
resolution: {integrity: sha512-OJdQJVwtKnTAuv2a9JQlOd0gHbbGsXwT+N6M6YQiXZ3/5WdlXey1zhnD78GXwZsf8Cz0R7QIGTBECO4ur4fnKg==}
engines: {node: '>= 10'}
hasBin: true
optionalDependencies:
'@tauri-apps/cli-darwin-arm64': 1.0.2
'@tauri-apps/cli-darwin-x64': 1.0.2
'@tauri-apps/cli-linux-arm-gnueabihf': 1.0.2
'@tauri-apps/cli-linux-arm64-gnu': 1.0.2
'@tauri-apps/cli-linux-arm64-musl': 1.0.2
'@tauri-apps/cli-linux-x64-gnu': 1.0.2
'@tauri-apps/cli-linux-x64-musl': 1.0.2
'@tauri-apps/cli-win32-ia32-msvc': 1.0.2
'@tauri-apps/cli-win32-x64-msvc': 1.0.2
dev: false

@ -5,7 +5,8 @@ description = "Interface with SQL databases."
authors.workspace = true authors.workspace = true
license.workspace = true license.workspace = true
edition.workspace = true edition.workspace = true
rust-version.workspace = true #rust-version.workspace = true
rust-version = "1.65"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -16,7 +17,7 @@ tauri.workspace = true
log.workspace = true log.workspace = true
thiserror.workspace = true thiserror.workspace = true
futures-core = "0.3" futures-core = "0.3"
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "json", "time"] } sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "json", "time"] }
time = "0.3" time = "0.3"
tokio = { version = "1", features = ["sync"] } tokio = { version = "1", features = ["sync"] }

@ -4,7 +4,7 @@ Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx)
## Install ## Install
_This plugin requires a Rust version of at least **1.64**_ _This plugin requires a Rust version of at least **1.65**_
There are three general methods of installation that we can recommend. There are three general methods of installation that we can recommend.
@ -65,6 +65,37 @@ const db = await Database.load("postgres://postgres:password@localhost/test");
await db.execute("INSERT INTO ..."); await db.execute("INSERT INTO ...");
``` ```
## Syntax
We use sqlx as our underlying library, adopting their query syntax:
- sqlite and postgres use the "$#" syntax when substituting query data
- mysql uses "?" when substituting query data
```javascript
// INSERT and UPDATE examples for sqlite and postgres
const result = await db.execute(
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
[todos.id, todos.title, todos.status],
);
const result = await db.execute(
"UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
[todos.title, todos.status, todos.id],
);
// INSERT and UPDATE examples for mysql
const result = await db.execute(
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
[todos.id, todos.title, todos.status],
);
const result = await db.execute(
"UPDATE todos SET title = ?, completed = ? WHERE id = ?",
[todos.title, todos.status, todos.id],
);
```
## Contributing ## Contributing
PRs accepted. Please make sure to read the Contributing Guide before making a pull request. PRs accepted. Please make sure to read the Contributing Guide before making a pull request.

@ -76,10 +76,29 @@ export default class Database {
* *
* @example * @example
* ```ts * ```ts
* // for sqlite & postgres
* // INSERT example
* const result = await db.execute(
* "INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
* [ todos.id, todos.title, todos.status ]
* );
* // UPDATE example
* const result = await db.execute( * const result = await db.execute(
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", * "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
* [ todos.title, todos.status, todos.id ] * [ todos.title, todos.status, todos.id ]
* ); * );
*
* // for mysql
* // INSERT example
* const result = await db.execute(
* "INSERT into todos (id, title, status) VALUES (?, ?, ?)",
* [ todos.id, todos.title, todos.status ]
* );
* // UPDATE example
* const result = await db.execute(
* "UPDATE todos SET title = ?, completed = ? WHERE id = ?",
* [ todos.title, todos.status, todos.id ]
* );
* ``` * ```
*/ */
async execute(query: string, bindValues?: unknown[]): Promise<QueryResult> { async execute(query: string, bindValues?: unknown[]): Promise<QueryResult> {
@ -89,15 +108,13 @@ export default class Database {
db: this.path, db: this.path,
query, query,
values: bindValues ?? [], values: bindValues ?? [],
} },
); );
return { return {
lastInsertId, lastInsertId,
rowsAffected, rowsAffected,
}; };
} }
/** /**
* **select** * **select**
* *
@ -105,9 +122,15 @@ export default class Database {
* *
* @example * @example
* ```ts * ```ts
* // for sqlite & postgres
* const result = await db.select( * const result = await db.select(
* "SELECT * from todos WHERE id = $1", id * "SELECT * from todos WHERE id = $1", id
* ); * );
*
* // for mysql
* const result = await db.select(
* "SELECT * from todos WHERE id = ?", id
* );
* ``` * ```
*/ */
async select<T>(query: string, bindValues?: unknown[]): Promise<T> { async select<T>(query: string, bindValues?: unknown[]): Promise<T> {

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -177,7 +177,7 @@ export class Store {
*/ */
async onKeyChange<T>( async onKeyChange<T>(
key: string, key: string,
cb: (value: T | null) => void cb: (value: T | null) => void,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return await listen<ChangePayload<T>>("store://change", (event) => { return await listen<ChangePayload<T>>("store://change", (event) => {
if (event.payload.path === this.path && event.payload.key === key) { if (event.payload.path === this.path && event.payload.key === key) {
@ -192,7 +192,7 @@ export class Store {
* @returns A promise resolving to a function to unlisten to the event. * @returns A promise resolving to a function to unlisten to the event.
*/ */
async onChange<T>( async onChange<T>(
cb: (key: string, value: T | null) => void cb: (key: string, value: T | null) => void,
): Promise<UnlistenFn> { ): Promise<UnlistenFn> {
return await listen<ChangePayload<T>>("store://change", (event) => { return await listen<ChangePayload<T>>("store://change", (event) => {
if (event.payload.path === this.path) { if (event.payload.path === this.path) {

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -16,7 +16,7 @@ tauri.workspace = true
log.workspace = true log.workspace = true
thiserror.workspace = true thiserror.workspace = true
iota_stronghold = "1" iota_stronghold = "1"
iota-crypto = "0.21" iota-crypto = "0.23"
hex = "0.4" hex = "0.4"
zeroize = { version = "1", features = ["zeroize_derive"] } zeroize = { version = "1", features = ["zeroize_derive"] }

@ -23,7 +23,7 @@ export type StoreKey =
| ArrayBuffer; | ArrayBuffer;
function toBytesDto( function toBytesDto(
v: ClientPath | VaultPath | RecordPath | StoreKey v: ClientPath | VaultPath | RecordPath | StoreKey,
): string | number[] { ): string | number[] {
if (typeof v === "string") { if (typeof v === "string") {
return v; return v;
@ -125,7 +125,7 @@ class ProcedureExecutor {
*/ */
async generateSLIP10Seed( async generateSLIP10Seed(
outputLocation: Location, outputLocation: Location,
sizeBytes?: number sizeBytes?: number,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await invoke<number[]>("plugin:stronghold|execute_procedure", { return await invoke<number[]>("plugin:stronghold|execute_procedure", {
...this.procedureArgs, ...this.procedureArgs,
@ -152,7 +152,7 @@ class ProcedureExecutor {
chain: number[], chain: number[],
source: "Seed" | "Key", source: "Seed" | "Key",
sourceLocation: Location, sourceLocation: Location,
outputLocation: Location outputLocation: Location,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await invoke<number[]>("plugin:stronghold|execute_procedure", { return await invoke<number[]>("plugin:stronghold|execute_procedure", {
...this.procedureArgs, ...this.procedureArgs,
@ -181,7 +181,7 @@ class ProcedureExecutor {
async recoverBIP39( async recoverBIP39(
mnemonic: string, mnemonic: string,
outputLocation: Location, outputLocation: Location,
passphrase?: string passphrase?: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await invoke<number[]>("plugin:stronghold|execute_procedure", { return await invoke<number[]>("plugin:stronghold|execute_procedure", {
...this.procedureArgs, ...this.procedureArgs,
@ -205,7 +205,7 @@ class ProcedureExecutor {
*/ */
async generateBIP39( async generateBIP39(
outputLocation: Location, outputLocation: Location,
passphrase?: string passphrase?: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await invoke<number[]>("plugin:stronghold|execute_procedure", { return await invoke<number[]>("plugin:stronghold|execute_procedure", {
...this.procedureArgs, ...this.procedureArgs,
@ -245,7 +245,7 @@ class ProcedureExecutor {
*/ */
async signEd25519( async signEd25519(
privateKeyLocation: Location, privateKeyLocation: Location,
msg: string msg: string,
): Promise<Uint8Array> { ): Promise<Uint8Array> {
return await invoke<number[]>("plugin:stronghold|execute_procedure", { return await invoke<number[]>("plugin:stronghold|execute_procedure", {
...this.procedureArgs, ...this.procedureArgs,
@ -310,7 +310,7 @@ export class Store {
async insert( async insert(
key: StoreKey, key: StoreKey,
value: number[], value: number[],
lifetime?: Duration lifetime?: Duration,
): Promise<void> { ): Promise<void> {
return await invoke("plugin:stronghold|save_store_record", { return await invoke("plugin:stronghold|save_store_record", {
snapshotPath: this.path, snapshotPath: this.path,
@ -328,7 +328,7 @@ export class Store {
snapshotPath: this.path, snapshotPath: this.path,
client: this.client, client: this.client,
key: toBytesDto(key), key: toBytesDto(key),
} },
).then((v) => (v != null ? Uint8Array.from(v) : null)); ).then((v) => (v != null ? Uint8Array.from(v) : null));
} }
} }

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -58,7 +58,7 @@ upload(
"https://example.com/file-upload", "https://example.com/file-upload",
"./path/to/my/file.txt", "./path/to/my/file.txt",
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress (progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress
{ "Content-Type": "text/plain" } // optional headers to send with the request { "Content-Type": "text/plain" }, // optional headers to send with the request
); );
``` ```
@ -69,7 +69,7 @@ download(
"https://example.com/file-download-link", "https://example.com/file-download-link",
"./path/to/save/my/file.txt", "./path/to/save/my/file.txt",
(progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress (progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress
{ "Content-Type": "text/plain" } // optional headers to send with the request { "Content-Type": "text/plain" }, // optional headers to send with the request
); );
``` ```

@ -31,7 +31,7 @@ async function upload(
url: string, url: string,
filePath: string, filePath: string,
progressHandler?: ProgressHandler, progressHandler?: ProgressHandler,
headers?: Map<string, string> headers?: Map<string, string>,
): Promise<void> { ): Promise<void> {
const ids = new Uint32Array(1); const ids = new Uint32Array(1);
window.crypto.getRandomValues(ids); window.crypto.getRandomValues(ids);
@ -59,7 +59,7 @@ async function download(
url: string, url: string,
filePath: string, filePath: string,
progressHandler?: ProgressHandler, progressHandler?: ProgressHandler,
headers?: Map<string, string> headers?: Map<string, string>,
): Promise<void> { ): Promise<void> {
const ids = new Uint32Array(1); const ids = new Uint32Array(1);
window.crypto.getRandomValues(ids); window.crypto.getRandomValues(ids);

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -18,4 +18,4 @@ thiserror.workspace = true
rand = "0.8" rand = "0.8"
futures-util = "0.3" futures-util = "0.3"
tokio = { version = "1", features = ["net", "sync"] } tokio = { version = "1", features = ["net", "sync"] }
tokio-tungstenite = { version = "0.19", features = ["native-tls"] } tokio-tungstenite = { version = "0.20", features = ["native-tls"] }

@ -11,14 +11,14 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "2.1.0",
"@sveltejs/kit": "^1.15.5", "@sveltejs/kit": "1.22.4",
"@tauri-apps/cli": "^1.2.3", "@tauri-apps/cli": "1.4.0",
"svelte": "^3.58.0", "svelte": "4.1.2",
"svelte-check": "^3.2.0", "svelte-check": "3.4.6",
"tslib": "^2.5.0", "tslib": "2.6.1",
"typescript": "^5.0.4", "typescript": "5.1.6",
"vite": "^4.2.1" "vite": "4.4.9"
}, },
"dependencies": { "dependencies": {
"tauri-plugin-websocket-api": "link:../../" "tauri-plugin-websocket-api": "link:../../"

@ -2774,9 +2774,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-tungstenite" name = "tokio-tungstenite"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2"
dependencies = [ dependencies = [
"futures-util", "futures-util",
"log", "log",
@ -2806,9 +2806,9 @@ dependencies = [
[[package]] [[package]]
name = "tungstenite" name = "tungstenite"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"bytes", "bytes",

@ -13,7 +13,7 @@ tauri = { version = "1", features = [] }
tokio = { version = "1", features = ["net"] } tokio = { version = "1", features = ["net"] }
futures-util = "0.3" futures-util = "0.3"
tauri-plugin-websocket = { path = "../../../" } tauri-plugin-websocket = { path = "../../../" }
tokio-tungstenite = "0.19" tokio-tungstenite = "0.20"
[build-dependencies] [build-dependencies]
tauri-build = { version = "1", features = [] } tauri-build = { version = "1", features = [] }

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />

@ -53,7 +53,7 @@ export default class WebSocket {
m = { type: "Binary", data: message }; m = { type: "Binary", data: message };
} else { } else {
throw new Error( throw new Error(
"invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array" "invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array",
); );
} }
return await invoke("plugin:websocket|send", { return await invoke("plugin:websocket|send", {

@ -24,9 +24,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -45,7 +45,8 @@ struct ConnectionManager(Mutex<HashMap<Id, WebSocketWriter>>);
#[derive(Default, Deserialize)] #[derive(Default, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ConnectionConfig { pub struct ConnectionConfig {
pub max_send_queue: Option<usize>, pub write_buffer_size: Option<usize>,
pub max_write_buffer_size: Option<usize>,
pub max_message_size: Option<usize>, pub max_message_size: Option<usize>,
pub max_frame_size: Option<usize>, pub max_frame_size: Option<usize>,
pub accept_unmasked_frames: bool, pub accept_unmasked_frames: bool,
@ -53,9 +54,15 @@ pub struct ConnectionConfig {
impl From<ConnectionConfig> for WebSocketConfig { impl From<ConnectionConfig> for WebSocketConfig {
fn from(config: ConnectionConfig) -> Self { fn from(config: ConnectionConfig) -> Self {
// Disabling the warning on max_send_queue which we don't use anymore since it was deprecated.
#[allow(deprecated)]
Self { Self {
max_send_queue: config.max_send_queue, max_send_queue: None,
write_buffer_size: config.write_buffer_size.unwrap_or(128 * 1024),
max_write_buffer_size: config.max_write_buffer_size.unwrap_or(usize::MAX),
// This may be harmful since if it's not provided from js we're overwriting the default value with None, meaning no size limit.
max_message_size: config.max_message_size, max_message_size: config.max_message_size,
// This may be harmful since if it's not provided from js we're overwriting the default value with None, meaning no size limit.
max_frame_size: config.max_frame_size, max_frame_size: config.max_frame_size,
accept_unmasked_frames: config.accept_unmasked_frames, accept_unmasked_frames: config.accept_unmasked_frames,
} }

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

@ -23,7 +23,7 @@ async function saveWindowState(flags: StateFlags): Promise<void> {
*/ */
async function restoreState( async function restoreState(
label: WindowLabel, label: WindowLabel,
flags: StateFlags flags: StateFlags,
): Promise<void> { ): Promise<void> {
return invoke("plugin:window-state|restore_state", { label, flags }); return invoke("plugin:window-state|restore_state", { label, flags });
} }

@ -25,9 +25,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.5.0" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../../shared/rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../../shared/tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}

File diff suppressed because it is too large Load Diff

@ -24,9 +24,9 @@
"LICENSE" "LICENSE"
], ],
"devDependencies": { "devDependencies": {
"tslib": "^2.4.1" "tslib": "2.6.1"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0" "@tauri-apps/api": "1.4.0"
} }
} }

@ -5,7 +5,7 @@ import { createConfig } from "../rollup.config.mjs";
export default createConfig({ export default createConfig({
input: "guest-js/index.ts", input: "guest-js/index.ts",
pkg: JSON.parse( pkg: JSON.parse(
readFileSync(new URL("./package.json", import.meta.url), "utf8") readFileSync(new URL("./package.json", import.meta.url), "utf8"),
), ),
external: [/^@tauri-apps\/api/], external: [/^@tauri-apps\/api/],
}); });

@ -1 +0,0 @@
../tsconfig.json

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["guest-js/*.ts"]
}
Loading…
Cancel
Save