Skip to content

Sign-in hardening; self-hosted wallet deadline and hosting payment fixes - #2134

Open
feruzm wants to merge 6 commits into
developfrom
fix/auth-hosting-1117h
Open

feruzm wants to merge 6 commits into
developfrom
fix/auth-hosting-1117h

Conversation

@feruzm

@feruzm feruzm commented Nov 17, 2026

Copy link
Copy Markdown
Member

Sign-in hardening across web and hosting, plus self-hosted and hosting payment fixes.

Closes #2125, closes #2128

Self-hosted (#2125)

  • Keychain broadcasts get a deadline: 30 s, or 10 minutes once the extension has answered a ping, so a user reading the prompt is not cut off. The message asks the user to check the wallet before trying again.

Hosting API

  • Payment dedup keyed on trx_id alone: a second transfer op in the same transaction is silently discarded #2128: each payment transfer in a transaction is recorded under its own key. The first keeps the bare transaction id, so existing rows still de-duplicate; later ones use <trx>:<opIndex>.
  • Suspended tenants:
    • activating a subscription keeps a suspended tenant suspended;
    • a new card payment for a suspended tenant is acknowledged (credited, not published).
  • Reserved names: tenant names the platform reserves cannot be created or claimed.
  • Sign-in:
    • HiveSigner sign-in accepts only an access token for the account HiveSigner names (not a code, refresh token or login message);
    • each login challenge is stored and used on its own.

Web

  • Token check: server routes that identify a user from a HiveSigner token accept only an access token issued to this app, for the account HiveSigner names.
  • Login callback: the HiveSigner callback completes only a login this browser started, through a one-time state value kept for 30 minutes. Back after signing in no longer reopens the login dialog.
  • Base URLs: links and metadata take their base from the request only for the site's own hosts, without a port; anything else uses the configured base.

Tests (written first, failing before the change)

Spec Failed before
apps/self-hosted/src/features/auth/utils/extension-broadcast-deadline.test.ts broadcast never settled
apps/self-hosted/hosting/api/src/payment-listener-multi-op.test.ts second transfer reused the first key
apps/self-hosted/hosting/api/src/payment-keeps-suspension.test.ts status set to active
apps/self-hosted/hosting/api/src/routes/internal.test.ts (suspended case) 500 for a recorded payment
apps/self-hosted/hosting/api/src/utils/reserved-tenant-names.test.ts reserved name accepted
apps/self-hosted/hosting/api/src/routes/auth-challenge-per-request.test.ts second challenge replaced the first
apps/self-hosted/hosting/api/src/routes/auth-handoff.test.ts (token kinds) code token accepted
apps/web/src/specs/server/hivesigner-verify.spec.ts other tokens accepted
apps/web/src/specs/app/auth-login-state.spec.tsx callback without state signed in
apps/web/src/specs/utils/server-app-base.spec.ts header host used as base

Green after: web 6936, self-hosted 1080 plus its build, hosting API 487 plus tsc, pnpm typecheck, pnpm lint, and the script audits with --fail.

Before deploy

  • Check that HIVESIGNER_CLIENT_ID, where it is set server-side, is the same app id the login uses (default ecency.app).
  • Do one HiveSigner login on an installed PWA (iOS and Android) after deploy.

…gs the action

Keychain broadcasts get a 30 s deadline (10 min after the extension has
answered a ping, so a user reading the prompt is not cut off), with a
message to check the wallet before trying again.

Closes #2125
…d tenant status

- Each payment transfer in a transaction is recorded under its own key, so a
  second transfer in the same transaction is no longer skipped as a repeat.
- Activating a subscription keeps a suspended tenant suspended.
- Tenant names reserved by the platform cannot be created or claimed.

Closes #2128
- HiveSigner sign-in accepts only an access token issued to this app for the
  account HiveSigner names.
- Each login challenge is stored and used on its own, so starting a second
  login does not affect the first.
- Server routes that identify a user from a HiveSigner token accept only an
  access token issued to this app, for the account HiveSigner names.
- The HiveSigner login callback completes only a login started in the same
  tab (one-time state value, safe under a double mount).
- Base URLs written into links and metadata come from the request only for
  the site's own hosts; anything else uses the configured base.
- A new payment for a suspended tenant is acknowledged (credited, not
  published) instead of answering a retryable error.
- Hosting sign-in keeps the access-token and account checks but accepts any
  app, since a blog may use its own HiveSigner app.
- The login state value is kept per browser for 30 minutes, so a login that
  finishes in another tab completes; a stray callback no longer clears a
  pending one; Back after signing in does not open the login dialog.
- The base URL drops a port taken from a request header.
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 140d820c-2924-496d-be7e-d6323117a5ef
Commits

Reviewing files that changed from the base of the PR and between 99ee999 and abd22d8.

Files selected for processing: 22

  • apps/self-hosted/hosting/api/src/payment-keeps-suspension.test.ts
  • apps/self-hosted/hosting/api/src/payment-listener-multi-op.test.ts
  • apps/self-hosted/hosting/api/src/payment-listener.ts
  • apps/self-hosted/hosting/api/src/routes/auth-challenge-per-request.test.ts
  • apps/self-hosted/hosting/api/src/routes/auth-handoff.test.ts
  • apps/self-hosted/hosting/api/src/routes/auth.ts
  • apps/self-hosted/hosting/api/src/routes/internal.test.ts
  • apps/self-hosted/hosting/api/src/routes/internal.ts
  • apps/self-hosted/hosting/api/src/routes/tenants.ts
  • apps/self-hosted/hosting/api/src/utils/reserved-tenant-names.test.ts
  • apps/self-hosted/hosting/api/src/utils/reserved-tenant-names.ts
  • apps/self-hosted/hosting/api/src/utils/subscription-status-sql.ts
  • apps/self-hosted/src/features/auth/utils/extension-broadcast-deadline.test.ts
  • apps/self-hosted/src/features/auth/utils/hive-extensions.ts
  • apps/self-hosted/src/features/auth/utils/keychain.ts
  • apps/web/src/app/auth/_page.tsx
  • apps/web/src/server/hivesigner-verify.ts
  • apps/web/src/specs/app/auth-login-state.spec.tsx
  • apps/web/src/specs/server/hivesigner-verify.spec.ts
  • apps/web/src/specs/utils/server-app-base.spec.ts
  • apps/web/src/utils/hive-signer.ts
  • apps/web/src/utils/server-app-base.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T23:34:51.804550Z 94b01b1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Harden sign-in and fix wallet and hosting payment edge cases

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Harden HiveSigner sign-in with token checks, one-time browser state, and independent hosting
 challenges.
• Preserve suspensions, record every payment transfer, reject reserved names, and bound wallet
 waits.
• Restrict request-derived base URLs to site hosts and add regression tests across affected apps.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 5 capabilities

  • 5 affected capabilities span independent functional scopes: browser wallet-extension transaction broadcasting, self-hosted hosting authentication integration, self-hosted tenant subscription and payment lifecycle, web HiveSigner authentication integration, web canonical URL and metadata generation.
  • The payment listener, public subscribe route, internal activation route, tenant row, and config publication all implement one bounded outcome: turning a Hive payment into a tenant subscription/config state.
  • They are propagation hops of the same payment lifecycle, not independent technical capabilities.
  • Challenge login, HiveSigner exchange, and handoff minting all establish or carry the same hosting user identity into a hosting session.
  • They are distinct entry points of one bounded authentication integration; the Redis challenge and HiveSigner API are propagation hops.
  • The authorization URL state, callback validation, code exchange, and user-store update jointly implement one browser sign-in outcome.
  • Storage and React callback handling are propagation hops within that integration, not separate capabilities.
  • The generic broadcast helper and the post-ping keychain wrapper both implement one user outcome: submitting Hive operations through an extension.
  • The ping, popup request, timeout, and blockchain result are sequential propagation steps of that bounded integration.
  • Community, entry, feed, profile, creator-economy, RSS, and oEmbed consumers use the same bounded URL-base decision to produce absolute links.
  • They are downstream surfaces of one canonical-base capability, not independent functional scopes.
Sources

apps/self-hosted/src/features/auth/utils/keychain.ts[127-146]

  deadlineMs = 30000,
): Promise<KeychainResponse> {
  return new Promise<KeychainResponse>((resolve, reject) => {
    const keychain = instance ?? defaultInstance();

    if (!keychain) {
      reject(new Error('Hive extension is unavailable or disabled.'));
      return;
    }

    let finished = false;
    const timeout = setTimeout(() => {
      if (!finished) {
        reject(
          new Error(
            'The wallet did not answer in time. The request may still be open in the wallet: check it before trying again.',
          ),
        );
      }
    }, deadlineMs);
Behavioral complexity 🔴 High 🧩 State transitions, Interacting branches

  • Before: any callback with a valid-looking code proceeded to exchange.
  • After: login initiation issues a state, stores it with a 30-minute TTL, callback validation consumes it, and a module-level marker suppresses a duplicate in-flight effect.
  • New correctness conditions: the pending state must survive the browser/tab transition, expire at the intended boundary, be consumed exactly once, and not be removed by a stray or duplicate callback before the legitimate callback arrives.
  • The single localStorage slot also creates an overwrite transition for concurrent login attempts.
Potential damage 🔴 High 🩹 Financial error

  • The key plausible failure is an external duplicate transaction: the browser reports a timeout, the wallet request remains open, and a user retries before checking the popup.
  • Reverting the timeout text or deadline does not reverse a Hive transaction already broadcast; recovery requires wallet/provider support, recipient refund, or manual compensation, and may not be available.
  • A too-long deadline can instead cause temporary inability to continue, but that is secondary to the unrecoverable external-effect risk.
  • A client-side revert restores the previous waiting behavior for future requests but cannot undo an already broadcast transaction.
  • Duplicate or mistaken transfers require blockchain-recipient cooperation or manual compensation; pending UI state can be recovered by checking the wallet and transaction history.
Sources

apps/self-hosted/src/features/auth/utils/keychain.ts[127-146]

  deadlineMs = 30000,
): Promise<KeychainResponse> {
  return new Promise<KeychainResponse>((resolve, reject) => {
    const keychain = instance ?? defaultInstance();

    if (!keychain) {
      reject(new Error('Hive extension is unavailable or disabled.'));
      return;
    }

    let finished = false;
    const timeout = setTimeout(() => {
      if (!finished) {
        reject(
          new Error(
            'The wallet did not answer in time. The request may still be open in the wallet: check it before trying again.',
          ),
        );
      }
    }, deadlineMs);
Assessed commit 94b01b1 > Snapshot assessment: the current PR revision could not be verified.
Diagram

graph TD
  Browser["Browser"] --> Login["Web login"] --> HiveSigner["HiveSigner"] --> Callback["Login callback"]
  Login --> State[("Login state")] --> Callback
  WebVerifier["Web verifier"] --> HiveSigner
  HostingAuth["Hosting auth"] --> HiveSigner
  HostingAuth --> Challenges[("Login challenges")]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Atomically consume hosting challenges
  • ➕ Prevents concurrent verification requests from both using the same challenge.
  • ➖ Requires Redis-side compare-and-delete behavior to retain the current invalid-signature retry semantics.
2. Share HiveSigner token parsing
  • ➕ Reduces duplication of security-sensitive token-shape checks between web and hosting.
  • ➖ Requires a shared package and must preserve different app policies: web requires its configured app, while hosting accepts blog-specific apps.

Recommendation: Keep the targeted fixes: they address distinct failures without coupling the apps or changing payment history keys. Consider atomic challenge consumption as a security follow-up; the current get-then-delete sequence does not prevent concurrent reuse.

Files changed (22) +760 / -44

Bug fix (12) +265 / -40
payment-listener.tsRecord each transfer without lifting suspensions +36/-13

Record each transfer without lifting suspensions

• Assigns distinct payment keys within a transaction while retaining the bare transaction ID for its first payment. Also rejects reserved tenant names and preserves suspended status when crediting a payment.

apps/self-hosted/hosting/api/src/payment-listener.ts

auth.tsIsolate challenges and validate hosting sign-in tokens +69/-10

Isolate challenges and validate hosting sign-in tokens

• Stores challenges by account and nonce so concurrent logins do not replace one another. Requires a posting access token whose sole author matches the account returned by HiveSigner.

apps/self-hosted/hosting/api/src/routes/auth.ts

internal.tsCredit suspended tenants without publishing them +10/-2

Credit suspended tenants without publishing them

• Preserves suspension during internal payment activation and acknowledges the payment without generating configuration. Also refuses claims for reserved tenant names.

apps/self-hosted/hosting/api/src/routes/internal.ts

tenants.tsProtect tenant creation and subscription status +6/-1

Protect tenant creation and subscription status

• Rejects reserved tenant names before validation and keeps an operator-suspended tenant suspended when a subscription payment extends its term.

apps/self-hosted/hosting/api/src/routes/tenants.ts

reserved-tenant-names.tsCentralize reserved tenant names +11/-0

Centralize reserved tenant names

• Adds a case-insensitive check that prevents tenants from claiming the default configuration name.

apps/self-hosted/hosting/api/src/utils/reserved-tenant-names.ts

subscription-status-sql.tsShare suspension-preserving activation SQL +8/-0

Share suspension-preserving activation SQL

• Defines the status expression used by payment paths to activate ordinary tenants without overriding an operator suspension.

apps/self-hosted/hosting/api/src/utils/subscription-status-sql.ts

hive-extensions.tsAllow longer broadcasts after extension ping +6/-1

Allow longer broadcasts after extension ping

• Passes a ten-minute deadline to broadcasts once the extension has responded to a liveness ping.

apps/self-hosted/src/features/auth/utils/hive-extensions.ts

keychain.tsMake broadcast deadline configurable and timeout actionable +13/-3

Make broadcast deadline configurable and timeout actionable

• Keeps the default 30-second deadline, permits callers to extend it, and tells users to check the wallet before retrying.

apps/self-hosted/src/features/auth/utils/keychain.ts

_page.tsxRequire pending state for HiveSigner callbacks +22/-3

Require pending state for HiveSigner callbacks

• Consumes one-time login state before exchanging a code, handles duplicate mount effects, and avoids reopening the login dialog for an already signed-in user.

apps/web/src/app/auth/_page.tsx

hivesigner-verify.tsRestrict web identity checks to this app's access tokens +19/-1

Restrict web identity checks to this app's access tokens

• Rejects non-posting tokens, tokens for other apps, and tokens whose sole author differs from the account returned by HiveSigner.

apps/web/src/server/hivesigner-verify.ts

hive-signer.tsIssue and consume expiring login state +43/-1

Issue and consume expiring login state

• Adds a random state to HiveSigner authorize URLs and stores it in browser storage. Callback validation consumes a matching state once within 30 minutes.

apps/web/src/utils/hive-signer.ts

server-app-base.tsConstrain request-header hosts used in base URLs +22/-5

Constrain request-header hosts used in base URLs

• Uses request-derived hosts only for the site's own domain or subdomains, strips ports, and normalizes forwarded protocol handling; other hosts fall back to the configured base.

apps/web/src/utils/server-app-base.ts

Tests (10) +495 / -4
payment-keeps-suspension.test.tsCover suspension preservation across payment paths +31/-0

Cover suspension preservation across payment paths

• Checks the shared SQL expression and its use by the listener, tenant subscription route, and internal activation route.

apps/self-hosted/hosting/api/src/payment-keeps-suspension.test.ts

payment-listener-multi-op.test.tsTest distinct keys for transfers in one transaction +32/-0

Test distinct keys for transfers in one transaction

• Covers multiple payment transfers, preceding nonpayment operations, and transfers to other accounts.

apps/self-hosted/hosting/api/src/payment-listener-multi-op.test.ts

auth-challenge-per-request.test.tsTest independent, account-bound login challenges +70/-0

Test independent, account-bound login challenges

• Verifies that a second challenge does not replace the first, another account cannot use it, and a completed challenge cannot be reused.

apps/self-hosted/hosting/api/src/routes/auth-challenge-per-request.test.ts

auth-handoff.test.tsCover HiveSigner handoff token restrictions +30/-4

Cover HiveSigner handoff token restrictions

• Adds cases for token kind, malformed tokens, blog-specific apps, and mismatched token authors while updating valid handoff fixtures.

apps/self-hosted/hosting/api/src/routes/auth-handoff.test.ts

internal.test.tsTest payment acknowledgement for suspended tenants +14/-0

Test payment acknowledgement for suspended tenants

• Confirms that internal activation acknowledges a recorded payment without publishing configuration for a suspended tenant.

apps/self-hosted/hosting/api/src/routes/internal.test.ts

reserved-tenant-names.test.tsTest reserved-name enforcement +27/-0

Test reserved-name enforcement

• Checks case-insensitive rejection of the fallback config name and coverage of all three tenant-creation paths.

apps/self-hosted/hosting/api/src/utils/reserved-tenant-names.test.ts

extension-broadcast-deadline.test.tsTest wallet broadcast deadlines and guidance +58/-0

Test wallet broadcast deadlines and guidance

• Checks that a responsive wallet can complete after 30 seconds and that a timed-out request warns users it may still be open.

apps/self-hosted/src/features/auth/utils/extension-broadcast-deadline.test.ts

auth-login-state.spec.tsxCover one-time HiveSigner callback state +136/-0

Cover one-time HiveSigner callback state

• Tests fresh and expiring states, missing or mismatched callbacks, double mounts, cross-tab completion, replay prevention, and Back navigation.

apps/web/src/specs/app/auth-login-state.spec.tsx

hivesigner-verify.spec.tsTest web HiveSigner token identity checks +45/-0

Test web HiveSigner token identity checks

• Covers valid access tokens and rejection of other apps, token kinds, malformed values, and mismatched accounts.

apps/web/src/specs/server/hivesigner-verify.spec.ts

server-app-base.spec.tsTest trusted request-derived base URLs +52/-0

Test trusted request-derived base URLs

• Checks own-host and subdomain handling, port removal, fallback for untrusted headers, and configured-base precedence.

apps/web/src/specs/utils/server-app-base.spec.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94b01b13f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +37 to +38
if (op[0] !== 'transfer' || op[1]?.to !== paymentAccount) return;
found.push({ key: found.length === 0 ? trxId : `${trxId}:${opIndex}`, transfer: op[1] });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve legacy payment keys when non-HBD transfers come first

When replaying a transaction processed before this change that contains a HIVE transfer followed by an HBD transfer to the payment account, the HBD payment is credited twice. Previously, processTransfer ignored the HIVE transfer without inserting a payment row, so the HBD transfer was recorded under the bare transaction ID. This helper instead assigns that bare ID to the ignored HIVE transfer and gives the HBD transfer a new suffixed key, bypassing both existing deduplication checks and extending the subscription again. Assign the legacy bare key to the first HBD transfer rather than the first transfer of any currency, and cover this mixed-currency replay case.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The follow-up changes appear safe to merge; no blocking issues remain.

Summary

This PR hardens sign-in and fixes wallet waits and hosting payments. Both previous findings are addressed; no new actionable issues were found in the follow-up changes.

  • HiveSigner sign-ins check the token type and the account it names.
  • Web login callbacks need a one-time state from a login this browser started.
  • Hosting keeps each login challenge separate until it is used or expires.
  • Wallet broadcasts wait longer after the extension answers a ping.
  • Each payment transfer in a Hive transaction gets its own record key.
  • Hosting payments extend suspended tenants without lifting their suspension.
  • Hosting refuses tenant names reserved for platform files.
  • Web links and metadata use request hosts only when they belong to the site.

Reviews (2) · Last reviewed commit: "fix(hosting-api,web): replayed payments ..." · Reviewed by Greptile

Comment thread apps/web/src/utils/hive-signer.ts Resolved
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (2) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. New payment parsing code loses type checking through any 📘 Rule violation ⚙ Maintainability
Description
The new paymentTransfers helper declares its operations parameter as `ReadonlyArray<[string,
any]>`, so the transfer payload is untyped where the payment key is computed. The call site in
PaymentListener also casts the whole operations array with as any, which silently bypasses the
type of tx.operations for the new loop. A later change to the transfer shape would not be caught
by the compiler here, and the same untyped payload then flows into processTransfer.
Code

apps/self-hosted/hosting/api/src/payment-listener.ts[31]

+  operations: ReadonlyArray<[string, any]>,
Evidence
The added paymentTransfers signature and the added loop call use any ([string, any] and
tx.operations as any) in new TypeScript code, which the checklist forbids without a typed
alternative such as unknown or a transfer interface.

Rule 2668119: Disallow implicit and any types in new TypeScript code
apps/self-hosted/hosting/api/src/payment-listener.ts[31-31]
apps/self-hosted/hosting/api/src/payment-listener.ts[204-204]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
Issue description
The new `paymentTransfers` helper and its call site use `any` (parameter `operations: ReadonlyArray<[string, any]>` and `tx.operations as any`), which violates the no-`any` rule for new TypeScript code.
Fix Focus Areas
- apps/self-hosted/hosting/api/src/payment-listener.ts[31-31]
- apps/self-hosted/hosting/api/src/payment-listener.ts[204-204]
Recommended Fix
Define a `TransferOp` type (`{ from: string; to: string; amount: string; memo: string }`) and type the operations parameter as `ReadonlyArray<[string, unknown]>` narrowed with a type guard on `op[0] === 'transfer'`. Replace `tx.operations as any` with a typed cast to the declared operation type, or type the transaction result where it is fetched.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Login spec mocks use any in new test code 📘 Rule violation ⚙ Maintainability
Description
The new login-state spec types its store selector parameter as (s: any) and its vi.importActual
call as ``, so the mocked store and utils module are untyped in the new file. Tests that rely on
this pattern cannot catch a mismatch between the mock and the real useGlobalStore or @/utils
exports.
Code

apps/web/src/specs/app/auth-login-state.spec.tsx[27]

+    pick({ addUser: vi.fn(), setActiveUser: vi.fn(), toggleUiProp: h.toggle, activeUser: h.activeUser })
Evidence
The new spec file adds any in the useGlobalStore mock selector parameter and in the
vi.importActual generic, both of which the checklist disallows in new TypeScript files.

Rule 2668119: Disallow implicit and any types in new TypeScript code
apps/web/src/specs/app/auth-login-state.spec.tsx[27-31]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
Issue description
The new spec `apps/web/src/specs/app/auth-login-state.spec.tsx` uses `any` in the global store mock selector and in `vi.importActual<any>`, which the no-`any` rule forbids for new TypeScript code.
Fix Focus Areas
- apps/web/src/specs/app/auth-login-state.spec.tsx[27-31]
Recommended Fix
Type the selector argument with a narrow interface listing `addUser`, `setActiveUser`, `toggleUiProp`, and `activeUser`, and use `vi.importActual<typeof import("@/utils")>` in place of `<any>`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. A second login invalidates the first ✓ Resolved

Resolving commit: abd22d8

Resolution reason
Login state is now stored as a bounded array of pending {state, at} entries rather than one slot.
Starting a second login appends rather than replaces, so the first callback still matches and
completes. Only the matched entry is consumed; expired entries are filtered out on read.
Description
issueHsLoginState replaces the sole stored state whenever another HiveSigner login starts. If a
user starts login in two tabs, the first callback fails consumeHsLoginState even while its
authorization code is valid and redirects without exchanging it.

View medium (4)
4. Blocked browser storage prevents login 🐞 Bug ☼ Reliability
Description
issueHsLoginState returns an authorization URL after a failed localStorage write, although
consumeHsLoginState returns false when storage cannot be read. In a browser or PWA where
localStorage is unavailable, the user can finish HiveSigner authorization but every callback is
rejected before the code exchange.
Code

apps/web/src/utils/hive-signer.ts[R23-28]

+  try {
+    localStorage.setItem(HS_LOGIN_STATE_KEY, JSON.stringify({ state, at: Date.now() }));
+  } catch {
+    // No storage: the callback then refuses, and the user signs in again.
+  }
+  return state;
Evidence
The storage-write catch still returns the state; the callback requires consumption to succeed, and
the read catch always returns false.

apps/web/src/utils/hive-signer.ts[19-29]
apps/web/src/utils/hive-signer.ts[36-49]
apps/web/src/app/auth/_page.tsx[40-49]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The login starts even when its required callback state cannot be persisted.
## Fix Focus Areas
- apps/web/src/utils/hive-signer.ts[19-49]
- apps/web/src/app/auth/_page.tsx[40-49]
## Recommended Fix
Provide a secure, callback-readable fallback for the pending state when localStorage is unavailable, or stop the login before redirecting and show an actionable error. Test storage exceptions on both issuance and consumption.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Challenge requests can fill Redis 🐞 Bug ☼ Reliability
Description
/challenge now writes a fresh Redis key for every unauthenticated request instead of replacing the
account's previous challenge, with no per-account limit on outstanding keys. The existing per-IP
limit allows repeated issuance across clients, leaving all of those distinct keys resident for five
minutes even when none is used to sign in.
Code

apps/self-hosted/hosting/api/src/routes/auth.ts[75]

+    await challengeStore.set(challengeKey(username, nonce), challenge, ttlSeconds);
Evidence
Any existing Hive username can request a new nonce; Redis stores each username-and-nonce combination
separately with a five-minute TTL. The API applies per-IP rather than per-account rate limits.

apps/self-hosted/hosting/api/src/routes/auth.ts[55-75]
apps/self-hosted/hosting/api/src/utils/redis.ts[49-72]
apps/self-hosted/hosting/api/src/index.ts[62-81]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Per-nonce challenge keys accumulate without an account-level bound on the unauthenticated issuance route.
## Fix Focus Areas
- apps/self-hosted/hosting/api/src/routes/auth.ts[55-75]
- apps/self-hosted/hosting/api/src/utils/redis.ts[49-84]
## Recommended Fix
Atomically cap the number of live challenges per account while retaining support for concurrent legitimate logins. Expire the accounting with the challenges and test issuance at the limit.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Second batched payment can't be looked up by its transaction id 🐞 Bug ≡ Correctness
Description
paymentTransfers stores transfers after the first under :, but GET /v1/payments/verify/:trxId
queries trx_id = $1 using the bare transaction ID. When one transaction pays for multiple blogs,
verification returns only the first payment’s status even though later payments are credited.
Code

apps/self-hosted/hosting/api/src/payment-listener.ts[R36-39]

+  operations.forEach((op, opIndex) => {
+    if (op[0] !== 'transfer' || op[1]?.to !== paymentAccount) return;
+    found.push({ key: found.length === 0 ? trxId : `${trxId}:${opIndex}`, transfer: op[1] });
+  });
Evidence
The listener passes a generated : key to payment processing for transfers after the first. The
verification route instead queries for equality with the caller’s bare transaction ID and returns
one row, so it cannot retrieve payments stored under the suffixed keys.

apps/self-hosted/hosting/api/src/routes/payments.ts[154-178]
apps/self-hosted/hosting/api/src/payment-listener.ts[30-41]
apps/self-hosted/hosting/api/src/payment-listener.ts[30-40]
apps/self-hosted/hosting/api/src/payment-listener.ts[204-213]
apps/self-hosted/hosting/api/src/routes/payments.ts[154-180]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Payment rows for later transfers in a transaction use suffixed operation keys, but transaction verification looks up only the bare transaction ID and returns one result.
## Fix Focus Areas
- apps/self-hosted/hosting/api/src/payment-listener.ts[30-40]
- apps/self-hosted/hosting/api/src/routes/payments.ts[154-180]
## Recommended Fix
Keep exact matching for the bare transaction ID and also retrieve rows whose keys begin with that ID followed by `:`. If using `LIKE`, validate `trxId` as hex or escape pattern characters before querying. Return all matching payments in a form that distinguishes transfers, such as a `payments` array, and add a multi-transfer verification test.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Login-only tokens fail hosting sign-in 🔗 Cross-repo conflict ≡ Correctness
Description
ecencyAccessTokenAuthor rejects every token whose signed message is not posting, including
HiveSigner's valid login access tokens. When a hosted blog uses HiveSigner's scope=login flow
with its own app account, its token reaches /v1/auth/hivesigner but is rejected before the
identity check.
Code

apps/self-hosted/hosting/api/src/routes/auth.ts[222]

+      message?.signed_message?.type !== 'posting' ||
Evidence
The new hosting check rejects tokens unless their type is posting. The pinned HiveSigner UI issues
type login for a login-scope token response, and its documented app-account flow returns that
value as an access token accepted by /api/me.

vision-web -> hivesigner-ui
apps/self-hosted/hosting/api/src/routes/auth.ts[213-229]
External repo: ecency/hivesigner-ui, src/lib/oauth.ts [423-439]
External repo: ecency/hivesigner-ui, src/docs/en/login-only.md [11-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
HiveSigner issues app-bound `login` access tokens for `scope=login`, but hosting rejects them as though they were not access tokens.
## Fix Focus Areas
- apps/self-hosted/hosting/api/src/routes/auth.ts[213-233]
## Recommended Fix
Accept `login` as well as `posting` token types for hosting identity verification, while retaining the single-author check and `/api/me` verification. Add a test using a valid app-bound login token.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

8. Wallets without a ping get a 10-minute wait 🐞 Bug ☼ Reliability
Description
broadcastViaKeychainLike always passes the 10-minute BROADCAST_AFTER_PING_DEADLINE_MS. But
pingKeychain resolves right away, without any answer, when the instance has no requestHandshake.
For such a wallet the 'extension answered the ping' assumption is false, so an extension that is
dead or asleep leaves the user stuck on a spinner for 10 minutes instead of failing after the old 30
s.
Code

apps/self-hosted/src/features/auth/utils/hive-extensions.ts[R440-443]

+  // The extension answered the ping, so it is alive: wait for the wallet's own
+  // answer, however long the user takes in the popup. The long deadline only
+  // covers an extension that dies mid-request (#2125).
+  return broadcastViaKeychain(account, operations, authType, instance, BROADCAST_AFTER_PING_DEADLINE_MS);
Evidence
pingKeychain returns immediately when requestHandshake is not a function. The broadcast is then
always given the long deadline, whether or not a handshake actually happened.

apps/self-hosted/src/features/auth/utils/hive-extensions.ts[390-419]
apps/self-hosted/src/features/auth/utils/hive-extensions.ts[431-444]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The 10-minute broadcast deadline is applied even when `pingKeychain` skipped the handshake because the instance has no `requestHandshake`.
## Fix Focus Areas
- apps/self-hosted/src/features/auth/utils/hive-extensions.ts[390-444]
## Recommended Fix
Have `pingKeychain` resolve to a boolean that says whether a handshake was answered. In `broadcastViaKeychainLike`, pass `BROADCAST_AFTER_PING_DEADLINE_MS` only when it is true; otherwise keep the default 30 s deadline.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…ng logins

- The first HBD transfer in a transaction keeps the bare trx id, as the
  listener recorded it before, so a replay over older blocks finds its row.
- Logins started in several tabs each complete (a few pending state values,
  30 minutes each).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant