From c262c66497e0cc7d8b7ea2d9cc5b85f5d31093e6 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 18 Dec 2023 15:28:26 -0500 Subject: [PATCH] fix: re-add browser support (#706) Signed-off-by: Michael Beemer --- libs/shared/flagd-core/src/lib/feature-flag.ts | 4 ++-- libs/shared/flagd-core/tsconfig.lib.json | 2 +- libs/shared/flagd-core/tsconfig.spec.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/shared/flagd-core/src/lib/feature-flag.ts b/libs/shared/flagd-core/src/lib/feature-flag.ts index 7c5bf6f7f..30a7079cf 100644 --- a/libs/shared/flagd-core/src/lib/feature-flag.ts +++ b/libs/shared/flagd-core/src/lib/feature-flag.ts @@ -1,5 +1,5 @@ import { FlagValue } from '@openfeature/core'; -import { createHash } from 'crypto'; +import { sha1 } from 'object-hash'; /** * Flagd flag configuration structure mapping to schema definition. @@ -26,7 +26,7 @@ export class FeatureFlag { this._defaultVariant = flag['defaultVariant']; this._variants = new Map(Object.entries(flag['variants'])); this._targeting = flag['targeting']; - this._hash = createHash('sha1').update(JSON.stringify(flag)).digest('base64'); + this._hash = sha1(flag); } get hash(): string { diff --git a/libs/shared/flagd-core/tsconfig.lib.json b/libs/shared/flagd-core/tsconfig.lib.json index 4befa7f09..36e88999e 100644 --- a/libs/shared/flagd-core/tsconfig.lib.json +++ b/libs/shared/flagd-core/tsconfig.lib.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../../../dist/out-tsc", "declaration": true, - "types": ["node"] + "types": [] }, "include": ["src/**/*.ts"], "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] diff --git a/libs/shared/flagd-core/tsconfig.spec.json b/libs/shared/flagd-core/tsconfig.spec.json index b2ee74a6b..97775bd24 100644 --- a/libs/shared/flagd-core/tsconfig.spec.json +++ b/libs/shared/flagd-core/tsconfig.spec.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest"] }, "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] }