@sponsorkit/sdk/node
Native client for CLIs and desktop apps (loopback or paste-back sign-in, per-user config directory).
On this page
@sponsorkit/sdk/node: the Sponsorkit client for Node.js, Bun and Deno
(CLIs, desktop apps, servers acting for one user). Sign-in uses a loopback
redirect to the system browser, or paste-back when headless; state lives in
the per-user config directory.
import { … } from "@sponsorkit/sdk/node";Example#
import { Sponsorkit } from "@sponsorkit/sdk/node";
const sk = new Sponsorkit({ github: "octocat", appName: "my-cli" });
const fc = await sk.getFinancialContribution();Exports#
Classes#
| Name | Summary |
|---|---|
Sponsorkit | Sponsorkit client for native runtimes. |
Interfaces#
| Name | Summary |
|---|---|
NodeOpenCheckoutOptions | Native openCheckout() options. |
NodeSignInOptions | Native signIn() options. |
SponsorkitOptions | Options for the native client. |
Type aliases#
| Name | Summary |
|---|---|
SignInMethod | How native sign-in delivers the code. |
Functions#
| Name | Summary |
|---|---|
browserCommand | The command used to open a URL on platform. |
defaultStorageDir | The 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). |
fileStorage | Stores one <targets_hash>.json file per target set in dir. |
openSystemBrowser | Opens url (http/https only) in the system browser. |
Re-exported#
This entry point also exports these symbols, documented under @sponsorkit/sdk:
canonicalTargets, CheckoutOptions, CheckoutResult, codeChallenge, Contribution, ContributionKind, ContributionResult, ContributionStatus, createCodeVerifier, DEFAULT_API_BASE_URL, DEFAULT_CACHE_TTL, DEFAULT_CHECKOUT_POLL_INTERVAL, DEFAULT_CHECKOUT_TIMEOUT, DEFAULT_SIGN_IN_TIMEOUT, DEFAULT_SITE_BASE_URL, Env, FetchLike, FinancialContribution, Frequency, Identity, isSponsorkitError, localStorageAdapter, memoryStorage, MOCK_PRESETS, MockOption, MockPreset, Money, Nag, NagDueOptions, NagOptions, NagPredicate, NagState, normalizeTarget, OpenCheckoutOptions, parseTarget, Provider, PROVIDERS, resetProcessState, SignInOptions, SponsorEntity, SPONSORKIT_ERROR_CODES, SponsorkitCore, SponsorkitCoreOptions, SponsorkitError, SponsorkitErrorCode, SponsorkitStorage, StorageFile, Supporter, Target, TargetInfo, TargetOptions, targetsFrom, targetsHash, targetsParam, TargetTier, targetToString, WebStorageLike
Functions#
browserCommand()#
function browserCommand(url: string, platform: string = process.platform): { command: string; args: string[] }The command used to open a URL on platform. The URL is passed as a single argv entry, never through a shell.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | required | |
platform | string | process.platform |
Returns { command: string; args: string[] }
defaultStorageDir()#
function defaultStorageDir(env: Record<string, string | undefined> = process.env, platform: string = process.platform): string | nullThe 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).
Returns null when no per-user directory can be determined (e.g. HOME is unset or not absolute);
the client then keeps its state in memory and never falls back to the current directory.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
env | Record<string, string | undefined> | process.env | |
platform | string | process.platform |
Returns string | null
fileStorage()#
function fileStorage(dir: string): SponsorkitStorageStores one <targets_hash>.json file per target set in dir. The directory
is created with mode 0700 on first write and files are written with mode
0600 via a temp file and an atomic rename. Instances are shared per directory.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
dir | string | required |
Returns SponsorkitStorage (SponsorkitStorage)
openSystemBrowser()#
function openSystemBrowser(url: string): Promise<void>Opens url (http/https only) in the system browser. Rejects if no opener could be started.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | required |
Returns Promise<void>