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

@openfeature/web-sdk

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openfeature/web-sdk - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

58

dist/cjs/index.js

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

NOOP_PROVIDER: () => NOOP_PROVIDER,
NOOP_TRANSACTION_CONTEXT_PROPAGATOR: () => NOOP_TRANSACTION_CONTEXT_PROPAGATOR,
OpenFeature: () => OpenFeature,

@@ -731,13 +730,2 @@ OpenFeatureAPI: () => OpenFeatureAPI,

// ../shared/src/transaction-context/no-op-transaction-context-propagator.ts
var NoopTransactionContextPropagator = class {
getTransactionContext() {
return {};
}
setTransactionContext(_, callback) {
callback();
}
};
var NOOP_TRANSACTION_CONTEXT_PROPAGATOR = new NoopTransactionContextPropagator();
// ../shared/src/type-guards.ts

@@ -766,3 +754,2 @@ function isString(value) {

this._hooks = [];
this._transactionContextPropagator = NOOP_TRANSACTION_CONTEXT_PROPAGATOR;
this._context = {};

@@ -984,3 +971,3 @@ this._logger = new DefaultLogger();

} catch (err) {
this.handleShutdownError(this._defaultProvider, err);
this.handleShutdownError(provider, err);
}

@@ -991,2 +978,14 @@ }))

}
clearProvidersAndSetDefault(defaultProvider) {
return __async(this, null, function* () {
try {
yield this.close();
} catch (err) {
this._logger.error("Unable to cleanly close providers. Resetting to the default configuration.");
} finally {
this._clientProviders.clear();
this._defaultProvider = defaultProvider;
}
});
}
handleShutdownError(provider, err) {

@@ -996,26 +995,2 @@ this._logger.error(`Error during shutdown of provider ${provider.metadata.name}: ${err}`);

}
setTransactionContextPropagator(transactionContextPropagator) {
const baseMessage = "Invalid TransactionContextPropagator, will not be set: ";
if (typeof (transactionContextPropagator == null ? void 0 : transactionContextPropagator.getTransactionContext) !== "function") {
this._logger.error(`${baseMessage}: getTransactionContext is not a function.`);
} else if (typeof (transactionContextPropagator == null ? void 0 : transactionContextPropagator.setTransactionContext) !== "function") {
this._logger.error(`${baseMessage}: setTransactionContext is not a function.`);
} else {
this._transactionContextPropagator = transactionContextPropagator;
}
return this;
}
setTransactionContext(transactionContext, callback, ...args) {
this._transactionContextPropagator.setTransactionContext(transactionContext, callback, ...args);
}
getTransactionContext() {
try {
return this._transactionContextPropagator.getTransactionContext();
} catch (err) {
const error = err;
this._logger.error(`Error getting transaction context: ${error == null ? void 0 : error.message}, returning empty context.`);
this._logger.error(error == null ? void 0 : error.stack);
return {};
}
}
};

@@ -1119,2 +1094,9 @@

}
/**
* Clears all registered providers and resets the default provider.
* @returns {Promise<void>}
*/
clearProviders() {
return super.clearProvidersAndSetDefault(NOOP_PROVIDER);
}
};

@@ -1121,0 +1103,0 @@ var OpenFeature = OpenFeatureAPI.getInstance();

@@ -691,13 +691,2 @@ var __create = Object.create;

// ../shared/src/transaction-context/no-op-transaction-context-propagator.ts
var NoopTransactionContextPropagator = class {
getTransactionContext() {
return {};
}
setTransactionContext(_, callback) {
callback();
}
};
var NOOP_TRANSACTION_CONTEXT_PROPAGATOR = new NoopTransactionContextPropagator();
// ../shared/src/type-guards.ts

@@ -726,3 +715,2 @@ function isString(value) {

this._hooks = [];
this._transactionContextPropagator = NOOP_TRANSACTION_CONTEXT_PROPAGATOR;
this._context = {};

@@ -944,3 +932,3 @@ this._logger = new DefaultLogger();

} catch (err) {
this.handleShutdownError(this._defaultProvider, err);
this.handleShutdownError(provider, err);
}

@@ -951,2 +939,14 @@ }))

}
clearProvidersAndSetDefault(defaultProvider) {
return __async(this, null, function* () {
try {
yield this.close();
} catch (err) {
this._logger.error("Unable to cleanly close providers. Resetting to the default configuration.");
} finally {
this._clientProviders.clear();
this._defaultProvider = defaultProvider;
}
});
}
handleShutdownError(provider, err) {

@@ -956,26 +956,2 @@ this._logger.error(`Error during shutdown of provider ${provider.metadata.name}: ${err}`);

}
setTransactionContextPropagator(transactionContextPropagator) {
const baseMessage = "Invalid TransactionContextPropagator, will not be set: ";
if (typeof (transactionContextPropagator == null ? void 0 : transactionContextPropagator.getTransactionContext) !== "function") {
this._logger.error(`${baseMessage}: getTransactionContext is not a function.`);
} else if (typeof (transactionContextPropagator == null ? void 0 : transactionContextPropagator.setTransactionContext) !== "function") {
this._logger.error(`${baseMessage}: setTransactionContext is not a function.`);
} else {
this._transactionContextPropagator = transactionContextPropagator;
}
return this;
}
setTransactionContext(transactionContext, callback, ...args) {
this._transactionContextPropagator.setTransactionContext(transactionContext, callback, ...args);
}
getTransactionContext() {
try {
return this._transactionContextPropagator.getTransactionContext();
} catch (err) {
const error = err;
this._logger.error(`Error getting transaction context: ${error == null ? void 0 : error.message}, returning empty context.`);
this._logger.error(error == null ? void 0 : error.stack);
return {};
}
}
};

@@ -1079,2 +1055,9 @@

}
/**
* Clears all registered providers and resets the default provider.
* @returns {Promise<void>}
*/
clearProviders() {
return super.clearProvidersAndSetDefault(NOOP_PROVIDER);
}
};

@@ -1272,3 +1255,2 @@ var OpenFeature = OpenFeatureAPI.getInstance();

NOOP_PROVIDER,
NOOP_TRANSACTION_CONTEXT_PROPAGATOR,
OpenFeature,

@@ -1275,0 +1257,0 @@ OpenFeatureAPI,

@@ -460,54 +460,2 @@ type FlagValueType = 'boolean' | 'string' | 'number' | 'object';

/**
* Transaction context is a mechanism for adding transaction specific context that
* is merged with evaluation context prior to flag evaluation. Examples of potential
* transaction specific context include: a user id, user agent, or request path.
*/
type TransactionContext = EvaluationContext;
interface ManageTransactionContextPropagator<T> extends TransactionContextPropagator {
/**
* EXPERIMENTAL: Transaction context propagation is experimental and subject to change.
* The OpenFeature Enhancement Proposal regarding transaction context can be found [here](https://github.com/open-feature/ofep/pull/32).
*
* Sets a transaction context propagator on this receiver. The transaction context
* propagator is responsible for persisting context for the duration of a single
* transaction.
* @experimental
* @template T The type of the receiver
* @param {TransactionContextPropagator} transactionContextPropagator The context propagator to be used
* @returns {T} The receiver (this object)
*/
setTransactionContextPropagator(transactionContextPropagator: TransactionContextPropagator): T;
}
interface TransactionContextPropagator {
/**
* EXPERIMENTAL: Transaction context propagation is experimental and subject to change.
* The OpenFeature Enhancement Proposal regarding transaction context can be found [here](https://github.com/open-feature/ofep/pull/32).
*
* Returns the currently defined transaction context using the registered transaction
* context propagator.
* @experimental
* @returns {TransactionContext} The current transaction context
*/
getTransactionContext(): TransactionContext;
/**
* EXPERIMENTAL: Transaction context propagation is experimental and subject to change.
* The OpenFeature Enhancement Proposal regarding transaction context can be found [here](https://github.com/open-feature/ofep/pull/32).
*
* Sets the transaction context using the registered transaction context propagator.
* @experimental
* @template R The return value of the callback
* @param {TransactionContext} transactionContext The transaction specific context
* @param {(...args: unknown[]) => R} callback Callback function used to set the transaction context on the stack
* @param {...unknown[]} args Optional arguments that are passed to the callback function
*/
setTransactionContext<R>(transactionContext: TransactionContext, callback: (...args: unknown[]) => R, ...args: unknown[]): void;
}
declare class NoopTransactionContextPropagator implements TransactionContextPropagator {
getTransactionContext(): EvaluationContext;
setTransactionContext(_: EvaluationContext, callback: () => void): void;
}
declare const NOOP_TRANSACTION_CONTEXT_PROPAGATOR: NoopTransactionContextPropagator;
/**
* Checks whether the parameter is a string.

@@ -537,5 +485,4 @@ * @param {unknown} value The value to check

declare abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProvider> implements Eventing, EvaluationLifeCycle<OpenFeatureCommonAPI<P>>, ManageLogger<OpenFeatureCommonAPI<P>>, ManageTransactionContextPropagator<OpenFeatureCommonAPI<P>> {
declare abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProvider> implements Eventing, EvaluationLifeCycle<OpenFeatureCommonAPI<P>>, ManageLogger<OpenFeatureCommonAPI<P>> {
protected _hooks: Hook[];
protected _transactionContextPropagator: TransactionContextPropagator;
protected _context: EvaluationContext;

@@ -625,6 +572,4 @@ protected _logger: Logger;

close(): Promise<void>;
protected clearProvidersAndSetDefault(defaultProvider: P): Promise<void>;
private handleShutdownError;
setTransactionContextPropagator(transactionContextPropagator: TransactionContextPropagator): OpenFeatureCommonAPI<P>;
setTransactionContext<R>(transactionContext: TransactionContext, callback: (...args: unknown[]) => R, ...args: unknown[]): void;
getTransactionContext(): TransactionContext;
}

@@ -834,2 +779,7 @@

getClient(name?: string, version?: string): Client;
/**
* Clears all registered providers and resets the default provider.
* @returns {Promise<void>}
*/
clearProviders(): Promise<void>;
}

