oriko-core

Crates.iooriko-core
lib.rsoriko-core
version0.1.1
created_at2025-12-29 22:27:37.475252+00
updated_at2025-12-31 21:50:43.960645+00
descriptionVoudo Oriko core utilities - database, auth, and encryption
homepage
repositoryhttps://github.com/your-org/email-apps
max_upload_size
id2011588
size83,099
(cbeninati)

documentation

README

oriko-core

Voudo Oriko core utilities - database, authentication, and encryption.

Installation

Add to your Cargo.toml:

[dependencies]
oriko-core = { path = "../packages/oriko-core" }
# Or from crates.io (when published)
# oriko-core = "0.1.0"

Features

Database

use oriko_core::Database;

// Create or open a database
let mut db = Database::new("/path/to/database.db")?;

// Get connection
let conn = db.connection();

Authentication

use oriko_core::{OAuthFlow, OAuthProvider, GmailCredentials, run_gmail_oauth_flow};

// Run OAuth flow
let credentials = GmailCredentials::from_env()
    .ok_or("Missing credentials")?;

let (tokens, user_info) = run_gmail_oauth_flow(credentials).await?;

Encryption

use oriko_core::{encrypt_tokens, decrypt_tokens};
use std::path::Path;

let app_data_dir = Path::new("/app/data");
let tokens_json = r#"{"access_token": "..."}"#;

// Encrypt
let encrypted = encrypt_tokens(app_data_dir, tokens_json)?;

// Decrypt
let decrypted = decrypt_tokens(app_data_dir, &encrypted)?;

API

Database

  • Database::new(path) - Create or open database
  • Database::connection() - Get read-only connection
  • Database::connection_mut() - Get mutable connection

Authentication

  • OAuthFlow::new(provider, credentials, redirect_port) - Create OAuth flow
  • OAuthFlow::generate_auth_url() - Generate authorization URL
  • OAuthFlow::exchange_code(code) - Exchange authorization code for tokens
  • run_gmail_oauth_flow(credentials) - Complete Gmail OAuth flow
  • fetch_user_info(access_token) - Fetch user information
  • refresh_access_token(refresh_token, credentials) - Refresh access token

Encryption

  • encrypt_tokens(app_data_dir, tokens_json) - Encrypt tokens
  • decrypt_tokens(app_data_dir, encrypted_hex) - Decrypt tokens
Commit count: 0

cargo fmt