server module
Backend verification: check a session token your frontend sent you.
Backend verification: check a session token your frontend sent you.
use sponsorkit::{Targets, server::verify_session};
let fc = verify_session(token, &Targets::github("octocat")).await?;
let supporter = fc.signed_in && !fc.active().is_empty();use sponsorkit::server;Structs#
| Name | Description |
|---|---|
VerifyOptions | Options for verify_session_with. |
Functions and constants#
| Name | Kind | Description |
|---|---|---|
verify_session | function | Verifies a session token against https://api.sponsorkit.io and returns its live result. |
verify_session_with | function | Calls GET /api/v1/contributions with the token and checks that the session is bound to exactly targets (canonical comparison). |
Functions#
verify_session#
pub async fn verify_session(
token: &str,
targets: &Targets,
) -> Result<ContributionResult>Verifies a session token against https://api.sponsorkit.io and returns its live result.
See verify_session_with.
| Parameter | Type |
|---|---|
token | &str |
targets | &Targets |
Returns: Result<ContributionResult> (see Result, ContributionResult)
verify_session_with#
pub async fn verify_session_with(
token: &str,
targets: &Targets,
options: VerifyOptions,
) -> Result<ContributionResult>Calls GET /api/v1/contributions with the token and checks that the
session is bound to exactly targets (canonical comparison). Touches no
local storage and never serves a cache.
Errors: invalid_config (bad targets or api_base_url),
session_invalid, targets_mismatch, and network_error when the answer
could not be verified: the API is unreachable, did not answer within the
request timeout, or answered 5xx, 429 or something unexpected. On 429, Error::retry_after carries the
Retry-After the API sent.
| Parameter | Type |
|---|---|
token | &str |
targets | &Targets |
options | VerifyOptions |
Returns: Result<ContributionResult> (see Result, ContributionResult)