New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cloudflare/workers-shared

Package Overview
Dependencies
Maintainers
35
Versions
947
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/workers-shared - npm Package Compare versions

Comparing version

to
0.15.0

3

dist/utils/constants.d.ts

@@ -23,1 +23,4 @@ /** Reserved header at the start of the whole manifest, NOT in each entry (currently unused)

export declare const MAX_ASSET_SIZE: number;
export declare const CF_ASSETS_IGNORE_FILENAME = ".assetsignore";
export declare const REDIRECTS_FILENAME = "_redirects";
export declare const HEADERS_FILENAME = "_headers";

@@ -0,3 +1,22 @@

import type { PathOrFileDescriptor } from "node:fs";
/** normalises sep for windows and prefix with `/` */
export declare const normalizeFilePath: (relativeFilepath: string) => string;
export declare const getContentType: (absFilePath: string) => string;
/**
* Generate a function that can match relative filepaths against a list of gitignore formatted patterns.
*/
export declare function createPatternMatcher(patterns: string[], exclude: boolean): (filePath: string) => boolean;
export declare function thrownIsDoesNotExistError(thrown: unknown): thrown is Error & {
code: "ENOENT";
};
export declare function maybeGetFile(filePath: PathOrFileDescriptor): string;
/**
* Create a function for filtering out ignored assets.
*
* The generated function takes an asset path, relative to the asset directory,
* and returns true if the asset should not be ignored.
*/
export declare function createAssetsIgnoreFunction(dir: string): Promise<{
assetsIgnoreFunction: (filePath: string) => boolean;
assetsIgnoreFilePresent: boolean;
}>;

@@ -18,2 +18,111 @@ import { z } from "zod";

}>;
declare const MetadataStaticRedirects: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
lineNumber: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
lineNumber?: number;
}, {
status?: number;
to?: string;
lineNumber?: number;
}>>;
export type MetadataStaticRedirects = z.infer<typeof MetadataStaticRedirects>;
declare const MetadataRedirects: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
}, {
status?: number;
to?: string;
}>>;
export type MetadataRedirects = z.infer<typeof MetadataRedirects>;
declare const MetadataHeaders: z.ZodRecord<z.ZodString, z.ZodObject<{
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
unset: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
set?: Record<string, string>;
unset?: string[];
}, {
set?: Record<string, string>;
unset?: string[];
}>>;
export type MetadataHeaders = z.infer<typeof MetadataHeaders>;
export declare const RedirectsSchema: z.ZodOptional<z.ZodObject<{
version: z.ZodLiteral<1>;
staticRules: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
lineNumber: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
lineNumber?: number;
}, {
status?: number;
to?: string;
lineNumber?: number;
}>>;
rules: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
}, {
status?: number;
to?: string;
}>>;
}, "strip", z.ZodTypeAny, {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
}, {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
}>>;
export declare const HeadersSchema: z.ZodOptional<z.ZodObject<{
version: z.ZodLiteral<2>;
rules: z.ZodRecord<z.ZodString, z.ZodObject<{
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
unset: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
set?: Record<string, string>;
unset?: string[];
}, {
set?: Record<string, string>;
unset?: string[];
}>>;
}, "strip", z.ZodTypeAny, {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
}, {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
}>>;
export declare const AssetConfigSchema: z.ZodObject<{

@@ -26,2 +135,75 @@ account_id: z.ZodOptional<z.ZodNumber>;

not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>;
redirects: z.ZodOptional<z.ZodObject<{
version: z.ZodLiteral<1>;
staticRules: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
lineNumber: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
lineNumber?: number;
}, {
status?: number;
to?: string;
lineNumber?: number;
}>>;
rules: z.ZodRecord<z.ZodString, z.ZodObject<{
status: z.ZodNumber;
to: z.ZodString;
}, "strip", z.ZodTypeAny, {
status?: number;
to?: string;
}, {
status?: number;
to?: string;
}>>;
}, "strip", z.ZodTypeAny, {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
}, {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
}>>;
headers: z.ZodOptional<z.ZodObject<{
version: z.ZodLiteral<2>;
rules: z.ZodRecord<z.ZodString, z.ZodObject<{
set: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
unset: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
set?: Record<string, string>;
unset?: string[];
}, {
set?: Record<string, string>;
unset?: string[];
}>>;
}, "strip", z.ZodTypeAny, {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
}, {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
}>>;
}, "strip", z.ZodTypeAny, {

@@ -34,2 +216,21 @@ account_id?: number;

not_found_handling?: "none" | "single-page-application" | "404-page";
redirects?: {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
};
headers?: {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
};
}, {

@@ -42,2 +243,21 @@ account_id?: number;

not_found_handling?: "none" | "single-page-application" | "404-page";
redirects?: {
version?: 1;
staticRules?: Record<string, {
status?: number;
to?: string;
lineNumber?: number;
}>;
rules?: Record<string, {
status?: number;
to?: string;
}>;
};
headers?: {
version?: 2;
rules?: Record<string, {
set?: Record<string, string>;
unset?: string[];
}>;
};
}>;

@@ -79,1 +299,2 @@ export type RouterConfig = z.infer<typeof RouterConfigSchema>;

}
export {};

10

package.json
{
"name": "@cloudflare/workers-shared",
"version": "0.14.5",
"version": "0.15.0",
"description": "Package that is used at Cloudflare to power some internal features of Cloudflare Workers.",

@@ -31,3 +31,3 @@ "keywords": [

"@cloudflare/vitest-pool-workers": "^0.5.41",
"@cloudflare/workers-types": "^4.20250224.0",
"@cloudflare/workers-types": "^4.20250310.0",
"@sentry/cli": "^2.37.0",

@@ -37,2 +37,3 @@ "@types/mime": "^3.0.4",

"esbuild": "0.17.19",
"ignore": "^5.2.0",
"rimraf": "^5.0.10",

@@ -75,6 +76,7 @@ "toucan-js": "4.0.0",

"generate-sourcemaps:router-worker": "pnpx wrangler versions upload -c router-worker/wrangler.toml --dry-run --outdir=./dist",
"test": "concurrently --group -n router-worker,asset-worker \"pnpm run test:router-worker\" \"pnpm run test:asset-worker\"",
"test": "concurrently --group -n router-worker,asset-worker,utils \"pnpm run test:router-worker\" \"pnpm run test:asset-worker\" \"pnpm run test:utils\"",
"test:asset-worker": "vitest -c asset-worker/vitest.config.mts --dir asset-worker",
"test:ci": "concurrently --group -n router-worker,asset-worker \"pnpm run test:router-worker --run\" \"pnpm run test:asset-worker --run\"",
"test:ci": "concurrently --group -n router-worker,asset-worker,utils \"pnpm run test:router-worker --run\" \"pnpm run test:asset-worker --run\" \"pnpm run test:utils --run\"",
"test:router-worker": "vitest -c router-worker/vitest.config.mts --dir router-worker",
"test:utils": "vitest --dir utils",
"types:emit": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir ./dist",

@@ -81,0 +83,0 @@ "upload-sourcemaps": "pnpm run upload-sourcemaps:asset-worker && pnpm run upload-sourcemaps:router-worker",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet