Skip to content

Commit

Permalink
fixup! Expose the QR code parsing structs used by the QR login mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed May 21, 2024
1 parent e922f08 commit 4be534b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/qr_login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct QrCodeData {
#[wasm_bindgen]
impl QrCodeData {
/// Create new [`QrCodeData`] from a given public key, a rendezvous URL and,
/// optionally, a homeserver ULR.
/// optionally, a homeserver URL.
///
/// If a homeserver URL is given, then the [`QrCodeData`] mode will be
/// [`QrCodeMode::Reciprocate`], i.e. the QR code will contain data for the
Expand Down Expand Up @@ -93,25 +93,28 @@ impl QrCodeData {
Ok(Self { inner: qr_login::QrCodeData::from_base64(data)? })
}

/// Encode the [`QrCodeData`] into a list of bytes.
/// Encode the [`QrCodeData`] into a string using base64.
///
/// The list of bytes can be used by a QR code generator to create an image
/// containing a QR code.
/// This format can be used for debugging purposes and the
/// [`QrcodeData::from_base64()`] method can be used to parse the string
/// again.
pub fn to_base64(&self) -> String {
self.inner.to_base64()
}

/// Get the Curve25519 public key embedded in the [`QrCodeData`].
///
/// This Curve25519 public key should be used to establish an ECIES channel
/// with the other device.
/// This Curve25519 public key should be used to establish an
/// [ECIES](https://en.wikipedia.org/wiki/Integrated_Encryption_Scheme)
/// (Elliptic Curve Integrated Encryption Scheme) channel with the other
/// device.
#[wasm_bindgen(getter)]
pub fn public_key(&self) -> Curve25519PublicKey {
self.inner.public_key.into()
}

/// Get the URL of the rendezvous server which will be used to exchange
/// devices between the two devices.
/// messages between the two devices.
#[wasm_bindgen(getter)]
pub fn rendezvous_url(&self) -> String {
self.inner.rendezvous_url.as_str().to_owned()
Expand Down

0 comments on commit 4be534b

Please sign in to comment.