kauth-sdk-node
Advanced tools
Comparing version 2.0.10 to 2.0.11-alpha.0
@@ -31,2 +31,4 @@ import { AuthenticationInformation } from '../../authenticator'; | ||
tracerInjected?: boolean; | ||
traceConsumerKey?: string; | ||
traceConsumer?: string; | ||
marmotTenantId?: number; | ||
@@ -33,0 +35,0 @@ marmotAccessKeyId?: string; |
@@ -7,2 +7,6 @@ import { KauthConfig } from '../config/config'; | ||
constructor({ kflowOrigin, marmotTenantId, marmotAccessKeyId, marmotAccessKeySecret, kflowServiceName, kflowServicePort, }: KauthConfig); | ||
setTraceId(traceId: string): void; | ||
setSpanId(spanId: string): void; | ||
setUserId(userId: string): void; | ||
setTraceConsumers(consumers: Record<string, string> | ((val: Record<string, string>) => Record<string, string>)): void; | ||
startProcessInstanceByKey(body: KflowCreateProcessRequest): Promise<string>; | ||
@@ -9,0 +13,0 @@ completeTaskService(userId: string | number, body: KflowCompleteTaskServiceRequest): Promise<void>; |
@@ -10,2 +10,14 @@ "use strict"; | ||
} | ||
setTraceId(traceId) { | ||
this.marmotUtil.setTraceId(traceId); | ||
} | ||
setSpanId(spanId) { | ||
this.marmotUtil.setSpanId(spanId); | ||
} | ||
setUserId(userId) { | ||
this.marmotUtil.setUserId(userId); | ||
} | ||
setTraceConsumers(consumers) { | ||
this.marmotUtil.setTraceConsumers(consumers); | ||
} | ||
async startProcessInstanceByKey(body) { | ||
@@ -12,0 +24,0 @@ return this.marmotUtil.post(http_1.ProcessUri, body); |
@@ -6,2 +6,3 @@ import { MarmotOptions } from '../tool/marmot'; | ||
features: any; | ||
traceConsumers?: any; | ||
} | ||
@@ -8,0 +9,0 @@ export interface KflowCompleteGraphServiceTaskRequest extends MarmotOptions { |
@@ -41,2 +41,3 @@ /// <reference types="node" /> | ||
private spanId?; | ||
private traceConsumers?; | ||
constructor(origin: string, tenantId?: number, accessKeyId?: string, accessKeySecret?: string, serviceName?: string, servicePort?: string); | ||
@@ -46,2 +47,3 @@ setUserId(userId: string): void; | ||
setSpanId(spanId: string): void; | ||
setTraceConsumers(traceConsumers: Record<string, string> | ((val: Record<string, string>) => Record<string, string>)): void; | ||
get<RequestType extends ParsedUrlQueryInput | MarmotOptions, ResponseType>(path: string, params?: RequestType): Promise<ResponseType>; | ||
@@ -54,3 +56,4 @@ post<RequestType extends MarmotOptions, ResponseType>(path: string, params?: RequestType, config?: AxiosRequestConfig): Promise<ResponseType>; | ||
format<T>(response: AxiosResponse<BasicReponse<any>>): Promise<T>; | ||
private formatTraceConsumers; | ||
} | ||
export {}; |
@@ -39,2 +39,10 @@ "use strict"; | ||
} | ||
setTraceConsumers(traceConsumers) { | ||
if (typeof traceConsumers === 'function') { | ||
this.traceConsumers = traceConsumers(this.traceConsumers || {}); | ||
} | ||
else { | ||
this.traceConsumers = traceConsumers; | ||
} | ||
} | ||
async get(path, params) { | ||
@@ -95,2 +103,5 @@ // 兼容老的写法 | ||
} | ||
if (this.traceConsumers) { | ||
headers['x-kauth-trace-consumers'] = this.formatTraceConsumers(this.traceConsumers); | ||
} | ||
if (!this.proxyMatched) { | ||
@@ -108,2 +119,3 @@ // 如果直连转发,需要传入 x-gw-tenant-id | ||
headers.authorization = `Marmot ${this.accessKeyId}:${signature}`; | ||
console.log('request headers', headers); | ||
return headers; | ||
@@ -127,3 +139,12 @@ } | ||
} | ||
formatTraceConsumers(traceConsumers) { | ||
return Object | ||
.keys(traceConsumers) | ||
.map((k) => { | ||
const v = this.traceConsumers[k]; | ||
return `${k}:${v}`; | ||
}) | ||
.join(','); | ||
} | ||
} | ||
exports.MarmotUtil = MarmotUtil; |
{ | ||
"name": "kauth-sdk-node", | ||
"version": "2.0.10", | ||
"version": "2.0.11-alpha.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
77009
1658
2