This commit is contained in:
admin 2025-08-21 20:46:49 +02:00
parent b9f546d045
commit 8471ff8eaf
2 changed files with 40 additions and 4 deletions

View File

@ -1,11 +1,15 @@
{ {
"name": "@apihub24/token-authentication", "name": "@apihub24/token-authentication",
"version": "1.0.2", "version": "1.0.3",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"scripts": { "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": { "dependencies": {
"@nestjs/common": "^11.1.6", "@nestjs/common": "^11.1.6",
@ -15,7 +19,11 @@
"class-validator": "^0.14.2" "class-validator": "^0.14.2"
}, },
"devDependencies": { "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": [], "keywords": [],
"author": { "author": {
@ -26,5 +34,26 @@
"license": "MIT", "license": "MIT",
"publishConfig": { "publishConfig": {
"access": "public" "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": [
"<rootDir>/src/"
],
"moduleNameMapper": {}
} }
} }

View File

@ -1,8 +1,15 @@
import { IAccount } from "../models/account"; import { IAccount } from "../models/account";
import { ISession } from "../models/session"; import { ISession } from "../models/session";
export type Algorithm = "HS256" | "HS384" | "HS512";
export interface ITokenService { export interface ITokenService {
generate(session: ISession): Promise<string>; generate(
session: ISession,
subject: string,
expires: string,
algorithm: Algorithm
): Promise<string>;
validate(token: string): Promise<boolean>; validate(token: string): Promise<boolean>;
getAccount(token: string): Promise<IAccount | null>; getAccount(token: string): Promise<IAccount | null>;
} }