Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@postman/postman-sdk

Package Overview
Dependencies
Maintainers
350
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@postman/postman-sdk - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9-beta.1

12

build/postman/base-sdk.js

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

const logger_1 = require("./utils/logger");
const api_1 = require("@opentelemetry/api");
class PostmanBaseSDK {

@@ -29,4 +28,3 @@ constructor(config) {

}
// Keeping logLevel error as the base, so that errors are populated out.
(0, logger_1.setLogger)(this.config.debug === true ? api_1.DiagLogLevel.DEBUG : api_1.DiagLogLevel.ERROR);
(0, logger_1.setLogger)(this.config.debug === true ? 2 /* LogLevel.DEBUG */ : 3 /* LogLevel.INFO */);
this.postmanTracer = new tracing_1.PostmanTracer(this.config);

@@ -47,3 +45,3 @@ this.postmanTracer.initialize();

if (retryCount > base_types_1.DEFAULT_HEALTH_CHECK_RETRIES) {
logger_1._diag.error('Postman SDK healthcheck retries exhausted');
logger_1.logger.info('Postman SDK healthcheck retries exhausted');
this.disable();

@@ -53,3 +51,3 @@ return;

context_1.PostmanContext.setHealthCheckRetryCount(retryCount + 1);
logger_1._diag.debug(`Retrying Postman SDK healthcheck count: ${retryCount}`);
logger_1.logger.debug(`Retrying Postman SDK healthcheck count: ${retryCount}`);
this.enableHealthCheck(Math.pow(base_types_1.EXPONENTIAL_BACKOFF_BASE, retryCount) *

@@ -62,3 +60,3 @@ base_types_1.DEFAULT_HEALTH_PING_INTERVAL);

return;
logger_1._diag.error('Disabling Postman SDK healthcheck');
logger_1.logger.info('Disabling Postman SDK healthcheck');
// @ts-expect-error Ignore param type checking

@@ -144,3 +142,3 @@ clearTimeout(healthCheckSetTimeoutId);

catch (err) {
logger_1._diag.error(
logger_1.logger.error(
// eslint-disable-next-line no-multi-str

@@ -147,0 +145,0 @@ 'JSONParseError: Failed to read `POSTMAN_SDK_ENABLE` config from environment variables. \

@@ -22,3 +22,3 @@ "use strict";

catch (e) {
logger_1._diag.error(`Unable to parse regExRule ${this.DataRedactionRulesSettings[rule_name]} error: ${e}`);
logger_1.logger.error(`Unable to parse regExRule ${this.DataRedactionRulesSettings[rule_name]} error: ${e}`);
}

@@ -36,3 +36,3 @@ });

catch (e) {
logger_1._diag.error(`Unable to perform redaction error ${e}`);
logger_1.logger.error(`Unable to perform redaction error ${e}`);
}

@@ -39,0 +39,0 @@ }

@@ -28,3 +28,3 @@ "use strict";

catch (err) {
logger_1._diag.debug('Failed to parse JSON when redacting senstive data. Bailing out !!');
logger_1.logger.error('Failed to parse JSON when redacting senstive data. Bailing out !!');
return jsonString;

@@ -31,0 +31,0 @@ }

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

const instrumentation_1 = require("@opentelemetry/instrumentation");
const core_1 = require("@opentelemetry/core");
const version_1 = require("../../version");

@@ -18,3 +19,3 @@ const logger_1 = require("../utils/logger");

new instrumentation_1.InstrumentationNodeModuleDefinition('express', ['^4.0.0'], (moduleExports, moduleVersion) => {
this._diag.info(`Applying postman patch for express@${moduleVersion}`);
logger_1.logger.info(`Applying postman patch for express@${moduleVersion}`);
// patch express.Resonse.send

@@ -29,3 +30,3 @@ if ((0, instrumentation_1.isWrapped)(moduleExports.response.send)) {

return;
this._diag.debug(`Removing postman patch for express@${moduleVersion}`);
logger_1.logger.debug(`Removing postman patch for express@${moduleVersion}`);
this._unwrap(moduleExports.response, 'send');

@@ -46,11 +47,25 @@ })

return function send(...args) {
instrumentation._diag.debug('Running postman send patch');
logger_1.logger.debug('Running postman send patch');
const originalSendResponse = original.apply(this, args);
const span = api_1.trace.getSpan(api_1.context.active());
let span = api_1.trace.getSpan(api_1.context.active());
let newSpanFlag = false;
if (!(0, utils_1.shouldReportSpan)(span)) {
instrumentation._diag.debug('Span undefined or ended, returning original response.send');
return originalSendResponse;
const spanOptions = {
kind: api_1.SpanKind.SERVER,
attributes: undefined
};
span = instrumentation.tracer.startSpan(this.req.method, spanOptions, api_1.context.active());
// create a new span and set as active. Set attributes for the same.
span.setAttributes({
'http.method': this.req.method,
'http.status_code': this.req.statusCode,
'http.host': this.req.hostname,
'http.target': this.req.url,
startTimeUnixNano: (0, core_1.hrTime)()
});
newSpanFlag = true;
logger_1.logger.debug('Span undefined or ended, re-creating a new span.');
}
if (!this.req.route.path) {
instrumentation._diag.error(`Issue: Missing Request route: ${JSON.stringify(this.req.route)}`);
logger_1.logger.info('Issue: Missing Request route.');
}

@@ -70,2 +85,6 @@ const reqObject = {

}
// need to end span too. Only when we created the span.
if (newSpanFlag) {
span === null || span === void 0 ? void 0 : span.end();
}
return originalSendResponse;

@@ -72,0 +91,0 @@ };

@@ -21,3 +21,3 @@ "use strict";

new instrumentation_1.InstrumentationNodeModuleDefinition('fastify', ['^3.0.0', '^4.0.0'], (moduleExports, moduleVersion) => {
this._diag.info(`Applying postman patch for fastify@${moduleVersion}`);
logger_1.logger.info(`Applying postman patch for fastify@${moduleVersion}`);
return this._patchConstructor(moduleExports);

@@ -40,3 +40,3 @@ })

const instrumentation = this;
this._diag.debug('Patching fastify constructor function');
logger_1.logger.debug('Patching fastify constructor function');
function fastify(...args) {

@@ -63,3 +63,3 @@ const app = original.apply(this, args);

if (!(0, utils_1.shouldReportSpan)(span)) {
instrumentation._diag.debug('Span undefined or ended, returning originial reply.send');
logger_1.logger.debug('Span undefined or ended, returning originial reply.send');
done();

@@ -82,3 +82,3 @@ }

const instrumentation = this;
this._diag.debug('Patching fastify reply.send function');
logger_1.logger.debug('Patching fastify reply.send function');
return function patchSend(original) {

@@ -85,0 +85,0 @@ return function send(...args) {

@@ -27,3 +27,4 @@ "use strict";

if (this.config.redactSensitiveData &&
(this.config.redactSensitiveData.enable || this.config.redactSensitiveData.enable === undefined)) {
(this.config.redactSensitiveData.enable ||
this.config.redactSensitiveData.enable === undefined)) {
const redactionRules = this.config.redactSensitiveData.rules || {};

@@ -40,5 +41,2 @@ this.dataRedactionEngine = new data_redactions_1.DataRedaction(redactionRules);

});
if (this.config.debug) {
provider.addSpanProcessor(new sdk_trace_node_1.SimpleSpanProcessor(new sdk_trace_node_1.ConsoleSpanExporter()));
}
let bufferConfig;

@@ -90,3 +88,2 @@ if (this.config.bufferIntervalInMilliseconds !== undefined &&

};
logger_1._diag.debug(`Postman Exporter configered with url: ${otelExporterConfig.url}`);
const otelExporter = new exporter_trace_otlp_http_1.OTLPTraceExporter(otelExporterConfig);

@@ -96,3 +93,3 @@ return otelExporter;

suppress() {
logger_1._diag.error('Disable PostmanTracer');
logger_1.logger.info('Disable PostmanTracer');
api_1.context.with((0, core_1.suppressTracing)(context_1.PostmanContext.getInstance()), () => {

@@ -103,3 +100,3 @@ context_1.PostmanContext.setNewContext(api_1.context.active());

unsupress() {
logger_1._diag.error('Enable PostmanTracer');
logger_1.logger.info('Enable PostmanTracer');
api_1.context.with((0, core_1.unsuppressTracing)(context_1.PostmanContext.getInstance()), () => {

@@ -106,0 +103,0 @@ context_1.PostmanContext.setNewContext(api_1.context.active());

@@ -20,3 +20,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
logger_1._diag.debug('Postman SDK Bootstraping');
logger_1.logger.debug('Postman SDK Bootstraping');
const response = yield (0, rest_client_1.syncRequest)(sdkConfig.receiverBaseUrl + config_1.BOOTSTRAP_PATH, {

@@ -23,0 +23,0 @@ method: 'POST',

@@ -19,3 +19,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
logger_1._diag.debug('Postman SDK healthcheck');
logger_1.logger.debug('Postman SDK healthcheck');
const response = yield (0, rest_client_1.syncRequest)(sdkConfig.receiverBaseUrl + config_1.HEALTHCHECK_PATH, {

@@ -22,0 +22,0 @@ method: 'POST',

@@ -39,3 +39,3 @@ "use strict";

// content-type = application/json at the moment.
logger_1._diag.debug('Unable to parse JSON data while applying truncation. Bailing out.');
logger_1.logger.debug('Unable to parse JSON data while applying truncation. Bailing out.');
return data;

@@ -42,0 +42,0 @@ }

@@ -1,4 +0,15 @@

import { DiagLogger, DiagLogLevel } from '@opentelemetry/api';
import { DiagLogger } from '@opentelemetry/api';
import { Logger } from 'tslog';
export declare let _diag: DiagLogger;
export declare const POSTMAN_LOGGING_NAMESPACE = "@postman/postman-sdk:";
export declare function setLogger(logLevel: DiagLogLevel, namespace?: string): void;
export declare const enum LogLevel {
SILLY = 0,
TRACE = 1,
DEBUG = 2,
INFO = 3,
WARN = 4,
ERROR = 5,
FATAL = 6
}
export declare const logger: Logger<unknown>;
export declare function setLogger(logLevel: LogLevel, namespace?: string): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setLogger = exports.POSTMAN_LOGGING_NAMESPACE = exports._diag = void 0;
exports.setLogger = exports.logger = exports.POSTMAN_LOGGING_NAMESPACE = exports._diag = void 0;
/* eslint-disable no-unused-vars */
const api_1 = require("@opentelemetry/api");
const tslog_1 = require("tslog");
exports.POSTMAN_LOGGING_NAMESPACE = '@postman/postman-sdk:';
exports.logger = new tslog_1.Logger({
name: exports.POSTMAN_LOGGING_NAMESPACE,
hideLogPositionForProduction: true
});
function setLogger(logLevel, namespace = exports.POSTMAN_LOGGING_NAMESPACE) {
api_1.diag.setLogger(new api_1.DiagConsoleLogger(), logLevel);
api_1.diag.setLogger(new api_1.DiagConsoleLogger(), api_1.DiagLogLevel.WARN);
exports._diag = api_1.diag.createComponentLogger({ namespace: namespace });
exports.logger.settings.minLevel = logLevel;
}
exports.setLogger = setLogger;

@@ -33,3 +33,3 @@ "use strict";

finally {
logger_1._diag.debug(`Postman SDK API url: ${url} status: ${response.status} body: ${JSON.stringify(respBody)}`);
logger_1.logger.debug(`Postman SDK API status: ${response.status} body: ${JSON.stringify(respBody)}`);
// @ts-expect-error Ignore property respBody doesn't exists on response.

@@ -36,0 +36,0 @@ response.respBody = respBody;

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

export declare const VERSION = "0.1.8";
export declare const VERSION = "0.1.9-beta.1";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = '0.1.8';
exports.VERSION = '0.1.9-beta.1';
{
"name": "@postman/postman-sdk",
"version": "0.1.8",
"version": "0.1.9-beta.1",
"description": "",

@@ -38,2 +38,3 @@ "main": "build/index.js",

"ts-transformer-keys": "0.4.4",
"tslog": "^4.8.2",
"ttypescript": "1.5.15"

@@ -40,0 +41,0 @@ },

@@ -1,2 +0,2 @@

![Postman](./images/postman_banner.jpg)
![Postman](https://user-images.githubusercontent.com/117167853/230871188-0b05ff7c-8b61-401b-9d9a-4c1cb79ade88.jpg)

@@ -3,0 +3,0 @@ ### About

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