diff --git a/package.json b/package.json index a1f0425..b9a0bfb 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,15 @@ { "name": "@apihub24/token-authentication", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "dist/index.js", "types": "./dist/index.d.ts", "scripts": { - "build": "tsc" + "build": "tsc", + "test": "jest", + "test:coverage": "jest --coverage", + "pub": "npm publish", + "rel": "npm i && npm run build && npm run test:coverage" }, "dependencies": { "@nestjs/common": "^11.1.6", @@ -15,7 +19,11 @@ "class-validator": "^0.14.2" }, "devDependencies": { - "typescript": "^5.9.2" + "@nestjs/testing": "^11.1.6", + "typescript": "^5.9.2", + "@types/jest": "^30.0.0", + "jest": "^30.0.0", + "ts-jest": "^29.4.1" }, "keywords": [], "author": { @@ -26,5 +34,26 @@ "license": "MIT", "publishConfig": { "access": "public" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": ".", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "./coverage", + "testEnvironment": "node", + "roots": [ + "/src/" + ], + "moduleNameMapper": {} } } diff --git a/src/contracts/services/token.service.ts b/src/contracts/services/token.service.ts index 64b9cb6..14636e3 100644 --- a/src/contracts/services/token.service.ts +++ b/src/contracts/services/token.service.ts @@ -1,8 +1,15 @@ import { IAccount } from "../models/account"; import { ISession } from "../models/session"; +export type Algorithm = "HS256" | "HS384" | "HS512"; + export interface ITokenService { - generate(session: ISession): Promise; + generate( + session: ISession, + subject: string, + expires: string, + algorithm: Algorithm + ): Promise; validate(token: string): Promise; getAccount(token: string): Promise; }