Skip to content

About

Hivesigner API module

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Hivesigner API

Hivesigner API module handles access token creation/verification, signing, broadcasting transactions, oauth2 for dapps.

Configuration

Variable Purpose
BROADCASTER_USERNAME The account apps grant posting authority to.
BROADCASTER_POSTING_WIF_FILE Path to a file holding that account's posting key. Defaults to /run/secrets/broadcaster_posting_wif, where production mounts it as a swarm secret. The service will not start without a readable, valid key.
BROADCAST_NETWORK mainnet for hivesigner.com, otherwise testnet.
API_PORT Listening port, default 3000.

The key is deliberately not an environment variable: env vars are shown by docker service inspect and docker inspect, while a secret file is mounted into the task only. The deploy workflow creates the swarm secret from the repository secret BROADCASTER_POSTING_WIF. Secrets are immutable, so each key value gets its own secret name (a hash suffix); changing the repository secret and redeploying creates a new one. Older ones are removed after a healthy deploy, except the one the service's previous spec uses, which a rollback needs; that one goes on the deploy after.

The app directory: GET /api/apps

Public and unauthenticated. Which apps use Hivesigner, ranked by how many people use them:

{
  "updated_at": "...",
  "building": false,
  "window_days": 7,
  "featured": ["ecency.app", "peakd.app", "..."],
  "apps": [
    { "username": "ecency.app", "name": "Ecency", "about": "...",
      "website": "https://ecency.com", "site": "ok",
      "users": 412, "requests": 9310,
      "first_seen": "2026-08-01", "last_seen": "2026-09-15", "new": false }
  ]
}

Where the list comes from

Two signals. Both are needed.

Usage orders it. Every authenticated request carries an app name as req.proxy. helpers/usage.js counts that per app per UTC day. The directory ranks on the sum of each day's distinct-user count over the last apps.active_days UTC days, today included (7 means today plus the previous six days), so a person active on three days counts three times. An app with no request inside that window drops off on the next build and comes back the moment it is used again, so departures need no curating. An app first seen inside the window, and after the record itself began, is marked "new": true; on a fresh deployment nothing is new until the history is older than the app.

Registration decides who is on it. req.proxy is signed_message.app, a string chosen by whoever built the token. The signature proves the user signed the message, not that the app is who it claims. Any account can sign a token naming any app. So a counted name is only listed if the account has granted posting authority to the broadcaster, which is the same condition verifyPermissions enforces before this API will broadcast for an app. No third party can perform it for an account they do not control.

The gate runs on a wide ranked pool (apps.candidate_pool) before the cut to apps.max_apps, so an unregistered name costs a slot in an RPC batch rather than a slot in the directory.

There is no follow list, no post-metadata scraping and no fallback list. A fresh deployment answers "building": true with an empty list and rebuilds on the fast cadence (apps.retry_minutes) until traffic fills it, then is correct permanently. A fallback would be a second code path that only runs when nobody is watching.

What counts as an "app"

One that broadcasts through Hivesigner. That is narrower than one that uses it: a site using Hivesigner only to log people in never needs to grant posting authority to the broadcaster, because /api/me and /api/oauth2/token go through authenticate while only /api/broadcast goes through verifyPermissions. A login-only app therefore cannot appear here automatically. apps.pinned is the only route for it.

profile.type === 'app' in the account's own metadata is deliberately not accepted as a substitute. It is account-controlled, but it is a label any account can put on itself at no cost and with no reference to Hivesigner, so accepting it would reopen what the gate closes. It also costs nothing measurable: of 26 well known Hive app accounts checked on chain, 5 carry type: 'app' and all 5 have the grant as well.

What is still checked on-chain

The app's website, because usage cannot tell you a domain lapsed. Several here did: buildteam.io and cryptobrewmaster.io both redirect to gambling sites today. Usage says an app is running; the site check says where it sends people. An app whose site no longer lands on its own domain stays in apps with its site reason, but cannot be featured.

Rebuilt on a timer (apps.refresh_minutes); requests only ever read the last good answer. A failed rebuild keeps the previous one.

