Storeware Docs

Installation stores

Where your app keeps each shop’s tokens and secrets.

import { ... } from '@storeware/plugin-sdk';

installationFrom

A store's record from a fresh token response, keeping secrets it already held.

function installationFrom(tokens: StorewareTokens, previous: StoredInstallation | null, now?: number): StoredInstallation

memoryInstallationStore

In memory, for tests and for trying things out. Gone when the process ends.

function memoryInstallationStore(): InstallationStore & { all(): StoredInstallation[]; }

kvInstallationStore

One key per shop in a key-value store, such as Cloudflare KV.

function kvInstallationStore(kv: KeyValue, prefix?: string): InstallationStore

StoredInstallation

NameTypeDescription
storeIdstring
installationIdstring
accessTokenstring
refreshTokenstring
accessTokenExpiresAtnumberMilliseconds since the epoch.
scopesstring[]
webhookSecretstring
sessionSecretstring
installedAtstring
uninstalledAt?stringSet when app.uninstalled.v1 arrives. The secrets stay for later privacy requests.
lastGrant?stringThe install grant last traded, so a redelivered app.installed.v1 is not traded twice.

InstallationStore

NameTypeDescription
get(storeId: string) => Promise<StoredInstallation | null>
save(installation: StoredInstallation) => Promise<void>
delete(storeId: string) => Promise<void>

KeyValue

The part of a key-value store this needs. Cloudflare KV fits as it is.

NameTypeDescription
get(key: string) => Promise<string | null>
put(key: string, value: string) => Promise<void>
delete(key: string) => Promise<void>

On this page