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.2.0-alpha to 2.2.0

dist/api/platform/AutoEnv.d.ts

26

CHANGELOG.md

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

## [2.2.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.1.1...js-sdk-common-v2.2.0) (2024-02-06)
### Features
* Implement common client side support for auto environment attributes. ([#356](https://github.com/launchdarkly/js-core/issues/356)) ([8d80259](https://github.com/launchdarkly/js-core/commit/8d80259f7379827e46bef8bcf8293e3b2d966d25))
* Implement common support for auto environment attributes. ([#355](https://github.com/launchdarkly/js-core/issues/355)) ([9f562e5](https://github.com/launchdarkly/js-core/commit/9f562e51c60ac5bfff835e7f6724904939710148))
* React-native support for auto-env attributes. Only affects react-native package. ([deea99c](https://github.com/launchdarkly/js-core/commit/deea99ca2fbb3865f2ce55a83b2cf12e0ae2db5e))
* Update eslint jest configuration and versions. ([deea99c](https://github.com/launchdarkly/js-core/commit/deea99ca2fbb3865f2ce55a83b2cf12e0ae2db5e))
### Bug Fixes
* Add LDOptions.application name and versionName. ([#358](https://github.com/launchdarkly/js-core/issues/358)) ([cd75210](https://github.com/launchdarkly/js-core/commit/cd75210d20e3d989897ea42276792d934ac8c9c1))
* Add RN SDK offline support through ConnectionMode. ([#361](https://github.com/launchdarkly/js-core/issues/361)) ([d97ce82](https://github.com/launchdarkly/js-core/commit/d97ce82861438a1b79b93799a9d061cdfa1ab027))
* Implement anonymous context processing ([#350](https://github.com/launchdarkly/js-core/issues/350)) ([308100d](https://github.com/launchdarkly/js-core/commit/308100d095259635bfd8beca8a11aa8b43d7f29a))
* RN streamer connection in background and foreground. ([#360](https://github.com/launchdarkly/js-core/issues/360)) ([c69b768](https://github.com/launchdarkly/js-core/commit/c69b7686eed1971288adfbe527b4bf53ba5fe2b7))
## [2.1.1](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.1.0...js-sdk-common-v2.1.1) (2024-01-16)
### Bug Fixes
* remove type modifiers on imports for better TS compatibility ([#346](https://github.com/launchdarkly/js-core/issues/346)) ([3506349](https://github.com/launchdarkly/js-core/commit/3506349512f2288ba9bc2b2bd79d6ed38fd3684c))
* Treat 413 HTTP status as recoverable for events. ([#348](https://github.com/launchdarkly/js-core/issues/348)) ([4a6d4c3](https://github.com/launchdarkly/js-core/commit/4a6d4c3cae25e4993a798d0fd315b51ef607d727))
## [2.1.0](https://github.com/launchdarkly/js-core/compare/js-sdk-common-v2.0.0...js-sdk-common-v2.1.0) (2023-11-14)

@@ -7,0 +33,0 @@

5

dist/api/platform/index.d.ts

@@ -0,3 +1,5 @@

export * from './AutoEnv';
export * from './Crypto';
export * from './Encoding';
export * from './Crypto';
export * from './EventSource';
export * from './Filesystem';

@@ -7,4 +9,3 @@ export * from './Info';

export * from './Requests';
export * from './EventSource';
export * from './Storage';
//# sourceMappingURL=index.d.ts.map

@@ -17,4 +17,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./AutoEnv"), exports);
__exportStar(require("./Crypto"), exports);
__exportStar(require("./Encoding"), exports);
__exportStar(require("./Crypto"), exports);
__exportStar(require("./EventSource"), exports);
__exportStar(require("./Filesystem"), exports);

@@ -24,4 +26,3 @@ __exportStar(require("./Info"), exports);

__exportStar(require("./Requests"), exports);
__exportStar(require("./EventSource"), exports);
__exportStar(require("./Storage"), exports);
//# sourceMappingURL=index.js.map

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

import type { LDApplication, LDDevice } from './AutoEnv';
/**

@@ -31,2 +32,12 @@ * Information about the platform of the SDK and the environment it is executing.

additional?: Record<string, string>;
/**
* Additional information about the executing environment. Should be populated
* when available. Not all platforms will have this data.
*/
ld_application?: LDApplication;
/**
* Device hardware information. Should be populated when available. Not all
* platforms will have this data.
*/
ld_device?: LDDevice;
}

@@ -33,0 +44,0 @@ export interface SdkData {

3

dist/Context.d.ts

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

import { LDContextCommon } from './api/context';
import { LDContext } from './api/context/LDContext';
import type { LDContext, LDContextCommon } from './api';
import AttributeReference from './AttributeReference';

@@ -4,0 +3,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AttributeReference_1 = require("./AttributeReference");
const context_1 = require("./internal/context");
const validators_1 = require("./validators");

@@ -35,32 +36,2 @@ // The general strategy for the context is to transform the passed in context

/**
* Check if a context is a single kind context.
* @param context
* @returns true if the context is a single kind context.
*/
function isSingleKind(context) {
if ('kind' in context) {
return validators_1.TypeValidators.String.is(context.kind) && context.kind !== 'multi';
}
return false;
}
/**
* Check if a context is a multi-kind context.
* @param context
* @returns true if it is a multi-kind context.
*/
function isMultiKind(context) {
if ('kind' in context) {
return validators_1.TypeValidators.String.is(context.kind) && context.kind === 'multi';
}
return false;
}
/**
* Check if a context is a legacy user context.
* @param context
* @returns true if it is a legacy user context.
*/
function isLegacyUser(context) {
return !('kind' in context) || context.kind === null || context.kind === undefined;
}
/**
* Check if the given value is a LDContextCommon.

@@ -282,9 +253,9 @@ * @param kindOrContext

}
if (isSingleKind(context)) {
if ((0, context_1.isSingleKind)(context)) {
return Context.fromSingleKindContext(context);
}
if (isMultiKind(context)) {
if ((0, context_1.isMultiKind)(context)) {
return Context.fromMultiKindContext(context);
}
if (isLegacyUser(context)) {
if ((0, context_1.isLegacyUser)(context)) {
return Context.fromLegacyUser(context);

@@ -291,0 +262,0 @@ }

@@ -18,3 +18,17 @@ export declare class LDFileDataSourceError extends Error {

}
/**
* Check if the HTTP error is recoverable. This will return false if a request
* made with any payload could not recover. If the reason for the failure
* is payload specific, for instance a payload that is too large, then
* it could recover with a different payload.
*/
export declare function isHttpRecoverable(status: number): boolean;
/**
* Returns true if the status could recover for a different payload.
*
* When used with event processing this indicates that we should discard
* the payload, but that a subsequent payload may succeed. Therefore we should
* not stop event processing.
*/
export declare function isHttpLocallyRecoverable(status: number): boolean;
//# sourceMappingURL=errors.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.isHttpRecoverable = exports.LDClientError = exports.LDUnexpectedResponseError = exports.LDStreamingError = exports.LDPollingError = exports.LDFileDataSourceError = void 0;
exports.isHttpLocallyRecoverable = exports.isHttpRecoverable = exports.LDClientError = exports.LDUnexpectedResponseError = exports.LDStreamingError = exports.LDPollingError = exports.LDFileDataSourceError = void 0;
class LDFileDataSourceError extends Error {

@@ -45,2 +45,8 @@ constructor(message) {

exports.LDClientError = LDClientError;
/**
* Check if the HTTP error is recoverable. This will return false if a request
* made with any payload could not recover. If the reason for the failure
* is payload specific, for instance a payload that is too large, then
* it could recover with a different payload.
*/
function isHttpRecoverable(status) {

@@ -53,2 +59,16 @@ if (status >= 400 && status < 500) {

exports.isHttpRecoverable = isHttpRecoverable;
/**
* Returns true if the status could recover for a different payload.
*
* When used with event processing this indicates that we should discard
* the payload, but that a subsequent payload may succeed. Therefore we should
* not stop event processing.
*/
function isHttpLocallyRecoverable(status) {
if (status === 413) {
return true;
}
return isHttpRecoverable(status);
}
exports.isHttpLocallyRecoverable = isHttpLocallyRecoverable;
//# sourceMappingURL=errors.js.map

@@ -14,2 +14,3 @@ import LDContextDeduplicator from '../../api/subsystem/LDContextDeduplicator';

export default class EventProcessor implements LDEventProcessor {
private readonly config;
private readonly contextDeduplicator?;

@@ -32,3 +33,4 @@ private readonly diagnosticsManager?;

private flushUsersTimer;
constructor(config: EventProcessorOptions, clientContext: ClientContext, contextDeduplicator?: LDContextDeduplicator | undefined, diagnosticsManager?: DiagnosticsManager | undefined);
constructor(config: EventProcessorOptions, clientContext: ClientContext, contextDeduplicator?: LDContextDeduplicator | undefined, diagnosticsManager?: DiagnosticsManager | undefined, start?: boolean);
start(): void;
private postDiagnosticEvent;

@@ -35,0 +37,0 @@ close(): void;

@@ -12,4 +12,4 @@ "use strict";

class EventProcessor {
constructor(config, clientContext, contextDeduplicator, diagnosticsManager) {
var _a;
constructor(config, clientContext, contextDeduplicator, diagnosticsManager, start = true) {
this.config = config;
this.contextDeduplicator = contextDeduplicator;

@@ -30,2 +30,8 @@ this.diagnosticsManager = diagnosticsManager;

this.contextFilter = new ContextFilter_1.default(config.allAttributesPrivate, config.privateAttributes.map((ref) => new AttributeReference_1.default(ref)));
if (start) {
this.start();
}
}
start() {
var _a, _b;
if (((_a = this.contextDeduplicator) === null || _a === void 0 ? void 0 : _a.flushInterval) !== undefined) {

@@ -46,5 +52,5 @@ this.flushUsersTimer = setInterval(() => {

}
}, config.flushInterval * 1000);
}, this.config.flushInterval * 1000);
if (this.diagnosticsManager) {
const initEvent = diagnosticsManager.createInitEvent();
const initEvent = this.diagnosticsManager.createInitEvent();
this.postDiagnosticEvent(initEvent);

@@ -56,4 +62,5 @@ this.diagnosticsTimer = setInterval(() => {

this.postDiagnosticEvent(statsEvent);
}, config.diagnosticRecordingInterval * 1000);
}, this.config.diagnosticRecordingInterval * 1000);
}
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug('Started EventProcessor.');
}

@@ -75,3 +82,5 @@ postDiagnosticEvent(event) {

if (this.shutdown) {
throw new LDInvalidSDKKeyError_1.default('Events cannot be posted because SDK key is invalid');
throw new LDInvalidSDKKeyError_1.default('Events cannot be posted because a permanent error has been encountered. ' +
'This is most likely an invalid SDK key. The specific error information ' +
'is logged independently.');
}

@@ -78,0 +87,0 @@ const eventsToFlush = this.queue;

@@ -42,3 +42,12 @@ "use strict";

if (!(0, errors_1.isHttpRecoverable)(status)) {
tryRes.status = subsystem_1.LDDeliveryStatus.FailedAndMustShutDown;
// If the HTTP request isn't recoverable. Meaning if we made the same request it
// would not recover, then we check if a different request could recover.
// If a different request could not recover, then we shutdown. If a different request could
// recover, then we just don't retry this specific request.
if (!(0, errors_1.isHttpLocallyRecoverable)(status)) {
tryRes.status = subsystem_1.LDDeliveryStatus.FailedAndMustShutDown;
}
else {
tryRes.status = subsystem_1.LDDeliveryStatus.Failed;
}
tryRes.error = error;

@@ -45,0 +54,0 @@ return tryRes;

@@ -5,2 +5,3 @@ export * from './diagnostics';

export * from './stream';
export * from './context';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./stream"), exports);
__exportStar(require("./context"), exports);
//# sourceMappingURL=index.js.map
import StreamingProcessor from './StreamingProcessor';
import { type StreamingErrorHandler } from './types';
export { StreamingProcessor, type StreamingErrorHandler };
import type { StreamingErrorHandler } from './types';
export { StreamingProcessor };
export type { StreamingErrorHandler };
//# sourceMappingURL=index.d.ts.map

@@ -11,2 +11,4 @@ import { LDLogger } from '../api';

version?: string;
name?: string;
versionName?: string;
};

@@ -13,0 +15,0 @@ logger?: LDLogger;

@@ -26,23 +26,21 @@ "use strict";

constructor(options) {
var _a, _b;
const tags = {};
const application = options === null || options === void 0 ? void 0 : options.application;
if ((application === null || application === void 0 ? void 0 : application.id) !== null && (application === null || application === void 0 ? void 0 : application.id) !== undefined) {
const { valid, message } = tagValidator.is(application.id, 'application.id');
if (!valid) {
(_a = options.logger) === null || _a === void 0 ? void 0 : _a.warn(message);
}
else {
tags['application-id'] = [application.id];
}
const logger = options === null || options === void 0 ? void 0 : options.logger;
if (application) {
Object.entries(application).forEach(([key, value]) => {
if (value !== null && value !== undefined) {
const { valid, message } = tagValidator.is(value, `application.${key}`);
if (!valid) {
logger === null || logger === void 0 ? void 0 : logger.warn(message);
}
else if (key === 'versionName') {
tags[`application-version-name`] = [value];
}
else {
tags[`application-${key}`] = [value];
}
}
});
}
if ((application === null || application === void 0 ? void 0 : application.version) !== null && (application === null || application === void 0 ? void 0 : application.version) !== undefined) {
const { valid, message } = tagValidator.is(application.version, 'application.version');
if (!valid) {
(_b = options.logger) === null || _b === void 0 ? void 0 : _b.warn(message);
}
else {
tags['application-version'] = [application.version];
}
}
const tagKeys = Object.keys(tags);

@@ -49,0 +47,0 @@ if (tagKeys.length) {

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

export default function clone<T>(obj: any): T;
export default function clone<T>(obj: any): any;
//# sourceMappingURL=clone.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function clone(obj) {
if (obj === undefined || obj === null) {
return obj;
}
return JSON.parse(JSON.stringify(obj));

@@ -5,0 +8,0 @@ }

import clone from './clone';
import { secondsToMillis } from './date';
import debounce from './debounce';
import deepCompact from './deepCompact';
import fastDeepEqual from './fast-deep-equal';

@@ -8,3 +10,3 @@ import { base64UrlEncode, defaultHeaders, httpErrorMessage, LDHeaders, shouldRetry } from './http';

import { VoidFunction } from './VoidFunction';
export { base64UrlEncode, clone, defaultHeaders, fastDeepEqual, httpErrorMessage, noop, LDHeaders, shouldRetry, secondsToMillis, sleep, VoidFunction, };
export { base64UrlEncode, clone, debounce, deepCompact, defaultHeaders, fastDeepEqual, httpErrorMessage, noop, LDHeaders, shouldRetry, secondsToMillis, sleep, VoidFunction, };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sleep = exports.secondsToMillis = exports.shouldRetry = exports.noop = exports.httpErrorMessage = exports.fastDeepEqual = exports.defaultHeaders = exports.clone = exports.base64UrlEncode = void 0;
exports.sleep = exports.secondsToMillis = exports.shouldRetry = exports.noop = exports.httpErrorMessage = exports.fastDeepEqual = exports.defaultHeaders = exports.deepCompact = exports.debounce = exports.clone = exports.base64UrlEncode = void 0;
const clone_1 = require("./clone");

@@ -8,2 +8,6 @@ exports.clone = clone_1.default;

Object.defineProperty(exports, "secondsToMillis", { enumerable: true, get: function () { return date_1.secondsToMillis; } });
const debounce_1 = require("./debounce");
exports.debounce = debounce_1.default;
const deepCompact_1 = require("./deepCompact");
exports.deepCompact = deepCompact_1.default;
const fast_deep_equal_1 = require("./fast-deep-equal");

@@ -10,0 +14,0 @@ exports.fastDeepEqual = fast_deep_equal_1.default;

{
"name": "@launchdarkly/js-sdk-common",
"version": "2.2.0-alpha",
"version": "2.2.0",
"type": "commonjs",

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

"lint": "npx eslint . --ext .ts",
"lint:fix": "yarn run lint --fix"
"lint:fix": "yarn run lint --fix",
"prettier": "prettier --write 'src/*.@(js|ts|tsx|json)'",
"check": "yarn && yarn prettier && yarn lint && tsc && yarn test"
},

@@ -35,4 +37,4 @@ "license": "Apache-2.0",

"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.45.0",

@@ -43,2 +45,3 @@ "eslint-config-airbnb-base": "^15.0.0",

"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.0.0",

@@ -45,0 +48,0 @@ "jest": "^29.5.0",

@@ -15,2 +15,6 @@ # LaunchDarkly SDK JavaScript Common Code

## Verifying SDK build provenance with the SLSA framework
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).
## About LaunchDarkly

@@ -17,0 +21,0 @@

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

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

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