apps.pinned forces an entry to the front of the featured list and rescues one with little usage; apps.excluded drops one outright. Pinning does not exempt an app from the site check. Featuring a lapsed domain would send people to whoever owns it now, whatever the config says.

Usage storage

45 days in /var/app/data/usage.json (override with USAGE_FILE), written at most once a minute and atomically, on a named volume so a deploy does not empty the directory.

It stores counts only. Distinct users are tallied in memory for the current day and folded to a number when written, so the file never records who used what. The cost is that a restart mid-day loses that day's deduplication.

Counts are cheap to inflate, since the name is caller-chosen, so they are treated as a ranking signal over unverified names and nothing more. Three ceilings bound the damage: each user may put at most 5 names a day on record that were not already there that day, a day takes at most 500 names from outside the trusted set, and 2000 in total.

The trusted set is every name the indexer has verified on chain as registered, from its last candidate pool. Those names are exempt from all three ceilings, and the set is written to trusted-apps.json beside the usage file and read back before the counts, so a restart does not reopen the ceilings to known apps. Names seen the day before are not trusted on that basis: letting them through let junk inherit itself day over day.

Refusal is not silent either. The first 200 names the ceilings turn away each day are kept, and the next build runs them through the same registration check as everything else. So a real app that registers on a day someone has filled is verified within one build, trusted from then on, and counted from its next request. Filling a day costs the attacker accounts and buys them at most one build interval of delay for a newcomer, and nothing at all against a known app.

PKCE on the code exchange: POST /api/oauth2/token

A code can carry a PKCE challenge (RFC 7636). The authorize page puts code_challenge and code_challenge_method: "S256" inside the code's signed message, so the challenge cannot be changed after the user approved.

Code Needs Single use Age limit Refresh token
No challenge (every app today) client_secret no none yes
Challenge, app has a secret client_secret and code_verifier yes 10 min (+5 for clocks) yes
Challenge, app has no secret (native app) code_verifier yes 10 min (+5 for clocks) no
Challenge, app has a secret and pkce_public: true code_verifier (secret optional) yes 10 min (+5 for clocks) only with the secret
  • code_verifier must be 43 to 128 characters of A-Z a-z 0-9 - . _ ~, and BASE64URL(SHA256(code_verifier)) must equal the challenge. Only S256.
  • pkce_public: true in the app profile is for an app that has a server (with the secret) and a native app (without it) on one account. Only the boolean true counts. A secret that is sent must be the right one.
  • An app account with an IP allowlist (allowed_ips) always needs the secret: the allowlist marks a server, and an address is a second check for it, never the only proof. Such an account cannot serve a native app. The address checked is the caller's as the proxy in front of the API reports it (one trusted hop, TRUSTED_PROXY_HOPS), never an entry the caller added to X-Forwarded-For. List every address the app's server can call from: a server that reaches the API over IPv6 is seen by its IPv6 address.
  • Used codes are kept in memory. A restart forgets them, so a code exchanged just before a restart could be exchanged once more until it expires, by whoever also holds its verifier.
  • A code signed with scope: "login" (the user approved sign-in only) is exchanged for a login token and no refresh token, with or without PKCE.
  • pkce_public opens the exchange to whoever holds a code and its verifier. For an https or loopback callback that adds nothing new (the token flow already sends a token there), but anyone can claim a custom scheme on a device: register only callbacks you control, preferably verified App Links or Universal Links.
  • Every PKCE failure answers 401 invalid_grant (an allowed_ips mismatch keeps its 401 unauthorized_access).
  • A code with a challenge is accepted only here, never as a token at /api/me.
  • Running more replicas needs a shared store for used codes (see helpers/middleware.js).

Full guide: https://hivesigner.com/docs/pkce

Learn more

Homepage: https://hivesigner.com

Documentation: https://hivesigner.com/docs

Hivesigner SDK: https://github.com/ecency/hivesigner-sdk

Hivesigner UI: https://github.com/ecency/hivesigner-ui

Issues

To report a non-critical issue, please file an issue on this GitHub project. If you find a security issue please report details to security@hivesigner.com or trusted community members. We will evaluate the risk and make a patch available before filing the issue.

About

Hivesigner API module

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages