
Security News
Google’s OSV Fix Just Added 500+ New Advisories — All Thanks to One Small Policy Change
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
@brainfish-ai/widgets-initiator
Advanced tools
This package provides a simple way to integrate a Brainfish in-app widget in your website or web application. It supports popup widgets with contextual help functionality.
npm install @brainfish-ai/web-widget
<script type="module">
import Brainfish from "https://cdn.jsdelivr.net/npm/@brainfish-ai/web-widget@latest/dist/web.js"
Brainfish.Widgets.init({ widgetKey: "your-key" });
</script>
The popup widget provides a floating button that opens a search interface in a modal overlay.
<!-- The widget will automatically create a floating button -->
<script>
Brainfish.Widgets.init({
widgetKey: "your-widget-key",
environment: "production" // or "staging", "local"
});
</script>
// Open the widget
Brainfish.Widgets.open();
// Close the widget
Brainfish.Widgets.close();
// Check if widget is ready
if (Brainfish.Widgets.isReady) {
// Widget is ready to use
}
// Identify a user
Brainfish.Widgets.identify({
name: "John Doe",
email: "john@example.com",
userId: "user_123"
});
// Set secret attributes (for internal use)
Brainfish.Widgets.setSecretAttributes("internal_data_123");
The contextual help feature allows you to open the widget with a pre-filled question based on user interaction.
// Trigger contextual help with a specific question
Brainfish.Widgets.onContextHelp("How do I reset my password?");
HTML with Help Icons:
<div class="form-field">
<label>Email Address</label>
<input type="email" value="user@example.com">
<button class="help-icon" data-question="How do I change my email address?">
<i class="ph ph-question"></i>
</button>
</div>
<script>
// Add event listeners to help icons
document.querySelectorAll('.help-icon').forEach(icon => {
icon.addEventListener('click', (e) => {
const question = e.target.dataset.question;
Brainfish.Widgets.onContextHelp(question);
});
});
</script>
Direct Button Integration:
<button onclick="Brainfish.Widgets.onContextHelp('How do I reset my password?')">
Reset Password
</button>
Programmatic Usage:
function showHelp(question) {
Brainfish.Widgets.onContextHelp(question);
}
// Usage
showHelp("How do I update my profile?");
The widget emits events when it opens and closes. You can listen to these events:
// Set up the abort controller
const controller = new AbortController();
const { signal } = controller;
// Listen for widget events
window.addEventListener('onBrainfishWidgetOpen', (event) => {
console.log('Widget opened');
// Your custom logic here
}, { signal });
window.addEventListener('onBrainfishWidgetClose', (event) => {
console.log('Widget closed');
// Your custom logic here
}, { signal });
// Clean up event listeners when no longer needed
controller.abort();
The widget automatically tracks analytics events:
Run the following command to build the widget:
yarn build:web-widget
cd packages/web-widget
npx serve ./ -p 8000 -C
The playground provides a comprehensive testing environment for the Brainfish widget:
open http://localhost:8000/playground/index.html
The playground includes:
You can test the widget in different environments by passing the env
parameter:
# Local environment
open http://localhost:8000/playground/index.html?env=local
# Staging environment
open http://localhost:8000/playground/index.html?env=staging
# Production environment
open http://localhost:8000/playground/index.html?env=prod
If you want to test with the agent widget (Next.js app), start it locally:
cd packages/agent-widget
npm run dev
This will run the agent widget on port 3000, which the playground will automatically connect to in local development mode.
FAQs
Brainfish Widgets Manager
We found that @brainfish-ai/widgets-initiator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
Research
/Security News
175 malicious npm packages (26k+ downloads) used unpkg CDN to host redirect scripts for a credential-phishing campaign targeting 135+ organizations worldwide.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.