184 lines
4.8 KiB
Rust
184 lines
4.8 KiB
Rust
//! Records crossing the JS boundary. Same fields as kv-ffi's UniFFI records, in camelCase; enums are
|
|
//! camelCase strings (`"login"`, `"secureNote"`, `"pendingApproval"`); byte fields are `Uint8Array`.
|
|
//! The TypeScript declarations for these live in `wasm.rs` (`TS_TYPES`); keep both in step.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum ItemKindDto {
|
|
Login,
|
|
SecureNote,
|
|
Card,
|
|
Identity,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum MatchLevelDto {
|
|
None,
|
|
Domain,
|
|
Host,
|
|
Exact,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum PlatformDto {
|
|
Ios,
|
|
Macos,
|
|
Android,
|
|
Windows,
|
|
Linux,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ItemSummary {
|
|
pub id: String,
|
|
pub kind: ItemKindDto,
|
|
pub title: String,
|
|
pub username: Option<String>,
|
|
pub urls: Vec<String>,
|
|
pub favorite: bool,
|
|
pub has_totp: bool,
|
|
/// Web only (not in kv-ffi's record): for tag filters and "recently modified" without `getItem`.
|
|
pub tags: Vec<String>,
|
|
pub modified_at: i64,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ItemDto {
|
|
/// Empty string means "new item".
|
|
#[serde(default)]
|
|
pub id: String,
|
|
pub kind: ItemKindDto,
|
|
pub title: String,
|
|
#[serde(default)]
|
|
pub username: Option<String>,
|
|
#[serde(default)]
|
|
pub password: Option<String>,
|
|
#[serde(default)]
|
|
pub urls: Vec<String>,
|
|
#[serde(default)]
|
|
pub totp: Option<String>,
|
|
#[serde(default)]
|
|
pub notes: Option<String>,
|
|
#[serde(default)]
|
|
pub favorite: bool,
|
|
#[serde(default)]
|
|
pub tags: Vec<String>,
|
|
#[serde(default)]
|
|
pub modified_at: i64,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TotpCode {
|
|
pub code: String,
|
|
pub seconds_remaining: u64,
|
|
pub period: u64,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ServerInfoDto {
|
|
pub version: String,
|
|
pub api: u32,
|
|
pub setup_open: bool,
|
|
pub min_client: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum LoginResult {
|
|
/// Logged in and unlocked.
|
|
Ok,
|
|
/// An enrolled device must approve this browser (or pass `totp`); call `login` again afterwards.
|
|
PendingApproval,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct SyncReport {
|
|
pub pulled: u32,
|
|
pub pushed: u32,
|
|
pub merged: u32,
|
|
pub restored_item_ids: Vec<String>,
|
|
pub vaults_synced: u32,
|
|
pub vaults_skipped: u32,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct DeviceDto {
|
|
pub device_id: String,
|
|
pub name: String,
|
|
pub platform: PlatformDto,
|
|
pub approved: bool,
|
|
pub revoked: bool,
|
|
pub current: bool,
|
|
pub created_at: String,
|
|
pub key_fingerprint: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct PasskeySummary {
|
|
pub item_id: String,
|
|
#[serde(with = "serde_bytes")]
|
|
pub credential_id: Vec<u8>,
|
|
pub rp_id: String,
|
|
#[serde(with = "serde_bytes")]
|
|
pub user_handle: Vec<u8>,
|
|
pub user_name: String,
|
|
pub created_at: i64,
|
|
}
|
|
|
|
/// `{ type: "onePux" } | { type: "csv" } | { type: "kestroveEncrypted", passphrase }`.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "camelCase")]
|
|
pub enum ImportFormat {
|
|
OnePux,
|
|
Csv,
|
|
KestroveEncrypted { passphrase: String },
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum DuplicateHandling {
|
|
Skip,
|
|
AddSuffix,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ImportOptions {
|
|
pub duplicates: DuplicateHandling,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ImportPreview {
|
|
pub total: u32,
|
|
pub logins: u32,
|
|
pub secure_notes: u32,
|
|
pub cards: u32,
|
|
pub identities: u32,
|
|
pub duplicates: u32,
|
|
pub attachments_skipped: u32,
|
|
pub warnings: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ImportReport {
|
|
pub imported: u32,
|
|
pub skipped_duplicates: u32,
|
|
pub renamed_duplicates: u32,
|
|
pub attachments_skipped: u32,
|
|
pub warnings: Vec<String>,
|
|
pub item_ids: Vec<String>,
|
|
}
|