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

@eppo/js-client-sdk-common

Package Overview
Dependencies
Maintainers
8
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eppo/js-client-sdk-common - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

6

dist/dto/rule-dto.d.ts

@@ -10,2 +10,8 @@ export declare enum OperatorType {

}
export declare enum OperatorValueType {
PLAIN_STRING = "PLAIN_STRING",
STRING_ARRAY = "STRING_ARRAY",
SEM_VER = "SEM_VER",
NUMERIC = "NUMERIC"
}
export interface Condition {

@@ -12,0 +18,0 @@ operator: OperatorType;

9

dist/dto/rule-dto.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OperatorType = void 0;
exports.OperatorValueType = exports.OperatorType = void 0;
var OperatorType;

@@ -14,2 +14,9 @@ (function (OperatorType) {

})(OperatorType = exports.OperatorType || (exports.OperatorType = {}));
var OperatorValueType;
(function (OperatorValueType) {
OperatorValueType["PLAIN_STRING"] = "PLAIN_STRING";
OperatorValueType["STRING_ARRAY"] = "STRING_ARRAY";
OperatorValueType["SEM_VER"] = "SEM_VER";
OperatorValueType["NUMERIC"] = "NUMERIC";
})(OperatorValueType = exports.OperatorValueType || (exports.OperatorValueType = {}));
//# sourceMappingURL=rule-dto.js.map

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

/* eslint-disable @typescript-eslint/no-explicit-any */
const semver_1 = require("semver");
const rule_dto_1 = require("./dto/rule-dto");

@@ -28,11 +29,24 @@ const obfuscation_1 = require("./obfuscation");

const value = subjectAttributes[condition.attribute];
const conditionValueType = targetingRuleConditionValuesTypesFromValues(condition.value);
if (value != null) {
switch (condition.operator) {
case rule_dto_1.OperatorType.GTE:
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, condition.value, semver_1.gte);
}
return compareNumber(value, condition.value, (a, b) => a >= b);
case rule_dto_1.OperatorType.GT:
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, condition.value, semver_1.gt);
}
return compareNumber(value, condition.value, (a, b) => a > b);
case rule_dto_1.OperatorType.LTE:
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, condition.value, semver_1.lte);
}
return compareNumber(value, condition.value, (a, b) => a <= b);
case rule_dto_1.OperatorType.LT:
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, condition.value, semver_1.lt);
}
return compareNumber(value, condition.value, (a, b) => a < b);

@@ -52,11 +66,24 @@ case rule_dto_1.OperatorType.MATCHES:

const value = hashedSubjectAttributes[condition.attribute];
const conditionValueType = targetingRuleConditionValuesTypesFromValues(value);
if (value != null) {
switch (condition.operator) {
case (0, obfuscation_1.getMD5Hash)(rule_dto_1.OperatorType.GTE):
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, (0, obfuscation_1.decodeBase64)(condition.value), semver_1.gte);
}
return compareNumber(value, Number((0, obfuscation_1.decodeBase64)(condition.value)), (a, b) => a >= b);
case (0, obfuscation_1.getMD5Hash)(rule_dto_1.OperatorType.GT):
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, (0, obfuscation_1.decodeBase64)(condition.value), semver_1.gt);
}
return compareNumber(value, Number((0, obfuscation_1.decodeBase64)(condition.value)), (a, b) => a > b);
case (0, obfuscation_1.getMD5Hash)(rule_dto_1.OperatorType.LTE):
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, (0, obfuscation_1.decodeBase64)(condition.value), semver_1.lte);
}
return compareNumber(value, Number((0, obfuscation_1.decodeBase64)(condition.value)), (a, b) => a <= b);
case (0, obfuscation_1.getMD5Hash)(rule_dto_1.OperatorType.LT):
if (conditionValueType === rule_dto_1.OperatorValueType.SEM_VER) {
return compareSemVer(value, (0, obfuscation_1.decodeBase64)(condition.value), semver_1.lt);
}
return compareNumber(value, Number((0, obfuscation_1.decodeBase64)(condition.value)), (a, b) => a < b);

@@ -87,2 +114,26 @@ case (0, obfuscation_1.getMD5Hash)(rule_dto_1.OperatorType.MATCHES):

}
function compareSemVer(attributeValue, conditionValue, compareFn) {
return (!!(0, semver_1.valid)(attributeValue) &&
!!(0, semver_1.valid)(conditionValue) &&
compareFn(attributeValue, conditionValue));
}
function targetingRuleConditionValuesTypesFromValues(value) {
// Check if input is a number
if (typeof value === 'number') {
return rule_dto_1.OperatorValueType.NUMERIC;
}
if (Array.isArray(value)) {
return rule_dto_1.OperatorValueType.STRING_ARRAY;
}
// Check if input is a string that represents a SemVer
if ((0, semver_1.valid)(value)) {
return rule_dto_1.OperatorValueType.SEM_VER;
}
// Check if input is a string that represents a number
if (!isNaN(Number(value))) {
return rule_dto_1.OperatorValueType.NUMERIC;
}
// If none of the above, it's a general string
return rule_dto_1.OperatorValueType.PLAIN_STRING;
}
//# sourceMappingURL=rule_evaluator.js.map

6

package.json
{
"name": "@eppo/js-client-sdk-common",
"version": "2.1.1",
"version": "2.2.0",
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)",

@@ -44,2 +44,3 @@ "main": "dist/index.js",

"@types/md5": "^2.3.2",
"@types/semver": "^7.5.6",
"@typescript-eslint/eslint-plugin": "^5.13.0",

@@ -69,4 +70,5 @@ "@typescript-eslint/parser": "^5.13.0",

"lru-cache": "^10.0.1",
"md5": "^2.3.0"
"md5": "^2.3.0",
"semver": "^7.5.4"
}
}

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 too big to display

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