Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit of claims expiry #7106

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Change bot cmd number param values from u16 to f64 ([#7095](https://github.com/open-chat-labs/open-chat/pull/7095))
- Rename access token `parameters` to `command_args` ([#7104](https://github.com/open-chat-labs/open-chat/pull/7104))

### Fixes

- Fix unit of claims expiry ([#7106](https://github.com/open-chat-labs/open-chat/pull/7106))

## [[2.0.1530](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1530-local_user_index)] - 2024-12-19

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use types::User;
use crate::read_state;
use crate::RuntimeState;

#[update(candid = true, msgpack = true)]
#[update(candid = true)]
async fn execute_bot_command(args: Args) -> Response {
let c2c_args = match read_state(|state| validate(args, state)) {
Ok(c2c_args) => c2c_args,
Expand Down
4 changes: 2 additions & 2 deletions backend/integration_tests/src/client/local_user_index.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{generate_msgpack_query_call, generate_msgpack_update_call};
use crate::{generate_msgpack_query_call, generate_msgpack_update_call, generate_update_call};
use local_user_index_canister::*;

// Queries
Expand All @@ -7,7 +7,7 @@ generate_msgpack_query_call!(chat_events);
generate_msgpack_query_call!(group_and_community_summary_updates);

// Updates
generate_msgpack_update_call!(execute_bot_command);
generate_update_call!(execute_bot_command);
generate_msgpack_update_call!(invite_users_to_channel);
generate_msgpack_update_call!(invite_users_to_community);
generate_msgpack_update_call!(invite_users_to_group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn can_upgrade_to_diamond(pay_in_chat: bool, lifetime: bool) {
let public_key = client::user_index::happy_path::public_key(env, canister_ids.user_index);
let claims: Claims<DiamondMembershipDetails> = verify_jwt(&diamond_response.proof_jwt, &public_key).unwrap();

let claims_expiry = claims.exp() * 1000;
let claims_expiry = claims.exp();
assert!(now < claims_expiry && claims_expiry < now + DAY_IN_MS);
assert_eq!(claims.claim_type(), "diamond_membership");
assert_eq!(claims.custom().expires_at, diamond_response.expires_at);
Expand Down
4 changes: 2 additions & 2 deletions backend/libraries/jwt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ impl<T> Claims<T> {
}
}

pub fn exp(&self) -> u64 {
self.exp
pub fn exp(&self) -> TimestampMillis {
self.exp * 1000
}

pub fn claim_type(&self) -> &str {
Expand Down
Loading