
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
clearable-object
Advanced tools
A simple library for adding clear functionality to Cloudflare Durable Objects. Supports clearing storage and alarms with optional authentication.
A simple library for adding clear functionality to Cloudflare Durable Objects. Supports clearing storage and alarms with optional authentication.
npm i clearable-object
import { Clearable } from "clearable-object";
@Clearable({ secret: "user:pass", isPublic: false })
export class MyDurableObject extends DurableObject {
// Automatically adds GET /clear endpoint
}
import { Clear } from "clearable-object";
export class MyDurableObject extends DurableObject {
clear = new Clear(this, { secret: "user:pass" });
async fetch(request: Request) {
const url = new URL(request.url);
if (url.pathname === "/clear") {
const result = await this.clear.clear();
return new Response(JSON.stringify(result));
}
// ... your logic
}
}
GET /clear
- Clear all data (storage and alarm)GET /clear?storage=false
- Skip clearing storageGET /clear?alarm=false
- Skip clearing alarmawait clear.clear({
clearStorage: true, // Clear Durable Object storage
clearAlarm: true, // Clear scheduled alarm
});
const isAuthorized = clear.checkAuth(request);
return clear.unauthorizedResponse();
interface ClearResult {
success: boolean;
storageCleared: boolean; // Whether storage was cleared
alarmCleared: boolean; // Whether alarm was cleared
errors?: string[]; // Any errors encountered
warnings?: string[]; // Any warnings
}
interface ClearOptions {
secret?: string; // Authentication secret
isPublic?: boolean; // Allow unauthenticated access
}
Configure with secret
option. Supports Basic Auth and API key query parameter.
curl -u user:pass https://your-worker.com/clear
curl https://your-worker.com/clear?apiKey=user:pass
// Require authentication
@Clearable({ secret: "myuser:mypass" })
// Public access (no auth required)
@Clearable({ isPublic: true })
// No auth, not public (will reject all requests)
@Clearable()
{
"success": true,
"storageCleared": true,
"alarmCleared": true
}
{
"success": true,
"storageCleared": true,
"alarmCleared": false,
"warnings": ["No alarm was set to clear"]
}
{
"error": "Unauthorized",
"message": "Valid authentication required"
}
Full TypeScript support with proper type definitions for all methods and responses.
import { Clear, ClearResult, ClearOptions } from "clearable-object";
const clear = new Clear(durableObject, options);
const result: ClearResult = await clear.clear();
FAQs
A simple library for adding clear functionality to Cloudflare Durable Objects. Supports clearing storage and alarms with optional authentication.
The npm package clearable-object receives a total of 0 weekly downloads. As such, clearable-object popularity was classified as not popular.
We found that clearable-object 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.