Skip to content

Commit

Permalink
return authorization field as part of ClientToken
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyatmax committed Jan 17, 2025
1 parent 0c23798 commit e80aea0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/y-sweet-core/src/api_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub struct NewDocResponse {
pub doc_id: String,
}

#[derive(Serialize, Deserialize)]
#[derive(Copy, Clone, Serialize, Deserialize)]
pub enum Authorization {
#[serde(rename = "read-only")]
ReadOnly,
Expand Down Expand Up @@ -59,6 +59,10 @@ pub struct ClientToken {
/// An optional token that can be used to authenticate the client to the server.
#[serde(skip_serializing_if = "Option::is_none")]
pub token: Option<String>,

/// The authorization level of the client.
#[serde(rename = "authorization")]
pub authorization: Authorization,
}

#[derive(Deserialize, Debug)]
Expand Down
1 change: 1 addition & 0 deletions crates/y-sweet/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ async fn auth_doc(
base_url: Some(base_url),
doc_id,
token,
authorization,
}))
}

Expand Down
3 changes: 3 additions & 0 deletions js-pkg/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export type ClientToken = {

/** A string that grants the bearer access to the document. By default, the development server does not require a token. */
token?: string

/** The authorization level of the client. */
authorization?: Authorization
}

export type CheckStoreResult = { ok: true } | { ok: false; error: string }
Expand Down

0 comments on commit e80aea0

Please sign in to comment.