@ghostpaygg/node 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Deposits: `fee` and `net_amount` are filled in from `deposit.pending` (and `deposit.held`) as the expected values,
6
+ instead of `0`. They are final on `deposit.credited`. A deposit below the minimum shows `fee` = `amount`, `net_amount` `0`.
7
+ - `webhookDeliveries.retry()` also works on a `PENDING` delivery waiting for its next automatic retry: it is sent now
8
+ and the same delivery is returned (200). `FAILED` deliveries still get a new delivery (201).
9
+ - Webhook signing secrets are `whsec_` + 44 alphanumeric characters (still valid base64; older secrets keep working).
10
+
3
11
  ## 1.1.0
4
12
 
5
13
  - Withdrawals no longer need approval: every withdrawal is created `QUEUED` and sent. Removed the `PENDING_APPROVAL`
package/dist/index.cjs CHANGED
@@ -67,7 +67,7 @@ var WebhookVerificationError = class extends GhostPayError {
67
67
  };
68
68
 
69
69
  // src/version.ts
70
- var VERSION = "1.1.0";
70
+ var VERSION = "1.2.0";
71
71
 
72
72
  // src/http.ts
73
73
  var RETRY_BASE_MS = 500;
@@ -405,7 +405,7 @@ var GhostPay = class {
405
405
  list: (params = {}, opts) => listResult(http, "/v1/webhook-deliveries", params, opts),
406
406
  /** With every attempt (status code, response body, timing). */
407
407
  get: (id, opts) => get(`/v1/webhook-deliveries/${seg(id)}`, void 0, opts),
408
- /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */
408
+ /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */
409
409
  retry: (id, opts) => post(`/v1/webhook-deliveries/${seg(id)}/retry`, void 0, opts)
410
410
  };
