Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 08bb37f

Browse files
fix(jsonwebtoken): make Claims.data optional
1 parent 940e063 commit 08bb37f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎packages/jsonwebtoken/index.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const enum Algorithm {
3030
EdDSA = 11,
3131
}
3232
export interface Claims {
33-
data: Record<string, any>
33+
data?: Record<string, any>
3434
aud?: string
3535
exp?: Number
3636
iat?: Number

‎packages/jsonwebtoken/src/claims.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use serde_json::{Map, Number, Value};
55
#[napi(object)]
66
#[derive(Debug, Serialize, Deserialize)]
77
pub struct Claims {
8-
pub data: Map<String, Value>,
8+
#[serde(skip_serializing_if = "Option::is_none")]
9+
pub data: Option<Map<String, Value>>,
910
// Recipient for which the JWT is intended
1011
#[serde(skip_serializing_if = "Option::is_none")]
1112
pub aud: Option<String>,
@@ -49,7 +50,7 @@ impl Default for Claims {
4950
#[inline]
5051
fn default() -> Self {
5152
Self {
52-
data: Map::new(),
53+
data: Some(Map::new()),
5354
aud: None,
5455
exp: None,
5556
iat: Some(jsonwebtoken::get_current_timestamp().into()),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /