diff --git a/README.md b/README.md index 4afbb47..00d0cbd 100644 --- a/README.md +++ b/README.md @@ -194,9 +194,10 @@ The transactions will be sent as a JSON array in the body of the request with th Use the following env vars to setup: -| env variable name | description | -| ----------------- | ------------------ | -| `WEB_POST_URL ` | The URL to post to | +| env variable name | description | +| ------------------------------ | ---------------------------------------------------------------------------- | +| `WEB_POST_URL` | The URL to post to | +| `WEB_POST_AUTHORIZATION_TOKEN` | The Authorization header value (i.e. `Bearer *****`, but can use any schema) | > [!IMPORTANT] > Be sure to post only to a trusted server. diff --git a/src/bot/storage/web-post.ts b/src/bot/storage/web-post.ts index e63f9e7..8ad3a1d 100644 --- a/src/bot/storage/web-post.ts +++ b/src/bot/storage/web-post.ts @@ -8,6 +8,7 @@ const logger = createLogger("WebPostStorage"); export class WebPostStorage implements TransactionStorage { private url = process.env.WEB_POST_URL || ""; + private authorizationToken = process.env.WEB_POST_AUTHORIZATION_TOKEN || ""; canSave() { return Boolean(this.url) && URL.canParse(this.url); @@ -30,6 +31,9 @@ export class WebPostStorage implements TransactionStorage { method: "POST", headers: { "Content-Type": "application/json", + ...(this.authorizationToken && { + Authorization: this.authorizationToken, + }), }, body: JSON.stringify(nonPendingTxns.map((tx) => tableRow(tx))), }),