Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into examples
Browse files Browse the repository at this point in the history
  • Loading branch information
blaine-arcjet committed Dec 13, 2023
2 parents fa32df4 + f71c12b commit 1b5b9ec
Show file tree
Hide file tree
Showing 19 changed files with 317 additions and 435 deletions.
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
# Our dependencies should be checked daily
interval: "daily"
assignees:
- blaine-arcjet
groups:
dependencies:
dependency-type: "production"
dev-dependencies:
dependency-type: "development"
ignore:
# Ignore updates to the @types/node package due to conflict between
# Headers in DOM.
- dependency-name: "@types/node"
versions: [">18.18"]
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: npm

# Workflow

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
omit=optional
28 changes: 14 additions & 14 deletions analyze/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ async function init(): Promise<WasmAPI | undefined> {
}

if (state === "uninitialized") {
let wasmModule: WebAssembly.Module;
// We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
// possible values: "edge" | "nodejs" | undefined
if (process.env["NEXT_RUNTIME"] === "edge") {
const mod = await import(
// @ts-expect-error
"./wasm/arcjet_analyze_js_req_bg.wasm?module"
);
wasmModule = mod.default;
} else {
const { wasm } = await import("./wasm/arcjet.wasm.js");
wasmModule = await WebAssembly.compile(wasm);
}

try {
let wasmModule: WebAssembly.Module;
// We use `NEXT_RUNTIME` env var to DCE the Node/Browser code in the `else` block
// possible values: "edge" | "nodejs" | undefined
if (process.env["NEXT_RUNTIME"] === "edge") {
const mod = await import(
// @ts-expect-error
"./wasm/arcjet_analyze_js_req_bg.wasm?module"
);
wasmModule = mod.default;
} else {
const { wasm } = await import("./wasm/arcjet.wasm.js");
wasmModule = await WebAssembly.compile(await wasm());
}

await initWasm(wasmModule);
state = "initialized";
} catch (err) {
Expand Down
17 changes: 9 additions & 8 deletions analyze/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcjet/analyze",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Arcjet local analysis engine",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "analyze"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "module",
"main": "./index.js",
Expand All @@ -35,17 +36,17 @@
"./wasm/arcjet_analyze_js_req_bg.js"
],
"dependencies": {
"@arcjet/logger": "1.0.0-alpha.2"
"@arcjet/logger": "1.0.0-alpha.3"
},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.2",
"@arcjet/rollup-config": "1.0.0-alpha.2",
"@arcjet/tsconfig": "1.0.0-alpha.2",
"@arcjet/eslint-config": "1.0.0-alpha.3",
"@arcjet/rollup-config": "1.0.0-alpha.3",
"@arcjet/tsconfig": "1.0.0-alpha.3",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.8.0",
"@types/node": "18.18.0",
"jest": "29.7.0",
"rollup": "4.6.1",
"typescript": "5.3.2"
"typescript": "5.3.3"
},
"publishConfig": {
"access": "public",
Expand Down
6 changes: 5 additions & 1 deletion analyze/wasm/arcjet.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@
* properly support consistent asset bundling techniques.
*/

export const wasm: ArrayBuffer;
/**
* Returns an ArrayBuffer for the Arcjet Wasm binary, decoded from a base64 Data
* URL.
*/
export function wasm(): Promise<ArrayBuffer>;
15 changes: 11 additions & 4 deletions analyze/wasm/arcjet.wasm.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions arcjet-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ export function createMiddleware<const Rules extends (Primitive | Product)[]>(
* the request is blocked, a `NextApiResponse` instance will be returned based
* on the configured decision response.
*/
export function withArcjet(
export function withArcjet<Args extends [ArcjetNextRequest, ...unknown[]], Res>(
// TODO(#221): This type needs to be tightened to only allow Primitives or Products that don't have extra props
arcjet: ArcjetNext<(Primitive<EmptyObject> | Product<EmptyObject>)[]>,
handler: (...args: any[]) => any,
handler: (...args: Args) => Promise<Res>,
) {
return async (request: ArcjetNextRequest, ...rest: unknown[]) => {
return async (...args: Args) => {
const request = args[0];
const decision = await arcjet.protect(request);
if (decision.isDenied()) {
// TODO(#222): Content type negotiation using `Accept` header
Expand All @@ -272,7 +273,7 @@ export function withArcjet(
);
}
} else {
return handler(request, ...rest);
return handler(...args);
}
};
}
23 changes: 12 additions & 11 deletions arcjet-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcjet/next",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Arcjet SDK for the Next.js framework",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "arcjet-next"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "module",
"main": "./index.js",
Expand All @@ -31,20 +32,20 @@
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
},
"dependencies": {
"@arcjet/ip": "1.0.0-alpha.2",
"@connectrpc/connect-web": "1.1.3",
"arcjet": "1.0.0-alpha.2",
"next": "14.0.3"
"@arcjet/ip": "1.0.0-alpha.3",
"@connectrpc/connect-web": "1.1.4",
"arcjet": "1.0.0-alpha.3",
"next": "14.0.4"
},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.2",
"@arcjet/rollup-config": "1.0.0-alpha.2",
"@arcjet/tsconfig": "1.0.0-alpha.2",
"@arcjet/eslint-config": "1.0.0-alpha.3",
"@arcjet/rollup-config": "1.0.0-alpha.3",
"@arcjet/tsconfig": "1.0.0-alpha.3",
"@jest/globals": "29.7.0",
"@types/node": "18.18.0",
"@rollup/wasm-node": "4.8.0",
"jest": "29.7.0",
"rollup": "4.6.1",
"typescript": "5.3.2"
"typescript": "5.3.3"
},
"publishConfig": {
"access": "public",
Expand Down
21 changes: 11 additions & 10 deletions arcjet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arcjet",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Arcjet TypeScript and JavaScript SDK core",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "arcjet"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "module",
"main": "./index.js",
Expand All @@ -31,20 +32,20 @@
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"dependencies": {
"@arcjet/analyze": "1.0.0-alpha.2",
"@arcjet/logger": "1.0.0-alpha.2",
"@arcjet/protocol": "1.0.0-alpha.2"
"@arcjet/analyze": "1.0.0-alpha.3",
"@arcjet/logger": "1.0.0-alpha.3",
"@arcjet/protocol": "1.0.0-alpha.3"
},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.2",
"@arcjet/rollup-config": "1.0.0-alpha.2",
"@arcjet/tsconfig": "1.0.0-alpha.2",
"@arcjet/eslint-config": "1.0.0-alpha.3",
"@arcjet/rollup-config": "1.0.0-alpha.3",
"@arcjet/tsconfig": "1.0.0-alpha.3",
"@edge-runtime/jest-environment": "2.3.7",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.8.0",
"@types/node": "18.18.0",
"jest": "29.7.0",
"rollup": "4.6.1",
"typescript": "5.3.2"
"typescript": "5.3.3"
},
"publishConfig": {
"access": "public",
Expand Down
11 changes: 6 additions & 5 deletions eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcjet/eslint-config",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Custom eslint config for Arcjet projects",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "eslint-config"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "commonjs",
"main": "./index.js",
Expand All @@ -24,11 +25,11 @@
"lint": "eslint ."
},
"dependencies": {
"eslint-config-next": "14.0.3",
"eslint-config-next": "14.0.4",
"eslint-config-prettier": "9.1.0",
"eslint-config-turbo": "1.10.16",
"eslint-config-turbo": "1.11.2",
"eslint-plugin-react": "7.33.2",
"next": "14.0.3"
"next": "14.0.4"
},
"peerDependencies": {
"eslint": "^8"
Expand Down
15 changes: 8 additions & 7 deletions ip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcjet/ip",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Arcjet utilities for finding the originating IP of a request",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "ip"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "module",
"main": "./index.js",
Expand All @@ -32,14 +33,14 @@
},
"dependencies": {},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.2",
"@arcjet/rollup-config": "1.0.0-alpha.2",
"@arcjet/tsconfig": "1.0.0-alpha.2",
"@arcjet/eslint-config": "1.0.0-alpha.3",
"@arcjet/rollup-config": "1.0.0-alpha.3",
"@arcjet/tsconfig": "1.0.0-alpha.3",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.8.0",
"@types/node": "18.18.0",
"jest": "29.7.0",
"rollup": "4.6.1",
"typescript": "5.3.2"
"typescript": "5.3.3"
},
"publishConfig": {
"access": "public",
Expand Down
15 changes: 8 additions & 7 deletions logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcjet/logger",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Arcjet logging interface which mirrors the console interface but allows log levels",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
Expand All @@ -10,7 +10,8 @@
"directory": "logger"
},
"engines": {
"node": ">=18"
"node": ">=18",
"npm": ">=10"
},
"type": "module",
"main": "./index.js",
Expand All @@ -32,14 +33,14 @@
},
"dependencies": {},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.2",
"@arcjet/rollup-config": "1.0.0-alpha.2",
"@arcjet/tsconfig": "1.0.0-alpha.2",
"@arcjet/eslint-config": "1.0.0-alpha.3",
"@arcjet/rollup-config": "1.0.0-alpha.3",
"@arcjet/tsconfig": "1.0.0-alpha.3",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.8.0",
"@types/node": "18.18.0",
"jest": "29.7.0",
"rollup": "4.6.1",
"typescript": "5.3.2"
"typescript": "5.3.3"
},
"publishConfig": {
"access": "public",
Expand Down
Loading

0 comments on commit 1b5b9ec

Please sign in to comment.