New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kauth-sdk-node

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kauth-sdk-node - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [0.1.17](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.16...v0.1.17) (2021-03-01)
### Features
* jwt refresh ([61aa920](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/commit/61aa920bb0614b3c9e6b21e47a0bb04853ab8d50))
## [0.1.16](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-node/compare/v0.1.15...v0.1.16) (2021-02-09)

@@ -2,0 +11,0 @@

@@ -6,5 +6,7 @@ import { AuthenticationInformation } from './base';

verify(token: string): Promise<number>;
refresh(token: string): string;
}
export interface AuthenticationProvider {
verify(token: string): Promise<AuthenticationInformation>;
refresh(token: string): string;
authenticate(authenticationInformation: AuthenticationInformation): string;

@@ -14,4 +16,6 @@ }

private secret;
private duration;
constructor(kauthConfig: KauthConfig);
verify(token: string): Promise<number>;
refresh(token: string): string;
}

@@ -24,3 +28,4 @@ export declare class JsonWebTokenAuthenticationProvider implements AuthenticationProvider {

verify(token: string): Promise<AuthenticationInformation>;
refresh(token: string): string;
authenticate(authenticationInformation: AuthenticationInformation): string;
}

@@ -15,2 +15,3 @@ "use strict";

this.secret = kauthConfig.jwtSecret;
this.duration = kauthConfig.jwtDuration;
}

@@ -26,2 +27,13 @@ async verify(token) {

}
refresh(token) {
const { iat, ...claims } = jsonwebtoken_1.default.decode(token);
// jwt life duration
const duration = Math.floor(Date.now() / 1000) - iat;
if (duration > this.duration / 2 && duration < this.duration) {
const exp = dayjs_1.default().add(this.duration, 'second').unix();
claims[Exp] = exp;
return jsonwebtoken_1.default.sign(claims, this.secret);
}
return null;
}
}

@@ -45,2 +57,13 @@ exports.JsonWebTokenSubjectProvider = JsonWebTokenSubjectProvider;

}
refresh(token) {
const { iat, ...claims } = jsonwebtoken_1.default.decode(token);
// jwt life duration
const duration = Math.floor(Date.now() / 1000) - iat;
if (duration > this.duration / 2 && duration < this.duration) {
const exp = dayjs_1.default().add(this.duration, 'second').unix();
claims[Exp] = exp;
return jsonwebtoken_1.default.sign(claims, this.secret);
}
return null;
}
authenticate(authenticationInformation) {

@@ -47,0 +70,0 @@ const exp = dayjs_1.default().add(this.duration, 'second').unix();

2

package.json
{
"name": "kauth-sdk-node",
"version": "0.1.16",
"version": "0.1.17",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc