From 05a53f7d20724dd56518d786d4e56394d699e595 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Tue, 18 Mar 2025 10:22:12 +0100 Subject: [PATCH 1/4] feat: decrease memory usage of rate limiter slightly --- packages/node-sdk/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node-sdk/src/utils.ts b/packages/node-sdk/src/utils.ts index 0fe077aa..15d3ad7a 100644 --- a/packages/node-sdk/src/utils.ts +++ b/packages/node-sdk/src/utils.ts @@ -160,7 +160,7 @@ export function hashObject(obj: Record): string { const hash = createHash("sha1"); updateSha1Hash(hash, obj); - return hash.digest("hex"); + return hash.digest("base64"); } export function once ReturnType>( From fdfa9045db188b89f7632c4090742e0c72407616 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Tue, 18 Mar 2025 11:52:38 +0100 Subject: [PATCH 2/4] fix docs --- packages/node-sdk/README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 1e289289..1044c8c0 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -10,16 +10,13 @@ Install using `yarn` or `npm` with: > `yarn add -s @bucketco/node-sdk` or `npm install -s @bucketco/node-sdk`. -Other supported languages/frameworks are in the -[Supported languages](https://docs.bucket.co/quickstart/supported-languages) -documentation pages. +Other supported languages/frameworks are in the [Supported languages](https://docs.bucket.co/quickstart/supported-languages) documentation pages. -You can also [use the HTTP API directly](https://docs.bucket.co/reference/http-tracking-api) +You can also [use the HTTP API directly](https://docs.bucket.co/api/http-api) ## Basic usage -To get started you need to obtain your secret key from the -[environment settings](https://app.bucket.co/envs/current/settings/app-environments) +To get started you need to obtain your secret key from the [environment settings](https://app.bucket.co/envs/current/settings/app-environments) in Bucket. > [!CAUTION] @@ -138,8 +135,8 @@ await client.flush(); ### Rate Limiting -The SDK includes automatic rate limiting for feature events to prevent overwhelming the API. Rate limiting is applied per -unique combination of feature key and context. The rate limiter window size is configurable: +The SDK includes automatic rate limiting for feature events to prevent overwhelming the API. +Rate limiting is applied per unique combination of feature key and context. The rate limiter window size is configurable: ```typescript const client = new BucketClient({ From 17a7529a3ec796390c9cfd792fde14537debe842 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Tue, 18 Mar 2025 11:58:05 +0100 Subject: [PATCH 3/4] fix tests --- packages/node-sdk/test/utils.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/node-sdk/test/utils.test.ts b/packages/node-sdk/test/utils.test.ts index 43fc90ae..ce91255f 100644 --- a/packages/node-sdk/test/utils.test.ts +++ b/packages/node-sdk/test/utils.test.ts @@ -167,7 +167,7 @@ describe("hashObject", () => { expectedHash.update("name"); expectedHash.update("Alice"); - expect(hash).toBe(expectedHash.digest("hex")); + expect(hash).toBe(expectedHash.digest("base64")); }); it("should hash arrays within objects", () => { @@ -180,7 +180,7 @@ describe("hashObject", () => { expectedHash.update("2"); expectedHash.update("3"); - expect(hash).toBe(expectedHash.digest("hex")); + expect(hash).toBe(expectedHash.digest("base64")); }); }); From 978a92b8483c088d0346ddd11d145ccb7980560b Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Mon, 24 Mar 2025 15:39:43 +0100 Subject: [PATCH 4/4] fix one more test --- packages/node-sdk/test/client.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/node-sdk/test/client.test.ts b/packages/node-sdk/test/client.test.ts index 86c1ddfc..67102e40 100644 --- a/packages/node-sdk/test/client.test.ts +++ b/packages/node-sdk/test/client.test.ts @@ -1596,9 +1596,7 @@ describe("BucketClient", () => { await client.initialize(); client.getFeatures({ user, company, other: otherContext }); - expect(isAllowedSpy).toHaveBeenCalledWith( - "d461e93fe41f6297ab43402d0fc6d63e2444e07d", - ); + expect(isAllowedSpy).toHaveBeenCalledWith("1GHpP+QfYperQ0AtD8bWPiRE4H0="); }); it("should return evaluated features when only user is defined", async () => {