
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
obsidianlab-sdk
Advanced tools
Official JavaScript/TypeScript SDK for ObsidianLab Feature Flag Management
Official JavaScript/TypeScript SDK for ObsidianLab - Feature Flag Management System.
npm install obsidianlab-sdk
const { ObsidianLabClient } = require("obsidianlab-sdk");
// Initialize client
const client = new ObsidianLabClient({
sdkKey: "pk_prod_your_sdk_key_here",
apiUrl: "https://api.obsidianlab.io/api",
});
await client.initialize();
// Check flag
const isEnabled = await client.isEnabled("new-feature", {
userId: "user_123",
userType: "premium",
});
if (isEnabled) {
// Show new feature
}
import { ObsidianLabProvider, useFlag } from "obsidianlab-sdk";
function App() {
return (
<ObsidianLabProvider config={{ sdkKey: "pk_prod_xxx" }}>
<Dashboard />
</ObsidianLabProvider>
);
}
function Dashboard() {
const { isEnabled } = useFlag("new-feature", { userId: "user_123" });
return <div>{isEnabled && <NewFeature />}</div>;
}
ObsidianLabClientnew ObsidianLabClient(config: ObsidianLabConfig)
Config Options:
| Option | Type | Default | Description |
|---|---|---|---|
sdkKey | string | required | Your project SDK key |
apiUrl | string | http://localhost:8000/api | ObsidianLab API URL |
enableCache | boolean | true | Enable local caching |
cacheTTL | number | 60000 | Cache TTL in ms |
pollingInterval | number | 0 | Auto-refresh interval (0 = disabled) |
onError | function | console.error | Error handler |
onFlagsUpdated | function | undefined | Callback when flags update |
initialize()Fetches all flags from the API. Must be called before evaluating flags.
await client.initialize();
isEnabled(flagKey, context)Check if a flag is enabled (returns boolean).
const isEnabled = await client.isEnabled("new-checkout", {
userId: "user_123",
userType: "premium",
country: "IT",
});
Parameters:
flagKey (string) - Flag key to evaluatecontext (object) - User context for targetingReturns: Promise<boolean>
evaluate(flagKey, context)Evaluate a flag with detailed result.
const result = await client.evaluate("new-checkout", {
userId: "user_123",
});
console.log(result);
// {
// flagKey: 'new-checkout',
// value: true,
// reason: 'RULE_MATCHED',
// ruleId: 'rule_abc'
// }
Returns: Promise<EvaluationResult>
getAllFlags()Get all cached flags.
const flags = client.getAllFlags();
Returns: Flag[]
getFlag(flagKey)Get a specific flag.
const flag = client.getFlag("new-checkout");
Returns: Flag | undefined
refresh()Manually refresh flags from API.
await client.refresh();
destroy()Cleanup and stop polling.
client.destroy();
ObsidianLabProviderWrap your app to provide ObsidianLab context.
<ObsidianLabProvider config={{ sdkKey: "pk_prod_xxx" }}>
<App />
</ObsidianLabProvider>
useFlag(flagKey, context)Check if a flag is enabled.
function MyComponent() {
const { isEnabled, loading } = useFlag("new-feature", {
userId: "user_123",
});
if (loading) return <Spinner />;
return <div>{isEnabled && <NewFeature />}</div>;
}
useFlagValue(flagKey, context)Get detailed evaluation result.
function MyComponent() {
const { result, loading } = useFlagValue("new-feature", {
userId: "user_123",
});
console.log(result?.reason); // 'RULE_MATCHED'
}
useObsidianLab()Access SDK client directly.
function MyComponent() {
const { client, loading, error, flags } = useObsidianLab();
if (loading) return <Spinner />;
if (error) return <Error message={error.message} />;
return <div>Total flags: {flags.length}</div>;
}
Pass any custom attributes for targeting:
const context = {
userId: "user_123", // For rollout percentage
email: "user@example.com", // Custom attribute
userType: "premium", // Custom attribute
country: "IT", // Custom attribute
age: 25, // Custom attribute
plan: "enterprise", // Custom attribute
};
const isEnabled = await client.isEnabled("feature", context);
ObsidianLab supports 9 targeting operators:
| Operator | Description | Example |
|---|---|---|
equals | Exact match | userType === 'premium' |
notEquals | Not equal | userType !== 'free' |
in | In array | country in ['IT', 'US'] |
notIn | Not in array | country not in ['CN'] |
contains | String contains | email contains '@company.com' |
startsWith | String starts with | email starts with 'admin' |
endsWith | String ends with | email ends with '.edu' |
greaterThan | Number > | age > 18 |
lessThan | Number < | age < 65 |
Use userId in context for consistent rollout:
// 20% rollout (same user always gets same result)
const isEnabled = await client.isEnabled("gradual-rollout", {
userId: "user_123", // Required for consistent hashing
userType: "premium",
});
const variant = await client.isEnabled("ab-test-variant-a", {
userId: user.id,
});
if (variant) {
showVariantA();
} else {
showVariantB();
}
// Enable for 10% of premium users
const useNewAPI = await client.isEnabled("new-api", {
userId: user.id,
userType: "premium",
});
const apiUrl = useNewAPI ? "/api/v2" : "/api/v1";
// Instantly disable feature if issues
const featureEnabled = await client.isEnabled("risky-feature", {
userId: user.id,
});
if (featureEnabled) {
// Execute risky code
}
const enableLogs = await client.isEnabled("debug-logs", {
email: user.email, // Rule: email in ['dev@company.com']
});
if (enableLogs) {
console.log("Debug info...");
}
const client = new ObsidianLabClient({
sdkKey: "pk_prod_xxx",
pollingInterval: 300000, // Refresh every 5 minutes
onFlagsUpdated: (flags) => {
console.log("Flags updated!", flags.length);
},
});
const client = new ObsidianLabClient({
sdkKey: "pk_prod_xxx",
onError: (error) => {
console.error("ObsidianLab Error:", error);
// Send to error tracking (Sentry, etc.)
},
});
const client = new ObsidianLabClient({
sdkKey: "pk_prod_xxx",
cacheTTL: 30000, // Refresh every 30 seconds
});
Full TypeScript support with types included.
import {
ObsidianLabClient,
ObsidianLabConfig,
EvaluationContext,
EvaluationResult,
} from "obsidianlab-sdk";
const config: ObsidianLabConfig = {
sdkKey: "pk_prod_xxx",
};
const client = new ObsidianLabClient(config);
const context: EvaluationContext = {
userId: "user_123",
userType: "premium",
};
const result: EvaluationResult = await client.evaluate("flag", context);
MIT License
Copyright (c) 2025 Davide Faggionato
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Official JavaScript/TypeScript SDK for ObsidianLab Feature Flag Management
We found that obsidianlab-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.