Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.81 KB

File metadata and controls

38 lines (27 loc) · 1.81 KB

Shortlinks Feature

Shortlinks Preview

Shortlinks allow users to earn tokens by solving links from third-party URL shortener services (e.g., Shorte.st, Ouo.io).

🔗 Mechanics

Admin Configuration

  • Config Params: Name, API URL ({url}), API Token, Reward Amount, Daily Limit.
  • API Integration: The system generates a unique verification URL (/shortlinks/verify/{token}) and sends it to the provider's API to get a shortened link.

User Flow

  1. Selection: User sees available shortlinks (filtered by daily limit IP/User checks).
  2. Generation: System generates a unique, single-use token and creates a shortlink_session (valid for 1 hour).
  3. Redirection: User is sent to the Provider's Short URL.
  4. Verification: After solving the captcha/ads, the Provider redirects the user back to the verification URL with the token.
  5. Reward: Logic validates the token, ensures it hasn't expired, and credits the user.

🛡️ Security

  1. Session Tokens:

    • Cryptographically random 16-byte hex tokens.
    • Single-use: Deleted immediately upon verification (Atomic Transaction).
    • Bound to User ID and IP Address.
  2. Strict Limits:

    • Daily Limit: Enforced per Link ID.
    • Cross-Account Check: Checks if the IP Address has already claimed the link today, preventing multi-accounting on the same WiFi.
  3. Atomic Verification:

    • DELETE ... RETURNING pattern ensures a token can strictly be used once, even with concurrent requests.

🛠️ Implementation

  • Service: lib/services/shortlinks.ts
  • Models: shortlinks, shortlink_claims, shortlink_sessions.
  • API: /api/shortlinks/verify/[token]