411
411
  this.events = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/http.ts","../src/errors.ts","../src/version.ts","../src/webhooks.ts","../src/client.ts"],"sourcesContent":["export { GhostPay, GhostPay as default } from \"./client.js\";\nexport { GhostPayApiError, GhostPayConnectionError, GhostPayError, WebhookVerificationError } from \"./errors.js\";\nexport type { GhostPayOptions, ListResult, RequestOptions, ResponseMeta, WithResponse } from \"./http.js\";\nexport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\nexport { VERSION } from \"./version.js\";\nexport type * from \"./types.js\";\n","import { randomUUID } from \"node:crypto\";\nimport { GhostPayApiError, GhostPayConnectionError, GhostPayError } from \"./errors.js\";\nimport type { ErrorCode, Page } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\n\nexport interface GhostPayOptions {\n /** Secret API key (`gp_live_…`). Only the public checkout calls work without one. */\n apiKey?: string;\n /** API host. Default `https://api.ghostpay.gg`. */\n baseUrl?: string;\n /** Per-attempt timeout. Default 30 s. */\n timeoutMs?: number;\n /** Retries after a network error, timeout, 429 or 5xx (always with the same Idempotency-Key). Default 2. */\n maxRetries?: number;\n /** Custom fetch (proxies, tests). Default: global fetch. */\n fetch?: typeof fetch;\n /** Appended to the User-Agent, e.g. `my-casino/2.1`. */\n appInfo?: string;\n}\n\nexport interface RequestOptions {\n /** Idempotency-Key for this POST. Default: a random UUID, reused on every retry of this call. */\n idempotencyKey?: string;\n timeoutMs?: number;\n maxRetries?: number;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n}\n\nexport interface ResponseMeta {\n status: number;\n headers: Headers;\n /** The API replayed a stored response for this Idempotency-Key. */\n idempotentReplayed: boolean;\n idempotencyKey: string | undefined;\n}\n\n/** A response object; `lastResponse` (not enumerable, not serialized) has status, headers and idempotency info. */\nexport type WithResponse<T> = T & { readonly lastResponse: ResponseMeta };\n\ntype Method = \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\ntype Query = Record<string, string | number | boolean | undefined | null>;\n\nexport interface RequestSpec {\n method: Method;\n path: string;\n query?: Query | undefined;\n body?: unknown;\n /** Send the API key (false for public checkout calls). */\n auth?: boolean;\n /**\n * Retry a POST after the request may have reached the server. False for calls whose response is never stored for\n * idempotent replay (webhook endpoint creation returns a secret), where a retry would act twice.\n */\n retryAfterSend?: boolean;\n}\n\nconst RETRY_BASE_MS = 500;\nconst RETRY_MAX_MS = 8_000;\n\nconst DEFAULT_BASE_URL = \"https://api.ghostpay.gg\";\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly userAgent: string;\n\n constructor(private readonly options: GhostPayOptions) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) throw new GhostPayError(\"No fetch available: use Node 18+ or pass options.fetch\");\n this.userAgent = `ghostpay-node/${VERSION} node/${process.versions.node}${options.appInfo ? ` ${options.appInfo}` : \"\"}`;\n }\n\n async request<T>(spec: RequestSpec, options: RequestOptions = {}): Promise<WithResponse<T>> {\n const auth = spec.auth ?? true;\n if (auth && !this.options.apiKey) throw new GhostPayError(\"This call needs an API key: new GhostPay({ apiKey, baseUrl })\");\n\n const url = this.baseUrl + spec.path + queryString(spec.query);\n const idempotencyKey = spec.method === \"POST\" ? (options.idempotencyKey ?? randomUUID()) : undefined;\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"user-agent\": this.userAgent,\n ...(auth ? { authorization: `Bearer ${this.options.apiKey}` } : {}),\n ...(idempotencyKey ? { \"idempotency-key\": idempotencyKey } : {}),\n ...(spec.body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n ...options.headers,\n };\n const body = spec.body !== undefined ? JSON.stringify(spec.body) : undefined;\n const maxRetries = options.maxRetries ?? this.options.maxRetries ?? 2;\n const timeoutMs = options.timeoutMs ?? this.options.timeoutMs ?? 30_000;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let text: string;\n try {\n ({ response, text } = await this.send(url, { method: spec.method, headers, ...(body !== undefined ? { body } : {}) }, timeoutMs, options.signal));\n } catch (error) {\n if (options.signal?.aborted) throw error;\n const sent = !(error instanceof GhostPayConnectionError && isRefused(error));\n if (attempt < maxRetries && (spec.method === \"GET\" || !sent || spec.retryAfterSend !== false)) {\n await sleep(backoff(attempt));\n continue;\n }\n throw error;\n }\n\n const parsed = text ? safeJson(text) : undefined;\n if (response.ok) {\n if (parsed === undefined && text) throw new GhostPayError(`Invalid JSON from ${spec.method} ${spec.path} (HTTP ${response.status})`);\n return withMeta(parsed as T, {\n status: response.status,\n headers: response.headers,\n idempotentReplayed: response.headers.get(\"idempotent-replayed\") === \"true\",\n idempotencyKey,\n });\n }\n\n const error = toApiError(response, parsed, text);\n if (attempt < maxRetries && retryable(error) && (spec.method === \"GET\" || spec.retryAfterSend !== false)) {\n await sleep(retryAfterMs(response.headers) ?? backoff(attempt));\n continue;\n }\n throw error;\n }\n }\n\n /** Every item of a cursor-paginated list, fetching pages as needed. */\n async *paginate<T extends { id: string }>(path: string, query: Query, options?: RequestOptions): AsyncGenerator<T> {\n let after = query.after ?? undefined;\n for (;;) {\n const page = await this.request<Page<T>>({ method: \"GET\", path, query: { ...query, after } }, options);\n for (const item of page.data) yield item;\n const last = page.data[page.data.length - 1];\n if (!page.has_more || !last) return;\n after = last.id;\n }\n }\n\n private async send(url: string, init: RequestInit, timeoutMs: number, signal?: AbortSignal): Promise<{ response: Response; text: string }> {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n try {\n const response = await this.fetchImpl(url, { ...init, signal: controller.signal });\n return { response, text: await response.text() };\n } catch (error) {\n if (signal?.aborted) throw error;\n if (timedOut) throw new GhostPayConnectionError(`Request timed out after ${timeoutMs} ms`, true, { cause: error });\n throw new GhostPayConnectionError(`Could not reach GhostPay: ${(error as Error)?.message ?? error}`, false, { cause: error });\n } finally {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n}\n\n/** A list call: await it for one page, or `for await` it to walk every item across pages. */\nexport type ListResult<T> = Promise<WithResponse<Page<T>>> & AsyncIterable<T>;\n\nexport function listResult<T extends { id: string }>(http: HttpClient, path: string, query: Query = {}, options?: RequestOptions): ListResult<T> {\n let pending: Promise<WithResponse<Page<T>>> | undefined;\n const first = () => (pending ??= http.request<Page<T>>({ method: \"GET\", path, query }, options));\n return {\n then: (onFulfilled, onRejected) => first().then(onFulfilled, onRejected),\n catch: (onRejected) => first().catch(onRejected),\n finally: (onFinally) => first().finally(onFinally),\n [Symbol.toStringTag]: \"ListResult\",\n [Symbol.asyncIterator]: () => http.paginate<T>(path, query, options),\n } as ListResult<T>;\n}\n\nfunction withMeta<T>(value: T, meta: ResponseMeta): WithResponse<T> {\n const target = (value && typeof value === \"object\" ? value : {}) as object;\n Object.defineProperty(target, \"lastResponse\", { value: meta, enumerable: false });\n return target as WithResponse<T>;\n}\n\nfunction toApiError(response: Response, parsed: unknown, text: string): GhostPayApiError {\n const envelope = (parsed as { error?: { code?: string; message?: string; param?: string } } | undefined)?.error;\n const code = (envelope?.code ?? (response.status >= 500 ? \"api_error\" : \"invalid_request\")) as ErrorCode;\n const message = envelope?.message ?? `HTTP ${response.status}${text ? `: ${text.slice(0, 200)}` : \"\"}`;\n return new GhostPayApiError(response.status, code, message, envelope?.param, response.headers, parsed ?? text);\n}\n\nfunction retryable(error: GhostPayApiError): boolean {\n if (error.status === 429 || error.status >= 500) return true;\n // The same Idempotency-Key is still running on the server: its result will be replayed shortly.\n return error.status === 409 && error.code === \"conflict\" && !error.param && /idempotency-key/i.test(error.message);\n}\n\nfunction isRefused(error: GhostPayConnectionError): boolean {\n const cause = (error.cause as { cause?: { code?: string } } | undefined)?.cause;\n return cause?.code === \"ECONNREFUSED\" || cause?.code === \"ENOTFOUND\" || cause?.code === \"EAI_AGAIN\";\n}\n\nfunction backoff(attempt: number): number {\n const base = Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** attempt);\n return base / 2 + Math.random() * (base / 2);\n}\n\nfunction retryAfterMs(headers: Headers): number | undefined {\n const value = headers.get(\"retry-after\");\n if (!value) return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.min(RETRY_MAX_MS * 4, Math.max(0, seconds * 1000));\n const date = Date.parse(value);\n return Number.isFinite(date) ? Math.min(RETRY_MAX_MS * 4, Math.max(0, date - Date.now())) : undefined;\n}\n\nfunction queryString(query: Query | undefined): string {\n if (!query) return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) params.set(key, String(value));\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { ErrorCode } from \"./types.js\";\n\n/** Base class of every error this SDK throws. */\nexport class GhostPayError extends Error {\n override name = \"GhostPayError\";\n}\n\n/** The API answered with an error envelope. Switch on `code`; it is stable. */\nexport class GhostPayApiError extends GhostPayError {\n override name = \"GhostPayApiError\";\n readonly status: number;\n readonly code: ErrorCode;\n readonly param: string | undefined;\n readonly headers: Headers;\n readonly raw: unknown;\n\n constructor(status: number, code: ErrorCode, message: string, param: string | undefined, headers: Headers, raw: unknown) {\n super(message);\n this.status = status;\n this.code = code;\n this.param = param;\n this.headers = headers;\n this.raw = raw;\n }\n}\n\n/** No response: DNS, connection refused/reset, or the request timed out. Safe to retry with the same Idempotency-Key. */\nexport class GhostPayConnectionError extends GhostPayError {\n override name = \"GhostPayConnectionError\";\n readonly timedOut: boolean;\n constructor(message: string, timedOut: boolean, options?: { cause?: unknown }) {\n super(message, options);\n this.timedOut = timedOut;\n }\n}\n\n/** A webhook request failed signature or timestamp checks. Reply 400 and do not process it. */\nexport class WebhookVerificationError extends GhostPayError {\n override name = \"WebhookVerificationError\";\n}\n","export const VERSION = \"1.1.0\";\n","import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { WebhookVerificationError } from \"./errors.js\";\nimport type { WebhookEvent } from \"./types.js\";\n\nexport type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;\nexport type WebhookPayload = string | Uint8Array;\n\nexport interface WebhookOptions {\n /** Accepted clock difference in seconds, both ways. Default 300 (5 minutes). */\n toleranceSec?: number;\n}\n\nconst PREFIX = \"whsec_\";\n\n/**\n * Verifies GhostPay webhook requests (Standard Webhooks: HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`).\n * Pass several secrets while rotating an endpoint's secret.\n */\nexport class Webhook {\n private readonly keys: Buffer[];\n private readonly toleranceSec: number;\n\n constructor(secret: string | string[], options: WebhookOptions = {}) {\n const secrets = Array.isArray(secret) ? secret : [secret];\n if (secrets.length === 0 || secrets.some((value) => typeof value !== \"string\" || value.length === 0)) {\n throw new WebhookVerificationError(\"A webhook signing secret (whsec_…) is required\");\n }\n this.keys = secrets.map(decodeSecret);\n this.toleranceSec = options.toleranceSec ?? 300;\n }\n\n /**\n * Checks the signature and timestamp and returns the parsed, typed event. `payload` must be the raw request body,\n * exactly as received (e.g. `express.raw({ type: \"application/json\" })`), never re-serialized JSON.\n */\n verify(payload: WebhookPayload, headers: WebhookHeaders, now: Date = new Date()): WebhookEvent {\n const body = rawBody(payload);\n const id = header(headers, \"webhook-id\");\n const timestamp = header(headers, \"webhook-timestamp\");\n const signatures = header(headers, \"webhook-signature\");\n if (!id || !timestamp || !signatures) throw new WebhookVerificationError(\"Missing webhook-id, webhook-timestamp or webhook-signature header\");\n\n const seconds = Number(timestamp);\n if (!/^\\d+$/.test(timestamp) || !Number.isSafeInteger(seconds)) throw new WebhookVerificationError(\"Invalid webhook-timestamp\");\n const skew = Math.floor(now.getTime() / 1000) - seconds;\n if (skew > this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is too old\");\n if (skew < -this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is in the future\");\n\n const expected = this.keys.map((key) => sign(key, id, timestamp, body));\n const valid = signatures.split(\" \").some((entry) => {\n const [version, signature] = entry.split(\",\", 2);\n if (version !== \"v1\" || !signature) return false;\n const given = Buffer.from(signature, \"base64\");\n return expected.some((candidate) => given.length === candidate.length && timingSafeEqual(given, candidate));\n });\n if (!valid) throw new WebhookVerificationError(\"No matching webhook signature\");\n\n let event: WebhookEvent;\n try {\n event = JSON.parse(body.toString(\"utf8\")) as WebhookEvent;\n } catch {\n throw new WebhookVerificationError(\"Webhook body is not valid JSON\");\n }\n if (!event || typeof event !== \"object\" || event.id !== id) throw new WebhookVerificationError(\"Webhook body id does not match webhook-id\");\n return event;\n }\n\n /** The `webhook-signature` header value for a body (for your own tests). */\n sign(id: string, timestamp: number | Date, payload: WebhookPayload): string {\n const seconds = String(typeof timestamp === \"number\" ? timestamp : Math.floor(timestamp.getTime() / 1000));\n return `v1,${sign(this.keys[0]!, id, seconds, rawBody(payload)).toString(\"base64\")}`;\n }\n}\n\nfunction sign(key: Buffer, id: string, timestamp: string, body: Buffer): Buffer {\n return createHmac(\"sha256\", key).update(`${id}.${timestamp}.`).update(body).digest();\n}\n\nfunction decodeSecret(secret: string): Buffer {\n const key = Buffer.from(secret.startsWith(PREFIX) ? secret.slice(PREFIX.length) : secret, \"base64\");\n if (key.length === 0) throw new WebhookVerificationError(\"Invalid webhook signing secret\");\n return key;\n}\n\nfunction rawBody(payload: WebhookPayload): Buffer {\n if (typeof payload === \"string\") return Buffer.from(payload, \"utf8\");\n if (payload instanceof Uint8Array) return Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);\n throw new WebhookVerificationError(\n \"Pass the raw request body (string or Buffer), not parsed JSON: re-serializing changes the bytes and breaks the signature\",\n );\n}\n\nfunction header(headers: WebhookHeaders, name: string): string | undefined {\n if (typeof (headers as Headers).get === \"function\") return (headers as Headers).get(name) ?? undefined;\n const record = headers as Record<string, string | string[] | undefined>;\n const key = Object.keys(record).find((candidate) => candidate.toLowerCase() === name);\n const value = key === undefined ? undefined : record[key];\n return Array.isArray(value) ? value.join(\" \") : value;\n}\n","import { HttpClient, listResult, type GhostPayOptions, type ListResult, type RequestOptions } from \"./http.js\";\nimport type {\n Address,\n AddressCreateParams,\n AddressListParams,\n Balance,\n Checkout,\n CheckoutSelectParams,\n Currency,\n Customer,\n CustomerListParams,\n CustomerUpsertParams,\n Deposit,\n DepositListParams,\n Event,\n EventListParams,\n Invoice,\n InvoiceCreateParams,\n InvoiceListParams,\n Network,\n Page,\n Rate,\n Settings,\n Stats,\n StatsParams,\n Transaction,\n TransactionDetail,\n TransactionListParams,\n WebhookDelivery,\n WebhookDeliveryListParams,\n WebhookDeliveryWithAttempts,\n WebhookEndpoint,\n WebhookEndpointCreateParams,\n WebhookEndpointListParams,\n WebhookEndpointUpdateParams,\n WebhookEndpointWithSecret,\n WebhookReplayParams,\n Withdrawal,\n WithdrawalCreateParams,\n WithdrawalListParams,\n WithdrawalQuote,\n WithdrawalQuoteParams,\n} from \"./types.js\";\nimport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\n\nconst seg = (value: string) => encodeURIComponent(value);\ntype Q = Record<string, string | number | boolean | undefined | null>;\n\nexport class GhostPay {\n readonly networks;\n readonly currencies;\n readonly rates;\n readonly balances;\n readonly customers;\n readonly addresses;\n readonly deposits;\n readonly invoices;\n readonly withdrawals;\n readonly webhookEndpoints;\n readonly webhookDeliveries;\n readonly events;\n readonly transactions;\n readonly stats;\n readonly settings;\n readonly checkout;\n readonly webhooks;\n\n constructor(options: GhostPayOptions) {\n const http = new HttpClient(options);\n const get = <T>(path: string, query?: Q, opts?: RequestOptions) => http.request<T>({ method: \"GET\", path, query }, opts);\n const post = <T>(path: string, body?: unknown, opts?: RequestOptions, extra?: { auth?: boolean; retryAfterSend?: boolean }) =>\n http.request<T>({ method: \"POST\", path, body, ...extra }, opts);\n\n this.networks = {\n /** Every network, with confirmations and whether deposits/withdrawals are on. */\n list: (opts?: RequestOptions) => get<Page<Network>>(\"/v1/networks\", undefined, opts),\n };\n this.currencies = {\n /** Enabled currencies with your minimums and fees. */\n list: (opts?: RequestOptions) => get<Page<Currency>>(\"/v1/currencies\", undefined, opts),\n };\n this.rates = {\n /** Indicative USD price per currency. */\n list: (opts?: RequestOptions) => get<Page<Rate>>(\"/v1/rates\", undefined, opts),\n };\n this.balances = {\n /** Available, on-hold and pending balance per currency. */\n list: (opts?: RequestOptions) => get<Page<Balance>>(\"/v1/balances\", undefined, opts),\n };\n\n this.customers = {\n /** Create the customer, or update its metadata if `external_id` exists. */\n upsert: (params: CustomerUpsertParams, opts?: RequestOptions) => post<Customer>(\"/v1/customers\", params, opts),\n list: (params: CustomerListParams = {}, opts?: RequestOptions): ListResult<Customer> => listResult(http, \"/v1/customers\", params, opts),\n /** By `cus_…` id or `ext:<external_id>`. */\n get: (customer: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(customer)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(`ext:${externalId}`)}`, undefined, opts),\n };\n\n this.addresses = {\n /** The customer's permanent deposit address for the network's address scope (created on first call; `lastResponse.status` 201). */\n getOrCreate: (params: AddressCreateParams, opts?: RequestOptions) => post<Address>(\"/v1/addresses\", params, opts),\n list: (params: AddressListParams = {}, opts?: RequestOptions): ListResult<Address> => listResult(http, \"/v1/addresses\", params, opts),\n /** By `addr_…` id or the on-chain address. */\n get: (address: string, opts?: RequestOptions) => get<Address>(`/v1/addresses/${seg(address)}`, undefined, opts),\n /** Stop handing this address out; payments to it are still credited. */\n retire: (address: string, opts?: RequestOptions) => post<Address>(`/v1/addresses/${seg(address)}/retire`, undefined, opts),\n /** Your own addresses for funding your balance, one per address scope; credited with no fees. */\n topUps: (opts?: RequestOptions) => get<{ data: Address[] }>(\"/v1/top-up-addresses\", undefined, opts),\n };\n\n this.deposits = {\n list: (params: DepositListParams = {}, opts?: RequestOptions): ListResult<Deposit> => listResult(http, \"/v1/deposits\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Deposit>(`/v1/deposits/${seg(id)}`, undefined, opts),\n };\n\n this.invoices = {\n create: (params: InvoiceCreateParams, opts?: RequestOptions) => post<Invoice>(\"/v1/invoices\", params, opts),\n list: (params: InvoiceListParams = {}, opts?: RequestOptions): ListResult<Invoice> => listResult(http, \"/v1/invoices\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Invoice>(`/v1/invoices/${seg(id)}`, undefined, opts),\n /** Only while `NEW`. */\n cancel: (id: string, opts?: RequestOptions) => post<Invoice>(`/v1/invoices/${seg(id)}/cancel`, undefined, opts),\n };\n\n this.withdrawals = {\n /** Fee, total and whether your balance covers it. Creates nothing. */\n quote: (params: WithdrawalQuoteParams, opts?: RequestOptions) =>\n post<WithdrawalQuote>(\"/v1/withdrawals/quote\", params, opts),\n /**\n * Pays out from your balance. The Idempotency-Key defaults to `withdrawal:<external_id>` when you give an\n * `external_id`, so retrying the same payout (even after a restart) can never pay twice.\n */\n create: (params: WithdrawalCreateParams, opts: RequestOptions = {}) =>\n post<Withdrawal>(\"/v1/withdrawals\", params, {\n ...opts,\n ...(opts.idempotencyKey === undefined && params.external_id ? { idempotencyKey: `withdrawal:${params.external_id}` } : {}),\n }),\n list: (params: WithdrawalListParams = {}, opts?: RequestOptions): ListResult<Withdrawal> => listResult(http, \"/v1/withdrawals\", params, opts),\n /** By `wd_…` id or your external id. */\n get: (withdrawal: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(`ext:${externalId}`)}`, undefined, opts),\n /** Only before it is sent. The hold returns to your available balance. */\n cancel: (withdrawal: string, opts?: RequestOptions) => post<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}/cancel`, undefined, opts),\n };\n\n this.webhookEndpoints = {\n /** The response's `secret` is shown only once: store it. Not retried once sent (a retry would create a second endpoint). */\n create: (params: WebhookEndpointCreateParams, opts?: RequestOptions) =>\n post<WebhookEndpointWithSecret>(\"/v1/webhook-endpoints\", params, opts, { retryAfterSend: false }),\n list: (params: WebhookEndpointListParams = {}, opts?: RequestOptions): ListResult<WebhookEndpoint> =>\n listResult(http, \"/v1/webhook-endpoints\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<WebhookEndpoint>(`/v1/webhook-endpoints/${seg(id)}`, undefined, opts),\n update: (id: string, params: WebhookEndpointUpdateParams, opts?: RequestOptions) =>\n http.request<WebhookEndpoint>({ method: \"PATCH\", path: `/v1/webhook-endpoints/${seg(id)}`, body: params }, opts),\n delete: (id: string, opts?: RequestOptions) =>\n http.request<{ id: string; object: \"webhook_endpoint\"; deleted: true }>({ method: \"DELETE\", path: `/v1/webhook-endpoints/${seg(id)}` }, opts),\n /** Sends a `ping` event to this endpoint. */\n test: (id: string, opts?: RequestOptions) =>\n post<{ event: Event; delivery: WebhookDelivery }>(`/v1/webhook-endpoints/${seg(id)}/test`, undefined, opts),\n /** Re-sends matching events created in `[from, to]` as new deliveries; events already queued for the endpoint are skipped. */\n replay: (id: string, params: WebhookReplayParams, opts?: RequestOptions) =>\n post<{ queued: number }>(`/v1/webhook-endpoints/${seg(id)}/replay`, params, opts),\n };\n\n this.webhookDeliveries = {\n list: (params: WebhookDeliveryListParams = {}, opts?: RequestOptions): ListResult<WebhookDelivery> =>\n listResult(http, \"/v1/webhook-deliveries\", params, opts),\n /** With every attempt (status code, response body, timing). */\n get: (id: string, opts?: RequestOptions) => get<WebhookDeliveryWithAttempts>(`/v1/webhook-deliveries/${seg(id)}`, undefined, opts),\n /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */\n retry: (id: string, opts?: RequestOptions) => post<WebhookDelivery>(`/v1/webhook-deliveries/${seg(id)}/retry`, undefined, opts),\n };\n\n this.events = {\n /** One page: newest first, or oldest first after `params.after`. */\n list: (params: EventListParams = {}, opts?: RequestOptions) => get<Page<Event>>(\"/v1/events\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Event>(`/v1/events/${seg(id)}`, undefined, opts),\n /**\n * Every event after `after` (default: from the very first), oldest first, across pages. Store the last id you\n * processed and pass it next time to catch up after downtime.\n */\n since: (after = \"evt_0\", params: Omit<EventListParams, \"after\"> = {}, opts?: RequestOptions): AsyncIterable<Event> =>\n http.paginate<Event>(\"/v1/events\", { ...params, after }, opts),\n };\n\n this.transactions = {\n /** Deposits, top-ups, withdrawals and payouts, newest first. */\n list: (params: TransactionListParams = {}, opts?: RequestOptions): ListResult<Transaction> => listResult(http, \"/v1/transactions\", params, opts),\n /** With the full deposit or withdrawal and every event about it, including webhook deliveries. */\n get: (id: string, opts?: RequestOptions) => get<TransactionDetail>(`/v1/transactions/${seg(id)}`, undefined, opts),\n };\n\n this.stats = {\n /** Balances and daily volume in USD at current rates (default 30 days). */\n get: (params: StatsParams = {}, opts?: RequestOptions) => get<Stats>(\"/v1/stats\", params, opts),\n };\n\n this.settings = {\n get: (opts?: RequestOptions) => get<Settings>(\"/v1/settings\", undefined, opts),\n };\n\n this.checkout = {\n /** Public: what a payer needs to pay an invoice (no API key needed). */\n get: (invoiceId: string, opts?: RequestOptions) => http.request<Checkout>({ method: \"GET\", path: `/v1/checkout/${seg(invoiceId)}`, auth: false }, opts),\n /** Public: choose the payment currency once, while the invoice is `NEW`. */\n select: (invoiceId: string, params: CheckoutSelectParams, opts?: RequestOptions) =>\n post<Checkout>(`/v1/checkout/${seg(invoiceId)}/select`, params, opts, { auth: false }),\n };\n\n this.webhooks = {\n /** Verify a webhook request and return the typed event (see `Webhook.verify`). */\n verify: (payload: WebhookPayload, headers: WebhookHeaders, secret: string | string[], options?: WebhookOptions) =>\n new Webhook(secret, options).verify(payload, headers),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,SAA0B,IAAW,cAAc,IAAI,EAAE,CAAC,IAAI,QAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,MAK/F,OAAO,CAAC,QAAQ,SAAS,SAAyC,CAAC,GAAG,SACpE,KAAK,SAAgB,cAAc,EAAE,GAAG,QAAQ,MAAM,GAAG,IAAI;AAAA,IACjE;AAEA,SAAK,eAAe;AAAA;AAAA,MAElB,MAAM,CAAC,SAAgC,CAAC,GAAG,SAAmD,WAAW,MAAM,oBAAoB,QAAQ,IAAI;AAAA;AAAA,MAE/I,KAAK,CAAC,IAAY,SAA0B,IAAuB,oBAAoB,IAAI,EAAE,CAAC,IAAI,QAAW,IAAI;AAAA,IACnH;AAEA,SAAK,QAAQ;AAAA;AAAA,MAEX,KAAK,CAAC,SAAsB,CAAC,GAAG,SAA0B,IAAW,aAAa,QAAQ,IAAI;AAAA,IAChG;AAEA,SAAK,WAAW;AAAA,MACd,KAAK,CAAC,SAA0B,IAAc,gBAAgB,QAAW,IAAI;AAAA,IAC/E;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,KAAK,CAAC,WAAmB,SAA0B,KAAK,QAAkB,EAAE,QAAQ,OAAO,MAAM,gBAAgB,IAAI,SAAS,CAAC,IAAI,MAAM,MAAM,GAAG,IAAI;AAAA;AAAA,MAEtJ,QAAQ,CAAC,WAAmB,QAA8B,SACxD,KAAe,gBAAgB,IAAI,SAAS,CAAC,WAAW,QAAQ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,IACzF;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,QAAQ,CAAC,SAAyB,SAAyB,QAA2BC,aACpF,IAAI,QAAQ,QAAQA,QAAO,EAAE,OAAO,SAAS,OAAO;AAAA,IACxD;AAAA,EACF;AACF;","names":["error","import_node_crypto","options"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/http.ts","../src/errors.ts","../src/version.ts","../src/webhooks.ts","../src/client.ts"],"sourcesContent":["export { GhostPay, GhostPay as default } from \"./client.js\";\nexport { GhostPayApiError, GhostPayConnectionError, GhostPayError, WebhookVerificationError } from \"./errors.js\";\nexport type { GhostPayOptions, ListResult, RequestOptions, ResponseMeta, WithResponse } from \"./http.js\";\nexport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\nexport { VERSION } from \"./version.js\";\nexport type * from \"./types.js\";\n","import { randomUUID } from \"node:crypto\";\nimport { GhostPayApiError, GhostPayConnectionError, GhostPayError } from \"./errors.js\";\nimport type { ErrorCode, Page } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\n\nexport interface GhostPayOptions {\n /** Secret API key (`gp_live_…`). Only the public checkout calls work without one. */\n apiKey?: string;\n /** API host. Default `https://api.ghostpay.gg`. */\n baseUrl?: string;\n /** Per-attempt timeout. Default 30 s. */\n timeoutMs?: number;\n /** Retries after a network error, timeout, 429 or 5xx (always with the same Idempotency-Key). Default 2. */\n maxRetries?: number;\n /** Custom fetch (proxies, tests). Default: global fetch. */\n fetch?: typeof fetch;\n /** Appended to the User-Agent, e.g. `my-casino/2.1`. */\n appInfo?: string;\n}\n\nexport interface RequestOptions {\n /** Idempotency-Key for this POST. Default: a random UUID, reused on every retry of this call. */\n idempotencyKey?: string;\n timeoutMs?: number;\n maxRetries?: number;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n}\n\nexport interface ResponseMeta {\n status: number;\n headers: Headers;\n /** The API replayed a stored response for this Idempotency-Key. */\n idempotentReplayed: boolean;\n idempotencyKey: string | undefined;\n}\n\n/** A response object; `lastResponse` (not enumerable, not serialized) has status, headers and idempotency info. */\nexport type WithResponse<T> = T & { readonly lastResponse: ResponseMeta };\n\ntype Method = \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\ntype Query = Record<string, string | number | boolean | undefined | null>;\n\nexport interface RequestSpec {\n method: Method;\n path: string;\n query?: Query | undefined;\n body?: unknown;\n /** Send the API key (false for public checkout calls). */\n auth?: boolean;\n /**\n * Retry a POST after the request may have reached the server. False for calls whose response is never stored for\n * idempotent replay (webhook endpoint creation returns a secret), where a retry would act twice.\n */\n retryAfterSend?: boolean;\n}\n\nconst RETRY_BASE_MS = 500;\nconst RETRY_MAX_MS = 8_000;\n\nconst DEFAULT_BASE_URL = \"https://api.ghostpay.gg\";\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly userAgent: string;\n\n constructor(private readonly options: GhostPayOptions) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) throw new GhostPayError(\"No fetch available: use Node 18+ or pass options.fetch\");\n this.userAgent = `ghostpay-node/${VERSION} node/${process.versions.node}${options.appInfo ? ` ${options.appInfo}` : \"\"}`;\n }\n\n async request<T>(spec: RequestSpec, options: RequestOptions = {}): Promise<WithResponse<T>> {\n const auth = spec.auth ?? true;\n if (auth && !this.options.apiKey) throw new GhostPayError(\"This call needs an API key: new GhostPay({ apiKey, baseUrl })\");\n\n const url = this.baseUrl + spec.path + queryString(spec.query);\n const idempotencyKey = spec.method === \"POST\" ? (options.idempotencyKey ?? randomUUID()) : undefined;\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"user-agent\": this.userAgent,\n ...(auth ? { authorization: `Bearer ${this.options.apiKey}` } : {}),\n ...(idempotencyKey ? { \"idempotency-key\": idempotencyKey } : {}),\n ...(spec.body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n ...options.headers,\n };\n const body = spec.body !== undefined ? JSON.stringify(spec.body) : undefined;\n const maxRetries = options.maxRetries ?? this.options.maxRetries ?? 2;\n const timeoutMs = options.timeoutMs ?? this.options.timeoutMs ?? 30_000;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let text: string;\n try {\n ({ response, text } = await this.send(url, { method: spec.method, headers, ...(body !== undefined ? { body } : {}) }, timeoutMs, options.signal));\n } catch (error) {\n if (options.signal?.aborted) throw error;\n const sent = !(error instanceof GhostPayConnectionError && isRefused(error));\n if (attempt < maxRetries && (spec.method === \"GET\" || !sent || spec.retryAfterSend !== false)) {\n await sleep(backoff(attempt));\n continue;\n }\n throw error;\n }\n\n const parsed = text ? safeJson(text) : undefined;\n if (response.ok) {\n if (parsed === undefined && text) throw new GhostPayError(`Invalid JSON from ${spec.method} ${spec.path} (HTTP ${response.status})`);\n return withMeta(parsed as T, {\n status: response.status,\n headers: response.headers,\n idempotentReplayed: response.headers.get(\"idempotent-replayed\") === \"true\",\n idempotencyKey,\n });\n }\n\n const error = toApiError(response, parsed, text);\n if (attempt < maxRetries && retryable(error) && (spec.method === \"GET\" || spec.retryAfterSend !== false)) {\n await sleep(retryAfterMs(response.headers) ?? backoff(attempt));\n continue;\n }\n throw error;\n }\n }\n\n /** Every item of a cursor-paginated list, fetching pages as needed. */\n async *paginate<T extends { id: string }>(path: string, query: Query, options?: RequestOptions): AsyncGenerator<T> {\n let after = query.after ?? undefined;\n for (;;) {\n const page = await this.request<Page<T>>({ method: \"GET\", path, query: { ...query, after } }, options);\n for (const item of page.data) yield item;\n const last = page.data[page.data.length - 1];\n if (!page.has_more || !last) return;\n after = last.id;\n }\n }\n\n private async send(url: string, init: RequestInit, timeoutMs: number, signal?: AbortSignal): Promise<{ response: Response; text: string }> {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n try {\n const response = await this.fetchImpl(url, { ...init, signal: controller.signal });\n return { response, text: await response.text() };\n } catch (error) {\n if (signal?.aborted) throw error;\n if (timedOut) throw new GhostPayConnectionError(`Request timed out after ${timeoutMs} ms`, true, { cause: error });\n throw new GhostPayConnectionError(`Could not reach GhostPay: ${(error as Error)?.message ?? error}`, false, { cause: error });\n } finally {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n}\n\n/** A list call: await it for one page, or `for await` it to walk every item across pages. */\nexport type ListResult<T> = Promise<WithResponse<Page<T>>> & AsyncIterable<T>;\n\nexport function listResult<T extends { id: string }>(http: HttpClient, path: string, query: Query = {}, options?: RequestOptions): ListResult<T> {\n let pending: Promise<WithResponse<Page<T>>> | undefined;\n const first = () => (pending ??= http.request<Page<T>>({ method: \"GET\", path, query }, options));\n return {\n then: (onFulfilled, onRejected) => first().then(onFulfilled, onRejected),\n catch: (onRejected) => first().catch(onRejected),\n finally: (onFinally) => first().finally(onFinally),\n [Symbol.toStringTag]: \"ListResult\",\n [Symbol.asyncIterator]: () => http.paginate<T>(path, query, options),\n } as ListResult<T>;\n}\n\nfunction withMeta<T>(value: T, meta: ResponseMeta): WithResponse<T> {\n const target = (value && typeof value === \"object\" ? value : {}) as object;\n Object.defineProperty(target, \"lastResponse\", { value: meta, enumerable: false });\n return target as WithResponse<T>;\n}\n\nfunction toApiError(response: Response, parsed: unknown, text: string): GhostPayApiError {\n const envelope = (parsed as { error?: { code?: string; message?: string; param?: string } } | undefined)?.error;\n const code = (envelope?.code ?? (response.status >= 500 ? \"api_error\" : \"invalid_request\")) as ErrorCode;\n const message = envelope?.message ?? `HTTP ${response.status}${text ? `: ${text.slice(0, 200)}` : \"\"}`;\n return new GhostPayApiError(response.status, code, message, envelope?.param, response.headers, parsed ?? text);\n}\n\nfunction retryable(error: GhostPayApiError): boolean {\n if (error.status === 429 || error.status >= 500) return true;\n // The same Idempotency-Key is still running on the server: its result will be replayed shortly.\n return error.status === 409 && error.code === \"conflict\" && !error.param && /idempotency-key/i.test(error.message);\n}\n\nfunction isRefused(error: GhostPayConnectionError): boolean {\n const cause = (error.cause as { cause?: { code?: string } } | undefined)?.cause;\n return cause?.code === \"ECONNREFUSED\" || cause?.code === \"ENOTFOUND\" || cause?.code === \"EAI_AGAIN\";\n}\n\nfunction backoff(attempt: number): number {\n const base = Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** attempt);\n return base / 2 + Math.random() * (base / 2);\n}\n\nfunction retryAfterMs(headers: Headers): number | undefined {\n const value = headers.get(\"retry-after\");\n if (!value) return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.min(RETRY_MAX_MS * 4, Math.max(0, seconds * 1000));\n const date = Date.parse(value);\n return Number.isFinite(date) ? Math.min(RETRY_MAX_MS * 4, Math.max(0, date - Date.now())) : undefined;\n}\n\nfunction queryString(query: Query | undefined): string {\n if (!query) return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) params.set(key, String(value));\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { ErrorCode } from \"./types.js\";\n\n/** Base class of every error this SDK throws. */\nexport class GhostPayError extends Error {\n override name = \"GhostPayError\";\n}\n\n/** The API answered with an error envelope. Switch on `code`; it is stable. */\nexport class GhostPayApiError extends GhostPayError {\n override name = \"GhostPayApiError\";\n readonly status: number;\n readonly code: ErrorCode;\n readonly param: string | undefined;\n readonly headers: Headers;\n readonly raw: unknown;\n\n constructor(status: number, code: ErrorCode, message: string, param: string | undefined, headers: Headers, raw: unknown) {\n super(message);\n this.status = status;\n this.code = code;\n this.param = param;\n this.headers = headers;\n this.raw = raw;\n }\n}\n\n/** No response: DNS, connection refused/reset, or the request timed out. Safe to retry with the same Idempotency-Key. */\nexport class GhostPayConnectionError extends GhostPayError {\n override name = \"GhostPayConnectionError\";\n readonly timedOut: boolean;\n constructor(message: string, timedOut: boolean, options?: { cause?: unknown }) {\n super(message, options);\n this.timedOut = timedOut;\n }\n}\n\n/** A webhook request failed signature or timestamp checks. Reply 400 and do not process it. */\nexport class WebhookVerificationError extends GhostPayError {\n override name = \"WebhookVerificationError\";\n}\n","export const VERSION = \"1.2.0\";\n","import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { WebhookVerificationError } from \"./errors.js\";\nimport type { WebhookEvent } from \"./types.js\";\n\nexport type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;\nexport type WebhookPayload = string | Uint8Array;\n\nexport interface WebhookOptions {\n /** Accepted clock difference in seconds, both ways. Default 300 (5 minutes). */\n toleranceSec?: number;\n}\n\nconst PREFIX = \"whsec_\";\n\n/**\n * Verifies GhostPay webhook requests (Standard Webhooks: HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`).\n * Pass several secrets while rotating an endpoint's secret.\n */\nexport class Webhook {\n private readonly keys: Buffer[];\n private readonly toleranceSec: number;\n\n constructor(secret: string | string[], options: WebhookOptions = {}) {\n const secrets = Array.isArray(secret) ? secret : [secret];\n if (secrets.length === 0 || secrets.some((value) => typeof value !== \"string\" || value.length === 0)) {\n throw new WebhookVerificationError(\"A webhook signing secret (whsec_…) is required\");\n }\n this.keys = secrets.map(decodeSecret);\n this.toleranceSec = options.toleranceSec ?? 300;\n }\n\n /**\n * Checks the signature and timestamp and returns the parsed, typed event. `payload` must be the raw request body,\n * exactly as received (e.g. `express.raw({ type: \"application/json\" })`), never re-serialized JSON.\n */\n verify(payload: WebhookPayload, headers: WebhookHeaders, now: Date = new Date()): WebhookEvent {\n const body = rawBody(payload);\n const id = header(headers, \"webhook-id\");\n const timestamp = header(headers, \"webhook-timestamp\");\n const signatures = header(headers, \"webhook-signature\");\n if (!id || !timestamp || !signatures) throw new WebhookVerificationError(\"Missing webhook-id, webhook-timestamp or webhook-signature header\");\n\n const seconds = Number(timestamp);\n if (!/^\\d+$/.test(timestamp) || !Number.isSafeInteger(seconds)) throw new WebhookVerificationError(\"Invalid webhook-timestamp\");\n const skew = Math.floor(now.getTime() / 1000) - seconds;\n if (skew > this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is too old\");\n if (skew < -this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is in the future\");\n\n const expected = this.keys.map((key) => sign(key, id, timestamp, body));\n const valid = signatures.split(\" \").some((entry) => {\n const [version, signature] = entry.split(\",\", 2);\n if (version !== \"v1\" || !signature) return false;\n const given = Buffer.from(signature, \"base64\");\n return expected.some((candidate) => given.length === candidate.length && timingSafeEqual(given, candidate));\n });\n if (!valid) throw new WebhookVerificationError(\"No matching webhook signature\");\n\n let event: WebhookEvent;\n try {\n event = JSON.parse(body.toString(\"utf8\")) as WebhookEvent;\n } catch {\n throw new WebhookVerificationError(\"Webhook body is not valid JSON\");\n }\n if (!event || typeof event !== \"object\" || event.id !== id) throw new WebhookVerificationError(\"Webhook body id does not match webhook-id\");\n return event;\n }\n\n /** The `webhook-signature` header value for a body (for your own tests). */\n sign(id: string, timestamp: number | Date, payload: WebhookPayload): string {\n const seconds = String(typeof timestamp === \"number\" ? timestamp : Math.floor(timestamp.getTime() / 1000));\n return `v1,${sign(this.keys[0]!, id, seconds, rawBody(payload)).toString(\"base64\")}`;\n }\n}\n\nfunction sign(key: Buffer, id: string, timestamp: string, body: Buffer): Buffer {\n return createHmac(\"sha256\", key).update(`${id}.${timestamp}.`).update(body).digest();\n}\n\nfunction decodeSecret(secret: string): Buffer {\n const key = Buffer.from(secret.startsWith(PREFIX) ? secret.slice(PREFIX.length) : secret, \"base64\");\n if (key.length === 0) throw new WebhookVerificationError(\"Invalid webhook signing secret\");\n return key;\n}\n\nfunction rawBody(payload: WebhookPayload): Buffer {\n if (typeof payload === \"string\") return Buffer.from(payload, \"utf8\");\n if (payload instanceof Uint8Array) return Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);\n throw new WebhookVerificationError(\n \"Pass the raw request body (string or Buffer), not parsed JSON: re-serializing changes the bytes and breaks the signature\",\n );\n}\n\nfunction header(headers: WebhookHeaders, name: string): string | undefined {\n if (typeof (headers as Headers).get === \"function\") return (headers as Headers).get(name) ?? undefined;\n const record = headers as Record<string, string | string[] | undefined>;\n const key = Object.keys(record).find((candidate) => candidate.toLowerCase() === name);\n const value = key === undefined ? undefined : record[key];\n return Array.isArray(value) ? value.join(\" \") : value;\n}\n","import { HttpClient, listResult, type GhostPayOptions, type ListResult, type RequestOptions } from \"./http.js\";\nimport type {\n Address,\n AddressCreateParams,\n AddressListParams,\n Balance,\n Checkout,\n CheckoutSelectParams,\n Currency,\n Customer,\n CustomerListParams,\n CustomerUpsertParams,\n Deposit,\n DepositListParams,\n Event,\n EventListParams,\n Invoice,\n InvoiceCreateParams,\n InvoiceListParams,\n Network,\n Page,\n Rate,\n Settings,\n Stats,\n StatsParams,\n Transaction,\n TransactionDetail,\n TransactionListParams,\n WebhookDelivery,\n WebhookDeliveryListParams,\n WebhookDeliveryWithAttempts,\n WebhookEndpoint,\n WebhookEndpointCreateParams,\n WebhookEndpointListParams,\n WebhookEndpointUpdateParams,\n WebhookEndpointWithSecret,\n WebhookReplayParams,\n Withdrawal,\n WithdrawalCreateParams,\n WithdrawalListParams,\n WithdrawalQuote,\n WithdrawalQuoteParams,\n} from \"./types.js\";\nimport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\n\nconst seg = (value: string) => encodeURIComponent(value);\ntype Q = Record<string, string | number | boolean | undefined | null>;\n\nexport class GhostPay {\n readonly networks;\n readonly currencies;\n readonly rates;\n readonly balances;\n readonly customers;\n readonly addresses;\n readonly deposits;\n readonly invoices;\n readonly withdrawals;\n readonly webhookEndpoints;\n readonly webhookDeliveries;\n readonly events;\n readonly transactions;\n readonly stats;\n readonly settings;\n readonly checkout;\n readonly webhooks;\n\n constructor(options: GhostPayOptions) {\n const http = new HttpClient(options);\n const get = <T>(path: string, query?: Q, opts?: RequestOptions) => http.request<T>({ method: \"GET\", path, query }, opts);\n const post = <T>(path: string, body?: unknown, opts?: RequestOptions, extra?: { auth?: boolean; retryAfterSend?: boolean }) =>\n http.request<T>({ method: \"POST\", path, body, ...extra }, opts);\n\n this.networks = {\n /** Every network, with confirmations and whether deposits/withdrawals are on. */\n list: (opts?: RequestOptions) => get<Page<Network>>(\"/v1/networks\", undefined, opts),\n };\n this.currencies = {\n /** Enabled currencies with your minimums and fees. */\n list: (opts?: RequestOptions) => get<Page<Currency>>(\"/v1/currencies\", undefined, opts),\n };\n this.rates = {\n /** Indicative USD price per currency. */\n list: (opts?: RequestOptions) => get<Page<Rate>>(\"/v1/rates\", undefined, opts),\n };\n this.balances = {\n /** Available, on-hold and pending balance per currency. */\n list: (opts?: RequestOptions) => get<Page<Balance>>(\"/v1/balances\", undefined, opts),\n };\n\n this.customers = {\n /** Create the customer, or update its metadata if `external_id` exists. */\n upsert: (params: CustomerUpsertParams, opts?: RequestOptions) => post<Customer>(\"/v1/customers\", params, opts),\n list: (params: CustomerListParams = {}, opts?: RequestOptions): ListResult<Customer> => listResult(http, \"/v1/customers\", params, opts),\n /** By `cus_…` id or `ext:<external_id>`. */\n get: (customer: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(customer)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(`ext:${externalId}`)}`, undefined, opts),\n };\n\n this.addresses = {\n /** The customer's permanent deposit address for the network's address scope (created on first call; `lastResponse.status` 201). */\n getOrCreate: (params: AddressCreateParams, opts?: RequestOptions) => post<Address>(\"/v1/addresses\", params, opts),\n list: (params: AddressListParams = {}, opts?: RequestOptions): ListResult<Address> => listResult(http, \"/v1/addresses\", params, opts),\n /** By `addr_…` id or the on-chain address. */\n get: (address: string, opts?: RequestOptions) => get<Address>(`/v1/addresses/${seg(address)}`, undefined, opts),\n /** Stop handing this address out; payments to it are still credited. */\n retire: (address: string, opts?: RequestOptions) => post<Address>(`/v1/addresses/${seg(address)}/retire`, undefined, opts),\n /** Your own addresses for funding your balance, one per address scope; credited with no fees. */\n topUps: (opts?: RequestOptions) => get<{ data: Address[] }>(\"/v1/top-up-addresses\", undefined, opts),\n };\n\n this.deposits = {\n list: (params: DepositListParams = {}, opts?: RequestOptions): ListResult<Deposit> => listResult(http, \"/v1/deposits\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Deposit>(`/v1/deposits/${seg(id)}`, undefined, opts),\n };\n\n this.invoices = {\n create: (params: InvoiceCreateParams, opts?: RequestOptions) => post<Invoice>(\"/v1/invoices\", params, opts),\n list: (params: InvoiceListParams = {}, opts?: RequestOptions): ListResult<Invoice> => listResult(http, \"/v1/invoices\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Invoice>(`/v1/invoices/${seg(id)}`, undefined, opts),\n /** Only while `NEW`. */\n cancel: (id: string, opts?: RequestOptions) => post<Invoice>(`/v1/invoices/${seg(id)}/cancel`, undefined, opts),\n };\n\n this.withdrawals = {\n /** Fee, total and whether your balance covers it. Creates nothing. */\n quote: (params: WithdrawalQuoteParams, opts?: RequestOptions) =>\n post<WithdrawalQuote>(\"/v1/withdrawals/quote\", params, opts),\n /**\n * Pays out from your balance. The Idempotency-Key defaults to `withdrawal:<external_id>` when you give an\n * `external_id`, so retrying the same payout (even after a restart) can never pay twice.\n */\n create: (params: WithdrawalCreateParams, opts: RequestOptions = {}) =>\n post<Withdrawal>(\"/v1/withdrawals\", params, {\n ...opts,\n ...(opts.idempotencyKey === undefined && params.external_id ? { idempotencyKey: `withdrawal:${params.external_id}` } : {}),\n }),\n list: (params: WithdrawalListParams = {}, opts?: RequestOptions): ListResult<Withdrawal> => listResult(http, \"/v1/withdrawals\", params, opts),\n /** By `wd_…` id or your external id. */\n get: (withdrawal: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(`ext:${externalId}`)}`, undefined, opts),\n /** Only before it is sent. The hold returns to your available balance. */\n cancel: (withdrawal: string, opts?: RequestOptions) => post<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}/cancel`, undefined, opts),\n };\n\n this.webhookEndpoints = {\n /** The response's `secret` is shown only once: store it. Not retried once sent (a retry would create a second endpoint). */\n create: (params: WebhookEndpointCreateParams, opts?: RequestOptions) =>\n post<WebhookEndpointWithSecret>(\"/v1/webhook-endpoints\", params, opts, { retryAfterSend: false }),\n list: (params: WebhookEndpointListParams = {}, opts?: RequestOptions): ListResult<WebhookEndpoint> =>\n listResult(http, \"/v1/webhook-endpoints\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<WebhookEndpoint>(`/v1/webhook-endpoints/${seg(id)}`, undefined, opts),\n update: (id: string, params: WebhookEndpointUpdateParams, opts?: RequestOptions) =>\n http.request<WebhookEndpoint>({ method: \"PATCH\", path: `/v1/webhook-endpoints/${seg(id)}`, body: params }, opts),\n delete: (id: string, opts?: RequestOptions) =>\n http.request<{ id: string; object: \"webhook_endpoint\"; deleted: true }>({ method: \"DELETE\", path: `/v1/webhook-endpoints/${seg(id)}` }, opts),\n /** Sends a `ping` event to this endpoint. */\n test: (id: string, opts?: RequestOptions) =>\n post<{ event: Event; delivery: WebhookDelivery }>(`/v1/webhook-endpoints/${seg(id)}/test`, undefined, opts),\n /** Re-sends matching events created in `[from, to]` as new deliveries; events already queued for the endpoint are skipped. */\n replay: (id: string, params: WebhookReplayParams, opts?: RequestOptions) =>\n post<{ queued: number }>(`/v1/webhook-endpoints/${seg(id)}/replay`, params, opts),\n };\n\n this.webhookDeliveries = {\n list: (params: WebhookDeliveryListParams = {}, opts?: RequestOptions): ListResult<WebhookDelivery> =>\n listResult(http, \"/v1/webhook-deliveries\", params, opts),\n /** With every attempt (status code, response body, timing). */\n get: (id: string, opts?: RequestOptions) => get<WebhookDeliveryWithAttempts>(`/v1/webhook-deliveries/${seg(id)}`, undefined, opts),\n /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */\n retry: (id: string, opts?: RequestOptions) => post<WebhookDelivery>(`/v1/webhook-deliveries/${seg(id)}/retry`, undefined, opts),\n };\n\n this.events = {\n /** One page: newest first, or oldest first after `params.after`. */\n list: (params: EventListParams = {}, opts?: RequestOptions) => get<Page<Event>>(\"/v1/events\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Event>(`/v1/events/${seg(id)}`, undefined, opts),\n /**\n * Every event after `after` (default: from the very first), oldest first, across pages. Store the last id you\n * processed and pass it next time to catch up after downtime.\n */\n since: (after = \"evt_0\", params: Omit<EventListParams, \"after\"> = {}, opts?: RequestOptions): AsyncIterable<Event> =>\n http.paginate<Event>(\"/v1/events\", { ...params, after }, opts),\n };\n\n this.transactions = {\n /** Deposits, top-ups, withdrawals and payouts, newest first. */\n list: (params: TransactionListParams = {}, opts?: RequestOptions): ListResult<Transaction> => listResult(http, \"/v1/transactions\", params, opts),\n /** With the full deposit or withdrawal and every event about it, including webhook deliveries. */\n get: (id: string, opts?: RequestOptions) => get<TransactionDetail>(`/v1/transactions/${seg(id)}`, undefined, opts),\n };\n\n this.stats = {\n /** Balances and daily volume in USD at current rates (default 30 days). */\n get: (params: StatsParams = {}, opts?: RequestOptions) => get<Stats>(\"/v1/stats\", params, opts),\n };\n\n this.settings = {\n get: (opts?: RequestOptions) => get<Settings>(\"/v1/settings\", undefined, opts),\n };\n\n this.checkout = {\n /** Public: what a payer needs to pay an invoice (no API key needed). */\n get: (invoiceId: string, opts?: RequestOptions) => http.request<Checkout>({ method: \"GET\", path: `/v1/checkout/${seg(invoiceId)}`, auth: false }, opts),\n /** Public: choose the payment currency once, while the invoice is `NEW`. */\n select: (invoiceId: string, params: CheckoutSelectParams, opts?: RequestOptions) =>\n post<Checkout>(`/v1/checkout/${seg(invoiceId)}/select`, params, opts, { auth: false }),\n };\n\n this.webhooks = {\n /** Verify a webhook request and return the typed event (see `Webhook.verify`). */\n verify: (payload: WebhookPayload, headers: WebhookHeaders, secret: string | string[], options?: WebhookOptions) =>\n new Webhook(secret, options).verify(payload, headers),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAA2B;;;ACGpB,IAAM,gBAAN,c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QAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,MAK/F,OAAO,CAAC,QAAQ,SAAS,SAAyC,CAAC,GAAG,SACpE,KAAK,SAAgB,cAAc,EAAE,GAAG,QAAQ,MAAM,GAAG,IAAI;AAAA,IACjE;AAEA,SAAK,eAAe;AAAA;AAAA,MAElB,MAAM,CAAC,SAAgC,CAAC,GAAG,SAAmD,WAAW,MAAM,oBAAoB,QAAQ,IAAI;AAAA;AAAA,MAE/I,KAAK,CAAC,IAAY,SAA0B,IAAuB,oBAAoB,IAAI,EAAE,CAAC,IAAI,QAAW,IAAI;AAAA,IACnH;AAEA,SAAK,QAAQ;AAAA;AAAA,MAEX,KAAK,CAAC,SAAsB,CAAC,GAAG,SAA0B,IAAW,aAAa,QAAQ,IAAI;AAAA,IAChG;AAEA,SAAK,WAAW;AAAA,MACd,KAAK,CAAC,SAA0B,IAAc,gBAAgB,QAAW,IAAI;AAAA,IAC/E;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,KAAK,CAAC,WAAmB,SAA0B,KAAK,QAAkB,EAAE,QAAQ,OAAO,MAAM,gBAAgB,IAAI,SAAS,CAAC,IAAI,MAAM,MAAM,GAAG,IAAI;AAAA;AAAA,MAEtJ,QAAQ,CAAC,WAAmB,QAA8B,SACxD,KAAe,gBAAgB,IAAI,SAAS,CAAC,WAAW,QAAQ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,IACzF;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,QAAQ,CAAC,SAAyB,SAAyB,QAA2BC,aACpF,IAAI,QAAQ,QAAQA,QAAO,EAAE,OAAO,SAAS,OAAO;AAAA,IACxD;AAAA,EACF;AACF;","names":["error","import_node_crypto","options"]}
