Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@miniflare/durable-objects

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miniflare/durable-objects - npm Package Compare versions

Comparing version 2.0.0-rc.4 to 2.0.0-rc.5

9

dist/src/index.d.ts
import { Awaitable } from '@miniflare/shared';
import { Compatibility } from '@miniflare/shared';
import { Context } from '@miniflare/shared';
import { Log } from '@miniflare/shared';
import { MiniflareError } from '@miniflare/shared';
import { Mount } from '@miniflare/shared';
import { Plugin } from '@miniflare/shared';

@@ -59,3 +58,3 @@ import { PluginContext } from '@miniflare/shared';

#private;
constructor(objectName: string, factory: DurableObjectFactory, compat?: Compatibility, log?: Log);
constructor(objectName: string, factory: DurableObjectFactory, ctx?: PluginContext);
newUniqueId(_options?: NewUniqueIdOptions): DurableObjectId;

@@ -100,3 +99,3 @@ idFromName(name: string): DurableObjectId;

beforeReload(): void;
reload(bindings: Context, moduleExports: Context, mountedModuleExports: Record<string, Context>): void;
reload(bindings: Context, moduleExports: Context, mounts: Map<string, Mount>): void;
dispose(): void;

@@ -133,3 +132,3 @@ }

readonly id: DurableObjectId;
constructor(factory: DurableObjectFactory, id: DurableObjectId, compat?: Compatibility, log?: Log);
constructor(factory: DurableObjectFactory, id: DurableObjectId, ctx?: PluginContext);
get name(): string | undefined;

@@ -136,0 +135,0 @@ fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;

@@ -100,11 +100,9 @@ var __create = Object.create;

var DurableObjectStub = class {
constructor(factory, id, compat, log) {
constructor(factory, id, ctx) {
this.id = id;
this.#factory = factory;
this.#compat = compat;
this.#log = log;
this.#ctx = ctx;
}
#factory;
#compat;
#log;
#ctx;
get name() {

@@ -115,3 +113,3 @@ return this.id.name;

const state = await this.#factory(this.id);
if (!this.#compat?.isEnabled("durable_object_fetch_requires_full_url") && typeof input === "string") {
if (!this.#ctx?.compat.isEnabled("durable_object_fetch_requires_full_url") && typeof input === "string") {
input = new import_url.URL(input, "https://fake-host");

@@ -121,10 +119,16 @@ }

if (url.protocol !== "http:" && url.protocol !== "https:") {
if (this.#compat?.isEnabled("fetch_refuses_unknown_protocols")) {
if (this.#ctx?.compat.isEnabled("fetch_refuses_unknown_protocols")) {
throw new TypeError(`Fetch API cannot load: ${url.toString()}`);
} else {
this.#log?.warn((0, import_core._buildUnknownProtocolWarning)(url));
this.#ctx?.log.warn((0, import_core._buildUnknownProtocolWarning)(url));
}
}
const req = input instanceof import_core.Request && !init ? input : new import_core.Request(input, init);
const res = await new import_shared2.RequestContext().runWith(() => state[kFetch]((0, import_core.withInputGating)((0, import_core.withImmutableHeaders)(req))));
const parentContext = (0, import_shared2.getRequestContext)();
const requestDepth = (parentContext?.requestDepth ?? 0) + 1;
const res = await new import_shared2.RequestContext({
requestDepth,
pipelineDepth: 1,
durableObject: true
}).runWith(() => state[kFetch]((0, import_core.withInputGating)((0, import_core.withImmutableHeaders)(req))));
const validRes = res instanceof import_core.Response || res instanceof import_undici.Response;

@@ -143,5 +147,4 @@ if (!validRes) {

#objectNameHashHex;
#compat;
#log;
constructor(objectName, factory, compat, log) {
#ctx;
constructor(objectName, factory, ctx) {
this.#objectName = objectName;

@@ -151,4 +154,3 @@ this.#factory = factory;

this.#objectNameHashHex = hexEncode(this.#objectNameHash);
this.#compat = compat;
this.#log = log;
this.#ctx = ctx;
}

@@ -182,3 +184,3 @@ newUniqueId(_options) {

}
return new DurableObjectStub(this.#factory, id, this.#compat, this.#log);
return new DurableObjectStub(this.#factory, id, this.#ctx);
}

@@ -781,3 +783,3 @@ };

const factory = (id) => this.getObject(storage, id);
return new DurableObjectNamespace(objectName, factory, this.ctx.compat, this.ctx.log);
return new DurableObjectNamespace(objectName, factory, this.ctx);
}

@@ -798,3 +800,3 @@ setup(storageFactory) {

}
reload(bindings, moduleExports, mountedModuleExports) {
reload(bindings, moduleExports, mounts) {
this.#constructors.clear();

@@ -806,5 +808,5 @@ for (const { name, className, scriptName } of this.#processedObjects) {

} else {
const scriptExports = mountedModuleExports[scriptName];
const scriptExports = mounts.get(scriptName)?.moduleExports;
if (!scriptExports) {
throw new DurableObjectError("ERR_SCRIPT_NOT_FOUND", `Script ${scriptName} for Durable Object ${name} not found`);
throw new DurableObjectError("ERR_SCRIPT_NOT_FOUND", `Script "${scriptName}" for Durable Object "${name}" not found`);
}

@@ -816,4 +818,4 @@ constructor = scriptExports[className];

} else {
const script = scriptName ? ` in script ${scriptName}` : "";
throw new DurableObjectError("ERR_CLASS_NOT_FOUND", `Class ${className}${script} for Durable Object ${name} not found`);
const script = scriptName ? ` in script "${scriptName}"` : "";
throw new DurableObjectError("ERR_CLASS_NOT_FOUND", `Class "${className}"${script} for Durable Object "${name}" not found`);
}

@@ -820,0 +822,0 @@ }

{
"name": "@miniflare/durable-objects",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"description": "Durable Objects module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers",

@@ -38,12 +38,12 @@ "keywords": [

"dependencies": {
"@miniflare/core": "2.0.0-rc.4",
"@miniflare/shared": "2.0.0-rc.4",
"@miniflare/storage-memory": "2.0.0-rc.4",
"@miniflare/core": "2.0.0-rc.5",
"@miniflare/shared": "2.0.0-rc.5",
"@miniflare/storage-memory": "2.0.0-rc.5",
"undici": "^4.11.1"
},
"devDependencies": {
"@miniflare/cache": "2.0.0-rc.4",
"@miniflare/runner-vm": "2.0.0-rc.4",
"@miniflare/shared-test": "2.0.0-rc.4"
"@miniflare/cache": "2.0.0-rc.5",
"@miniflare/runner-vm": "2.0.0-rc.5",
"@miniflare/shared-test": "2.0.0-rc.5"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc