diff --git a/src/AzureAppConfigurationImpl.ts b/src/AzureAppConfigurationImpl.ts index 328d7620..d6565d84 100644 --- a/src/AzureAppConfigurationImpl.ts +++ b/src/AzureAppConfigurationImpl.ts @@ -17,7 +17,6 @@ import { ENABLED_KEY_NAME, METADATA_KEY_NAME, ETAG_KEY_NAME, - FEATURE_FLAG_ID_KEY_NAME, FEATURE_FLAG_REFERENCE_KEY_NAME, ALLOCATION_KEY_NAME, SEED_KEY_NAME, @@ -671,7 +670,6 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration { const metadata = featureFlag[TELEMETRY_KEY_NAME][METADATA_KEY_NAME]; featureFlag[TELEMETRY_KEY_NAME][METADATA_KEY_NAME] = { [ETAG_KEY_NAME]: setting.etag, - [FEATURE_FLAG_ID_KEY_NAME]: await this.#calculateFeatureFlagId(setting), [FEATURE_FLAG_REFERENCE_KEY_NAME]: this.#createFeatureFlagReference(setting), ...(metadata || {}) }; @@ -699,56 +697,6 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration { return featureFlag; } - async #calculateFeatureFlagId(setting: ConfigurationSetting): Promise { - let crypto; - - // Check for browser environment - if (typeof window !== "undefined" && window.crypto && window.crypto.subtle) { - crypto = window.crypto; - } - // Check for Node.js environment - else if (typeof global !== "undefined" && global.crypto) { - crypto = global.crypto; - } - // Fallback to native Node.js crypto module - else { - try { - if (typeof module !== "undefined" && module.exports) { - crypto = require("crypto"); - } - else { - crypto = await import("crypto"); - } - } catch (error) { - console.error("Failed to load the crypto module:", error.message); - throw error; - } - } - - let baseString = `${setting.key}\n`; - if (setting.label && setting.label.trim().length !== 0) { - baseString += `${setting.label}`; - } - - // Convert to UTF-8 encoded bytes - const data = new TextEncoder().encode(baseString); - - // In the browser, use crypto.subtle.digest - if (crypto.subtle) { - const hashBuffer = await crypto.subtle.digest("SHA-256", data); - const hashArray = new Uint8Array(hashBuffer); - // btoa/atob is also available in Node.js 18+ - const base64String = btoa(String.fromCharCode(...hashArray)); - const base64urlString = base64String.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); - return base64urlString; - } - // In Node.js, use the crypto module's hash function - else { - const hash = crypto.createHash("sha256").update(data).digest(); - return hash.toString("base64url"); - } - } - #createFeatureFlagReference(setting: ConfigurationSetting): string { let featureFlagReference = `${this.#clientManager.endpoint.origin}/kv/${setting.key}`; if (setting.label && setting.label.trim().length !== 0) { diff --git a/src/featureManagement/constants.ts b/src/featureManagement/constants.ts index 564bfbd9..eb3282dd 100644 --- a/src/featureManagement/constants.ts +++ b/src/featureManagement/constants.ts @@ -8,7 +8,6 @@ export const TELEMETRY_KEY_NAME = "telemetry"; export const ENABLED_KEY_NAME = "enabled"; export const METADATA_KEY_NAME = "metadata"; export const ETAG_KEY_NAME = "ETag"; -export const FEATURE_FLAG_ID_KEY_NAME = "FeatureFlagId"; export const FEATURE_FLAG_REFERENCE_KEY_NAME = "FeatureFlagReference"; export const ALLOCATION_KEY_NAME = "allocation"; export const DEFAULT_WHEN_ENABLED_KEY_NAME = "default_when_enabled"; diff --git a/test/featureFlag.test.ts b/test/featureFlag.test.ts index 906a15ff..0219cdc2 100644 --- a/test/featureFlag.test.ts +++ b/test/featureFlag.test.ts @@ -327,7 +327,6 @@ describe("feature flags", function () { expect(featureFlag.telemetry).not.undefined; expect(featureFlag.telemetry.enabled).equals(true); expect(featureFlag.telemetry.metadata.ETag).equals("ETag"); - expect(featureFlag.telemetry.metadata.FeatureFlagId).equals("krkOsu9dVV9huwbQDPR6gkV_2T0buWxOCS-nNsj5-6g"); expect(featureFlag.telemetry.metadata.FeatureFlagReference).equals(`${createMockedEndpoint()}/kv/.appconfig.featureflag/Telemetry_1`); featureFlag = featureFlags[1]; @@ -336,7 +335,6 @@ describe("feature flags", function () { expect(featureFlag.telemetry).not.undefined; expect(featureFlag.telemetry.enabled).equals(true); expect(featureFlag.telemetry.metadata.ETag).equals("ETag"); - expect(featureFlag.telemetry.metadata.FeatureFlagId).equals("Rc8Am7HIGDT7HC5Ovs3wKN_aGaaK_Uz1mH2e11gaK0o"); expect(featureFlag.telemetry.metadata.FeatureFlagReference).equals(`${createMockedEndpoint()}/kv/.appconfig.featureflag/Telemetry_2?label=Test`); }); });