Scan your whole stack
From OX Research Newsroom
Are you using @sdxc/flags?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v2026.11.29
@sdxc/flags was last scanned on 29 Nov 2026 at version 2026.11.29. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 2026.11.29 LATEST | 29 Nov 2026 | No rules fired |
| 2026.11.22 | 22 Nov 2026 | No rules fired |
| 2026.11.10 | 10 Nov 2026 | No rules fired |
| 2026.11.3 | 3 Nov 2026 | Not shown |
| 2026.10.25 | 25 Oct 2026 | Not shown |
Findings for v2026.11.29. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 2026.11.29; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Feature flag evaluation implementing the OpenFeature specification.
The API follows OpenFeature v0.9.0: the flag system is a provider you
hand to an instance you own, the subject travels with each call, and an evaluation that cannot
resolve returns the default it was handed, with the reason on its detailed form.
npm add @sdxc/flags
Optional peers, each needed only by the entry point that uses it:
remix for the router middleware,
@sdxc/jobs for the dispatcher middleware, and
vitest for the conformance suite. Structure flags take
any Standard Schema library; the examples use remix/data-schema.
import { createFlags } from "@sdxc/flags/client";
import { InMemoryProvider } from "@sdxc/flags/provider/memory";
let flags = createFlags({
provider: () =>
new InMemoryProvider({
"new-checkout": { variants: { on: true, off: false }, defaultVariant: "off" },
}),
});
let client = flags.getClient();
await client.boolean("new-checkout", false, { targetingKey: "user-1" }); // false
let details = await client.stringDetails("checkout-copy-variant", "control");
details.value; // "control", the default it was handed
details.reason; // "ERROR"
details.errorCode; // "FLAG_NOT_FOUND"
Every method is asynchronous and none throws. A structure flag takes a schema, and a value the
schema rejects answers the default with TYPE_MISMATCH:
import * as s from "remix/data-schema";
let copy = await client.object(
"checkout-copy",
{ title: "Checkout", cta: "Pay" },
{ schema: s.object({ title: s.string(), cta: s.string() }) },
);
A catalog writes each key, type and default once, so call sites restate none of them:
import { defineFlags, flag } from "@sdxc/flags/catalog";
import * as s from "remix/data-schema";
export let features = defineFlags({
newCheckout: flag.boolean("new-checkout", false),
digestBatch: flag.number("digest-batch-size", 50),
checkoutCopy: flag.object("checkout-copy", s.object({ title: s.string(), cta: s.string() }), {
title: "Checkout",
cta: "Pay",
}),
});
await client.get(features.newCheckout); // Promise<boolean>
await client.get(features.digestBatch, { context: { targetingKey: "team-1" } }); // Promise<number>
await client.get(features.newCheckout, { defaultValue: true }); // a different fallback for this call
await client.details(features.checkoutCopy); // EvaluationDetails<{ title: string; cta: string }>
The middleware reads the request's subject once and publishes a client as ctx.flags; importing
it is what types ctx.flags.
import featureFlags from "@sdxc/flags/middleware/router";
import { createRouter } from "remix/router";
import { flags } from "./flags.ts";
let router = createRouter({
middleware: [
featureFlags(flags, {
context: (ctx) => ({ targetingKey: ctx.request.headers.get("x-user-id") ?? undefined }),
}),
],
});
router.get("/checkout", async (ctx) => {
let enabled = await ctx.flags.boolean("new-checkout", false);
return new Response(enabled ? "new checkout" : "classic checkout");
});
import featureFlags from "@sdxc/flags/middleware/dispatcher";
import { createJobDispatcher, createJobHandler } from "@sdxc/jobs";
import { flags } from "./flags.ts";
import { jobs } from "./jobs.ts";
export let dispatcher = createJobDispatcher({
middleware: [featureFlags(flags, { context: (ctx) => ({ targetingKey: ctx.input.teamId }) })],
});
export default createJobHandler(jobs.sendWeeklyDigest, async (ctx) => {
if (await ctx.flags.boolean("weekly-digest-v2", false)) return sendV2(ctx.input);
return sendV1(ctx.input);
});
| Entry point | Contains |
|---|---|
@sdxc/flags |
Types only: context, details, reasons, error codes, hooks, events |
@sdxc/flags/client |
createFlags, the shipped hooks, the propagator |
@sdxc/flags/catalog |
defineFlags and flag |
@sdxc/flags/provider |
The Provider interface and the kit for writing one |
@sdxc/flags/provider/noop |
NoopProvider |
@sdxc/flags/provider/memory |
InMemoryProvider |
@sdxc/flags/conformance |
The Vitest suite a provider runs |
@sdxc/flags/middleware |
The Flags context key |
@sdxc/flags/middleware/router |
Middleware for a remix/router router |
@sdxc/flags/middleware/dispatcher |
Middleware for an @sdxc/jobs dispatcher |
createFlags(options?: FlagsOptions): FlagsBuilds an API instance; instances share no providers, context, hooks or handlers. Build it once at module scope, so its provider initializes once per process rather than once per request.
provider: a function building the default provider, called the first time it is needed.
Without it, evaluation runs through NoopProvider.context: the global evaluation context.hooks: hooks around every evaluation the instance makes.handlers: event handlers by event name, one handler or an array.propagator: where the transaction context comes from.FlagsThe instance createFlags returns.
| Member | Does |
|---|---|
getClient(domain?, context?) |
A client for the domain's provider, carrying context as its client context |
setProvider(provider) |
Sets and initializes the default provider; answers Result<void, ProviderError> |
setProvider(domain, provider) |
The same for one domain; clients of other domains keep the default |
setContext(context) |
Replaces the global context |
addHooks(...hooks) |
Adds API-level hooks |
addHandler(event, handler), removeHandler |
Subscribes to provider events across every domain |
setTransactionContext(context, callback) |
Runs callback with context as the transaction context |
setTransactionContextPropagator(propagator) |
Replaces the propagator |
providerMetadata(domain?) |
The metadata of the provider serving a domain |
ready() |
Resolves once every registered provider has initialized |
shutdown() |
Shuts every provider down and resets the instance; answers a Result |
Result comes from @sdxc/result. A context
field set at a later level wins, in this order: global, transaction, client, invocation, then
whatever a before hook returns. A field set to undefined removes it.
ClientWhat code evaluates through. boolean, string and number take
(key, defaultValue, context?, options?); object takes (key, defaultValue, options, context?),
with options.schema required. Each has a *Details twin answering EvaluationDetails<T>.
get(flag, options?) and details(flag, options?) evaluate a catalog handle.
addHooks, addHandler and removeHandler work at the client's domain, track(name, context?, details?) forwards an action to the provider's track, and metadata and providerStatus
describe the client.
wideEventHook(): HookSets feature_flag.key, feature_flag.result.reason, feature_flag.result.variant,
feature_flag.provider.name and, on failure, error.type and error.message on the current
wide event from @sdxc/logger. Outside a logged
invocation it does nothing.
redactHook(fields: string[]): HookRemoves the named fields from the context before the provider and later hooks see it.
asyncLocalStoragePropagator(): TransactionContextPropagatorA propagator backed by
AsyncLocalStorage, so code
nested inside flags.setTransactionContext(...) evaluates with that context.
defineFlags(catalog) and flagdefineFlags answers the object of handles it was given with every value type kept.
flag.boolean(key, defaultValue), flag.string(...) and flag.number(...) build handles;
flag.object(key, schema, defaultValue) types the default from the schema.
Providerinterface Provider {
readonly metadata: ProviderMetadata;
readonly hooks?: Hook[];
readonly events?: ProviderEvents;
readonly domainScoped?: boolean;
resolveBoolean(key, defaultValue, context): MaybePromise<ResolutionDetails<boolean>>;
resolveString(key, defaultValue, context): MaybePromise<ResolutionDetails<string>>;
resolveNumber(key, defaultValue, context): MaybePromise<ResolutionDetails<number>>;
resolveObject(key, defaultValue, context): MaybePromise<ResolutionDetails<JSONValue>>;
initialize?(context: EvaluationContext, domain?: string): Promise<void>;
shutdown?(): Promise<void>;
track?(name: string, context: EvaluationContext, details?: TrackingEventDetails): void;
}
Metadata and four resolvers make a working provider. A provider's status follows the events it
emits, so one with initialize stays NOT_READY until it emits PROVIDER_READY.
domainScoped: true refuses binding the same instance to a second domain.
resolved(value, details?) and failed(defaultValue, errorCode, errorMessage?)Build a resolver's answer: resolved carries a value with its variant, reason and
flagMetadata; failed carries the default, the ErrorCode and reason: "ERROR".
ProviderEventsThe emitter a provider holds as events, with emit(event, details?), on(event, handler) and
off(event, handler). A throwing listener leaves the others running.
ProviderErrornew ProviderError(code, message?, options?): an Error with an ErrorCode as code. Reject
initialize with one; a resolver that throws one reports its code instead of GENERAL.
NoopProviderAnswers every evaluation with its default and reason: "DEFAULT". It serves an instance with no
provider set and after shutdown().
new InMemoryProvider(flags?: FlagSet)A provider answering from a FlagSet in memory, with the full lifecycle and events.
putConfiguration(flags) swaps the set and emits PROVIDER_CONFIGURATION_CHANGED naming every
key in the old or new set. A flag resolves with reason STATIC, TARGETING_MATCH when contextEvaluator
names a variant, DEFAULT when it names none, and DISABLED with the caller's default when
disabled is set.
interface FlagConfiguration<T extends FlagValue = FlagValue> {
variants: Record<string, T>;
defaultVariant: string;
disabled?: boolean;
contextEvaluator?: (context: EvaluationContext) => string | undefined;
flagMetadata?: FlagMetadata;
}
type FlagSet = Record<string, FlagConfiguration>;
conformance(name, create, options: ConformanceOptions): voidRegisters Vitest tests checking a provider against the specification. create builds a fresh
provider per test, and each option turns on the group that needs it:
flags: the FlagSet the provider serves, for the resolution checks.lifecycle: the provider implements initialize and shutdown.failing: builds a provider whose initialize rejects, for the error-event checks.tracking: the provider implements track.Flags from ./middlewareThe context key both middlewares publish the client under; ctx.get(Flags) reads it where the
ctx.flags property is not typed.
featureFlags(flags, options?) from ./middleware/router and ./middleware/dispatcherThe default export of each. Awaits flags.ready(), then publishes
flags.getClient(options.domain, await options.context?.(ctx)) as ctx.flags. context runs
once per request or job run and may be async.
FlagValue is any JSON value and FlagValueType names its kind. EvaluationContext holds an
optional targetingKey plus any JSON or Date fields. A provider answers ResolutionDetails<T>;
a client answers EvaluationDetails<T>, which adds flagKey and always has flagMetadata.
Reason is an open string union (STATIC, DEFAULT, TARGETING_MATCH, SPLIT, CACHED,
DISABLED, UNKNOWN, STALE, ERROR); ErrorCode is closed (PROVIDER_NOT_READY,
PROVIDER_FATAL, FLAG_NOT_FOUND, PARSE_ERROR, TYPE_MISMATCH, TARGETING_KEY_MISSING,
INVALID_CONTEXT, GENERAL). Flag<T> and FlagOptions<T> are a catalog handle and its
per-call options; EvaluationOptions and ObjectEvaluationOptions<T> carry per-call hooks,
hints and the required schema. Hook, HookContext, HookData, HookHints and
HookStage describe hooks. ProviderStatus, ProviderEvent, ProviderEventDetails,
EventDetails, EventHandler and ProviderEventHandler describe events.
ClientMetadata, ProviderMetadata, FlagMetadata and EventMetadata identify clients,
providers, resolved flags and events. TrackingEventDetails is what track attaches, with an
optional numeric value. ResolvedDetails<T>, FlagsOptions, TransactionContextPropagator,
FeatureFlagsOptions and MaybePromise<T> are the shapes the functions above take.
The provider fetches its rules in initialize, emits PROVIDER_READY, and answers each
resolver with resolved or failed. The conformance suite checks it in a Vitest file.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.