Skip to content

Commit 3bc307a

Browse files
committed
Move wasm32-unknown-unknown with JS env support behind js feature
1 parent 381e9f6 commit 3bc307a

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
target:
2020
-
2121
features:
22-
-
23-
- derive
24-
- hmac-sha1
22+
- js
23+
- js,derive
24+
- js,hmac-sha1
2525
include:
2626
- toolchain: stable
27-
features: ''
27+
features: js
2828
target: wasm32-unknown-unknown
2929
steps:
3030
- uses: actions/checkout@v2

oauth1-request/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ either = { version = "1.2", optional = true }
3030
hmac = { version = "0.11", optional = true }
3131
sha-1 = { version = "0.9", optional = true }
3232

33+
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
34+
# `js` feature
35+
js-sys = { version = "0.3", optional = true }
36+
3337
[dev-dependencies]
3438
# Trick to make `proc-macro-crate` work in doctests.
3539
oauth1-request = { version = "0.5", path = "", default-features = false }
3640
version-sync = "0.9"
3741

38-
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
39-
js-sys = "0.3"
40-
4142
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
4243
getrandom = { version = "0.2", features = ["js"] }
4344
wasm-bindgen-test = "0.3"
@@ -46,4 +47,5 @@ wasm-bindgen-test = "0.3"
4647
default = ["derive", "hmac-sha1"]
4748
derive = ["oauth1-request-derive"]
4849
hmac-sha1 = ["hmac", "sha-1"]
50+
js = ["js-sys"]
4951
serde = ["oauth-credentials/serde"]

oauth1-request/src/serializer/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'a, SM: SignatureMethod> Serializer for Authorizer<'a, SM> {
276276
fn get_current_timestamp() -> u64 {
277277
cfg_if::cfg_if! {
278278
// `std::time::SystemTime::now` is not supported and panics on `wasm32-unknown-unknown` target
279-
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
279+
if #[cfg(all(feature = "js", target_arch = "wasm32", target_os = "unknown"))] {
280280
(js_sys::Date::now() / 1000.0) as u64
281281
} else {
282282
use std::time::{SystemTime, UNIX_EPOCH};

0 commit comments

Comments
 (0)