@unrevealed/node
Advanced tools
Comparing version 0.1.1 to 0.2.0-rc.1
@@ -35,3 +35,4 @@ import { UnrevealedLogger } from './Logger'; | ||
}): Promise<void>; | ||
_track(type: 'user' | 'team', body: unknown): Promise<void>; | ||
private _normalizeKey; | ||
private _track; | ||
private _log; | ||
@@ -38,0 +39,0 @@ private _logError; |
@@ -16,3 +16,5 @@ "use strict"; | ||
exports.UnrevealedClient = void 0; | ||
const crypto_1 = __importDefault(require("crypto")); | ||
const eventsource_1 = __importDefault(require("eventsource")); | ||
const constants_1 = require("./constants"); | ||
const errors_1 = require("./errors"); | ||
@@ -76,2 +78,14 @@ const fetch_1 = require("./fetch"); | ||
} | ||
if (user && | ||
featureAccess.userPercentageAccess > 0 && | ||
this._normalizeKey(`${featureKey}-${user.id}`) < | ||
featureAccess.userPercentageAccess / 100) { | ||
return true; | ||
} | ||
if (team && | ||
featureAccess.teamPercentageAccess > 0 && | ||
this._normalizeKey(`${featureKey}-${team.id}`) < | ||
featureAccess.teamPercentageAccess / 100) { | ||
return true; | ||
} | ||
return false; | ||
@@ -96,2 +110,8 @@ } | ||
} | ||
_normalizeKey(key) { | ||
const hash = crypto_1.default.createHash('sha1'); | ||
hash.update(key); | ||
const hashHex = hash.digest('hex'); | ||
return Number(BigInt(`0x${hashHex}`)) / constants_1.MAX_SHA1; | ||
} | ||
_track(type, body) { | ||
@@ -98,0 +118,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@unrevealed/node", | ||
"version": "0.1.1", | ||
"version": "0.2.0-rc.1", | ||
"description": "Unrevealed SDK for Node", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
22544
24
391