Commit 047dab2b by Percy Quispe Huarcaya

feat: Adding token creator and a parser

parent 16f04627
......@@ -51,6 +51,8 @@ parseJWT = (token, ...id) => {
}
}
*/
console.log("parseJWT -------");
console.log(decoded)
return decoded; // This will return the token's claims (payload)
} catch (err) {
console.error('Invalid token:', err.message);
......
import { JwtPayload } from "jsonwebtoken";
import { TokenModel } from "./tokenmodel";
/**
JwtPayload
[key: string]: any;
iss?: string | undefined;
sub?: string | undefined;
aud?: string | string[] | undefined;
exp?: number | undefined;
nbf?: number | undefined;
iat?: number | undefined;
jti?: string | undefined;
TokenModel
id: string;
issuedAt: number;
subject: object;
issuer: string;
iat: number;
exp: number;
*/
declare module 'security-ndjs-lib' {
export function createJWT(id: string, subject: object, time?: number): string;
export function parseJWT(token?: string, id?: string): JwtPayload; // Adjust the signature if needed
export function parseJWT(token?: string, id?: string): TokenModel; // Adjust the signature if needed
}
\ No newline at end of file
export interface TokenModel {
id: string;
issuedAt: number;
subject: object;
issuer: string;
iat: number;
exp: number;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment