1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! Small building blocks for Twitch integrations.
//!
//! `barbed` currently includes:
//!
//! - OAuth authorize URL construction and signed state verification
//! - Helix request builders and response parsers
//! - EventSub WebSocket payload decoding and chat subscription helpers
//! - IRC parsing plus an optional native async IRC client
//! - Checked-in Twitch API/EventSub/auth catalogs with generated low-level registries
//! - Provider-neutral emote models shared across Twitch/7TV/BTTV/FFZ helpers
//! - HMAC signing helpers for short-lived tokens and state payloads
//!
//! The default crate stays runtime-agnostic. Enable the `cloudflare-worker`
//! feature to send [`http::PreparedRequest`] values via the Cloudflare
//! Workers `Fetch` API. Enable the `reqwest-client`, `tokio-eventsub`,
//! and `tokio-irc` features for native Rust runtime helpers. Optional
//! provider crates are re-exported behind `seventv`, `bttv`, and `ffz`
//! feature flags.
//!
//! # Feature Flags
//!
//! - `cloudflare-worker`: adds transport helpers built on the Cloudflare
//! Workers `Fetch` API.
//! - `reqwest-client`: adds native HTTP helpers built on `reqwest`.
//! - `tokio-eventsub`: adds the native EventSub websocket client/runtime.
//! - `tokio-irc`: adds the native Twitch IRC client/runtime.
//! - `seventv`, `bttv`, `ffz`: re-export the corresponding provider crates.
//! - `seventv-reqwest`, `bttv-reqwest`, `ffz-reqwest`: enable reqwest-based
//! HTTP clients in the provider crates.
//!
//! # MSRV
//!
//! `barbed` currently targets Rust `1.85.0`.
//!
//! # Example
//!
//! ```rust
//! use barbed::http::percent_decode;
//! use barbed::oauth::{OAuthStatePayload, build_authorize_url, verify_oauth_state};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
//! struct AuthState {
//! redirect_to: String,
//! expires_at_ms: i64,
//! }
//!
//! impl OAuthStatePayload for AuthState {
//! fn expires_at_ms(&self) -> i64 {
//! self.expires_at_ms
//! }
//! }
//!
//! let state = AuthState {
//! redirect_to: "/dashboard".to_string(),
//! expires_at_ms: 1_700_000_060_000,
//! };
//!
//! let authorize_url = build_authorize_url(
//! "client-id",
//! "https://example.com/twitch/callback",
//! &["user:read:chat"],
//! &state,
//! "super-secret",
//! )?;
//!
//! let encoded_state = authorize_url
//! .split("&state=")
//! .nth(1)
//! .expect("missing state parameter");
//! let signed_state = percent_decode(encoded_state)?;
//! let verified: AuthState =
//! verify_oauth_state("super-secret", &signed_state, 1_700_000_000_000)?;
//!
//! assert_eq!(verified, state);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! This crate is intentionally small and still settling; expect API breakage
//! across `0.0.x` releases.
/// Re-exported provider-neutral emote types shared across workspace crates.
/// EventSub payload types and websocket subscription helpers.
/// Helix request builders and response parsers.
/// Percent-encoding and form-body helpers used by the request builders.
/// Identity types for authenticated Twitch users.
/// IRC parsing plus optional native async Twitch IRC transport helpers.
/// Native async helpers for OAuth, Helix, and EventSub interactions.
/// OAuth URL construction, token lifecycle helpers, and signed state handling.
/// Shared auth/session abstractions and in-memory implementations.
/// Shared HMAC signing helpers for short-lived payloads.
/// Checked-in Twitch surface catalogs generated from the published docs.
/// Cloudflare Workers transport helpers for prepared Twitch API requests.
/// Backwards-compatible alias for the legacy `client` module path.
/// Re-export of the core Twitch identity model.
pub use TwitchIdentity;
/// Re-export of the optional 7TV provider crate.
/// Re-export of the optional BetterTTV provider crate.
/// Re-export of the optional FrankerFaceZ provider crate.