Commit 12311dcf by Percy Quispe Huarcaya

feat: Adding token creator and a parser

parent e154737f
...@@ -10,6 +10,9 @@ describe('Token', () => { ...@@ -10,6 +10,9 @@ describe('Token', () => {
const token = createJWT(id, subject, unixTime); const token = createJWT(id, subject, unixTime);
const test = parseJWT(token); const test = parseJWT(token);
console.log("------------------------>")
console.log(test)
const payload = test.subject; const payload = test.subject;
expect(payload.usuarioId).toBe(395); expect(payload.usuarioId).toBe(395);
}); });
......
declare module 'security-ndjs-lib' { declare module 'security-ndjs-lib' {
export function createJWT(id: string, subject: object, time?: number): string; export function createJWT(id: string, subject: object, time?: number): string;
export function parseJWT(token: string, id?: string): string; // Adjust the signature if needed export function parseJWT(token: string, id?: string): TokenModel; // Adjust the signature if needed
} }
\ No newline at end of file
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