Skip to content

Commit 386225b

Browse files
committed
Merge branch 'feature/ci' into development
2 parents 9da9a64 + 18b47ce commit 386225b

8 files changed

Lines changed: 75 additions & 64 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli/src/deploy/known_hosts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
/// ```sh
3030
/// ssh-keyscan -t ed25519 api.smbcloud.xyz api-1.smbcloud.xyz 2>/dev/null
3131
/// ```
32-
3332
/// Pinned ed25519 host key for `api.smbcloud.xyz` (NodeJs / Static tier).
3433
pub const API_SMBCLOUD_XYZ: &str =
3534
"api.smbcloud.xyz ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINGy4LHGyOilS7SXo770V3tQnXDRVQr7X7JsPLCfy4XB";

crates/smbcloud-auth-sdk-py/src/lib.rs

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#![allow(unexpected_cfgs, unsafe_op_in_unsafe_fn)]
2+
// The #[pyfunction] macro generates FFI wrapper code that calls From<PyErr>::from(err)
3+
// on the error path of every wrapped function. Since PyErr: From<PyErr> is the identity
4+
// impl, clippy flags it as useless_conversion. We cannot change macro-generated code,
5+
// so suppress the lint at crate level.
6+
#![allow(clippy::useless_conversion)]
27

38
use pyo3::{
49
create_exception,
@@ -67,7 +72,7 @@ fn serialize<'py, T>(py: Python<'py>, value: &T) -> PyResult<PyObject>
6772
where
6873
T: Serialize,
6974
{
70-
Ok(pythonize(py, value)?.unbind().into())
75+
Ok(pythonize(py, value)?.unbind())
7176
}
7277

7378
fn login_payload(status: AccountStatus) -> LoginPayload {
@@ -120,18 +125,18 @@ fn signup_with_client(
120125
email: &str,
121126
password: &str,
122127
) -> PyResult<PyObject> {
123-
let env = parse_env(env)?;
124-
let client = client_credentials(app_id, app_secret);
125-
let result = runtime()
126-
.block_on(rust_signup_with_client(
127-
env,
128-
client,
129-
email.to_string(),
130-
password.to_string(),
131-
))
132-
.map_err(native_error)?;
133-
134-
serialize(py, &result)
128+
parse_env(env).and_then(|env| {
129+
let client = client_credentials(app_id, app_secret);
130+
runtime()
131+
.block_on(rust_signup_with_client(
132+
env,
133+
client,
134+
email.to_string(),
135+
password.to_string(),
136+
))
137+
.map_err(native_error)
138+
.and_then(|result| serialize(py, &result))
139+
})
135140
}
136141

137142
#[pyfunction]
@@ -143,19 +148,19 @@ fn login_with_client(
143148
email: &str,
144149
password: &str,
145150
) -> PyResult<PyObject> {
146-
let env = parse_env(env)?;
147-
let client = client_credentials(app_id, app_secret);
148-
let result = runtime()
149-
.block_on(rust_login_with_client(
150-
env,
151-
client,
152-
email.to_string(),
153-
password.to_string(),
154-
))
155-
.map(login_payload)
156-
.map_err(native_error)?;
157-
158-
serialize(py, &result)
151+
parse_env(env).and_then(|env| {
152+
let client = client_credentials(app_id, app_secret);
153+
runtime()
154+
.block_on(rust_login_with_client(
155+
env,
156+
client,
157+
email.to_string(),
158+
password.to_string(),
159+
))
160+
.map(login_payload)
161+
.map_err(native_error)
162+
.and_then(|result| serialize(py, &result))
163+
})
159164
}
160165

161166
#[pyfunction]
@@ -165,16 +170,16 @@ fn logout_with_client(
165170
app_secret: &str,
166171
access_token: &str,
167172
) -> PyResult<()> {
168-
let env = parse_env(env)?;
169-
let client = client_credentials(app_id, app_secret);
170-
171-
runtime()
172-
.block_on(rust_logout_with_client(
173-
env,
174-
client,
175-
access_token.to_string(),
176-
))
177-
.map_err(native_error)
173+
parse_env(env).and_then(|env| {
174+
let client = client_credentials(app_id, app_secret);
175+
runtime()
176+
.block_on(rust_logout_with_client(
177+
env,
178+
client,
179+
access_token.to_string(),
180+
))
181+
.map_err(native_error)
182+
})
178183
}
179184

180185
#[pyfunction]
@@ -185,13 +190,13 @@ fn me_with_client(
185190
app_secret: &str,
186191
access_token: &str,
187192
) -> PyResult<PyObject> {
188-
let env = parse_env(env)?;
189-
let client = client_credentials(app_id, app_secret);
190-
let result = runtime()
191-
.block_on(rust_me_with_client(env, client, access_token))
192-
.map_err(native_error)?;
193-
194-
serialize(py, &result)
193+
parse_env(env).and_then(|env| {
194+
let client = client_credentials(app_id, app_secret);
195+
runtime()
196+
.block_on(rust_me_with_client(env, client, access_token))
197+
.map_err(native_error)
198+
.and_then(|result| serialize(py, &result))
199+
})
195200
}
196201

197202
#[pyfunction]
@@ -201,12 +206,12 @@ fn remove_with_client(
201206
app_secret: &str,
202207
access_token: &str,
203208
) -> PyResult<()> {
204-
let env = parse_env(env)?;
205-
let client = client_credentials(app_id, app_secret);
206-
207-
runtime()
208-
.block_on(rust_remove_with_client(env, client, access_token))
209-
.map_err(native_error)
209+
parse_env(env).and_then(|env| {
210+
let client = client_credentials(app_id, app_secret);
211+
runtime()
212+
.block_on(rust_remove_with_client(env, client, access_token))
213+
.map_err(native_error)
214+
})
210215
}
211216

212217
#[pymodule(name = "_native")]

crates/smbcloud-auth-sdk-wasm/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ smbcloud-networking = { workspace = true }
3030
smbcloud-auth-sdk = { workspace = true }
3131
wasm-bindgen = { workspace = true }
3232
wasm-bindgen-futures = "0.4.50"
33+
34+
# uuid's v4 feature needs a randomness source on wasm32-unknown-unknown.
35+
# The `js` feature wires it to the Web Crypto API (crypto.getRandomValues).
36+
# This only activates when building for wasm32 targets.
37+
[target.'cfg(target_arch = "wasm32")'.dependencies]
38+
uuid = { version = "1", features = ["js"] }

crates/smbcloud-auth-sdk/src/apple.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ pub fn parse_callback_url(
8787
});
8888
}
8989

