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

@spotify-confidence/openfeature-web-provider

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spotify-confidence/openfeature-web-provider - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

53

build/cjs/ConfidenceWebProvider.js

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

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -21,6 +22,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { ErrorCode, OpenFeatureEventEmitter, ProviderEvents, ProviderStatus, } from '@openfeature/web-sdk';
import equal from 'fast-deep-equal';
import { ApplyManager, Configuration } from '@spotify-confidence/client-http';
export class ConfidenceWebProvider {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfidenceWebProvider = void 0;
const web_sdk_1 = require("@openfeature/web-sdk");
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
const client_http_1 = require("@spotify-confidence/client-http");
class ConfidenceWebProvider {
constructor(client, options) {

@@ -31,7 +37,7 @@ var _a;

};
this.status = ProviderStatus.NOT_READY;
this.status = web_sdk_1.ProviderStatus.NOT_READY;
this.configuration = null;
this.events = new OpenFeatureEventEmitter();
this.events = new web_sdk_1.OpenFeatureEventEmitter();
this.client = client;
this.applyManager = new ApplyManager({ client: this.client, timeout: ((_a = options === null || options === void 0 ? void 0 : options.apply) === null || _a === void 0 ? void 0 : _a.timeout) || 250 });
this.applyManager = new client_http_1.ApplyManager({ client: this.client, timeout: ((_a = options === null || options === void 0 ? void 0 : options.apply) === null || _a === void 0 ? void 0 : _a.timeout) || 250 });
}

@@ -44,7 +50,7 @@ initialize(context) {

});
this.status = ProviderStatus.READY;
this.status = web_sdk_1.ProviderStatus.READY;
return Promise.resolve();
}
catch (e) {
this.status = ProviderStatus.ERROR;
this.status = web_sdk_1.ProviderStatus.ERROR;
throw e;

@@ -56,6 +62,6 @@ }

return __awaiter(this, void 0, void 0, function* () {
if (equal(oldContext, newContext)) {
if ((0, fast_deep_equal_1.default)(oldContext, newContext)) {
return;
}
this.events.emit(ProviderEvents.Stale);
this.events.emit(web_sdk_1.ProviderEvents.Stale);
try {

@@ -66,8 +72,8 @@ this.configuration = yield this.client.resolve(this.convertContext(newContext || {}), {

});
this.status = ProviderStatus.READY;
this.events.emit(ProviderEvents.Ready);
this.status = web_sdk_1.ProviderStatus.READY;
this.events.emit(web_sdk_1.ProviderEvents.Ready);
}
catch (e) {
this.status = ProviderStatus.ERROR;
this.events.emit(ProviderEvents.Error);
this.status = web_sdk_1.ProviderStatus.ERROR;
this.events.emit(web_sdk_1.ProviderEvents.Error);
}

@@ -87,3 +93,3 @@ });

return {
errorCode: ErrorCode.PROVIDER_NOT_READY,
errorCode: web_sdk_1.ErrorCode.PROVIDER_NOT_READY,
value: defaultValue,

@@ -93,3 +99,3 @@ reason: 'ERROR',

}
if (!equal(this.configuration.context, this.convertContext(context))) {
if (!(0, fast_deep_equal_1.default)(this.configuration.context, this.convertContext(context))) {
return {

@@ -106,3 +112,3 @@ value: defaultValue,

return {
errorCode: ErrorCode.FLAG_NOT_FOUND,
errorCode: web_sdk_1.ErrorCode.FLAG_NOT_FOUND,
value: defaultValue,

@@ -112,6 +118,6 @@ reason: 'ERROR',

}
if (flag.reason !== Configuration.ResolveReason.Match) {
if (flag.reason !== client_http_1.Configuration.ResolveReason.Match) {
logger.info('No variant match for flag "%s"', flagName);
return {
errorCode: ErrorCode.GENERAL,
errorCode: web_sdk_1.ErrorCode.GENERAL,
value: defaultValue,

@@ -125,3 +131,3 @@ reason: flag.reason,

return {
errorCode: ErrorCode.PARSE_ERROR,
errorCode: web_sdk_1.ErrorCode.PARSE_ERROR,
value: defaultValue,

@@ -134,3 +140,3 @@ reason: 'ERROR',

return {
errorCode: ErrorCode.TYPE_MISMATCH,
errorCode: web_sdk_1.ErrorCode.TYPE_MISMATCH,
value: defaultValue,

@@ -161,3 +167,3 @@ reason: 'ERROR',

return {
errorCode: ErrorCode.GENERAL,
errorCode: web_sdk_1.ErrorCode.GENERAL,
value: defaultValue,

@@ -181,2 +187,3 @@ reason: 'ERROR',

}
exports.ConfidenceWebProvider = ConfidenceWebProvider;
//# sourceMappingURL=ConfidenceWebProvider.js.map

@@ -1,9 +0,13 @@

import { ConfidenceWebProvider } from './ConfidenceWebProvider';
import { ConfidenceClient } from '@spotify-confidence/client-http';
export function createConfidenceWebProvider(options) {
const confidenceClient = new ConfidenceClient(Object.assign(Object.assign({}, options), { apply: !options.apply }));
return new ConfidenceWebProvider(confidenceClient, {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConfidenceWebProvider = void 0;
const ConfidenceWebProvider_1 = require("./ConfidenceWebProvider");
const client_http_1 = require("@spotify-confidence/client-http");
function createConfidenceWebProvider(options) {
const confidenceClient = new client_http_1.ConfidenceClient(Object.assign(Object.assign({}, options), { apply: !options.apply }));
return new ConfidenceWebProvider_1.ConfidenceWebProvider(confidenceClient, {
apply: options.apply,
});
}
exports.createConfidenceWebProvider = createConfidenceWebProvider;
//# sourceMappingURL=factory.js.map

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

export * from './factory';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./factory"), exports);
//# sourceMappingURL=index.js.map

@@ -6,4 +6,8 @@ # Change Log

## <small>0.0.3 (2023-08-29)</small>
- fix: ensure the target output is esm or cjs ([3990909](https://github.com/spotify/confidence-openfeature-provider-js/commit/3990909))
## <small>0.0.2 (2023-08-29)</small>
- fix: bump openfeature sdks ([0d01b77](https://github.com/spotify/confidence-openfeature-provider-js/commit/0d01b77)), closes [#5](https://github.com/spotify/confidence-openfeature-provider-js/issues/5)
{
"name": "@spotify-confidence/openfeature-web-provider",
"license": "Apache-2.0",
"version": "0.0.2",
"version": "0.0.3",
"module": "build/esm/index.js",

@@ -9,3 +9,3 @@ "main": "build/cjs/index.js",

"dependencies": {
"@spotify-confidence/client-http": "^0.0.1",
"@spotify-confidence/client-http": "^0.0.2",
"fast-deep-equal": "^3.1.3"

@@ -25,3 +25,3 @@ },

},
"gitHead": "99d02572459a332db6926bc10309f165e966431f"
"gitHead": "c377e3d6611011820bd7799860f96aa1f5fcbe0b"
}

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