This is the authentication module for Opine, a simple npm module for verifying JWT tokens.
npm install @opine-official/authentication
import { verifyToken } from "@opine-official/authentication";
const token = "your-jwt-token";
const secretKey = "your-secret-key";
try {
const decoded = verifyToken(token, secretKey);
console.log(decoded);
} catch (err) {
console.error(err.message);
}
verifyToken(token: string, secretKey: string): any
Verifies a JWT token.
- token: The JWT token to verify.
- secretKey: The secret key used to verify the token.
Returns the decoded payload if the token is valid, throws an Error otherwise.
You can find the source code for this module on GitHub.
MIT
Remember to replace your-jwt-token and your-secret-key with actual values when using the module. You may also want to replace MIT with the actual license you're using, and add more sections as needed, such as Contributing, Tests, and Changelog.