90-
if let Some(expected_state) = expected_state {
91-
if state.as_deref() != Some(expected_state) {
92-
return Err(ErrorResponse::Error {
93-
error_code: ErrorCode::InvalidParams,
94-
message: "Apple callback state mismatch.".to_string(),
95-
});
96-
}
90+
if let Some(expected_state) = expected_state
91+
&& state.as_deref() != Some(expected_state)
92+
{
93+
return Err(ErrorResponse::Error {
94+
error_code: ErrorCode::InvalidParams,
95+
message: "Apple callback state mismatch.".to_string(),
96+
});
9797
}
9898

9999
Ok(AppleAuthSession {

crates/smbcloud-model/src/runner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use {
44
serde_repr::{Deserialize_repr, Serialize_repr},
55
std::{
66
fmt::{self, Display, Formatter},
7-
path::PathBuf,
7+
path::Path,
88
},
99
};
1010

@@ -54,7 +54,7 @@ pub enum SwiftFramework {
5454
}
5555

5656
impl Runner {
57-
pub fn from(repo_path: &PathBuf) -> Result<Runner, ErrorResponse> {
57+
pub fn from(repo_path: &Path) -> Result<Runner, ErrorResponse> {
5858
// Any package.json-driven app belongs on the NodeJs runner.
5959
// Framework-specific checks are not reliable because modern Next.js apps
6060
// do not need a next.config.* file at all.

crates/smbcloud-network/src/network.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ pub async fn request_login(builder: RequestBuilder) -> Result<AccountStatus, Err
206206
message: error_code.to_string(),
207207
})
208208
}
209-
(status, _) => parse_error_response(response).await.or_else(|_| {
210-
Err(ErrorResponse::Error {
209+
(status, _) => parse_error_response(response)
210+
.await
211+
.map_err(|_| ErrorResponse::Error {
211212
error_code: ErrorCode::NetworkError,
212213
message: format!("Unexpected login response status: {}", status),
213-
})
214-
}),
214+
}),
215215
}
216216
}
217217

sdk/npm/smbcloud-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@smbcloud/sdk-auth",
33
"description": "Browser Auth SDK for smbCloud, built from Rust and WebAssembly.",
4-
"version": "0.3.34",
4+
"version": "0.3.35",
55
"type": "module",
66
"main": "dist/smbcloud_auth_wasm.js",
77
"module": "dist/smbcloud_auth_wasm.js",

0 commit comments

Comments
 (0)