Skip to main content

origin_connector/
lib.rs

1//! The connector contract (ADR-0006).
2//!
3//! A connector declares *what* it is and how to reach it. The platform decides *when*
4//! to talk to it. It is deliberately small: scheduling and sync targets arrive in
5//! Phase 3, once there is a second connector to validate the shape against (ADR-0009).
6
7mod descriptor;
8mod registry;
9
10pub use descriptor::{AccountIdentity, AuthKind, ConnectorDescriptor};
11pub use registry::ConnectorRegistry;
12
13use async_trait::async_trait;
14use origin_domain::{AccountId, ConnectorId, Result};
15use std::fmt::Debug;
16
17/// An integration with one external service.
18#[async_trait]
19pub trait Connector: Debug + Send + Sync + 'static {
20    fn id(&self) -> ConnectorId;
21
22    /// What this connector is and what it needs. Used by the settings UI and by the
23    /// permission review — a connector cannot quietly widen its scopes.
24    fn descriptor(&self) -> ConnectorDescriptor;
25
26    /// Prove that an account's credentials still work, and report who they belong to.
27    ///
28    /// This is the one operation every connector must support. It is what turns
29    /// "we have a token" into "we have a working account", and it runs after
30    /// authorization and whenever credentials are suspected to be stale.
31    ///
32    /// Returns `AppError::Authentication` when the credentials are no longer valid —
33    /// the platform reacts by marking the account expired, not by retrying.
34    async fn verify(&self, account: &AccountId) -> Result<AccountIdentity>;
35}