@sponsorkit/sdk/server
Backend verification of a supporter's session token. No storage; runs in Workers.
@sponsorkit/sdk/server: backend verification. Works in Node,
Bun, Deno, Cloudflare Workers and browsers; touches no storage.
import { … } from "@sponsorkit/sdk/server";Example#
import { verifySession } from "@sponsorkit/sdk/server";
const fc = await verifySession(tokenFromFrontend, { github: "octocat" });
if (fc.active().length > 0) unlockPremium();Exports#
Interfaces#
| Name | Summary |
|---|---|
VerifySessionOptions | Options for verifySession. |
Functions#
| Name | Summary |
|---|---|
verifySession | Verifies a supporter's session token (sks_…) forwarded by your frontend and returns their live contributions for targets. |
Re-exported#
This entry point also exports these symbols, documented under @sponsorkit/sdk:
CheckoutOptions, CheckoutResult, Contribution, ContributionKind, ContributionResult, ContributionStatus, FetchLike, FinancialContribution, Frequency, Identity, isSponsorkitError, MockOption, MockPreset, Money, NagState, Provider, PROVIDERS, SponsorEntity, SPONSORKIT_ERROR_CODES, SponsorkitError, SponsorkitErrorCode, StorageFile, Supporter, TargetInfo, TargetOptions, TargetTier
Functions#
verifySession()#
async function verifySession(
token: string,
targets: TargetOptions | string | readonly string[],
options: VerifySessionOptions = {},
): Promise<FinancialContribution>Verifies a supporter's session token (sks_…) forwarded by your frontend and
returns their live contributions for targets.
Throws SponsorkitError with code:
invalid_config:targetsis missing or malformed;session_invalid: the token is missing, malformed, expired or rejected;targets_mismatch: the session was issued for a different target set;network_error: Sponsorkit could not be reached, answered 5xx or 429, or sent an unexpected response.retryAfterholds the seconds fromRetry-Afterwhen the API sent one (e.g. on 429).
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
token | string | required | |
targets | TargetOptions | string | readonly string[] | required | { github?, openCollective? }, a canonical target param, or a list of target strings. See TargetOptions. |
options | VerifySessionOptions | {} | See VerifySessionOptions. |
Returns Promise<FinancialContribution> (FinancialContribution)