
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
chrome-web-ai-types
Advanced tools
TypeScript definitions for Chrome’s built-in AI APIs (Summarizer, Writer, Rewriter, Proofreader, Translator, Language Detector, and Prompt API). Works with TypeScript, React, Angular, Vue, and any project using TypeScript.
npm install chrome-web-ai-types
# or
yarn add chrome-web-ai-types
# or
pnpm add chrome-web-ai-types
For the global types (Summarizer, Writer, Translator, etc.) to be recognized, add this at the top of a TypeScript file that uses the APIs (or in a global .d.ts in your project):
/// <reference types="chrome-web-ai-types" />
Example: in a React component, Angular service, or Vue component that calls the APIs, put that line before any other code. Alternatively, add it once in a file like src/global.d.ts or types/global.d.ts so all files in the project get the types.
| API | Description |
|---|---|
| Summarizer | Summarize text (key-points, tldr, teaser, headline) |
| Writer | Generate text (tone, format, length) |
| Rewriter | Rewrite text (tone, format, length) |
| Proofreader | Grammar and spelling review |
| Translator | Translate between languages |
| LanguageDetector | Detect text language |
| LanguageModel (Prompt API) | Prompts and sessions with Gemini Nano |
| window.ai | createLanguageModel() (legacy) |
All expose availability(), create(options?), streaming where applicable, and language options when documented.
The declarations are global. After installing the package, types are picked up automatically.
// No import needed
async function main() {
if (typeof Summarizer === "undefined") {
console.log("Summarizer not available in this environment.");
return;
}
const availability = await Summarizer.availability();
if (availability === "unavailable") return;
const summarizer = await Summarizer.create({
type: "key-points",
format: "markdown",
length: "short",
});
const summary = await summarizer.summarize("Your long text here...");
console.log(summary);
}
Ensure your tsconfig.json includes the right lib (usually automatic after install):
{
"compilerOptions": {
"lib": ["ES2020", "DOM"]
}
}
Install the package and use the APIs in components or hooks. Global types are available without imports.
// src/hooks/useSummarizer.ts
/// <reference types="chrome-web-ai-types" />
import { useState, useCallback } from "react";
export function useSummarizer() {
const [summary, setSummary] = useState<string>("");
const [loading, setLoading] = useState(false);
const summarize = useCallback(async (text: string) => {
if (typeof Summarizer === "undefined") {
throw new Error("Summarizer API not available.");
}
setLoading(true);
try {
const availability = await Summarizer.availability();
if (availability === "unavailable") {
throw new Error("Model unavailable.");
}
const summarizer = await Summarizer.create({ type: "key-points" });
const result = await summarizer.summarize(text);
setSummary(result);
return result;
} finally {
setLoading(false);
}
}, []);
return { summary, loading, summarize };
}
// src/components/SummarizerDemo.tsx
import { useSummarizer } from "../hooks/useSummarizer";
export function SummarizerDemo() {
const { summary, loading, summarize } = useSummarizer();
return (
<div>
<button
disabled={loading}
onClick={() => summarize("Long text to summarize...")}
>
{loading ? "Summarizing..." : "Summarize"}
</button>
{summary && <p>{summary}</p>}
</div>
);
}
In React + Vite or Create React App, a tsconfig with "lib": ["ES2020", "DOM"] is enough.
--
Install and use in <script setup lang="ts"> or composables; global types are recognized.
<!-- src/components/LanguageDetector.vue -->
<script setup lang="ts">
import { ref } from "vue";
const text = ref("");
const detectedLanguage = ref<string | null>(null);
const loading = ref(false);
async function detect() {
if (typeof LanguageDetector === "undefined") return;
loading.value = true;
try {
const detector = await LanguageDetector.create();
const results = await detector.detect(text.value);
detectedLanguage.value = results[0]?.detectedLanguage ?? null;
} finally {
loading.value = false;
}
}
</script>
<template>
<div>
<textarea v-model="text" placeholder="Enter some text" />
<button :disabled="loading" @click="detect">Detect language</button>
<p v-if="detectedLanguage">Language: {{ detectedLanguage }}</p>
</div>
</template>
APIs may be missing (older browser) or not ready (model not downloaded). Always check at runtime:
if (typeof Summarizer === "undefined") {
// API does not exist in this environment
return;
}
const availability = await Summarizer.availability();
// "available" | "unavailable" | "downloadable"
if (availability === "unavailable") {
// Cannot use
return;
}
if (availability === "downloadable") {
// Can call create(); model will download (may take a while)
const summarizer = await Summarizer.create({
monitor(m) {
m.addEventListener("downloadprogress", (e) => {
console.log(`Download: ${e.loaded * 100}%`);
});
},
});
// ...
}
npm install
npm run typecheck
# or
npm test
Files under tests/ assert that the definitions accept valid usage and reject invalid usage.
MIT
FAQs
TypeScript definitions for Chrome Web AI APIs
We found that chrome-web-ai-types 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.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.