chore: Merge branch v1 into v2 (#702)
parent
d4d1633c4d
commit
251852ccbc
@ -0,0 +1,5 @@
|
||||
---
|
||||
"sql": patch
|
||||
---
|
||||
|
||||
Fixed an issue where float-like values were decoded as `null`.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
"stronghold": patch
|
||||
---
|
||||
|
||||
Added `Builder::with_argon2`.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
"positioner": patch
|
||||
---
|
||||
|
||||
`TrayLeft`, `TrayRight` and `TrayCenter` will now position the window according to the tray position relative to the monitor dimensions to prevent windows being displayed partially off-screen.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
"upload": patch
|
||||
---
|
||||
|
||||
Use `BufWriter` to reduce IO calls.
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
"websocket": patch
|
||||
"websocket-js": patch
|
||||
---
|
||||
|
||||
Add support for custom request headers.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
use rand_core::{RngCore, SeedableRng};
|
||||
use std::path::Path;
|
||||
|
||||
/// NOTE: Hash supplied to Stronghold must be 32bits long.
|
||||
/// This is a current limitation of Stronghold.
|
||||
const HASH_LENGTH: usize = 32;
|
||||
|
||||
pub struct KeyDerivation {}
|
||||
|
||||
impl KeyDerivation {
|
||||
/// Will create a key from [`password`] and a generated salt.
|
||||
/// Salt will be generated to file [`salt_path`] or taken from it
|
||||
/// if file already exists
|
||||
pub fn argon2(password: &str, salt_path: &Path) -> Vec<u8> {
|
||||
let mut salt = [0u8; HASH_LENGTH];
|
||||
create_or_get_salt(&mut salt, salt_path);
|
||||
|
||||
argon2::hash_raw(password.as_bytes(), &salt, &Default::default())
|
||||
.expect("Failed to generate hash for password")
|
||||
}
|
||||
}
|
||||
|
||||
fn create_or_get_salt(salt: &mut [u8], salt_path: &Path) {
|
||||
if salt_path.is_file() {
|
||||
// Get existing salt
|
||||
let tmp = std::fs::read(salt_path).unwrap();
|
||||
salt.clone_from_slice(&tmp);
|
||||
} else {
|
||||
// Generate new salt
|
||||
let mut gen = ChaCha20Rng::from_entropy();
|
||||
gen.fill_bytes(salt);
|
||||
std::fs::write(salt_path, salt).expect("Failed to write salt for Stronghold")
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
if("__TAURI__"in window){var __TAURI_WEBSOCKET__=function(){"use strict";function e(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}var t;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,t.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((r=>{e(this,t,"f").call(this,r)}))}set onmessage(e){!function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?s.call(e,r):s?s.value=r:t.set(e,r)}(this,t,e,"f")}get onmessage(){return e(this,t,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function n(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}t=new WeakMap;class s{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const i=[],a=new r;return a.onmessage=e=>{i.forEach((t=>t(e)))},await n("plugin:websocket|connect",{url:e,onMessage:a,config:t}).then((e=>new s(e,i)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return await n("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return s}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})}
|
||||
if("__TAURI__"in window){var __TAURI_WEBSOCKET__=function(){"use strict";function e(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}var t;"function"==typeof SuppressedError&&SuppressedError;class r{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,t.set(this,(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((r=>{e(this,t,"f").call(this,r)}))}set onmessage(e){!function(e,t,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?s.call(e,r):s?s.value=r:t.set(e,r)}(this,t,e,"f")}get onmessage(){return e(this,t,"f")}toJSON(){return`__CHANNEL__:${this.id}`}}async function n(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}t=new WeakMap;class s{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,t){const a=[],i=new r;return i.onmessage=e=>{a.forEach((t=>t(e)))},(null==t?void 0:t.headers)&&(t.headers=Array.from(new Headers(t.headers).entries())),await n("plugin:websocket|connect",{url:e,onMessage:i,config:t}).then((e=>new s(e,a)))}addListener(e){this.listeners.push(e)}async send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return await n("plugin:websocket|send",{id:this.id,message:t})}async disconnect(){return await this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}return s}();Object.defineProperty(window.__TAURI__,"websocket",{value:__TAURI_WEBSOCKET__})}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["guest-js/*.ts"]
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["guest-js/*.ts"]
|
||||
}
|
Loading…
Reference in new issue