@0xlimo/iap API
Generated from the typings of @0xlimo/iap 0.1.0: every exported type, class and function.
Generated from @0xlimo/iap typings at build 3a4a58e45c+dirty. Do not edit by hand.
Typings: src/index.d.ts, src/server.d.ts. For concepts and examples see the package guide.
#@0xlimo/iap
import { ... } from "@0xlimo/iap";#IapErrorCode
type
type IapErrorCode =
| "canceled" | "insufficient_funds" | "limit_reached" | "already_owned" | "not_found"
| "not_signed_in" | "unavailable" | "busy" | "failed" | "timeout" | "not_in_launcher";#IapError
class
class IapError extends Error {
code: IapErrorCode | string;
}#Purchase
interface
interface Purchase {
id: string;
appid: number;
sku: string;
name?: string;
kind: "consumable" | "permanent";
quantity: number;
consumed?: number;
remaining?: number;
amount?: number;
amountUsd?: string;
status?: "paid" | "refunded";
[k: string]: unknown;
}#Item
interface
interface Item {
sku: string;
name: string;
description?: string;
price: number;
priceUsd: string;
kind: "consumable" | "permanent";
max_per_player?: number | null;
owned?: unknown;
[k: string]: unknown;
}#Entitlement
interface
interface Entitlement {
sku: string;
name: string;
kind: "consumable" | "permanent";
owned?: boolean;
available?: number;
[k: string]: unknown;
}#IapClient
interface
interface IapClient {
available(): boolean;
purchase(sku: string, opts?: { quantity?: number }): Promise<{ purchase: Purchase; receipt: string }>;
items(): Promise<{ items: Item[]; balance: number | null; balanceUsd: string | null }>;
inventory(): Promise<{ entitlements: Entitlement[]; purchases: Purchase[] }>;
close(): void;
}#createIapClient
function
function createIapClient(opts?: { window?: Window; launcherOrigin?: string | null }): IapClient;#available
function
function available(): boolean;#purchase
function
function purchase(sku: string, opts?: { quantity?: number }): Promise<{ purchase: Purchase; receipt: string }>;#items
function
function items(): Promise<{ items: Item[]; balance: number | null; balanceUsd: string | null }>;#inventory
function
function inventory(): Promise<{ entitlements: Entitlement[]; purchases: Purchase[] }>;@0xlimo/iap/client has the same typings as @0xlimo/iap.
#@0xlimo/iap/server
import { ... } from "@0xlimo/iap/server";#IapError
class
class IapError extends Error {
code: string;
status?: number;
body?: unknown;
}#ReceiptKey
interface
interface ReceiptKey { kid: string; ed25519: string; [k: string]: unknown }#Keys
type
type Keys = { keys: ReceiptKey[] } | ReceiptKey[] | Record<string, string>;#ReceiptPurchase
interface
interface ReceiptPurchase {
id: string;
appid: number;
steamid: string;
sku: string;
kind: "consumable" | "permanent";
quantity: number;
amount: number;
currency: string;
iat: number;
}#VerifyResult
type
type VerifyResult = { valid: true; purchase: ReceiptPurchase; payload: Record<string, unknown> } | { valid: false; reason: string };#publicKeyFromHex
function
function publicKeyFromHex(hex: string): KeyObject;#decodeReceipt
function
function decodeReceipt(receipt: string): Record<string, unknown> | null;#verifyReceipt
function
function verifyReceipt(receipt: string, opts: { keys: Keys; appid?: number | string | null }): VerifyResult;#fetchKeys
function
function fetchKeys(api?: string, opts?: { maxAgeMs?: number; force?: boolean; fetch?: typeof fetch }): Promise<Keys>;#IapServer
class
class IapServer {
constructor(opts: { api?: string; key: string; appid?: number | string | null; fetch?: typeof fetch });
static fromEnv(opts?: { api?: string; appid?: number | string | null; fetch?: typeof fetch }): IapServer;
api: string;
appid: string | null;
verify(what: string | { receipt: string } | { purchase: string }): Promise<{ valid: boolean; reason?: string; purchase?: Record<string, unknown> }>;
consume(purchaseOrReceipt: string, opts?: { quantity?: number; idempotencyKey?: string }): Promise<{ purchase: Record<string, unknown>; consumed_now: number }>;
inventory(steamid: string | number): Promise<{ steamid: string; appid: number; entitlements: unknown[]; purchases: unknown[] }>;
verifyOffline(receipt: string): Promise<VerifyResult>;
}#KEY_FILE
const
const KEY_FILE: "x1-iap.key";#hasServerKey
function
function hasServerKey(): boolean;