Socket
Socket
Sign inDemoInstall

@launchdarkly/js-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@launchdarkly/js-sdk-common - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.8.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.7.0...js-sdk-common-v2.8.0) (2024-09-03)
### Features
* Add support for Payload Filtering ([#551](https://github.com/launchdarkly/js-core/issues/551)) ([6f44383](https://github.com/launchdarkly/js-core/commit/6f4438323baed802d8f951ac82494e6cfa9932c5))
## [2.7.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.6.0...js-sdk-common-v2.7.0) (2024-08-28)

@@ -7,0 +14,0 @@

7

dist/internal/events/EventSender.js

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

const errors_1 = require("../../errors");
const options_1 = require("../../options");
const utils_1 = require("../../utils");

@@ -10,7 +11,7 @@ class EventSender {

const { basicConfiguration, platform } = clientContext;
const { sdkKey, serviceEndpoints: { events, analyticsEventPath, diagnosticEventPath, includeAuthorizationHeader, }, tags, } = basicConfiguration;
const { sdkKey, serviceEndpoints: { analyticsEventPath, diagnosticEventPath, includeAuthorizationHeader }, tags, } = basicConfiguration;
const { crypto, info, requests } = platform;
this.defaultHeaders = (0, utils_1.defaultHeaders)(sdkKey, info, tags, includeAuthorizationHeader);
this.eventsUri = `${events}${analyticsEventPath}`;
this.diagnosticEventsUri = `${events}${diagnosticEventPath}`;
this.eventsUri = (0, options_1.getEventsUri)(basicConfiguration.serviceEndpoints, analyticsEventPath, []);
this.diagnosticEventsUri = (0, options_1.getEventsUri)(basicConfiguration.serviceEndpoints, diagnosticEventPath, []);
this.requests = requests;

@@ -17,0 +18,0 @@ this.crypto = crypto;

@@ -17,3 +17,6 @@ import { EventName, ProcessStreamResponse } from '../../api';

private connectionAttemptStartTime?;
constructor(sdkKey: string, clientContext: ClientContext, streamUriPath: string, listeners: Map<EventName, ProcessStreamResponse>, diagnosticsManager?: DiagnosticsManager | undefined, errorHandler?: StreamingErrorHandler | undefined, streamInitialReconnectDelay?: number);
constructor(sdkKey: string, clientContext: ClientContext, streamUriPath: string, parameters: {
key: string;
value: string;
}[], listeners: Map<EventName, ProcessStreamResponse>, diagnosticsManager?: DiagnosticsManager | undefined, errorHandler?: StreamingErrorHandler | undefined, streamInitialReconnectDelay?: number);
private logConnectionStarted;

@@ -20,0 +23,0 @@ private logConnectionResult;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const errors_1 = require("../../errors");
const ServiceEndpoints_1 = require("../../options/ServiceEndpoints");
const utils_1 = require("../../utils");

@@ -11,3 +12,3 @@ const reportJsonError = (type, data, logger, errorHandler) => {

class StreamingProcessor {
constructor(sdkKey, clientContext, streamUriPath, listeners, diagnosticsManager, errorHandler, streamInitialReconnectDelay = 1) {
constructor(sdkKey, clientContext, streamUriPath, parameters, listeners, diagnosticsManager, errorHandler, streamInitialReconnectDelay = 1) {
this.listeners = listeners;

@@ -23,3 +24,3 @@ this.diagnosticsManager = diagnosticsManager;

this.requests = requests;
this.streamUri = `${basicConfiguration.serviceEndpoints.streaming}${streamUriPath}`;
this.streamUri = (0, ServiceEndpoints_1.getStreamingUri)(basicConfiguration.serviceEndpoints, streamUriPath, parameters);
}

@@ -26,0 +27,0 @@ logConnectionStarted() {

import ApplicationTags from './ApplicationTags';
import ClientContext from './ClientContext';
import OptionMessages from './OptionMessages';
import ServiceEndpoints from './ServiceEndpoints';
export { ApplicationTags, OptionMessages, ServiceEndpoints, ClientContext };
import ServiceEndpoints, { getEventsUri, getPollingUri, getStreamingUri } from './ServiceEndpoints';
export { ApplicationTags, OptionMessages, ServiceEndpoints, ClientContext, getStreamingUri, getPollingUri, getEventsUri, };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientContext = exports.ServiceEndpoints = exports.OptionMessages = exports.ApplicationTags = void 0;
exports.getEventsUri = exports.getPollingUri = exports.getStreamingUri = exports.ClientContext = exports.ServiceEndpoints = exports.OptionMessages = exports.ApplicationTags = void 0;
const ApplicationTags_1 = require("./ApplicationTags");

@@ -12,2 +12,5 @@ exports.ApplicationTags = ApplicationTags_1.default;

exports.ServiceEndpoints = ServiceEndpoints_1.default;
Object.defineProperty(exports, "getEventsUri", { enumerable: true, get: function () { return ServiceEndpoints_1.getEventsUri; } });
Object.defineProperty(exports, "getPollingUri", { enumerable: true, get: function () { return ServiceEndpoints_1.getPollingUri; } });
Object.defineProperty(exports, "getStreamingUri", { enumerable: true, get: function () { return ServiceEndpoints_1.getStreamingUri; } });
//# sourceMappingURL=index.js.map

@@ -9,2 +9,3 @@ /**

readonly events: string;
readonly payloadFilterKey?: string;
/** Valid paths are:

@@ -23,4 +24,37 @@ * /bulk

readonly includeAuthorizationHeader: boolean;
constructor(streaming: string, polling: string, events?: string, analyticsEventPath?: string, diagnosticEventPath?: string, includeAuthorizationHeader?: boolean);
constructor(streaming: string, polling: string, events?: string, analyticsEventPath?: string, diagnosticEventPath?: string, includeAuthorizationHeader?: boolean, payloadFilterKey?: string);
}
/**
* Get the URI for the streaming endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
export declare function getStreamingUri(endpoints: ServiceEndpoints, path: string, parameters: {
key: string;
value: string;
}[]): string;
/**
* Get the URI for the polling endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
export declare function getPollingUri(endpoints: ServiceEndpoints, path: string, parameters: {
key: string;
value: string;
}[]): string;
/**
* Get the URI for the events endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
export declare function getEventsUri(endpoints: ServiceEndpoints, path: string, parameters: {
key: string;
value: string;
}[]): string;
//# sourceMappingURL=ServiceEndpoints.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEventsUri = exports.getPollingUri = exports.getStreamingUri = void 0;
function canonicalizeUri(uri) {
return uri.replace(/\/+$/, '');
}
function canonicalizePath(path) {
return path.replace(/^\/+/, '').replace(/\?$/, '');
}
/**

@@ -10,3 +14,3 @@ * Specifies the base service URIs used by SDK components.

class ServiceEndpoints {
constructor(streaming, polling, events = ServiceEndpoints.DEFAULT_EVENTS, analyticsEventPath = '/bulk', diagnosticEventPath = '/diagnostic', includeAuthorizationHeader = true) {
constructor(streaming, polling, events = ServiceEndpoints.DEFAULT_EVENTS, analyticsEventPath = '/bulk', diagnosticEventPath = '/diagnostic', includeAuthorizationHeader = true, payloadFilterKey) {
this.streaming = canonicalizeUri(streaming);

@@ -18,2 +22,3 @@ this.polling = canonicalizeUri(polling);

this.includeAuthorizationHeader = includeAuthorizationHeader;
this.payloadFilterKey = payloadFilterKey;
}

@@ -23,2 +28,53 @@ }

exports.default = ServiceEndpoints;
function getWithParams(uri, parameters) {
if (parameters.length === 0) {
return uri;
}
const parts = parameters.map(({ key, value }) => `${key}=${value}`);
return `${uri}?${parts.join('&')}`;
}
/**
* Get the URI for the streaming endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
function getStreamingUri(endpoints, path, parameters) {
const canonicalizedPath = canonicalizePath(path);
const combinedParameters = [...parameters];
if (endpoints.payloadFilterKey) {
combinedParameters.push({ key: 'filter', value: endpoints.payloadFilterKey });
}
return getWithParams(`${endpoints.streaming}/${canonicalizedPath}`, combinedParameters);
}
exports.getStreamingUri = getStreamingUri;
/**
* Get the URI for the polling endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
function getPollingUri(endpoints, path, parameters) {
const canonicalizedPath = canonicalizePath(path);
const combinedParameters = [...parameters];
if (endpoints.payloadFilterKey) {
combinedParameters.push({ key: 'filter', value: endpoints.payloadFilterKey });
}
return getWithParams(`${endpoints.polling}/${canonicalizedPath}`, combinedParameters);
}
exports.getPollingUri = getPollingUri;
/**
* Get the URI for the events endpoint.
*
* @param endpoints The service endpoints.
* @param path The path to the resource, devoid of any query parameters or hrefs.
* @param parameters The query parameters. These query parameters must already have the appropriate encoding applied. This function WILL NOT apply it for you.
*/
function getEventsUri(endpoints, path, parameters) {
const canonicalizedPath = canonicalizePath(path);
return getWithParams(`${endpoints.events}/${canonicalizedPath}`, parameters);
}
exports.getEventsUri = getEventsUri;
//# sourceMappingURL=ServiceEndpoints.js.map

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

is(u) {
return !!u.match(this.expression);
return typeof u === 'string' && !!u.match(this.expression);
}

@@ -92,0 +92,0 @@ }

{
"name": "@launchdarkly/js-sdk-common",
"version": "2.7.0",
"version": "2.8.0",
"type": "commonjs",

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

@@ -15,3 +15,3 @@ # LaunchDarkly SDK JavaScript Common Code

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).

@@ -24,3 +24,3 @@ ## About LaunchDarkly

- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Disable parts of your application to facilitate maintenance, without taking everything offline.

@@ -27,0 +27,0 @@ - LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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