From ae657052fa327299b95efd6049d1636562462cd5 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 06:10:43 +0000 Subject: [PATCH 1/6] fix(node-sdk): exclude secret flags from v2 bootstrap --- .changeset/bootstrap-public-flags-only.md | 7 + packages/node-sdk/README.md | 6 +- packages/node-sdk/src/client.ts | 31 +- packages/node-sdk/src/flag-definitions.ts | 3 + packages/node-sdk/src/types.ts | 8 +- .../node-sdk/test/bootstrap-secrecy.test.ts | 320 ++++++++++++++++++ packages/node-sdk/test/fixtures.ts | 1 + packages/react-native-sdk/test/usage.test.tsx | 1 + 8 files changed, 371 insertions(+), 6 deletions(-) create mode 100644 .changeset/bootstrap-public-flags-only.md create mode 100644 packages/node-sdk/test/bootstrap-secrecy.test.ts diff --git a/.changeset/bootstrap-public-flags-only.md b/.changeset/bootstrap-public-flags-only.md new file mode 100644 index 00000000..69568244 --- /dev/null +++ b/.changeset/bootstrap-public-flags-only.md @@ -0,0 +1,7 @@ +--- +"@reflag/node-sdk": patch +--- + +Restrict `getFlagsForBootstrap()` (including bound clients) to flags explicitly marked public in the accepted definitions. Keep secret flags available for server evaluation and public-flag dependencies, but exclude their results and diagnostic source identifiers from bootstrap. + +Deploy the API visibility marker before upgrading the SDK and refresh saved fallback snapshots. Definitions without explicit public visibility, including older responses/snapshots, value-only fallbacks, and overrides for unknown keys, no longer authorize client exports. Overrides for known public flags remain supported. Bootstrap still includes the supplied context; pass only browser-safe attributes. diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 6d3cde0a..4a15ee77 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -184,7 +184,11 @@ const bootstrap = reflag.getFlagsForBootstrap(context); // flagStateVersion } ``` -Bootstrap uses batch evaluation and preserves selection metadata and raw context. It does **not** register browser checks. Local overrides/value-only fallbacks carry their values without fabricated authored-selection metadata. +Bootstrap exports only flags explicitly marked public (`secret: false`) in the accepted definitions. Secret flags remain available to server reads and dependency evaluation, but their results and diagnostic source identifiers are not exported. Public selections retain their selection metadata. Bootstrap does **not** register browser checks. + +Deploy the API visibility marker before upgrading this SDK, and refresh persisted fallback snapshots. Older responses/snapshots without visibility still support server evaluation, but cannot authorize bootstrap exports. Value-only fallbacks and overrides for unknown or secret keys are excluded; overrides for known public flags remain exportable without fabricated authored-selection metadata. + +The context is still included in bootstrap data. Pass only browser-safe context attributes; do not embed credentials or server-only attributes. **This is a v2 bootstrap contract, not the existing v1 Browser/React/Vue bootstrap shape.** Those consumers require a coordinated migration before accepting this state. Likewise, the current OpenFeature provider deliberately remains on published Node SDK v1 until its separate migration. diff --git a/packages/node-sdk/src/client.ts b/packages/node-sdk/src/client.ts index 52062c09..a7eed099 100644 --- a/packages/node-sdk/src/client.ts +++ b/packages/node-sdk/src/client.ts @@ -507,19 +507,43 @@ export class ReflagClient { ]), ) as TypedFlags; } - /** Serialization is not a read by the browser; it must not emit check events. */ + /** + * Export only explicitly public flags, without registering checks. + * Secret dependencies still participate in server evaluation, but their results + * and diagnostic source identifiers are not exported. Definitions without + * visibility (including value-only fallbacks/unknown overrides) are excluded. + * Context is included unchanged; pass only browser-safe context attributes. + */ public getFlagsForBootstrap(options: ContextWithTracking): BootstrappedFlags { - const { flags, flagStateVersion } = this.evaluate( + const { flags, flagStateVersion, collection } = this.evaluate( options, undefined, false, ); + const publicKeys = new Set( + collection?.flags + .filter((flag) => flag.secret === false) + .map((flag) => flag.key), + ); + const publicFlags = Object.fromEntries( + Object.entries(flags) + .filter(([key]) => publicKeys.has(key)) + .map(([key, result]) => [ + key, + { + ...result, + // Match publishable-key HTTP evaluation: dependency origins can name + // private flags or segments, even when the requested root is public. + errors: result.errors.map(({ source: _source, ...error }) => error), + }, + ]), + ); return { protocolVersion: 2, context: JSON.parse( canonicalJSONStringify(contextOnly(options)), ) as Context, - flags: structuredClone(flags), + flags: structuredClone(publicFlags), ...(flagStateVersion === undefined ? {} : { flagStateVersion }), }; } @@ -580,6 +604,7 @@ export class ReflagClient { return { flags, flagStateVersion, + collection, evaluatedBeforeInitialization: !this.initialized, }; } diff --git a/packages/node-sdk/src/flag-definitions.ts b/packages/node-sdk/src/flag-definitions.ts index 8989b51c..caf022f4 100644 --- a/packages/node-sdk/src/flag-definitions.ts +++ b/packages/node-sdk/src/flag-definitions.ts @@ -187,11 +187,14 @@ export function prepareFlagCollection( ({ key, sourceVersionId, + secret, variants, rules, }: FlagCollection["flags"][number]) => ({ key, sourceVersionId, + // Older responses/snapshots and malformed visibility cannot authorize export. + secret: secret !== false, variants, rules, }), diff --git a/packages/node-sdk/src/types.ts b/packages/node-sdk/src/types.ts index 1c79e7e0..548b0bd2 100644 --- a/packages/node-sdk/src/types.ts +++ b/packages/node-sdk/src/types.ts @@ -76,8 +76,12 @@ export type FlagOverrides = Partial< >; export type FlagOverridesFn = (context: Context) => FlagOverrides; -export type FlagDefinition = CompiledFlag; -export type FlagCollection = CompiledCollection & { +export type FlagDefinition = CompiledFlag & { + /** Only explicit false authorizes export to a browser bootstrap payload. */ + secret?: boolean; +}; +export type FlagCollection = { + flags: FlagDefinition[]; segments: NonNullable; }; export type FlagsAPIResponse = FlagCollection & { diff --git a/packages/node-sdk/test/bootstrap-secrecy.test.ts b/packages/node-sdk/test/bootstrap-secrecy.test.ts new file mode 100644 index 00000000..0ccdb251 --- /dev/null +++ b/packages/node-sdk/test/bootstrap-secrecy.test.ts @@ -0,0 +1,320 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import { + fallbackProviders, + ReflagClient, + type ClientOptions, + type FlagsFallbackSnapshot, + type HttpClient, + type HttpClientResponse, +} from "../src"; +import { definition, snapshot } from "./fixtures"; + +const clients: ReflagClient[] = []; +const context = { company: { id: "acme" }, enableTracking: false }; +const privatePayload = "SERVER_ONLY_PAYLOAD"; + +function privateGraph() { + const dependency = { + ...definition("private-dependency", privatePayload, "off"), + secret: true, + }; + dependency.variants.on = privatePayload; + dependency.rules.unshift( + { + id: "private-missing-context", + filter: { + type: "context", + field: "user.plan", + operator: "IS", + values: ["pro"], + }, + result: { type: "variant", variantKey: "on" }, + }, + { + id: "private-grant", + filter: { + type: "context", + field: "company.id", + operator: "IS", + values: ["acme"], + }, + result: { type: "variant", variantKey: "on" }, + }, + ); + const root = { ...definition("public", false, "off"), secret: false }; + root.variants.on = true; + root.rules.unshift({ + id: "public-target", + filter: { type: "segment", key: "private-segment" }, + result: { type: "variant", variantKey: "on" }, + }); + return snapshot( + [root, dependency], + [ + { + key: "private-segment", + filter: { type: "flag", key: dependency.key, variantKey: "on" }, + }, + ], + ); +} + +function harness(body: unknown = privateGraph(), options: ClientOptions = {}) { + const state: { response: HttpClientResponse } = { + response: { + status: 200, + ok: true, + body: { success: true, ...(body as object) }, + etag: '"initial"', + }, + }; + const post = vi.fn(async () => ({ status: 200, ok: true, body: {} })); + const get = vi.fn(async () => state.response); + const client = new ReflagClient({ + secretKey: "syntheticSecretKeyWithMoreThan22Chars", + offline: false, + flagsSyncMode: "in-request", + flagsFetchRetries: 0, + logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }, + batchOptions: { intervalMs: 1e9, flushOnExit: false }, + httpClient: { get, post } as unknown as HttpClient, + ...options, + }); + clients.push(client); + return { client, state, get, post }; +} + +async function refresh(client: ReflagClient) { + await vi.advanceTimersByTimeAsync(1001); + await client.refreshFlags(); +} + +beforeEach(() => vi.useFakeTimers()); +afterEach(() => { + for (const client of clients.splice(0)) client.destroy(); + vi.useRealTimers(); +}); + +describe("bootstrap visibility boundary", () => { + it.each(["direct", "bound"])( + "exports only public roots through %s bootstrap, retaining private dependencies on the server", + async (mode) => { + const h = harness(); + await h.client.initialize(); + const bootstrap = + mode === "direct" + ? h.client.getFlagsForBootstrap(context) + : h.client.bindClient(context).getFlagsForBootstrap(); + expect(Object.keys(bootstrap.flags)).toEqual(["public"]); + expect(bootstrap).toMatchObject({ + protocolVersion: 2, + flagStateVersion: 1, + context: { company: { id: "acme" } }, + flags: { + public: { + value: true, + resolved: true, + variantKey: "on", + sourceVersionId: "version:public", + matchedRuleId: "public-target", + ruleResults: [{ ruleId: "public-target", matched: true }], + errors: [{ code: "MISSING_CONTEXT_FIELD", field: "user.plan" }], + }, + }, + }); + const serialized = JSON.stringify(bootstrap); + for (const privateData of [ + privatePayload, + "private-dependency", + "private-segment", + ]) + expect(serialized).not.toContain(privateData); + expect(bootstrap.flags.public!.errors[0]).not.toHaveProperty("source"); + await h.client.flush(); + expect(h.post).not.toHaveBeenCalled(); + expect(h.client.getFlags(context)).toEqual({ + public: true, + "private-dependency": privatePayload, + }); + expect(h.client.getFlag(context, "private-dependency", null)).toBe( + privatePayload, + ); + expect(h.client.getFlagDefinitions().flags).toContainEqual( + expect.objectContaining({ key: "private-dependency", secret: true }), + ); + bootstrap.flags.public!.value = false; + bootstrap.flags.public!.errors.length = 0; + expect(h.client.getFlagsForBootstrap(context).flags.public).toMatchObject( + { + value: true, + errors: [{ code: "MISSING_CONTEXT_FIELD" }], + }, + ); + }, + ); + + it.each([undefined, null, "false", 0, {}, true])( + "does not treat visibility %j as an explicit public declaration", + async (secret) => { + const flag = definition("unknown", privatePayload); + Reflect.deleteProperty(flag, "secret"); + if (secret !== undefined) Reflect.set(flag, "secret", secret); + const h = harness( + snapshot([{ ...definition("public", false), secret: false }, flag]), + ); + await h.client.initialize(); + expect(h.client.getFlag(context, "unknown", null)).toBe(privatePayload); + expect(Object.keys(h.client.getFlagsForBootstrap(context).flags)).toEqual( + ["public"], + ); + }, + ); + + it("does not let base or temporary overrides publish secret or unknown keys", async () => { + const h = harness(privateGraph(), { + flagOverrides: () => ({ + public: null, + "private-dependency": "PRIVATE_OVERRIDE", + unknown: "UNKNOWN_OVERRIDE", + }), + }); + await h.client.initialize(); + const pop = h.client.pushFlagOverrides({ + public: { nested: [false] }, + extra: "EXTRA_OVERRIDE", + }); + const bootstrap = h.client.getFlagsForBootstrap(context); + expect(bootstrap.flags).toEqual({ + public: { + flagKey: "public", + value: { nested: [false] }, + resolved: false, + ruleResults: [], + errors: [], + }, + }); + pop(); + expect( + h.client.getFlagsForBootstrap(context).flags.public!.value, + ).toBeNull(); + expect(h.client.getFlags(context)).toMatchObject({ + "private-dependency": "PRIVATE_OVERRIDE", + unknown: "UNKNOWN_OVERRIDE", + }); + }); + + it.each(["offline", "unavailable", "static"])( + "does not publish value-only %s fallbacks or overrides without visibility", + async (mode) => { + const h = harness(undefined, { + offline: mode === "offline", + fallbackFlags: { fallback: privatePayload }, + flagOverrides: { override: privatePayload }, + ...(mode === "static" + ? { + flagsFallbackProvider: fallbackProviders.static({ + flags: { fallback: privatePayload }, + }), + } + : {}), + }); + h.state.response = { status: 503, ok: false, body: undefined }; + expect(h.client.getFlagsForBootstrap(context).flags).toEqual({}); + await h.client.initialize(); + expect(h.client.getFlags(context)).toMatchObject({ + fallback: privatePayload, + override: privatePayload, + }); + expect(h.client.getFlagsForBootstrap(context).flags).toEqual({}); + }, + ); + + it("keeps visibility with its snapshot through 304s, visibility-only refreshes and stale responses", async () => { + const h = harness(); + await h.client.initialize(); + expect(Object.keys(h.client.getFlagsForBootstrap(context).flags)).toEqual([ + "public", + ]); + h.state.response = { status: 304, ok: false, body: undefined }; + await refresh(h.client); + expect(Object.keys(h.client.getFlagsForBootstrap(context).flags)).toEqual([ + "public", + ]); + const changed = privateGraph(); + Reflect.set(changed.flags[0]!, "secret", true); + // Visibility is transport metadata: even the same authored versions/values must replace it. + h.state.response = { + status: 200, + ok: true, + body: { success: true, ...changed }, + etag: '"visibility-only"', + }; + await refresh(h.client); + expect(h.client.getFlagsForBootstrap(context).flags).toEqual({}); + h.state.response.body = { success: true, ...changed, flagStateVersion: 2 }; + await refresh(h.client); + h.state.response = { + status: 200, + ok: true, + body: { success: true, ...privateGraph() }, + }; + await refresh(h.client); + expect(h.client.getFlagsForBootstrap(context)).toMatchObject({ + flagStateVersion: 2, + flags: {}, + }); + h.state.response = { status: 304, ok: false, body: undefined }; + await refresh(h.client); + expect(h.client.getFlagsForBootstrap(context).flags).toEqual({}); + }); + + it("owns visibility independently of HTTP responses, definition copies and bootstrap results", async () => { + const response = privateGraph(); + const h = harness(response); + await h.client.initialize(); + Reflect.set(response.flags[1]!, "secret", false); + const definitions = h.client.getFlagDefinitions(); + Reflect.set(definitions.flags[1]!, "secret", false); + expect(Object.keys(h.client.getFlagsForBootstrap(context).flags)).toEqual([ + "public", + ]); + expect(h.client.getFlagDefinitions().flags[0]).toHaveProperty( + "secret", + false, + ); + }); + + it("persists visibility and restores safe bootstrap without pruning the private evaluation graph", async () => { + let saved: FlagsFallbackSnapshot | undefined; + const provider = { + load: vi.fn(async () => saved), + save: vi.fn(async (_context: unknown, next: FlagsFallbackSnapshot) => { + saved = JSON.parse(JSON.stringify(next)) as FlagsFallbackSnapshot; + }), + }; + const live = harness(privateGraph(), { flagsFallbackProvider: provider }); + await live.client.initialize(); + await live.client.flush(); + expect(saved!.flags).toEqual(privateGraph().flags); + const fallback = harness(undefined, { flagsFallbackProvider: provider }); + fallback.state.response = { status: 503, ok: false, body: undefined }; + await fallback.client.initialize(); + expect( + Object.keys(fallback.client.getFlagsForBootstrap(context).flags), + ).toEqual(["public"]); + expect( + fallback.client.getFlagsForBootstrap(context).flags.public!.value, + ).toBe(true); + expect(fallback.client.getFlag(context, "private-dependency", null)).toBe( + privatePayload, + ); + // Older snapshots remain useful for server evaluation, but cannot authorize client exports. + for (const flag of saved!.flags) Reflect.deleteProperty(flag, "secret"); + const legacy = harness(undefined, { flagsFallbackProvider: provider }); + legacy.state.response = { status: 503, ok: false, body: undefined }; + await legacy.client.initialize(); + expect(legacy.client.getFlag(context, "public")).toBe(true); + expect(legacy.client.getFlagsForBootstrap(context).flags).toEqual({}); + }); +}); diff --git a/packages/node-sdk/test/fixtures.ts b/packages/node-sdk/test/fixtures.ts index c290aaf0..cf40b356 100644 --- a/packages/node-sdk/test/fixtures.ts +++ b/packages/node-sdk/test/fixtures.ts @@ -13,6 +13,7 @@ export function definition( return { key, sourceVersionId: `version:${key}`, + secret: false, variants: { [variantKey]: value }, rules: [ { diff --git a/packages/react-native-sdk/test/usage.test.tsx b/packages/react-native-sdk/test/usage.test.tsx index f6708613..4ea44cc0 100644 --- a/packages/react-native-sdk/test/usage.test.tsx +++ b/packages/react-native-sdk/test/usage.test.tsx @@ -322,6 +322,7 @@ describe("React Native v2", () => { flags: Object.entries(values).map(([key, value]) => ({ key, sourceVersionId: `source:${key}`, + secret: false, variants: { chosen: value }, rules: [ { From e21903e70c1f16cd50d7c63caf21acaec63d22f0 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 06:37:55 +0000 Subject: [PATCH 2/6] docs: use plain English for the bootstrap fix --- .changeset/bootstrap-public-flags-only.md | 6 ++++-- packages/node-sdk/README.md | 6 +++--- packages/node-sdk/src/client.ts | 9 ++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.changeset/bootstrap-public-flags-only.md b/.changeset/bootstrap-public-flags-only.md index 69568244..77bb91aa 100644 --- a/.changeset/bootstrap-public-flags-only.md +++ b/.changeset/bootstrap-public-flags-only.md @@ -2,6 +2,8 @@ "@reflag/node-sdk": patch --- -Restrict `getFlagsForBootstrap()` (including bound clients) to flags explicitly marked public in the accepted definitions. Keep secret flags available for server evaluation and public-flag dependencies, but exclude their results and diagnostic source identifiers from bootstrap. +Keep secret flags out of browser data returned by `getFlagsForBootstrap()`, including bound clients. Server-side reads still work, including public flags that depend on secret flags. Remove dependency names from error details sent to the browser. -Deploy the API visibility marker before upgrading the SDK and refresh saved fallback snapshots. Definitions without explicit public visibility, including older responses/snapshots, value-only fallbacks, and overrides for unknown keys, no longer authorize client exports. Overrides for known public flags remain supported. Bootstrap still includes the supplied context; pass only browser-safe attributes. +Deploy the API change that adds `secret` to flag definitions before upgrading, then refresh saved fallback snapshots. Only flags marked `secret: false` are included. Older definitions without this field, fallback values without definitions, and overrides for unknown or secret flags are left out. Overrides for known public flags still work. + +The browser can read the context you pass in. Leave out secrets and server-only attributes. diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 4a15ee77..d288ac45 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -184,11 +184,11 @@ const bootstrap = reflag.getFlagsForBootstrap(context); // flagStateVersion } ``` -Bootstrap exports only flags explicitly marked public (`secret: false`) in the accepted definitions. Secret flags remain available to server reads and dependency evaluation, but their results and diagnostic source identifiers are not exported. Public selections retain their selection metadata. Bootstrap does **not** register browser checks. +`getFlagsForBootstrap()` includes only public flags (`secret: false`). Secret flags stay on the server, where they can still be read or used by public flags. Error details sent to the browser omit dependency names. Creating bootstrap data does **not** record flag checks. -Deploy the API visibility marker before upgrading this SDK, and refresh persisted fallback snapshots. Older responses/snapshots without visibility still support server evaluation, but cannot authorize bootstrap exports. Value-only fallbacks and overrides for unknown or secret keys are excluded; overrides for known public flags remain exportable without fabricated authored-selection metadata. +Deploy the API change that adds `secret` to flag definitions before upgrading this SDK, then refresh saved fallback snapshots. Older definitions without this field still work on the server, but are not included in browser data. Fallback values without definitions and overrides for unknown or secret flags are also left out. Overrides for known public flags still work. -The context is still included in bootstrap data. Pass only browser-safe context attributes; do not embed credentials or server-only attributes. +The browser can read the context you pass in. Leave out secrets and server-only attributes. **This is a v2 bootstrap contract, not the existing v1 Browser/React/Vue bootstrap shape.** Those consumers require a coordinated migration before accepting this state. Likewise, the current OpenFeature provider deliberately remains on published Node SDK v1 until its separate migration. diff --git a/packages/node-sdk/src/client.ts b/packages/node-sdk/src/client.ts index a7eed099..54ecec74 100644 --- a/packages/node-sdk/src/client.ts +++ b/packages/node-sdk/src/client.ts @@ -508,11 +508,10 @@ export class ReflagClient { ) as TypedFlags; } /** - * Export only explicitly public flags, without registering checks. - * Secret dependencies still participate in server evaluation, but their results - * and diagnostic source identifiers are not exported. Definitions without - * visibility (including value-only fallbacks/unknown overrides) are excluded. - * Context is included unchanged; pass only browser-safe context attributes. + * Get public flag data for a browser without recording flag checks. + * Secret flags can still be read on the server and used by public flags. + * Flags without `secret: false` are left out. Dependency names are removed + * from error details. Include only browser-safe attributes in the context. */ public getFlagsForBootstrap(options: ContextWithTracking): BootstrappedFlags { const { flags, flagStateVersion, collection } = this.evaluate( From 497c95661536374fd58e9f73f55d93a4a0550945 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 06:43:38 +0000 Subject: [PATCH 3/6] docs: correct SDK upgrade instructions --- .changeset/bootstrap-public-flags-only.md | 2 +- packages/node-sdk/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/bootstrap-public-flags-only.md b/.changeset/bootstrap-public-flags-only.md index 77bb91aa..791b91fc 100644 --- a/.changeset/bootstrap-public-flags-only.md +++ b/.changeset/bootstrap-public-flags-only.md @@ -4,6 +4,6 @@ Keep secret flags out of browser data returned by `getFlagsForBootstrap()`, including bound clients. Server-side reads still work, including public flags that depend on secret flags. Remove dependency names from error details sent to the browser. -Deploy the API change that adds `secret` to flag definitions before upgrading, then refresh saved fallback snapshots. Only flags marked `secret: false` are included. Older definitions without this field, fallback values without definitions, and overrides for unknown or secret flags are left out. Overrides for known public flags still work. +After upgrading, fetch current flag definitions from Reflag to refresh saved fallback snapshots. Only flags marked `secret: false` are included. Older definitions without this field, fallback values without definitions, and overrides for unknown or secret flags are left out. Overrides for known public flags still work. The browser can read the context you pass in. Leave out secrets and server-only attributes. diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index d288ac45..56384572 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -186,7 +186,7 @@ const bootstrap = reflag.getFlagsForBootstrap(context); `getFlagsForBootstrap()` includes only public flags (`secret: false`). Secret flags stay on the server, where they can still be read or used by public flags. Error details sent to the browser omit dependency names. Creating bootstrap data does **not** record flag checks. -Deploy the API change that adds `secret` to flag definitions before upgrading this SDK, then refresh saved fallback snapshots. Older definitions without this field still work on the server, but are not included in browser data. Fallback values without definitions and overrides for unknown or secret flags are also left out. Overrides for known public flags still work. +After upgrading, fetch current flag definitions from Reflag to refresh saved fallback snapshots. Older definitions without this field still work on the server, but are not included in browser data. Fallback values without definitions and overrides for unknown or secret flags are also left out. Overrides for known public flags still work. The browser can read the context you pass in. Leave out secrets and server-only attributes. From 84b79bb939aa43bed458e6237e9e47f35c0d7c31 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 06:47:24 +0000 Subject: [PATCH 4/6] docs: shorten bootstrap changeset note --- .changeset/bootstrap-public-flags-only.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.changeset/bootstrap-public-flags-only.md b/.changeset/bootstrap-public-flags-only.md index 791b91fc..24e1200e 100644 --- a/.changeset/bootstrap-public-flags-only.md +++ b/.changeset/bootstrap-public-flags-only.md @@ -3,7 +3,3 @@ --- Keep secret flags out of browser data returned by `getFlagsForBootstrap()`, including bound clients. Server-side reads still work, including public flags that depend on secret flags. Remove dependency names from error details sent to the browser. - -After upgrading, fetch current flag definitions from Reflag to refresh saved fallback snapshots. Only flags marked `secret: false` are included. Older definitions without this field, fallback values without definitions, and overrides for unknown or secret flags are left out. Overrides for known public flags still work. - -The browser can read the context you pass in. Leave out secrets and server-only attributes. From af50cdabb1b06044c277f35b5d31e5193d5a7942 Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 07:17:41 +0000 Subject: [PATCH 5/6] docs: clarify bootstrap fallback behavior --- packages/node-sdk/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index 56384572..d9ef4174 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -184,9 +184,12 @@ const bootstrap = reflag.getFlagsForBootstrap(context); // flagStateVersion } ``` -`getFlagsForBootstrap()` includes only public flags (`secret: false`). Secret flags stay on the server, where they can still be read or used by public flags. Error details sent to the browser omit dependency names. Creating bootstrap data does **not** record flag checks. +`getFlagsForBootstrap()` includes only public flags. Secret flags can still be read on the server and used by public flags, but are not sent to the browser. Error details omit dependency names. Creating bootstrap data does **not** record flag checks. -After upgrading, fetch current flag definitions from Reflag to refresh saved fallback snapshots. Older definitions without this field still work on the server, but are not included in browser data. Fallback values without definitions and overrides for unknown or secret flags are also left out. Overrides for known public flags still work. +Overrides for public flags are included. Overrides for secret or unknown flags, `fallbackFlags`, and values from `fallbackProviders.static()` are not. + +> [!WARNING] +> When starting from an old saved snapshot without `secret` fields, server-side reads still work, but bootstrap `flags` is empty. The SDK fetches fresh definitions and updates the saved snapshot automatically when it can reach Reflag. The browser can read the context you pass in. Leave out secrets and server-only attributes. From 5d3e61910c26b43e43b82a0095e9d32f99d6502a Mon Sep 17 00:00:00 2001 From: Ron Cohen Date: Sat, 21 Nov 2026 07:41:30 +0000 Subject: [PATCH 6/6] docs: remove README changes from bootstrap fix --- packages/node-sdk/README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/node-sdk/README.md b/packages/node-sdk/README.md index d9ef4174..6d3cde0a 100644 --- a/packages/node-sdk/README.md +++ b/packages/node-sdk/README.md @@ -184,14 +184,7 @@ const bootstrap = reflag.getFlagsForBootstrap(context); // flagStateVersion } ``` -`getFlagsForBootstrap()` includes only public flags. Secret flags can still be read on the server and used by public flags, but are not sent to the browser. Error details omit dependency names. Creating bootstrap data does **not** record flag checks. - -Overrides for public flags are included. Overrides for secret or unknown flags, `fallbackFlags`, and values from `fallbackProviders.static()` are not. - -> [!WARNING] -> When starting from an old saved snapshot without `secret` fields, server-side reads still work, but bootstrap `flags` is empty. The SDK fetches fresh definitions and updates the saved snapshot automatically when it can reach Reflag. - -The browser can read the context you pass in. Leave out secrets and server-only attributes. +Bootstrap uses batch evaluation and preserves selection metadata and raw context. It does **not** register browser checks. Local overrides/value-only fallbacks carry their values without fabricated authored-selection metadata. **This is a v2 bootstrap contract, not the existing v1 Browser/React/Vue bootstrap shape.** Those consumers require a coordinated migration before accepting this state. Likewise, the current OpenFeature provider deliberately remains on published Node SDK v1 until its separate migration.