Compare commits

..

No commits in common. "master" and "v2.1.0" have entirely different histories.

6 changed files with 15 additions and 38 deletions

View File

@ -1,18 +1,5 @@
# Changelog
## 2024-09-05 - 2.2.1 - fix(core)
Add --allowimplicitany flag to build script
- Updated the build script in package.json to include the --allowimplicitany flag for TypeScript compilation.
## 2024-09-05 - 2.2.0 - feat(smartjwt)
Add nested JWT functionality
- Introduce `isNestedJwt` method to check if an object contains a nested JWT
- Implement `verifyNestedJwt` method to validate nested JWTs
- Add `createNestedJwt` method to create nested JWTs with given payload
- Include `nestedJwtGuard` for guarding nested JWT objects
## 2024-08-26 - 2.1.0 - feat(core)
Enhanced JWT handling and key management

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartjwt",
"version": "2.2.1",
"version": "2.1.0",
"private": false,
"description": "A JavaScript package for creating and verifying JWTs with strong typing support.",
"main": "dist_ts/index.js",
@ -9,7 +9,7 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --allowimplicitany)"
"build": "(tsbuild)"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.84",
@ -21,7 +21,6 @@
"dependencies": {
"@push.rocks/smartcrypto": "^2.0.4",
"@push.rocks/smartguard": "^3.1.0",
"@push.rocks/smartjson": "^5.0.20",
"@tsclass/tsclass": "^4.1.2",
"@types/jsonwebtoken": "^9.0.6",
"jsonwebtoken": "^9.0.2"

3
pnpm-lock.yaml generated
View File

@ -14,9 +14,6 @@ importers:
'@push.rocks/smartguard':
specifier: ^3.1.0
version: 3.1.0
'@push.rocks/smartjson':
specifier: ^5.0.20
version: 5.0.20
'@tsclass/tsclass':
specifier: ^4.1.2
version: 4.1.2

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartjwt',
version: '2.2.1',
version: '2.1.0',
description: 'A JavaScript package for creating and verifying JWTs with strong typing support.'
}

View File

@ -87,7 +87,7 @@ export class SmartJwt<T extends object = any> {
public isNestedJwt<T extends object>(
public isObjectWithJwt<T extends object>(
object: unknown,
): object is IObjectWithJwt<T> {
return (
@ -98,22 +98,17 @@ export class SmartJwt<T extends object = any> {
);
}
public async verifyNestedJwt<T extends object>(object: IObjectWithJwt<T>) {
const jwtData = await this.verifyJWTAndGetData(object.jwt);
(jwtData as any).jwt = object.jwt;
return plugins.smartjson.deepEqualObjects(object, jwtData);
}
public async createNestedJwt<T extends object>(payloadArg: T): Promise<IObjectWithJwt<T>> {
const jwt = await this.createJWT(payloadArg as any);
return {
...payloadArg,
jwt,
public jwtObjectGuard = new plugins.smartguard.Guard(async (dataArg: IObjectWithJwt<any>) => {
const jwtData = this.verifyJWTAndGetData(dataArg.jwt);
// check all other properties wether they match with jwtData
for (const key in dataArg) {
if (key !== 'jwt') {
if (jwtData[key] !== dataArg[key]) {
return false;
}
}
public nestedJwtGuard = new plugins.smartguard.Guard(async (dataArg: IObjectWithJwt<any>) => {
return this.verifyNestedJwt(dataArg);
}
return true;
}, {
name: 'jwtObjectGuard',
failedHint: 'is not a valid jwt object',

View File

@ -1,9 +1,8 @@
// @pushrocks scope
import * as smartcrypto from '@push.rocks/smartcrypto';
import * as smartguard from '@push.rocks/smartguard';
import * as smartjson from '@push.rocks/smartjson';
export { smartcrypto, smartguard, smartjson };
export { smartcrypto, smartguard };
// thirdparty scope
import jsonwebtoken from 'jsonwebtoken';