UNPKG

@ledgerhq/live-common

Version:
35 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFeatureFlagsForLiveApp = getFeatureFlagsForLiveApp; function getFeatureFlagsForLiveApp({ requestedFeatureFlagIds, manifest, getFeature, }) { // Check if wildcard is present - if so, allow all feature flags const manifestFeatureFlags = manifest.featureFlags; // Filter requested IDs to only allowed ones (unless wildcard is present) let featureFlagIdsToFetch; if (manifestFeatureFlags === "*") { // Wildcard: allow all requested feature flags featureFlagIdsToFetch = requestedFeatureFlagIds; } else if (Array.isArray(manifestFeatureFlags)) { // Array: filter to only allowed feature flags featureFlagIdsToFetch = requestedFeatureFlagIds.filter(id => manifestFeatureFlags.includes(id)); } else { // No feature flags defined featureFlagIdsToFetch = []; } // Fetch each feature flag const features = {}; for (const featureFlagId of featureFlagIdsToFetch) { try { const feature = getFeature(featureFlagId); features[featureFlagId] = feature; } catch (_error) { // If feature doesn't exist or error occurs, set to null features[featureFlagId] = null; } } return features; } //# sourceMappingURL=resolver.js.map