Skip to content

feat(share-links): Build Share Link Management Service #191 - #202

Merged
SudiptaPaul-31 merged 1 commit into
SudiptaPaul-31:mainfrom
fastcharger2000:fix/share-link-management-191
Sep 27, 2026
Merged

SudiptaPaul-31 merged 1 commit into
SudiptaPaul-31:mainfrom
fastcharger2000:fix/share-link-management-191

Conversation

@fastcharger2000

Copy link
Copy Markdown
Contributor

Overview

This PR adds a Share Link Management Service for Codely: secure token generation, configurable expiration, create/list/revoke/validate APIs, and audit logging — without exposing snippet content.

Related Issue

Closes #191

Changes

🔗 Share Link Management

  • [ADD] lib/share-link-management.service.ts

    • Cryptographically secure 256-bit hex tokens (crypto.randomBytes).
    • Create links with optional expiresAt and visibility (read-only | read-write).
    • List active links only (expired/revoked excluded).
    • Revoke by id (immediate invalidation).
    • Validate by token with active / expired / revoked status.
    • In-memory audit log + durable logEvent hooks for create/revoke/validate.
  • [ADD] app/api/share-links/route.ts

    • POST /api/share-links — create share link.
    • GET /api/share-links?snippetId= — list active links.
  • [ADD] app/api/share-links/[id]/route.ts

    • DELETE /api/share-links/:id — revoke link.
  • [ADD] app/api/share-links/[id]/validate/route.ts

    • GET /api/share-links/:token/validate — validate active link (metadata only).
  • [ADD] lib/share-link-management.service.test.ts

    • Coverage for unique tokens, expiry enforcement, revoke-immediate-invalid, active-only listing, and audit events.

Verification Results

Expected: npx jest lib/share-link-management.service.test.ts
✅ Tokens unique / 64-char hex
✅ Expired links invalidated
✅ Revoked links fail validation immediately
✅ Listing excludes expired/revoked
✅ Responses contain metadata only (no snippet content)
Acceptance Criteria Status
Tokens are unique and secure ✅ 256-bit hex via crypto.randomBytes
Expiration enforced ✅ Expired links fail validate + excluded from list
APIs return consistent JSON schema ✅ { success, data } across endpoints
Revoked links are immediately invalid ✅ validate returns reason=revoked
Listing shows only active links ✅ expired/revoked filtered out
No sensitive snippet content exposed ✅ metadata/status only

Implements secure share-link generation, listing, revocation, validation, and audit logging for Closes SudiptaPaul-31#191.
@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@fastcharger2000 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown

@fastcharger2000 is attempting to deploy a commit to the Sudipta 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@SudiptaPaul-31
SudiptaPaul-31 merged commit 81c37cd into SudiptaPaul-31:main Sep 27, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Share Link Management Service

2 participants