Skip to content

Commit

Permalink
Fix unit of claims expiry (#7106)
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan authored Dec 20, 2024
1 parent 5c89b25 commit a0b36eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
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
2 changes: 1 addition & 1 deletion backend/integration_tests/src/diamond_membership_tests.rs
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

0 comments on commit a0b36eb

Please sign in to comment.