package/dist/index.d.cts CHANGED
@@ -247,8 +247,9 @@ interface components {
247
247
  network: components["schemas"]["NetworkId"];
248
248
  network_currency: components["schemas"]["NetworkCurrencyId"];
249
249
  amount: components["schemas"]["Decimal"];
250
+ /** @description Service + network fee. Before CREDITED it is the expected fee (the amount, if the deposit is below the minimum); final on deposit.credited. */
250
251
  fee: components["schemas"]["Decimal"];
251
- /** @description amount − fee; what is added to your balance. */
252
+ /** @description amount − fee; what is (or, before CREDITED, is expected to be) added to your balance. */
252
253
  net_amount: components["schemas"]["Decimal"];
253
254
  tx_hash: string;
254
255
  from_address: string | null;
@@ -1613,6 +1614,15 @@ interface operations {
1613
1614
  };
1614
1615
  requestBody?: never;
1615
1616
  responses: {
1617
+ /** @description The PENDING delivery, now due. */
1618
+ 200: {
1619
+ headers: {
1620
+ [name: string]: unknown;
1621
+ };
1622
+ content: {
1623
+ "application/json": components["schemas"]["WebhookDelivery"];
1624
+ };
1625
+ };
1616
1626
  /** @description The new delivery (PENDING). */
1617
1627
  201: {
1618
1628
  headers: {
@@ -2446,7 +2456,7 @@ declare class GhostPay {
2446
2456
  list: (params?: WebhookDeliveryListParams, opts?: RequestOptions) => ListResult<WebhookDelivery>;
2447
2457
  /** With every attempt (status code, response body, timing). */
2448
2458
  get: (id: string, opts?: RequestOptions) => Promise<WithResponse<WebhookDeliveryWithAttempts>>;
2449
- /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */
2459
+ /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */
2450
2460
  retry: (id: string, opts?: RequestOptions) => Promise<WithResponse<{
2451
2461
  id: string;
2452
2462
  object: "webhook_delivery";
@@ -2642,6 +2652,6 @@ declare class WebhookVerificationError extends GhostPayError {
2642
2652
  name: string;
2643
2653
  }
2644
2654
 
2645
- declare const VERSION = "1.1.0";
2655
+ declare const VERSION = "1.2.0";
2646
2656
 
2647
2657
  export { type AcceptedCurrency, type Address, type AddressCreateParams, type AddressListParams, type Balance, type Checkout, type CheckoutSelectParams, type Currency, type CurrencyCode, type Customer, type CustomerListParams, type CustomerUpsertParams, type Decimal, type DeliveryStatus, type Deposit, type DepositListParams, type DepositStatus, type EndpointEventType, type ErrorCode, type Event, type EventData, type EventListParams, type EventType, type Family, GhostPay, GhostPayApiError, GhostPayConnectionError, GhostPayError, type GhostPayOptions, type Invoice, type InvoiceCreateParams, type InvoiceListParams, type InvoiceStatus, type ListResult, type Metadata, type Network, type NetworkCurrencyId, type NetworkId, type Page, type Ping, type Rate, type RequestOptions, type ResponseMeta, type Settings, type Stats, type StatsParams, type Transaction, type TransactionDetail, type TransactionListParams, type TransactionType, VERSION, Webhook, type WebhookAttempt, type WebhookDelivery, type WebhookDeliveryListParams, type WebhookDeliveryWithAttempts, type WebhookEndpoint, type WebhookEndpointCreateParams, type WebhookEndpointListParams, type WebhookEndpointUpdateParams, type WebhookEndpointWithSecret, type WebhookEvent, type WebhookHeaders, type WebhookOptions, type WebhookPayload, type WebhookReplayParams, WebhookVerificationError, type WithResponse, type Withdrawal, type WithdrawalCreateParams, type WithdrawalListParams, type WithdrawalQuote, type WithdrawalQuoteParams, type WithdrawalStatus, GhostPay as default };
package/dist/index.d.ts CHANGED
@@ -247,8 +247,9 @@ interface components {
247
247
  network: components["schemas"]["NetworkId"];
248
248
  network_currency: components["schemas"]["NetworkCurrencyId"];
249
249
  amount: components["schemas"]["Decimal"];
250
+ /** @description Service + network fee. Before CREDITED it is the expected fee (the amount, if the deposit is below the minimum); final on deposit.credited. */
250
251
  fee: components["schemas"]["Decimal"];
251
- /** @description amount − fee; what is added to your balance. */
252
+ /** @description amount − fee; what is (or, before CREDITED, is expected to be) added to your balance. */
252
253
  net_amount: components["schemas"]["Decimal"];
253
254
  tx_hash: string;
254
255
  from_address: string | null;
@@ -1613,6 +1614,15 @@ interface operations {
1613
1614
  };
1614
1615
  requestBody?: never;
1615
1616
  responses: {
1617
+ /** @description The PENDING delivery, now due. */
1618
+ 200: {
1619
+ headers: {
1620
+ [name: string]: unknown;
1621
+ };
1622
+ content: {
1623
+ "application/json": components["schemas"]["WebhookDelivery"];
1624
+ };
1625
+ };
1616
1626
  /** @description The new delivery (PENDING). */
1617
1627
  201: {
1618
1628
  headers: {
@@ -2446,7 +2456,7 @@ declare class GhostPay {
2446
2456
  list: (params?: WebhookDeliveryListParams, opts?: RequestOptions) => ListResult<WebhookDelivery>;
2447
2457
  /** With every attempt (status code, response body, timing). */
2448
2458
  get: (id: string, opts?: RequestOptions) => Promise<WithResponse<WebhookDeliveryWithAttempts>>;
2449
- /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */
2459
+ /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */
2450
2460
  retry: (id: string, opts?: RequestOptions) => Promise<WithResponse<{
2451
2461
  id: string;
2452
2462
  object: "webhook_delivery";
@@ -2642,6 +2652,6 @@ declare class WebhookVerificationError extends GhostPayError {
2642
2652
  name: string;
2643
2653
  }
2644
2654
 
2645
- declare const VERSION = "1.1.0";
2655
+ declare const VERSION = "1.2.0";
2646
2656
 
2647
2657
  export { type AcceptedCurrency, type Address, type AddressCreateParams, type AddressListParams, type Balance, type Checkout, type CheckoutSelectParams, type Currency, type CurrencyCode, type Customer, type CustomerListParams, type CustomerUpsertParams, type Decimal, type DeliveryStatus, type Deposit, type DepositListParams, type DepositStatus, type EndpointEventType, type ErrorCode, type Event, type EventData, type EventListParams, type EventType, type Family, GhostPay, GhostPayApiError, GhostPayConnectionError, GhostPayError, type GhostPayOptions, type Invoice, type InvoiceCreateParams, type InvoiceListParams, type InvoiceStatus, type ListResult, type Metadata, type Network, type NetworkCurrencyId, type NetworkId, type Page, type Ping, type Rate, type RequestOptions, type ResponseMeta, type Settings, type Stats, type StatsParams, type Transaction, type TransactionDetail, type TransactionListParams, type TransactionType, VERSION, Webhook, type WebhookAttempt, type WebhookDelivery, type WebhookDeliveryListParams, type WebhookDeliveryWithAttempts, type WebhookEndpoint, type WebhookEndpointCreateParams, type WebhookEndpointListParams, type WebhookEndpointUpdateParams, type WebhookEndpointWithSecret, type WebhookEvent, type WebhookHeaders, type WebhookOptions, type WebhookPayload, type WebhookReplayParams, WebhookVerificationError, type WithResponse, type Withdrawal, type WithdrawalCreateParams, type WithdrawalListParams, type WithdrawalQuote, type WithdrawalQuoteParams, type WithdrawalStatus, GhostPay as default };
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ var WebhookVerificationError = class extends GhostPayError {
34
34
  };
35
35
 
36
36
  // src/version.ts
37
- var VERSION = "1.1.0";
37
+ var VERSION = "1.2.0";
38
38
 
39
39
  // src/http.ts
40
40
  var RETRY_BASE_MS = 500;
@@ -372,7 +372,7 @@ var GhostPay = class {
372
372
  list: (params = {}, opts) => listResult(http, "/v1/webhook-deliveries", params, opts),
373
373
  /** With every attempt (status code, response body, timing). */
374
374
  get: (id, opts) => get(`/v1/webhook-deliveries/${seg(id)}`, void 0, opts),
375
- /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */
375
+ /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */
376
376
  retry: (id, opts) => post(`/v1/webhook-deliveries/${seg(id)}/retry`, void 0, opts)
377
377
  };
378
378
  this.events = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/http.ts","../src/errors.ts","../src/version.ts","../src/webhooks.ts","../src/client.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { GhostPayApiError, GhostPayConnectionError, GhostPayError } from \"./errors.js\";\nimport type { ErrorCode, Page } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\n\nexport interface GhostPayOptions {\n /** Secret API key (`gp_live_…`). Only the public checkout calls work without one. */\n apiKey?: string;\n /** API host. Default `https://api.ghostpay.gg`. */\n baseUrl?: string;\n /** Per-attempt timeout. Default 30 s. */\n timeoutMs?: number;\n /** Retries after a network error, timeout, 429 or 5xx (always with the same Idempotency-Key). Default 2. */\n maxRetries?: number;\n /** Custom fetch (proxies, tests). Default: global fetch. */\n fetch?: typeof fetch;\n /** Appended to the User-Agent, e.g. `my-casino/2.1`. */\n appInfo?: string;\n}\n\nexport interface RequestOptions {\n /** Idempotency-Key for this POST. Default: a random UUID, reused on every retry of this call. */\n idempotencyKey?: string;\n timeoutMs?: number;\n maxRetries?: number;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n}\n\nexport interface ResponseMeta {\n status: number;\n headers: Headers;\n /** The API replayed a stored response for this Idempotency-Key. */\n idempotentReplayed: boolean;\n idempotencyKey: string | undefined;\n}\n\n/** A response object; `lastResponse` (not enumerable, not serialized) has status, headers and idempotency info. */\nexport type WithResponse<T> = T & { readonly lastResponse: ResponseMeta };\n\ntype Method = \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\ntype Query = Record<string, string | number | boolean | undefined | null>;\n\nexport interface RequestSpec {\n method: Method;\n path: string;\n query?: Query | undefined;\n body?: unknown;\n /** Send the API key (false for public checkout calls). */\n auth?: boolean;\n /**\n * Retry a POST after the request may have reached the server. False for calls whose response is never stored for\n * idempotent replay (webhook endpoint creation returns a secret), where a retry would act twice.\n */\n retryAfterSend?: boolean;\n}\n\nconst RETRY_BASE_MS = 500;\nconst RETRY_MAX_MS = 8_000;\n\nconst DEFAULT_BASE_URL = \"https://api.ghostpay.gg\";\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly userAgent: string;\n\n constructor(private readonly options: GhostPayOptions) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) throw new GhostPayError(\"No fetch available: use Node 18+ or pass options.fetch\");\n this.userAgent = `ghostpay-node/${VERSION} node/${process.versions.node}${options.appInfo ? ` ${options.appInfo}` : \"\"}`;\n }\n\n async request<T>(spec: RequestSpec, options: RequestOptions = {}): Promise<WithResponse<T>> {\n const auth = spec.auth ?? true;\n if (auth && !this.options.apiKey) throw new GhostPayError(\"This call needs an API key: new GhostPay({ apiKey, baseUrl })\");\n\n const url = this.baseUrl + spec.path + queryString(spec.query);\n const idempotencyKey = spec.method === \"POST\" ? (options.idempotencyKey ?? randomUUID()) : undefined;\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"user-agent\": this.userAgent,\n ...(auth ? { authorization: `Bearer ${this.options.apiKey}` } : {}),\n ...(idempotencyKey ? { \"idempotency-key\": idempotencyKey } : {}),\n ...(spec.body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n ...options.headers,\n };\n const body = spec.body !== undefined ? JSON.stringify(spec.body) : undefined;\n const maxRetries = options.maxRetries ?? this.options.maxRetries ?? 2;\n const timeoutMs = options.timeoutMs ?? this.options.timeoutMs ?? 30_000;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let text: string;\n try {\n ({ response, text } = await this.send(url, { method: spec.method, headers, ...(body !== undefined ? { body } : {}) }, timeoutMs, options.signal));\n } catch (error) {\n if (options.signal?.aborted) throw error;\n const sent = !(error instanceof GhostPayConnectionError && isRefused(error));\n if (attempt < maxRetries && (spec.method === \"GET\" || !sent || spec.retryAfterSend !== false)) {\n await sleep(backoff(attempt));\n continue;\n }\n throw error;\n }\n\n const parsed = text ? safeJson(text) : undefined;\n if (response.ok) {\n if (parsed === undefined && text) throw new GhostPayError(`Invalid JSON from ${spec.method} ${spec.path} (HTTP ${response.status})`);\n return withMeta(parsed as T, {\n status: response.status,\n headers: response.headers,\n idempotentReplayed: response.headers.get(\"idempotent-replayed\") === \"true\",\n idempotencyKey,\n });\n }\n\n const error = toApiError(response, parsed, text);\n if (attempt < maxRetries && retryable(error) && (spec.method === \"GET\" || spec.retryAfterSend !== false)) {\n await sleep(retryAfterMs(response.headers) ?? backoff(attempt));\n continue;\n }\n throw error;\n }\n }\n\n /** Every item of a cursor-paginated list, fetching pages as needed. */\n async *paginate<T extends { id: string }>(path: string, query: Query, options?: RequestOptions): AsyncGenerator<T> {\n let after = query.after ?? undefined;\n for (;;) {\n const page = await this.request<Page<T>>({ method: \"GET\", path, query: { ...query, after } }, options);\n for (const item of page.data) yield item;\n const last = page.data[page.data.length - 1];\n if (!page.has_more || !last) return;\n after = last.id;\n }\n }\n\n private async send(url: string, init: RequestInit, timeoutMs: number, signal?: AbortSignal): Promise<{ response: Response; text: string }> {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n try {\n const response = await this.fetchImpl(url, { ...init, signal: controller.signal });\n return { response, text: await response.text() };\n } catch (error) {\n if (signal?.aborted) throw error;\n if (timedOut) throw new GhostPayConnectionError(`Request timed out after ${timeoutMs} ms`, true, { cause: error });\n throw new GhostPayConnectionError(`Could not reach GhostPay: ${(error as Error)?.message ?? error}`, false, { cause: error });\n } finally {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n}\n\n/** A list call: await it for one page, or `for await` it to walk every item across pages. */\nexport type ListResult<T> = Promise<WithResponse<Page<T>>> & AsyncIterable<T>;\n\nexport function listResult<T extends { id: string }>(http: HttpClient, path: string, query: Query = {}, options?: RequestOptions): ListResult<T> {\n let pending: Promise<WithResponse<Page<T>>> | undefined;\n const first = () => (pending ??= http.request<Page<T>>({ method: \"GET\", path, query }, options));\n return {\n then: (onFulfilled, onRejected) => first().then(onFulfilled, onRejected),\n catch: (onRejected) => first().catch(onRejected),\n finally: (onFinally) => first().finally(onFinally),\n [Symbol.toStringTag]: \"ListResult\",\n [Symbol.asyncIterator]: () => http.paginate<T>(path, query, options),\n } as ListResult<T>;\n}\n\nfunction withMeta<T>(value: T, meta: ResponseMeta): WithResponse<T> {\n const target = (value && typeof value === \"object\" ? value : {}) as object;\n Object.defineProperty(target, \"lastResponse\", { value: meta, enumerable: false });\n return target as WithResponse<T>;\n}\n\nfunction toApiError(response: Response, parsed: unknown, text: string): GhostPayApiError {\n const envelope = (parsed as { error?: { code?: string; message?: string; param?: string } } | undefined)?.error;\n const code = (envelope?.code ?? (response.status >= 500 ? \"api_error\" : \"invalid_request\")) as ErrorCode;\n const message = envelope?.message ?? `HTTP ${response.status}${text ? `: ${text.slice(0, 200)}` : \"\"}`;\n return new GhostPayApiError(response.status, code, message, envelope?.param, response.headers, parsed ?? text);\n}\n\nfunction retryable(error: GhostPayApiError): boolean {\n if (error.status === 429 || error.status >= 500) return true;\n // The same Idempotency-Key is still running on the server: its result will be replayed shortly.\n return error.status === 409 && error.code === \"conflict\" && !error.param && /idempotency-key/i.test(error.message);\n}\n\nfunction isRefused(error: GhostPayConnectionError): boolean {\n const cause = (error.cause as { cause?: { code?: string } } | undefined)?.cause;\n return cause?.code === \"ECONNREFUSED\" || cause?.code === \"ENOTFOUND\" || cause?.code === \"EAI_AGAIN\";\n}\n\nfunction backoff(attempt: number): number {\n const base = Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** attempt);\n return base / 2 + Math.random() * (base / 2);\n}\n\nfunction retryAfterMs(headers: Headers): number | undefined {\n const value = headers.get(\"retry-after\");\n if (!value) return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.min(RETRY_MAX_MS * 4, Math.max(0, seconds * 1000));\n const date = Date.parse(value);\n return Number.isFinite(date) ? Math.min(RETRY_MAX_MS * 4, Math.max(0, date - Date.now())) : undefined;\n}\n\nfunction queryString(query: Query | undefined): string {\n if (!query) return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) params.set(key, String(value));\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { ErrorCode } from \"./types.js\";\n\n/** Base class of every error this SDK throws. */\nexport class GhostPayError extends Error {\n override name = \"GhostPayError\";\n}\n\n/** The API answered with an error envelope. Switch on `code`; it is stable. */\nexport class GhostPayApiError extends GhostPayError {\n override name = \"GhostPayApiError\";\n readonly status: number;\n readonly code: ErrorCode;\n readonly param: string | undefined;\n readonly headers: Headers;\n readonly raw: unknown;\n\n constructor(status: number, code: ErrorCode, message: string, param: string | undefined, headers: Headers, raw: unknown) {\n super(message);\n this.status = status;\n this.code = code;\n this.param = param;\n this.headers = headers;\n this.raw = raw;\n }\n}\n\n/** No response: DNS, connection refused/reset, or the request timed out. Safe to retry with the same Idempotency-Key. */\nexport class GhostPayConnectionError extends GhostPayError {\n override name = \"GhostPayConnectionError\";\n readonly timedOut: boolean;\n constructor(message: string, timedOut: boolean, options?: { cause?: unknown }) {\n super(message, options);\n this.timedOut = timedOut;\n }\n}\n\n/** A webhook request failed signature or timestamp checks. Reply 400 and do not process it. */\nexport class WebhookVerificationError extends GhostPayError {\n override name = \"WebhookVerificationError\";\n}\n","export const VERSION = \"1.1.0\";\n","import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { WebhookVerificationError } from \"./errors.js\";\nimport type { WebhookEvent } from \"./types.js\";\n\nexport type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;\nexport type WebhookPayload = string | Uint8Array;\n\nexport interface WebhookOptions {\n /** Accepted clock difference in seconds, both ways. Default 300 (5 minutes). */\n toleranceSec?: number;\n}\n\nconst PREFIX = \"whsec_\";\n\n/**\n * Verifies GhostPay webhook requests (Standard Webhooks: HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`).\n * Pass several secrets while rotating an endpoint's secret.\n */\nexport class Webhook {\n private readonly keys: Buffer[];\n private readonly toleranceSec: number;\n\n constructor(secret: string | string[], options: WebhookOptions = {}) {\n const secrets = Array.isArray(secret) ? secret : [secret];\n if (secrets.length === 0 || secrets.some((value) => typeof value !== \"string\" || value.length === 0)) {\n throw new WebhookVerificationError(\"A webhook signing secret (whsec_…) is required\");\n }\n this.keys = secrets.map(decodeSecret);\n this.toleranceSec = options.toleranceSec ?? 300;\n }\n\n /**\n * Checks the signature and timestamp and returns the parsed, typed event. `payload` must be the raw request body,\n * exactly as received (e.g. `express.raw({ type: \"application/json\" })`), never re-serialized JSON.\n */\n verify(payload: WebhookPayload, headers: WebhookHeaders, now: Date = new Date()): WebhookEvent {\n const body = rawBody(payload);\n const id = header(headers, \"webhook-id\");\n const timestamp = header(headers, \"webhook-timestamp\");\n const signatures = header(headers, \"webhook-signature\");\n if (!id || !timestamp || !signatures) throw new WebhookVerificationError(\"Missing webhook-id, webhook-timestamp or webhook-signature header\");\n\n const seconds = Number(timestamp);\n if (!/^\\d+$/.test(timestamp) || !Number.isSafeInteger(seconds)) throw new WebhookVerificationError(\"Invalid webhook-timestamp\");\n const skew = Math.floor(now.getTime() / 1000) - seconds;\n if (skew > this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is too old\");\n if (skew < -this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is in the future\");\n\n const expected = this.keys.map((key) => sign(key, id, timestamp, body));\n const valid = signatures.split(\" \").some((entry) => {\n const [version, signature] = entry.split(\",\", 2);\n if (version !== \"v1\" || !signature) return false;\n const given = Buffer.from(signature, \"base64\");\n return expected.some((candidate) => given.length === candidate.length && timingSafeEqual(given, candidate));\n });\n if (!valid) throw new WebhookVerificationError(\"No matching webhook signature\");\n\n let event: WebhookEvent;\n try {\n event = JSON.parse(body.toString(\"utf8\")) as WebhookEvent;\n } catch {\n throw new WebhookVerificationError(\"Webhook body is not valid JSON\");\n }\n if (!event || typeof event !== \"object\" || event.id !== id) throw new WebhookVerificationError(\"Webhook body id does not match webhook-id\");\n return event;\n }\n\n /** The `webhook-signature` header value for a body (for your own tests). */\n sign(id: string, timestamp: number | Date, payload: WebhookPayload): string {\n const seconds = String(typeof timestamp === \"number\" ? timestamp : Math.floor(timestamp.getTime() / 1000));\n return `v1,${sign(this.keys[0]!, id, seconds, rawBody(payload)).toString(\"base64\")}`;\n }\n}\n\nfunction sign(key: Buffer, id: string, timestamp: string, body: Buffer): Buffer {\n return createHmac(\"sha256\", key).update(`${id}.${timestamp}.`).update(body).digest();\n}\n\nfunction decodeSecret(secret: string): Buffer {\n const key = Buffer.from(secret.startsWith(PREFIX) ? secret.slice(PREFIX.length) : secret, \"base64\");\n if (key.length === 0) throw new WebhookVerificationError(\"Invalid webhook signing secret\");\n return key;\n}\n\nfunction rawBody(payload: WebhookPayload): Buffer {\n if (typeof payload === \"string\") return Buffer.from(payload, \"utf8\");\n if (payload instanceof Uint8Array) return Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);\n throw new WebhookVerificationError(\n \"Pass the raw request body (string or Buffer), not parsed JSON: re-serializing changes the bytes and breaks the signature\",\n );\n}\n\nfunction header(headers: WebhookHeaders, name: string): string | undefined {\n if (typeof (headers as Headers).get === \"function\") return (headers as Headers).get(name) ?? undefined;\n const record = headers as Record<string, string | string[] | undefined>;\n const key = Object.keys(record).find((candidate) => candidate.toLowerCase() === name);\n const value = key === undefined ? undefined : record[key];\n return Array.isArray(value) ? value.join(\" \") : value;\n}\n","import { HttpClient, listResult, type GhostPayOptions, type ListResult, type RequestOptions } from \"./http.js\";\nimport type {\n Address,\n AddressCreateParams,\n AddressListParams,\n Balance,\n Checkout,\n CheckoutSelectParams,\n Currency,\n Customer,\n CustomerListParams,\n CustomerUpsertParams,\n Deposit,\n DepositListParams,\n Event,\n EventListParams,\n Invoice,\n InvoiceCreateParams,\n InvoiceListParams,\n Network,\n Page,\n Rate,\n Settings,\n Stats,\n StatsParams,\n Transaction,\n TransactionDetail,\n TransactionListParams,\n WebhookDelivery,\n WebhookDeliveryListParams,\n WebhookDeliveryWithAttempts,\n WebhookEndpoint,\n WebhookEndpointCreateParams,\n WebhookEndpointListParams,\n WebhookEndpointUpdateParams,\n WebhookEndpointWithSecret,\n WebhookReplayParams,\n Withdrawal,\n WithdrawalCreateParams,\n WithdrawalListParams,\n WithdrawalQuote,\n WithdrawalQuoteParams,\n} from \"./types.js\";\nimport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\n\nconst seg = (value: string) => encodeURIComponent(value);\ntype Q = Record<string, string | number | boolean | undefined | null>;\n\nexport class GhostPay {\n readonly networks;\n readonly currencies;\n readonly rates;\n readonly balances;\n readonly customers;\n readonly addresses;\n readonly deposits;\n readonly invoices;\n readonly withdrawals;\n readonly webhookEndpoints;\n readonly webhookDeliveries;\n readonly events;\n readonly transactions;\n readonly stats;\n readonly settings;\n readonly checkout;\n readonly webhooks;\n\n constructor(options: GhostPayOptions) {\n const http = new HttpClient(options);\n const get = <T>(path: string, query?: Q, opts?: RequestOptions) => http.request<T>({ method: \"GET\", path, query }, opts);\n const post = <T>(path: string, body?: unknown, opts?: RequestOptions, extra?: { auth?: boolean; retryAfterSend?: boolean }) =>\n http.request<T>({ method: \"POST\", path, body, ...extra }, opts);\n\n this.networks = {\n /** Every network, with confirmations and whether deposits/withdrawals are on. */\n list: (opts?: RequestOptions) => get<Page<Network>>(\"/v1/networks\", undefined, opts),\n };\n this.currencies = {\n /** Enabled currencies with your minimums and fees. */\n list: (opts?: RequestOptions) => get<Page<Currency>>(\"/v1/currencies\", undefined, opts),\n };\n this.rates = {\n /** Indicative USD price per currency. */\n list: (opts?: RequestOptions) => get<Page<Rate>>(\"/v1/rates\", undefined, opts),\n };\n this.balances = {\n /** Available, on-hold and pending balance per currency. */\n list: (opts?: RequestOptions) => get<Page<Balance>>(\"/v1/balances\", undefined, opts),\n };\n\n this.customers = {\n /** Create the customer, or update its metadata if `external_id` exists. */\n upsert: (params: CustomerUpsertParams, opts?: RequestOptions) => post<Customer>(\"/v1/customers\", params, opts),\n list: (params: CustomerListParams = {}, opts?: RequestOptions): ListResult<Customer> => listResult(http, \"/v1/customers\", params, opts),\n /** By `cus_…` id or `ext:<external_id>`. */\n get: (customer: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(customer)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(`ext:${externalId}`)}`, undefined, opts),\n };\n\n this.addresses = {\n /** The customer's permanent deposit address for the network's address scope (created on first call; `lastResponse.status` 201). */\n getOrCreate: (params: AddressCreateParams, opts?: RequestOptions) => post<Address>(\"/v1/addresses\", params, opts),\n list: (params: AddressListParams = {}, opts?: RequestOptions): ListResult<Address> => listResult(http, \"/v1/addresses\", params, opts),\n /** By `addr_…` id or the on-chain address. */\n get: (address: string, opts?: RequestOptions) => get<Address>(`/v1/addresses/${seg(address)}`, undefined, opts),\n /** Stop handing this address out; payments to it are still credited. */\n retire: (address: string, opts?: RequestOptions) => post<Address>(`/v1/addresses/${seg(address)}/retire`, undefined, opts),\n /** Your own addresses for funding your balance, one per address scope; credited with no fees. */\n topUps: (opts?: RequestOptions) => get<{ data: Address[] }>(\"/v1/top-up-addresses\", undefined, opts),\n };\n\n this.deposits = {\n list: (params: DepositListParams = {}, opts?: RequestOptions): ListResult<Deposit> => listResult(http, \"/v1/deposits\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Deposit>(`/v1/deposits/${seg(id)}`, undefined, opts),\n };\n\n this.invoices = {\n create: (params: InvoiceCreateParams, opts?: RequestOptions) => post<Invoice>(\"/v1/invoices\", params, opts),\n list: (params: InvoiceListParams = {}, opts?: RequestOptions): ListResult<Invoice> => listResult(http, \"/v1/invoices\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Invoice>(`/v1/invoices/${seg(id)}`, undefined, opts),\n /** Only while `NEW`. */\n cancel: (id: string, opts?: RequestOptions) => post<Invoice>(`/v1/invoices/${seg(id)}/cancel`, undefined, opts),\n };\n\n this.withdrawals = {\n /** Fee, total and whether your balance covers it. Creates nothing. */\n quote: (params: WithdrawalQuoteParams, opts?: RequestOptions) =>\n post<WithdrawalQuote>(\"/v1/withdrawals/quote\", params, opts),\n /**\n * Pays out from your balance. The Idempotency-Key defaults to `withdrawal:<external_id>` when you give an\n * `external_id`, so retrying the same payout (even after a restart) can never pay twice.\n */\n create: (params: WithdrawalCreateParams, opts: RequestOptions = {}) =>\n post<Withdrawal>(\"/v1/withdrawals\", params, {\n ...opts,\n ...(opts.idempotencyKey === undefined && params.external_id ? { idempotencyKey: `withdrawal:${params.external_id}` } : {}),\n }),\n list: (params: WithdrawalListParams = {}, opts?: RequestOptions): ListResult<Withdrawal> => listResult(http, \"/v1/withdrawals\", params, opts),\n /** By `wd_…` id or your external id. */\n get: (withdrawal: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(`ext:${externalId}`)}`, undefined, opts),\n /** Only before it is sent. The hold returns to your available balance. */\n cancel: (withdrawal: string, opts?: RequestOptions) => post<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}/cancel`, undefined, opts),\n };\n\n this.webhookEndpoints = {\n /** The response's `secret` is shown only once: store it. Not retried once sent (a retry would create a second endpoint). */\n create: (params: WebhookEndpointCreateParams, opts?: RequestOptions) =>\n post<WebhookEndpointWithSecret>(\"/v1/webhook-endpoints\", params, opts, { retryAfterSend: false }),\n list: (params: WebhookEndpointListParams = {}, opts?: RequestOptions): ListResult<WebhookEndpoint> =>\n listResult(http, \"/v1/webhook-endpoints\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<WebhookEndpoint>(`/v1/webhook-endpoints/${seg(id)}`, undefined, opts),\n update: (id: string, params: WebhookEndpointUpdateParams, opts?: RequestOptions) =>\n http.request<WebhookEndpoint>({ method: \"PATCH\", path: `/v1/webhook-endpoints/${seg(id)}`, body: params }, opts),\n delete: (id: string, opts?: RequestOptions) =>\n http.request<{ id: string; object: \"webhook_endpoint\"; deleted: true }>({ method: \"DELETE\", path: `/v1/webhook-endpoints/${seg(id)}` }, opts),\n /** Sends a `ping` event to this endpoint. */\n test: (id: string, opts?: RequestOptions) =>\n post<{ event: Event; delivery: WebhookDelivery }>(`/v1/webhook-endpoints/${seg(id)}/test`, undefined, opts),\n /** Re-sends matching events created in `[from, to]` as new deliveries; events already queued for the endpoint are skipped. */\n replay: (id: string, params: WebhookReplayParams, opts?: RequestOptions) =>\n post<{ queued: number }>(`/v1/webhook-endpoints/${seg(id)}/replay`, params, opts),\n };\n\n this.webhookDeliveries = {\n list: (params: WebhookDeliveryListParams = {}, opts?: RequestOptions): ListResult<WebhookDelivery> =>\n listResult(http, \"/v1/webhook-deliveries\", params, opts),\n /** With every attempt (status code, response body, timing). */\n get: (id: string, opts?: RequestOptions) => get<WebhookDeliveryWithAttempts>(`/v1/webhook-deliveries/${seg(id)}`, undefined, opts),\n /** Re-sends a FAILED delivery's event as a new delivery (returned), retried per the endpoint's `auto_retry`. */\n retry: (id: string, opts?: RequestOptions) => post<WebhookDelivery>(`/v1/webhook-deliveries/${seg(id)}/retry`, undefined, opts),\n };\n\n this.events = {\n /** One page: newest first, or oldest first after `params.after`. */\n list: (params: EventListParams = {}, opts?: RequestOptions) => get<Page<Event>>(\"/v1/events\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Event>(`/v1/events/${seg(id)}`, undefined, opts),\n /**\n * Every event after `after` (default: from the very first), oldest first, across pages. Store the last id you\n * processed and pass it next time to catch up after downtime.\n */\n since: (after = \"evt_0\", params: Omit<EventListParams, \"after\"> = {}, opts?: RequestOptions): AsyncIterable<Event> =>\n http.paginate<Event>(\"/v1/events\", { ...params, after }, opts),\n };\n\n this.transactions = {\n /** Deposits, top-ups, withdrawals and payouts, newest first. */\n list: (params: TransactionListParams = {}, opts?: RequestOptions): ListResult<Transaction> => listResult(http, \"/v1/transactions\", params, opts),\n /** With the full deposit or withdrawal and every event about it, including webhook deliveries. */\n get: (id: string, opts?: RequestOptions) => get<TransactionDetail>(`/v1/transactions/${seg(id)}`, undefined, opts),\n };\n\n this.stats = {\n /** Balances and daily volume in USD at current rates (default 30 days). */\n get: (params: StatsParams = {}, opts?: RequestOptions) => get<Stats>(\"/v1/stats\", params, opts),\n };\n\n this.settings = {\n get: (opts?: RequestOptions) => get<Settings>(\"/v1/settings\", undefined, opts),\n };\n\n this.checkout = {\n /** Public: what a payer needs to pay an invoice (no API key needed). */\n get: (invoiceId: string, opts?: RequestOptions) => http.request<Checkout>({ method: \"GET\", path: `/v1/checkout/${seg(invoiceId)}`, auth: false }, opts),\n /** Public: choose the payment currency once, while the invoice is `NEW`. */\n select: (invoiceId: string, params: CheckoutSelectParams, opts?: RequestOptions) =>\n post<Checkout>(`/v1/checkout/${seg(invoiceId)}/select`, params, opts, { auth: false }),\n };\n\n this.webhooks = {\n /** Verify a webhook request and return the typed event (see `Webhook.verify`). */\n verify: (payload: WebhookPayload, headers: WebhookHeaders, secret: string | string[], options?: WebhookOptions) =>\n new Webhook(secret, options).verify(payload, headers),\n };\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACGpB,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B,OAAO;AAClB;AAGO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EACzC,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAgB,MAAiB,SAAiB,OAA2B,SAAkB,KAAc;AACvH,UAAM,OAAO;AACb,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,MAAM;AAAA,EACb;AACF;AAGO,IAAM,0BAAN,cAAsC,cAAc;AAAA,EAChD,OAAO;AAAA,EACP;AAAA,EACT,YAAY,SAAiB,UAAmB,SAA+B;AAC7E,UAAM,SAAS,OAAO;AACtB,SAAK,WAAW;AAAA,EAClB;AACF;AAGO,IAAM,2BAAN,cAAuC,cAAc;AAAA,EACjD,OAAO;AAClB;;;ACvCO,IAAM,UAAU;;;AFyDvB,IAAM,gBAAgB;AACtB,IAAM,eAAe;AAErB,IAAM,mBAAmB;AAElB,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAA6B,SAA0B;AAA1B;AAC3B,SAAK,WAAW,QAAQ,WAAW,kBAAkB,QAAQ,QAAQ,EAAE;AACvE,SAAK,YAAY,QAAQ,SAAS,WAAW;AA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B,QAA8B,SACxD,KAAe,gBAAgB,IAAI,SAAS,CAAC,WAAW,QAAQ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,IACzF;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,QAAQ,CAAC,SAAyB,SAAyB,QAA2BC,aACpF,IAAI,QAAQ,QAAQA,QAAO,EAAE,OAAO,SAAS,OAAO;AAAA,IACxD;AAAA,EACF;AACF;","names":["error","options"]}
1
+ {"version":3,"sources":["../src/http.ts","../src/errors.ts","../src/version.ts","../src/webhooks.ts","../src/client.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { GhostPayApiError, GhostPayConnectionError, GhostPayError } from \"./errors.js\";\nimport type { ErrorCode, Page } from \"./types.js\";\nimport { VERSION } from \"./version.js\";\n\nexport interface GhostPayOptions {\n /** Secret API key (`gp_live_…`). Only the public checkout calls work without one. */\n apiKey?: string;\n /** API host. Default `https://api.ghostpay.gg`. */\n baseUrl?: string;\n /** Per-attempt timeout. Default 30 s. */\n timeoutMs?: number;\n /** Retries after a network error, timeout, 429 or 5xx (always with the same Idempotency-Key). Default 2. */\n maxRetries?: number;\n /** Custom fetch (proxies, tests). Default: global fetch. */\n fetch?: typeof fetch;\n /** Appended to the User-Agent, e.g. `my-casino/2.1`. */\n appInfo?: string;\n}\n\nexport interface RequestOptions {\n /** Idempotency-Key for this POST. Default: a random UUID, reused on every retry of this call. */\n idempotencyKey?: string;\n timeoutMs?: number;\n maxRetries?: number;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n}\n\nexport interface ResponseMeta {\n status: number;\n headers: Headers;\n /** The API replayed a stored response for this Idempotency-Key. */\n idempotentReplayed: boolean;\n idempotencyKey: string | undefined;\n}\n\n/** A response object; `lastResponse` (not enumerable, not serialized) has status, headers and idempotency info. */\nexport type WithResponse<T> = T & { readonly lastResponse: ResponseMeta };\n\ntype Method = \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\ntype Query = Record<string, string | number | boolean | undefined | null>;\n\nexport interface RequestSpec {\n method: Method;\n path: string;\n query?: Query | undefined;\n body?: unknown;\n /** Send the API key (false for public checkout calls). */\n auth?: boolean;\n /**\n * Retry a POST after the request may have reached the server. False for calls whose response is never stored for\n * idempotent replay (webhook endpoint creation returns a secret), where a retry would act twice.\n */\n retryAfterSend?: boolean;\n}\n\nconst RETRY_BASE_MS = 500;\nconst RETRY_MAX_MS = 8_000;\n\nconst DEFAULT_BASE_URL = \"https://api.ghostpay.gg\";\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly userAgent: string;\n\n constructor(private readonly options: GhostPayOptions) {\n this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? globalThis.fetch;\n if (!this.fetchImpl) throw new GhostPayError(\"No fetch available: use Node 18+ or pass options.fetch\");\n this.userAgent = `ghostpay-node/${VERSION} node/${process.versions.node}${options.appInfo ? ` ${options.appInfo}` : \"\"}`;\n }\n\n async request<T>(spec: RequestSpec, options: RequestOptions = {}): Promise<WithResponse<T>> {\n const auth = spec.auth ?? true;\n if (auth && !this.options.apiKey) throw new GhostPayError(\"This call needs an API key: new GhostPay({ apiKey, baseUrl })\");\n\n const url = this.baseUrl + spec.path + queryString(spec.query);\n const idempotencyKey = spec.method === \"POST\" ? (options.idempotencyKey ?? randomUUID()) : undefined;\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"user-agent\": this.userAgent,\n ...(auth ? { authorization: `Bearer ${this.options.apiKey}` } : {}),\n ...(idempotencyKey ? { \"idempotency-key\": idempotencyKey } : {}),\n ...(spec.body !== undefined ? { \"content-type\": \"application/json\" } : {}),\n ...options.headers,\n };\n const body = spec.body !== undefined ? JSON.stringify(spec.body) : undefined;\n const maxRetries = options.maxRetries ?? this.options.maxRetries ?? 2;\n const timeoutMs = options.timeoutMs ?? this.options.timeoutMs ?? 30_000;\n\n for (let attempt = 0; ; attempt++) {\n let response: Response;\n let text: string;\n try {\n ({ response, text } = await this.send(url, { method: spec.method, headers, ...(body !== undefined ? { body } : {}) }, timeoutMs, options.signal));\n } catch (error) {\n if (options.signal?.aborted) throw error;\n const sent = !(error instanceof GhostPayConnectionError && isRefused(error));\n if (attempt < maxRetries && (spec.method === \"GET\" || !sent || spec.retryAfterSend !== false)) {\n await sleep(backoff(attempt));\n continue;\n }\n throw error;\n }\n\n const parsed = text ? safeJson(text) : undefined;\n if (response.ok) {\n if (parsed === undefined && text) throw new GhostPayError(`Invalid JSON from ${spec.method} ${spec.path} (HTTP ${response.status})`);\n return withMeta(parsed as T, {\n status: response.status,\n headers: response.headers,\n idempotentReplayed: response.headers.get(\"idempotent-replayed\") === \"true\",\n idempotencyKey,\n });\n }\n\n const error = toApiError(response, parsed, text);\n if (attempt < maxRetries && retryable(error) && (spec.method === \"GET\" || spec.retryAfterSend !== false)) {\n await sleep(retryAfterMs(response.headers) ?? backoff(attempt));\n continue;\n }\n throw error;\n }\n }\n\n /** Every item of a cursor-paginated list, fetching pages as needed. */\n async *paginate<T extends { id: string }>(path: string, query: Query, options?: RequestOptions): AsyncGenerator<T> {\n let after = query.after ?? undefined;\n for (;;) {\n const page = await this.request<Page<T>>({ method: \"GET\", path, query: { ...query, after } }, options);\n for (const item of page.data) yield item;\n const last = page.data[page.data.length - 1];\n if (!page.has_more || !last) return;\n after = last.id;\n }\n }\n\n private async send(url: string, init: RequestInit, timeoutMs: number, signal?: AbortSignal): Promise<{ response: Response; text: string }> {\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs);\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n try {\n const response = await this.fetchImpl(url, { ...init, signal: controller.signal });\n return { response, text: await response.text() };\n } catch (error) {\n if (signal?.aborted) throw error;\n if (timedOut) throw new GhostPayConnectionError(`Request timed out after ${timeoutMs} ms`, true, { cause: error });\n throw new GhostPayConnectionError(`Could not reach GhostPay: ${(error as Error)?.message ?? error}`, false, { cause: error });\n } finally {\n clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n}\n\n/** A list call: await it for one page, or `for await` it to walk every item across pages. */\nexport type ListResult<T> = Promise<WithResponse<Page<T>>> & AsyncIterable<T>;\n\nexport function listResult<T extends { id: string }>(http: HttpClient, path: string, query: Query = {}, options?: RequestOptions): ListResult<T> {\n let pending: Promise<WithResponse<Page<T>>> | undefined;\n const first = () => (pending ??= http.request<Page<T>>({ method: \"GET\", path, query }, options));\n return {\n then: (onFulfilled, onRejected) => first().then(onFulfilled, onRejected),\n catch: (onRejected) => first().catch(onRejected),\n finally: (onFinally) => first().finally(onFinally),\n [Symbol.toStringTag]: \"ListResult\",\n [Symbol.asyncIterator]: () => http.paginate<T>(path, query, options),\n } as ListResult<T>;\n}\n\nfunction withMeta<T>(value: T, meta: ResponseMeta): WithResponse<T> {\n const target = (value && typeof value === \"object\" ? value : {}) as object;\n Object.defineProperty(target, \"lastResponse\", { value: meta, enumerable: false });\n return target as WithResponse<T>;\n}\n\nfunction toApiError(response: Response, parsed: unknown, text: string): GhostPayApiError {\n const envelope = (parsed as { error?: { code?: string; message?: string; param?: string } } | undefined)?.error;\n const code = (envelope?.code ?? (response.status >= 500 ? \"api_error\" : \"invalid_request\")) as ErrorCode;\n const message = envelope?.message ?? `HTTP ${response.status}${text ? `: ${text.slice(0, 200)}` : \"\"}`;\n return new GhostPayApiError(response.status, code, message, envelope?.param, response.headers, parsed ?? text);\n}\n\nfunction retryable(error: GhostPayApiError): boolean {\n if (error.status === 429 || error.status >= 500) return true;\n // The same Idempotency-Key is still running on the server: its result will be replayed shortly.\n return error.status === 409 && error.code === \"conflict\" && !error.param && /idempotency-key/i.test(error.message);\n}\n\nfunction isRefused(error: GhostPayConnectionError): boolean {\n const cause = (error.cause as { cause?: { code?: string } } | undefined)?.cause;\n return cause?.code === \"ECONNREFUSED\" || cause?.code === \"ENOTFOUND\" || cause?.code === \"EAI_AGAIN\";\n}\n\nfunction backoff(attempt: number): number {\n const base = Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** attempt);\n return base / 2 + Math.random() * (base / 2);\n}\n\nfunction retryAfterMs(headers: Headers): number | undefined {\n const value = headers.get(\"retry-after\");\n if (!value) return undefined;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.min(RETRY_MAX_MS * 4, Math.max(0, seconds * 1000));\n const date = Date.parse(value);\n return Number.isFinite(date) ? Math.min(RETRY_MAX_MS * 4, Math.max(0, date - Date.now())) : undefined;\n}\n\nfunction queryString(query: Query | undefined): string {\n if (!query) return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) params.set(key, String(value));\n const text = params.toString();\n return text ? `?${text}` : \"\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { ErrorCode } from \"./types.js\";\n\n/** Base class of every error this SDK throws. */\nexport class GhostPayError extends Error {\n override name = \"GhostPayError\";\n}\n\n/** The API answered with an error envelope. Switch on `code`; it is stable. */\nexport class GhostPayApiError extends GhostPayError {\n override name = \"GhostPayApiError\";\n readonly status: number;\n readonly code: ErrorCode;\n readonly param: string | undefined;\n readonly headers: Headers;\n readonly raw: unknown;\n\n constructor(status: number, code: ErrorCode, message: string, param: string | undefined, headers: Headers, raw: unknown) {\n super(message);\n this.status = status;\n this.code = code;\n this.param = param;\n this.headers = headers;\n this.raw = raw;\n }\n}\n\n/** No response: DNS, connection refused/reset, or the request timed out. Safe to retry with the same Idempotency-Key. */\nexport class GhostPayConnectionError extends GhostPayError {\n override name = \"GhostPayConnectionError\";\n readonly timedOut: boolean;\n constructor(message: string, timedOut: boolean, options?: { cause?: unknown }) {\n super(message, options);\n this.timedOut = timedOut;\n }\n}\n\n/** A webhook request failed signature or timestamp checks. Reply 400 and do not process it. */\nexport class WebhookVerificationError extends GhostPayError {\n override name = \"WebhookVerificationError\";\n}\n","export const VERSION = \"1.2.0\";\n","import { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { WebhookVerificationError } from \"./errors.js\";\nimport type { WebhookEvent } from \"./types.js\";\n\nexport type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;\nexport type WebhookPayload = string | Uint8Array;\n\nexport interface WebhookOptions {\n /** Accepted clock difference in seconds, both ways. Default 300 (5 minutes). */\n toleranceSec?: number;\n}\n\nconst PREFIX = \"whsec_\";\n\n/**\n * Verifies GhostPay webhook requests (Standard Webhooks: HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{body}`).\n * Pass several secrets while rotating an endpoint's secret.\n */\nexport class Webhook {\n private readonly keys: Buffer[];\n private readonly toleranceSec: number;\n\n constructor(secret: string | string[], options: WebhookOptions = {}) {\n const secrets = Array.isArray(secret) ? secret : [secret];\n if (secrets.length === 0 || secrets.some((value) => typeof value !== \"string\" || value.length === 0)) {\n throw new WebhookVerificationError(\"A webhook signing secret (whsec_…) is required\");\n }\n this.keys = secrets.map(decodeSecret);\n this.toleranceSec = options.toleranceSec ?? 300;\n }\n\n /**\n * Checks the signature and timestamp and returns the parsed, typed event. `payload` must be the raw request body,\n * exactly as received (e.g. `express.raw({ type: \"application/json\" })`), never re-serialized JSON.\n */\n verify(payload: WebhookPayload, headers: WebhookHeaders, now: Date = new Date()): WebhookEvent {\n const body = rawBody(payload);\n const id = header(headers, \"webhook-id\");\n const timestamp = header(headers, \"webhook-timestamp\");\n const signatures = header(headers, \"webhook-signature\");\n if (!id || !timestamp || !signatures) throw new WebhookVerificationError(\"Missing webhook-id, webhook-timestamp or webhook-signature header\");\n\n const seconds = Number(timestamp);\n if (!/^\\d+$/.test(timestamp) || !Number.isSafeInteger(seconds)) throw new WebhookVerificationError(\"Invalid webhook-timestamp\");\n const skew = Math.floor(now.getTime() / 1000) - seconds;\n if (skew > this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is too old\");\n if (skew < -this.toleranceSec) throw new WebhookVerificationError(\"Webhook timestamp is in the future\");\n\n const expected = this.keys.map((key) => sign(key, id, timestamp, body));\n const valid = signatures.split(\" \").some((entry) => {\n const [version, signature] = entry.split(\",\", 2);\n if (version !== \"v1\" || !signature) return false;\n const given = Buffer.from(signature, \"base64\");\n return expected.some((candidate) => given.length === candidate.length && timingSafeEqual(given, candidate));\n });\n if (!valid) throw new WebhookVerificationError(\"No matching webhook signature\");\n\n let event: WebhookEvent;\n try {\n event = JSON.parse(body.toString(\"utf8\")) as WebhookEvent;\n } catch {\n throw new WebhookVerificationError(\"Webhook body is not valid JSON\");\n }\n if (!event || typeof event !== \"object\" || event.id !== id) throw new WebhookVerificationError(\"Webhook body id does not match webhook-id\");\n return event;\n }\n\n /** The `webhook-signature` header value for a body (for your own tests). */\n sign(id: string, timestamp: number | Date, payload: WebhookPayload): string {\n const seconds = String(typeof timestamp === \"number\" ? timestamp : Math.floor(timestamp.getTime() / 1000));\n return `v1,${sign(this.keys[0]!, id, seconds, rawBody(payload)).toString(\"base64\")}`;\n }\n}\n\nfunction sign(key: Buffer, id: string, timestamp: string, body: Buffer): Buffer {\n return createHmac(\"sha256\", key).update(`${id}.${timestamp}.`).update(body).digest();\n}\n\nfunction decodeSecret(secret: string): Buffer {\n const key = Buffer.from(secret.startsWith(PREFIX) ? secret.slice(PREFIX.length) : secret, \"base64\");\n if (key.length === 0) throw new WebhookVerificationError(\"Invalid webhook signing secret\");\n return key;\n}\n\nfunction rawBody(payload: WebhookPayload): Buffer {\n if (typeof payload === \"string\") return Buffer.from(payload, \"utf8\");\n if (payload instanceof Uint8Array) return Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);\n throw new WebhookVerificationError(\n \"Pass the raw request body (string or Buffer), not parsed JSON: re-serializing changes the bytes and breaks the signature\",\n );\n}\n\nfunction header(headers: WebhookHeaders, name: string): string | undefined {\n if (typeof (headers as Headers).get === \"function\") return (headers as Headers).get(name) ?? undefined;\n const record = headers as Record<string, string | string[] | undefined>;\n const key = Object.keys(record).find((candidate) => candidate.toLowerCase() === name);\n const value = key === undefined ? undefined : record[key];\n return Array.isArray(value) ? value.join(\" \") : value;\n}\n","import { HttpClient, listResult, type GhostPayOptions, type ListResult, type RequestOptions } from \"./http.js\";\nimport type {\n Address,\n AddressCreateParams,\n AddressListParams,\n Balance,\n Checkout,\n CheckoutSelectParams,\n Currency,\n Customer,\n CustomerListParams,\n CustomerUpsertParams,\n Deposit,\n DepositListParams,\n Event,\n EventListParams,\n Invoice,\n InvoiceCreateParams,\n InvoiceListParams,\n Network,\n Page,\n Rate,\n Settings,\n Stats,\n StatsParams,\n Transaction,\n TransactionDetail,\n TransactionListParams,\n WebhookDelivery,\n WebhookDeliveryListParams,\n WebhookDeliveryWithAttempts,\n WebhookEndpoint,\n WebhookEndpointCreateParams,\n WebhookEndpointListParams,\n WebhookEndpointUpdateParams,\n WebhookEndpointWithSecret,\n WebhookReplayParams,\n Withdrawal,\n WithdrawalCreateParams,\n WithdrawalListParams,\n WithdrawalQuote,\n WithdrawalQuoteParams,\n} from \"./types.js\";\nimport { Webhook, type WebhookHeaders, type WebhookOptions, type WebhookPayload } from \"./webhooks.js\";\n\nconst seg = (value: string) => encodeURIComponent(value);\ntype Q = Record<string, string | number | boolean | undefined | null>;\n\nexport class GhostPay {\n readonly networks;\n readonly currencies;\n readonly rates;\n readonly balances;\n readonly customers;\n readonly addresses;\n readonly deposits;\n readonly invoices;\n readonly withdrawals;\n readonly webhookEndpoints;\n readonly webhookDeliveries;\n readonly events;\n readonly transactions;\n readonly stats;\n readonly settings;\n readonly checkout;\n readonly webhooks;\n\n constructor(options: GhostPayOptions) {\n const http = new HttpClient(options);\n const get = <T>(path: string, query?: Q, opts?: RequestOptions) => http.request<T>({ method: \"GET\", path, query }, opts);\n const post = <T>(path: string, body?: unknown, opts?: RequestOptions, extra?: { auth?: boolean; retryAfterSend?: boolean }) =>\n http.request<T>({ method: \"POST\", path, body, ...extra }, opts);\n\n this.networks = {\n /** Every network, with confirmations and whether deposits/withdrawals are on. */\n list: (opts?: RequestOptions) => get<Page<Network>>(\"/v1/networks\", undefined, opts),\n };\n this.currencies = {\n /** Enabled currencies with your minimums and fees. */\n list: (opts?: RequestOptions) => get<Page<Currency>>(\"/v1/currencies\", undefined, opts),\n };\n this.rates = {\n /** Indicative USD price per currency. */\n list: (opts?: RequestOptions) => get<Page<Rate>>(\"/v1/rates\", undefined, opts),\n };\n this.balances = {\n /** Available, on-hold and pending balance per currency. */\n list: (opts?: RequestOptions) => get<Page<Balance>>(\"/v1/balances\", undefined, opts),\n };\n\n this.customers = {\n /** Create the customer, or update its metadata if `external_id` exists. */\n upsert: (params: CustomerUpsertParams, opts?: RequestOptions) => post<Customer>(\"/v1/customers\", params, opts),\n list: (params: CustomerListParams = {}, opts?: RequestOptions): ListResult<Customer> => listResult(http, \"/v1/customers\", params, opts),\n /** By `cus_…` id or `ext:<external_id>`. */\n get: (customer: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(customer)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Customer>(`/v1/customers/${seg(`ext:${externalId}`)}`, undefined, opts),\n };\n\n this.addresses = {\n /** The customer's permanent deposit address for the network's address scope (created on first call; `lastResponse.status` 201). */\n getOrCreate: (params: AddressCreateParams, opts?: RequestOptions) => post<Address>(\"/v1/addresses\", params, opts),\n list: (params: AddressListParams = {}, opts?: RequestOptions): ListResult<Address> => listResult(http, \"/v1/addresses\", params, opts),\n /** By `addr_…` id or the on-chain address. */\n get: (address: string, opts?: RequestOptions) => get<Address>(`/v1/addresses/${seg(address)}`, undefined, opts),\n /** Stop handing this address out; payments to it are still credited. */\n retire: (address: string, opts?: RequestOptions) => post<Address>(`/v1/addresses/${seg(address)}/retire`, undefined, opts),\n /** Your own addresses for funding your balance, one per address scope; credited with no fees. */\n topUps: (opts?: RequestOptions) => get<{ data: Address[] }>(\"/v1/top-up-addresses\", undefined, opts),\n };\n\n this.deposits = {\n list: (params: DepositListParams = {}, opts?: RequestOptions): ListResult<Deposit> => listResult(http, \"/v1/deposits\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Deposit>(`/v1/deposits/${seg(id)}`, undefined, opts),\n };\n\n this.invoices = {\n create: (params: InvoiceCreateParams, opts?: RequestOptions) => post<Invoice>(\"/v1/invoices\", params, opts),\n list: (params: InvoiceListParams = {}, opts?: RequestOptions): ListResult<Invoice> => listResult(http, \"/v1/invoices\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Invoice>(`/v1/invoices/${seg(id)}`, undefined, opts),\n /** Only while `NEW`. */\n cancel: (id: string, opts?: RequestOptions) => post<Invoice>(`/v1/invoices/${seg(id)}/cancel`, undefined, opts),\n };\n\n this.withdrawals = {\n /** Fee, total and whether your balance covers it. Creates nothing. */\n quote: (params: WithdrawalQuoteParams, opts?: RequestOptions) =>\n post<WithdrawalQuote>(\"/v1/withdrawals/quote\", params, opts),\n /**\n * Pays out from your balance. The Idempotency-Key defaults to `withdrawal:<external_id>` when you give an\n * `external_id`, so retrying the same payout (even after a restart) can never pay twice.\n */\n create: (params: WithdrawalCreateParams, opts: RequestOptions = {}) =>\n post<Withdrawal>(\"/v1/withdrawals\", params, {\n ...opts,\n ...(opts.idempotencyKey === undefined && params.external_id ? { idempotencyKey: `withdrawal:${params.external_id}` } : {}),\n }),\n list: (params: WithdrawalListParams = {}, opts?: RequestOptions): ListResult<Withdrawal> => listResult(http, \"/v1/withdrawals\", params, opts),\n /** By `wd_…` id or your external id. */\n get: (withdrawal: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}`, undefined, opts),\n getByExternalId: (externalId: string, opts?: RequestOptions) => get<Withdrawal>(`/v1/withdrawals/${seg(`ext:${externalId}`)}`, undefined, opts),\n /** Only before it is sent. The hold returns to your available balance. */\n cancel: (withdrawal: string, opts?: RequestOptions) => post<Withdrawal>(`/v1/withdrawals/${seg(withdrawal)}/cancel`, undefined, opts),\n };\n\n this.webhookEndpoints = {\n /** The response's `secret` is shown only once: store it. Not retried once sent (a retry would create a second endpoint). */\n create: (params: WebhookEndpointCreateParams, opts?: RequestOptions) =>\n post<WebhookEndpointWithSecret>(\"/v1/webhook-endpoints\", params, opts, { retryAfterSend: false }),\n list: (params: WebhookEndpointListParams = {}, opts?: RequestOptions): ListResult<WebhookEndpoint> =>\n listResult(http, \"/v1/webhook-endpoints\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<WebhookEndpoint>(`/v1/webhook-endpoints/${seg(id)}`, undefined, opts),\n update: (id: string, params: WebhookEndpointUpdateParams, opts?: RequestOptions) =>\n http.request<WebhookEndpoint>({ method: \"PATCH\", path: `/v1/webhook-endpoints/${seg(id)}`, body: params }, opts),\n delete: (id: string, opts?: RequestOptions) =>\n http.request<{ id: string; object: \"webhook_endpoint\"; deleted: true }>({ method: \"DELETE\", path: `/v1/webhook-endpoints/${seg(id)}` }, opts),\n /** Sends a `ping` event to this endpoint. */\n test: (id: string, opts?: RequestOptions) =>\n post<{ event: Event; delivery: WebhookDelivery }>(`/v1/webhook-endpoints/${seg(id)}/test`, undefined, opts),\n /** Re-sends matching events created in `[from, to]` as new deliveries; events already queued for the endpoint are skipped. */\n replay: (id: string, params: WebhookReplayParams, opts?: RequestOptions) =>\n post<{ queued: number }>(`/v1/webhook-endpoints/${seg(id)}/replay`, params, opts),\n };\n\n this.webhookDeliveries = {\n list: (params: WebhookDeliveryListParams = {}, opts?: RequestOptions): ListResult<WebhookDelivery> =>\n listResult(http, \"/v1/webhook-deliveries\", params, opts),\n /** With every attempt (status code, response body, timing). */\n get: (id: string, opts?: RequestOptions) => get<WebhookDeliveryWithAttempts>(`/v1/webhook-deliveries/${seg(id)}`, undefined, opts),\n /** FAILED: re-sends the event as a new delivery (returned). PENDING and waiting to retry: sends it now (same delivery returned). */\n retry: (id: string, opts?: RequestOptions) => post<WebhookDelivery>(`/v1/webhook-deliveries/${seg(id)}/retry`, undefined, opts),\n };\n\n this.events = {\n /** One page: newest first, or oldest first after `params.after`. */\n list: (params: EventListParams = {}, opts?: RequestOptions) => get<Page<Event>>(\"/v1/events\", params, opts),\n get: (id: string, opts?: RequestOptions) => get<Event>(`/v1/events/${seg(id)}`, undefined, opts),\n /**\n * Every event after `after` (default: from the very first), oldest first, across pages. Store the last id you\n * processed and pass it next time to catch up after downtime.\n */\n since: (after = \"evt_0\", params: Omit<EventListParams, \"after\"> = {}, opts?: RequestOptions): AsyncIterable<Event> =>\n http.paginate<Event>(\"/v1/events\", { ...params, after }, opts),\n };\n\n this.transactions = {\n /** Deposits, top-ups, withdrawals and payouts, newest first. */\n list: (params: TransactionListParams = {}, opts?: RequestOptions): ListResult<Transaction> => listResult(http, \"/v1/transactions\", params, opts),\n /** With the full deposit or withdrawal and every event about it, including webhook deliveries. */\n get: (id: string, opts?: RequestOptions) => get<TransactionDetail>(`/v1/transactions/${seg(id)}`, undefined, opts),\n };\n\n this.stats = {\n /** Balances and daily volume in USD at current rates (default 30 days). */\n get: (params: StatsParams = {}, opts?: RequestOptions) => get<Stats>(\"/v1/stats\", params, opts),\n };\n\n this.settings = {\n get: (opts?: RequestOptions) => get<Settings>(\"/v1/settings\", undefined, opts),\n };\n\n this.checkout = {\n /** Public: what a payer needs to pay an invoice (no API key needed). */\n get: (invoiceId: string, opts?: RequestOptions) => http.request<Checkout>({ method: \"GET\", path: `/v1/checkout/${seg(invoiceId)}`, auth: false }, opts),\n /** Public: choose the payment currency once, while the invoice is `NEW`. */\n select: (invoiceId: string, params: CheckoutSelectParams, opts?: RequestOptions) =>\n post<Checkout>(`/v1/checkout/${seg(invoiceId)}/select`, params, opts, { auth: false }),\n };\n\n this.webhooks = {\n /** Verify a webhook request and return the typed event (see `Webhook.verify`). */\n verify: (payload: WebhookPayload, headers: WebhookHeaders, secret: string | string[], options?: WebhookOptions) =>\n new Webhook(secret, options).verify(payload, headers),\n };\n }\n}\n"],"mappings":";AAAA,S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0B,IAAW,cAAc,IAAI,EAAE,CAAC,IAAI,QAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,MAK/F,OAAO,CAAC,QAAQ,SAAS,SAAyC,CAAC,GAAG,SACpE,KAAK,SAAgB,cAAc,EAAE,GAAG,QAAQ,MAAM,GAAG,IAAI;AAAA,IACjE;AAEA,SAAK,eAAe;AAAA;AAAA,MAElB,MAAM,CAAC,SAAgC,CAAC,GAAG,SAAmD,WAAW,MAAM,oBAAoB,QAAQ,IAAI;AAAA;AAAA,MAE/I,KAAK,CAAC,IAAY,SAA0B,IAAuB,oBAAoB,IAAI,EAAE,CAAC,IAAI,QAAW,IAAI;AAAA,IACnH;AAEA,SAAK,QAAQ;AAAA;AAAA,MAEX,KAAK,CAAC,SAAsB,CAAC,GAAG,SAA0B,IAAW,aAAa,QAAQ,IAAI;AAAA,IAChG;AAEA,SAAK,WAAW;AAAA,MACd,KAAK,CAAC,SAA0B,IAAc,gBAAgB,QAAW,IAAI;AAAA,IAC/E;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,KAAK,CAAC,WAAmB,SAA0B,KAAK,QAAkB,EAAE,QAAQ,OAAO,MAAM,gBAAgB,IAAI,SAAS,CAAC,IAAI,MAAM,MAAM,GAAG,IAAI;AAAA;AAAA,MAEtJ,QAAQ,CAAC,WAAmB,QAA8B,SACxD,KAAe,gBAAgB,IAAI,SAAS,CAAC,WAAW,QAAQ,MAAM,EAAE,MAAM,MAAM,CAAC;AAAA,IACzF;AAEA,SAAK,WAAW;AAAA;AAAA,MAEd,QAAQ,CAAC,SAAyB,SAAyB,QAA2BC,aACpF,IAAI,QAAQ,QAAQA,QAAO,EAAE,OAAO,SAAS,OAAO;AAAA,IACxD;AAAA,EACF;AACF;","names":["error","options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostpaygg/node",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Official Node.js client for the GhostPay crypto payments API",
5
5
  "license": "MIT",
6
6
  "type": "module",