Docs API reference JavaScript / TypeScript API reference JavaScript / TypeScript API reference Every public class, interface, type, function and constant of @sponsorkit/sdk 1.0.0, generated from the TypeScript source.
On this page Generated from the TypeScript source and doc comments of @sponsorkit/sdk 1.0.0. For installation, sign-in flows and worked examples, see the JavaScript / TypeScript guide .
Copy code
npm install @sponsorkit/sdk
Entry points#
The package has four entry points. Pick one by where your code runs; they share the same types, error codes and result shape.
All symbols#
Classes#
Name Entry point Summary FinancialContribution@sponsorkit/sdkA ContributionResult with filter helpers. Sponsorkit@sponsorkit/sdkSponsorkit client for browsers. Sponsorkit@sponsorkit/sdk/nodeSponsorkit client for native runtimes. SponsorkitBadgeElement@sponsorkit/sdk/elements<sponsorkit-badge github open-collective>: shows "Supporter ♥" when the signed-in user has an active contribution, and nothing otherwise.SponsorkitButtonElement@sponsorkit/sdk/elements<sponsorkit-button github open-collective amount currency frequency provider>: opens checkout (synchronously, in a popup) when clicked.SponsorkitCore@sponsorkit/sdkBase class with the shared client behaviour. SponsorkitError@sponsorkit/sdkThe only error type thrown by the SDK.
Interfaces#
Type aliases#
Name Entry point Summary CheckoutResult@sponsorkit/sdkThe outcome of openCheckout(). ContributionKind@sponsorkit/sdkWhether a contribution recurs. ContributionStatus@sponsorkit/sdkNormalized contribution status. Env@sponsorkit/sdkAn environment map (process.env-shaped). FetchLike@sponsorkit/sdkA fetch-compatible function. Frequency@sponsorkit/sdkHow often a contribution is charged. MockOption@sponsorkit/sdkMock mode: a preset name, or custom contributions to report as the signed-in supporter's. MockPreset@sponsorkit/sdkThe names of the built-in mock presets. NagPredicate@sponsorkit/sdkA predicate deciding whether the current supporter should see the nag. Provider@sponsorkit/sdkA contribution platform supported by Sponsorkit. SignInMethod@sponsorkit/sdk/nodeHow native sign-in delivers the code. SponsorkitErrorCode@sponsorkit/sdkError codes carried by SponsorkitError .
Functions#
Name Entry point Summary browserCommand@sponsorkit/sdk/nodeThe command used to open a URL on platform. canonicalTargets@sponsorkit/sdkDeduplicates and sorts (byte-wise) a target set; at least one target, at most one per provider. codeChallenge@sponsorkit/sdkPKCE S256: base64url(sha256(ascii(verifier))). createCodeVerifier@sponsorkit/sdkA new PKCE code_verifier: 32 random bytes, base64url (43 characters). defaultStorageDir@sponsorkit/sdk/nodeThe per-user Sponsorkit directory: $XDG_CONFIG_HOME/sponsorkit (Linux, default $HOME/.config), $HOME/Library/Application Support/sponsorkit (macOS), %APPDATA%\sponsorkit (Windows, default %USERPROFILE%\AppData\Roaming). defineElements@sponsorkit/sdk/elementsRegisters the elements (idempotent). fileStorage@sponsorkit/sdk/nodeStores one <targets_hash>.json file per target set in dir. isSponsorkitError@sponsorkit/sdkTrue if error is a SponsorkitError (optionally with the given code). localStorageAdapter@sponsorkit/sdkWraps a Web Storage object (default: localStorage) using the key sponsorkit:<targets_hash>. memoryStorage@sponsorkit/sdkIn-memory storage. normalizeTarget@sponsorkit/sdkNormalizes and validates one target. openSystemBrowser@sponsorkit/sdk/nodeOpens url (http/https only) in the system browser. parseTarget@sponsorkit/sdkParses provider:account. resetProcessState@sponsorkit/sdkForgets per-process state: nag runs already counted, the dev-check memo and the Retry-After memo. targetsFrom@sponsorkit/sdkBuilds the canonical target set from { github?, openCollective? }, a target param string, or a list of target strings. targetsHash@sponsorkit/sdktargets_hash: lowercase hex SHA-256 of the UTF-8 target param (storage key).targetsParam@sponsorkit/sdkThe canonical target param: github:x,open-collective:y. targetToString@sponsorkit/sdkgithub:<login> / open-collective:<slug>.verifySession@sponsorkit/sdk/serverVerifies a supporter's session token (sks_…) forwarded by your frontend and returns their live contributions for targets.
Constants#
Conventions#
Durations in options are seconds (cacheTtl, signInTimeout, requestTimeout, timeout); amounts are minor units (cents) with an ISO 4217 currency.
Every error the SDK throws is a SponsorkitError with a code . getFinancialContribution() never throws for network or server problems. See Error contract .
Cancellation uses the standard AbortSignal.