Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: blaine-arcjet <[email protected]>
  • Loading branch information
e-moran and blaine-arcjet authored Dec 13, 2024
1 parent ad66203 commit fb35216
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"skip-github-release": true
},
"analyze-wasm": {
"component": "@arcjet/analyze",
"component": "@arcjet/analyze-wasm",
"skip-github-release": true
},
"arcjet": {
Expand Down
8 changes: 4 additions & 4 deletions analyze-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<p>
<a href="https://www.npmjs.com/package/@arcjet/analyze-wasm">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fanalyze?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fanalyze-wasm?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fanalyze-wasm?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
Expand All @@ -20,7 +20,7 @@
code. Implement rate limiting, bot protection, email verification, and defense
against common attacks.

This is the [Arcjet][arcjet] local analysis engine WASM bindings
This package provides WebAssembly bindings to [Arcjet's][arcjet] local analysis engine.

## Installation

Expand All @@ -31,9 +31,9 @@ npm install -S @arcjet/analyze-wasm
## Implementation

This package provides analyze logic implemented as a WebAssembly module which
will run local analysis on request details before calling the Arcjet API.
will run local analysis on request details.

The [arcjet.wasm.js](./wasm/arcjet.wasm.js) file contains the binary inlined as
The `_virtual/arcjet_analyze_js_req.component.core.js` file contains the binary inlined as
a base64 [Data URL][mdn-data-url] with the `application/wasm` MIME type.

This was chosen to save on storage space over inlining the file directly as a
Expand Down
1 change: 0 additions & 1 deletion analyze-wasm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ interface AnalyzeContext {
type DetectSensitiveInfoFunction =
typeof ArcjetJsReqSensitiveInformationIdentifier.detect;

// TODO: Do we actually need this wasmCache or does `import` cache correctly?
const wasmCache = new Map<string, WebAssembly.Module>();

async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
Expand Down
7 changes: 3 additions & 4 deletions analyze-wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@arcjet/analyze-wasm",
"version": "1.0.0-alpha.34",
"description": "Arcjet local analysis engine",
"description": "WebAssembly bindings to Arcjet's local analysis engine",
"license": "Apache-2.0",
"homepage": "https://arcjet.com",
"repository": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"build": "npm run jco; rollup --config rollup.config.js",
"lint": "eslint .",
"pretest": "npm run build",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
"test": "node --test"
},
"dependencies": {
"@arcjet/protocol": "1.0.0-alpha.27"
Expand All @@ -55,10 +55,9 @@
"@arcjet/rollup-config": "1.0.0-alpha.27",
"@arcjet/tsconfig": "1.0.0-alpha.27",
"@bytecodealliance/jco": "1.5.0",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.23.0",
"@types/node": "18.18.0",
"jest": "29.7.0",
"expect": "29.7.0",
"typescript": "5.6.2"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion analyze/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ console.log("is email valid?", valid);

## Implementation

This package uses the wasm bindings provided by `@arcjet/analyze-wasm` to
This package uses the Wasm bindings provided by `@arcjet/analyze-wasm` to
call various functions that are exported by our wasm bindings.

We chose to put this logic in a separate package because we need to change the
Expand Down

0 comments on commit fb35216

Please sign in to comment.