@@ -842,2 +792,2 @@ /**

export { BeforeHookContext, Client, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, Features, FlagEvaluationOptions, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, Hook, HookContext, HookHints, InternalEventEmitter, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, ManageTransactionContextPropagator, Metadata, NOOP_PROVIDER, NOOP_TRANSACTION_CONTEXT_PROPAGATOR, OpenFeature, OpenFeatureAPI, OpenFeatureClient, OpenFeatureCommonAPI, OpenFeatureError, OpenFeatureEventEmitter, Paradigm, ParseError, PrimitiveValue, Provider, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TransactionContext, TransactionContextPropagator, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined };
export { BeforeHookContext, Client, ClientMetadata, CommonEventDetails, CommonProvider, ConfigChangeEvent, DefaultLogger, ErrorCode, ErrorEvent, EvaluationContext, EvaluationContextValue, EvaluationDetails, EvaluationLifeCycle, EventContext, EventDetails, EventHandler, EventMetadata, Eventing, Features, FlagEvaluationOptions, FlagMetadata, FlagNotFoundError, FlagValue, FlagValueType, GeneralError, Hook, HookContext, HookHints, InternalEventEmitter, InvalidContextError, JsonArray, JsonObject, JsonValue, LOG_LEVELS, Logger, ManageContext, ManageLogger, Metadata, NOOP_PROVIDER, OpenFeature, OpenFeatureAPI, OpenFeatureClient, OpenFeatureCommonAPI, OpenFeatureError, OpenFeatureEventEmitter, Paradigm, ParseError, PrimitiveValue, Provider, ProviderEvents, ProviderMetadata, ProviderStatus, ReadyEvent, ResolutionDetails, ResolutionReason, SafeLogger, StaleEvent, StandardResolutionReasons, TargetingKeyMissingError, TypeMismatchError, isObject, isString, objectOrUndefined, statusMatchesEvent, stringOrUndefined };
{
"name": "@openfeature/web-sdk",
"version": "0.4.1",
"version": "0.4.2",
"description": "OpenFeature SDK for Web",

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

@@ -19,4 +19,4 @@ <!-- markdownlint-disable MD033 -->

<!-- x-release-please-start-version -->
<a href="https://github.com/open-feature/js-sdk/releases/tag/web-sdk-v0.4.1">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.4.1&color=blue&style=for-the-badge" />
<a href="https://github.com/open-feature/js-sdk/releases/tag/web-sdk-v0.4.2">
<img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.4.2&color=blue&style=for-the-badge" />
</a>

@@ -23,0 +23,0 @@ <!-- x-release-please-end -->

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