Skip to content

feat(security): implement cryptographic token signing wrapper#2256

Merged
janavipandole merged 1 commit into
janavipandole:mainfrom
Prateek2007-cmd:fix/crypto-token-signing
Jun 14, 2026
Merged

feat(security): implement cryptographic token signing wrapper#2256
janavipandole merged 1 commit into
janavipandole:mainfrom
Prateek2007-cmd:fix/crypto-token-signing

Conversation

@Prateek2007-cmd

Copy link
Copy Markdown
Contributor

Description

This PR resolves Issue 4: Missing Cryptographic Token Signing.
Closes #2250
The secure-storage.js utility previously used a very basic XOR cipher with a hardcoded key to obscure tokens in local storage. This offered virtually zero security against data tampering. This PR replaces the naive XOR obfuscation with a robust HMAC-SHA256 signature generated using the native Web Crypto API (window.crypto.subtle).

While client-side storage is inherently accessible to the user, this approach guarantees data integrity (tamper evidence) by invalidating any modified local storage entries and fulfills the technical requirement of the previously pending TODO.

Changes Made

  • Implemented getKey(), signData(), and verifyData() utility functions using the window.crypto.subtle API.
  • Updated SecureStorage.setItem to asynchronously generate an HMAC signature and store the payload and signature together.
  • Updated SecureStorage.getItem to verify the signature of the payload before returning the data. If the signature is invalid, it logs a warning, purges the tampered data, and returns null.
  • Removed the obsolete TODO: Implement cryptographic token signing wrapper comment.

Type of Change

  • Security patch
  • New feature

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@Prateek2007-cmd is attempting to deploy a commit to the janavipandole's projects Team on Vercel.

A member of the Team first needs to authorize it.

@janavipandole janavipandole merged commit 7493272 into janavipandole:main Jun 14, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Cryptographic Token Signing

2 participants