Skip to content

Commit b9cf6e4

Browse files
peterpeterparkerarckoorKeatscoryanscovetta
authored
feat: redo ic_cdk patch (#10)
* feat: use ic-sdk instead of js-sys (#3) * feat: update toml for publishing fork (#4) * docs: update readme introduction for publishing fork (#5) * feat: alias compiled library with original name for usage (#6) * chore: make rust_crypto the default feature for publishing (#7) * build: bump ic_cdk to v0.19.0 (#8) * chore: update version for release * Rebase upstream sync and integrate v10.3.0 (#9) * Expose cryptography backends via CryptoProvider (Keats#452) * Bump action number in CI * Bump some dep * Use try_sign to avoid panics (Keats#479) Closes Keats#473 * fix: bump minimal version requirements (Keats#481) Before these changes this fails: ``` cargo minimal-versions check --no-default-features --features aws_lc_rs ``` * Fix type confusion * Fix formatting in Ed25519 key serialization (Keats#485) In the thumbprint() function, the serialized format of the Ed25519 curve is missing double quotes around "crv", which would likely affect interoperability between other implementations. Fixes Keats#484 * feat: redo * chore: merge main * docs: redo * chore: set version --------- Co-authored-by: arckoor <33837362+arckoor@users.noreply.github.com> Co-authored-by: Vincent Prouillet <github@vincentprouillet.com> Co-authored-by: Vincent Prouillet <balthek@gmail.com> Co-authored-by: Carlos O'Ryan <coryan@google.com> Co-authored-by: Michael Scovetta <michael.scovetta@gmail.com> * build: bump rust version in ci for ic_cdk timer * chore: merge main --------- Co-authored-by: arckoor <33837362+arckoor@users.noreply.github.com> Co-authored-by: Vincent Prouillet <github@vincentprouillet.com> Co-authored-by: Vincent Prouillet <balthek@gmail.com> Co-authored-by: Carlos O'Ryan <coryan@google.com> Co-authored-by: Michael Scovetta <michael.scovetta@gmail.com>
1 parent 9934c7f commit b9cf6e4

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
include:
4242
- build: pinned
4343
os: ubuntu-24.04
44-
rust: 1.86.0
44+
rust: 1.94.0
4545
- build: stable
4646
os: ubuntu-latest
4747
rust: stable

Cargo.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
2-
name = "jsonwebtoken"
3-
version = "10.3.0"
4-
authors = ["Vincent Prouillet <hello@vincentprouillet.com>"]
2+
name = "jsonwebtoken-ic"
3+
version = "10.3.0-ic.0"
4+
authors = ["Vincent Prouillet <hello@vincentprouillet.com>", "David Dal Busco <david@fluster.io>"]
55
license = "MIT"
66
readme = "README.md"
7-
description = "Create and decode JWTs in a strongly typed way."
8-
homepage = "https://github.com/Keats/jsonwebtoken"
9-
repository = "https://github.com/Keats/jsonwebtoken"
7+
description = "A fork of jsonwebtoken for the Internet Computer."
8+
homepage = "https://github.com/peterpeterparker/jsonwebtoken-ic"
9+
repository = "https://github.com/peterpeterparker/jsonwebtoken-ic"
10+
documentation = "https://docs.rs/jsonwebtoken-ic"
1011
keywords = ["jwt", "api", "token", "jwk"]
1112
edition = "2024"
1213
include = [
@@ -19,6 +20,9 @@ include = [
1920
]
2021
rust-version = "1.85.0"
2122

23+
[lib]
24+
name = "jsonwebtoken"
25+
2226
[package.metadata.docs.rs]
2327
features = ["rust_crypto"]
2428

@@ -45,7 +49,7 @@ rsa = { version = "0.9.6", optional = true }
4549
sha2 = { version = "0.10.7", optional = true, features = ["oid"] }
4650

4751
[target.'cfg(target_arch = "wasm32")'.dependencies]
48-
js-sys = "0.3"
52+
ic-cdk = "0.19.0"
4953
getrandom = "0.2"
5054

5155
[dev-dependencies]
@@ -64,7 +68,7 @@ time = { version = "0.3", features = ["wasm-bindgen"] }
6468
criterion = { version = "0.8", default-features = false }
6569

6670
[features]
67-
default = ["use_pem"]
71+
default = ["use_pem", "rust_crypto"]
6872
use_pem = ["pem", "simple_asn1"]
6973
rust_crypto = ["ed25519-dalek", "hmac", "p256", "p384", "rand", "rsa", "sha2"]
7074
aws_lc_rs = ["aws-lc-rs"]

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# jsonwebtoken
1+
# jsonwebtoken-ic
22

3-
[API documentation on docs.rs](https://docs.rs/jsonwebtoken/)
3+
[API documentation on docs.rs](https://docs.rs/jsonwebtoken-ic/)
44

55
See [JSON Web Tokens](https://en.wikipedia.org/wiki/JSON_Web_Token) for more information on what JSON Web Tokens are.
66

7+
> [!IMPORTANT]
8+
> This is a fork of [`jsonwebtoken`](https://github.com/Keats/jsonwebtoken) for the [Internet Computer](https://internetcomputer.org).
9+
> Check out the amazing upstream project.
10+
711
## Installation
812
Add the following to Cargo.toml:
913

1014
```toml
11-
# You will have to select either `aws_lc_rs` or `rust_crypto` as backend if you're not using your own
12-
jsonwebtoken = { version = "10", features = ["aws_lc_rs"] }
13-
# If you do not need pem decoding, you can disable the default feature `use_pem` that way:
14-
# jsonwebtoken = {version = "10", default-features = false, features = ["aws_lc_rs"] }
15+
# You have to select `rust_crypto`
16+
jsonwebtoken = { version = "10.3.0-ic.", default-features = false, features = ["rust_crypto"] }
1517
serde = {version = "1.0", features = ["derive"] }
1618
```
1719

src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub fn get_current_timestamp() -> u64 {
183183
#[cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))]
184184
#[must_use]
185185
pub fn get_current_timestamp() -> u64 {
186-
js_sys::Date::new_0().get_time() as u64 / 1000
186+
(ic_cdk::api::time() / 1_000_000_000) as u64
187187
}
188188

189189
#[derive(Deserialize)]

0 commit comments

Comments
 (0)