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

egg-kauth

Package Overview
Dependencies
Maintainers
5
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-kauth - npm Package Compare versions

Comparing version 2.0.7-alpha.2 to 2.0.7-alpha.3

43

app/lib/index.js

@@ -113,4 +113,2 @@ "use strict";

let sub;
// todo 打印开始时间
const startedAt = Date.now();
if (this.authHandler) {

@@ -154,4 +152,2 @@ sub = await this.subjectProvider.verify(token);

}
const endedAt = Date.now();
ctx.logger.info('[egg-kauth] tracerId is %s, resolve permission start %s, end %s, and expires %sms', ctx.tracer.traceId, startedAt, endedAt, endedAt - startedAt);
return next();

@@ -184,2 +180,3 @@ };

};
const kflowApi = new kauth_sdk_node_1.KflowApi(kauthConfig);
const kauthApi = new kauth_sdk_node_1.KauthApi(kauthConfig);

@@ -205,3 +202,3 @@ this.moziAuthenticator = new kauth_sdk_node_1.MoziAuthenticator(kauthApi);

this.authHandler = kauthConfig.authHandler;
const router = new KauthRouter(kauthConfig.apiInjected ? kauthApi : undefined, kauthConfig.tracerInjected);
const router = new KauthRouter(kauthConfig.apiInjected ? kauthApi : undefined, kauthConfig.apiInjected ? kflowApi : undefined, kauthConfig.tracerInjected, kauthConfig.traceConsumerKey, kauthConfig.traceConsumer);
router.route(kauthConfig.logoutUri, this.logout);

@@ -247,6 +244,9 @@ router.route(kauthConfig.moziAuthorizeUri, this.redirectMoziAuthorizeUri);

class KauthRouter {
constructor(kauthApi, tracerInjected) {
constructor(kauthApi, kflowApi, tracerInjected, traceConsumerKey, traceConsumer) {
this._routes = {};
this._kauthApi = kauthApi;
this._kflowApi = kflowApi;
this._tracerInjected = tracerInjected;
this._traceConsumerKey = traceConsumerKey,
this._traceConsumer = traceConsumer;
}

@@ -262,11 +262,9 @@ route(path, callback) {

ctx.kauthApi = this._kauthApi;
if (this._tracerInjected && ctx.tracer) {
// 根据 egg 规范,如果存在 tracer,那么将会保持在 ctx.tracer 中
const tracerId = ctx.tracer.traceId;
// 某些情况下,可能会出现 spanId 不存在的情况,这时候需要自己设置 spanId
const spanId = ctx.tracer.spanId || this.generateId(8);
this._kauthApi.setTraceId(tracerId);
this._kauthApi.setSpanId(spanId);
}
this.setTraceIdAndSpanIdIfNecessary(ctx, this._kflowApi);
}
if (this._kflowApi) {
ctx.kflowApi = this._kflowApi;
this.setTraceIdAndSpanIdIfNecessary(ctx, this._kflowApi);
this.setTraceConsumersIfNeccessary(ctx, this._kflowApi);
}
}

@@ -282,2 +280,19 @@ async dispatch(ctx, next) {

}
setTraceConsumersIfNeccessary(ctx, api) {
if (this._traceConsumerKey && this._traceConsumer) {
api.setTraceConsumers({
[this._traceConsumerKey]: this._traceConsumer,
});
}
}
setTraceIdAndSpanIdIfNecessary(ctx, api) {
if (this._tracerInjected && ctx.tracer) {
// 根据 egg 规范,如果存在 tracer,那么将会保持在 ctx.tracer 中
const traceId = ctx.tracer.traceId;
// 某些情况下,可能会出现 spanId 不存在的情况,这时候需要自己设置 spanId
const spanId = ctx.tracer.spanId || this.generateId(8);
api.setTraceId(traceId);
api.setSpanId(spanId);
}
}
generateId(bytes) {

@@ -284,0 +299,0 @@ const spanBuffer = Buffer.allocUnsafe(bytes);

{
"name": "egg-kauth",
"version": "2.0.7-alpha.2",
"version": "2.0.7-alpha.3",
"description": "egg kauth plugin",

@@ -27,3 +27,3 @@ "eggPlugin": {

"dependencies": {
"kauth-sdk-node": "^2.0.4"
"kauth-sdk-node": "2.0.11-alpha.0"
},

@@ -30,0 +30,0 @@ "devDependencies": {

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