Skip to content

Commit 9d9cdb3

Browse files
committed
CR: Names
1 parent 246a548 commit 9d9cdb3

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

livekit-api/src/access_token.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub struct Claims {
152152
}
153153

154154
impl Claims {
155-
pub fn with_unverified(token: &str) -> Result<Self, AccessTokenError> {
155+
pub fn from_unverified(token: &str) -> Result<Self, AccessTokenError> {
156156
let mut validation = jsonwebtoken::Validation::new(jsonwebtoken::Algorithm::HS256);
157157
validation.validate_exp = true;
158158
#[cfg(test)]
@@ -408,7 +408,7 @@ mod tests {
408408

409409
#[test]
410410
fn test_unverified_token() {
411-
let claims = Claims::with_unverified(TEST_TOKEN).expect("Failed to parse token");
411+
let claims = Claims::from_unverified(TEST_TOKEN).expect("Failed to parse token");
412412

413413
assert_eq!(claims.sub, "identity");
414414
assert_eq!(claims.name, "name");
@@ -432,7 +432,7 @@ mod tests {
432432
.to_jwt()
433433
.unwrap();
434434

435-
let claims = Claims::with_unverified(&token).expect("Failed to parse fresh token");
435+
let claims = Claims::from_unverified(&token).expect("Failed to parse fresh token");
436436
assert_eq!(claims.sub, "test");
437437
assert_eq!(claims.name, "test");
438438
assert_eq!(claims.video.room, "test-room");
@@ -441,7 +441,7 @@ mod tests {
441441
let parts: Vec<&str> = token.split('.').collect();
442442
let malformed_token = format!("{}.{}.wrongsignature", parts[0], parts[1]);
443443

444-
let claims = Claims::with_unverified(&malformed_token).expect("Failed to parse token with wrong signature");
444+
let claims = Claims::from_unverified(&malformed_token).expect("Failed to parse token with wrong signature");
445445
assert_eq!(claims.sub, "test");
446446
assert_eq!(claims.name, "test");
447447
}

livekit-uniffi/python_test/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def main():
1515

1616
credentials = ApiCredentials(key="devkey", secret="secret")
1717

18-
jwt = generate_token(
18+
jwt = token_generate(
1919
options=TokenOptions(room_name="test", identity="some_participant"),
2020
credentials=credentials,
2121
)
2222
print(f"Generated JWT: {jwt}")
2323

24-
decoded_grants = verify_token(
24+
decoded_grants = token_verify(
2525
token=jwt,
2626
credentials=credentials,
2727
)

livekit-uniffi/src/access_token.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub struct TokenOptions {
140140
/// variables `LIVEKIT_API_KEY` and `LIVEKIT_SECRET` respectively.
141141
///
142142
#[uniffi::export]
143-
pub fn generate_token(
143+
pub fn token_generate(
144144
options: TokenOptions,
145145
credentials: Option<ApiCredentials>,
146146
) -> Result<String, AccessTokenError> {
@@ -187,7 +187,7 @@ pub fn generate_token(
187187
/// variables `LIVEKIT_API_KEY` and `LIVEKIT_SECRET` respectively.
188188
///
189189
#[uniffi::export]
190-
pub fn verify_token(
190+
pub fn token_verify(
191191
token: &str,
192192
credentials: Option<ApiCredentials>,
193193
) -> Result<Claims, AccessTokenError> {
@@ -208,7 +208,7 @@ pub fn verify_token(
208208
/// WARNING: Do not use this for authentication - the signature is not verified!
209209
///
210210
#[uniffi::export]
211-
pub fn unverified_token(token: &str) -> Result<Claims, AccessTokenError> {
212-
let claims = access_token::Claims::with_unverified(token)?;
211+
pub fn token_claims_from_unverified(token: &str) -> Result<Claims, AccessTokenError> {
212+
let claims = access_token::Claims::from_unverified(token)?;
213213
Ok(claims.into())
214214
}

0 commit comments

Comments
 (0)