Skip to main content

systemprompt_identifiers/
oauth.rs

1//! OAuth flow identifiers.
2//!
3//! Refresh tokens, access-token `jti`s and authorization codes are opaque
4//! strings minted by the platform or presented back by a client. Their only
5//! shape is non-emptiness: `new` is for a value the platform minted or read
6//! back from storage, `try_new` for a value arriving from outside.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11crate::define_id!(RefreshTokenId, checked, |value| {
12    crate::macros::validate_non_empty("RefreshTokenId", value)
13});
14crate::define_id!(AccessTokenId, checked, |value| {
15    crate::macros::validate_non_empty("AccessTokenId", value)
16});
17crate::define_id!(AuthorizationCode, checked, |value| {
18    crate::macros::validate_non_empty("AuthorizationCode", value)
19});
20crate::define_id!(ChallengeId);
21
22impl AccessTokenId {
23    pub fn generate() -> Self {
24        Self(uuid::Uuid::new_v4().to_string())
25    }
26}
27
28impl ChallengeId {
29    pub fn generate() -> Self {
30        Self(uuid::Uuid::new_v4().to_string())
31    }
32}