Signed Request
Make a signed GET request to another Ghost(Pro) service. The package appends a
timestamp and optional source to the request path, signs it with an HMAC-SHA1
digest, and sends it with ky (native
fetch).
Install
npm install @tryghost/signed-request --save
or
pnpm add @tryghost/signed-request
Usage
Provides a signed GET request
Needs the following minimum arguments: Arg 1: hmac_key used to sign the request Arg 2: server address or ip to send request to (protocol is stripped) Arg 3: additional path of request or empty string e.g: /packages Optional Arg 4: options object with properties:
- source - where your request originated from
- protocol - to overwrite default request protocol of http://
- timeout - timeout in milliseconds for each attempt (default 5000)
- retries - number of retries for retryable failures (default 3)
- dispatcher - undici dispatcher passed through to
fetch, e.g. an undiciAgentfor keep-alive
The package ships TypeScript types and both CommonJS and ESM builds. exec is
accessed as a property of the imported module — signedRequest.exec(...) — and
returns ky's ResponsePromise. Prefer its body shortcuts —
await signedRequest.exec(...).json() or .text() — which keep timeout
applied while the body downloads. Awaiting exec() gives the native fetch
Response, but reading its body with response.json() is not bounded by
timeout. Non-2xx responses reject with HTTPError (with error.response),
network failures with NetworkError, and timeouts with TimeoutError; all are
re-exported from this package. Requests that time out are retried.
CommonJS
const signedRequest = require('@tryghost/signed-request');
async function purge() {
const body = await signedRequest.exec(hmac, server, path, options).json();
}
ESM / TypeScript
import signedRequest from '@tryghost/signed-request';
const body = await signedRequest.exec(hmac, server, path, options).json();
The ESM example uses a default import (requires esModuleInterop /
allowSyntheticDefaultImports in TypeScript); the imported value is the module
namespace, so call signedRequest.exec(...) exactly as in CommonJS.
Develop
This is a monorepo package, managed from the repo root.
Follow the instructions for the top-level repo.
git clonethis repo &cdinto it as usual- Run
pnpm installto install top-level dependencies.
Run
pnpm --filter @tryghost/signed-request dev
Test
pnpm --filter @tryghost/signed-request lintruns lintpnpm --filter @tryghost/signed-request testruns lint and tests
Copyright & License
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.