Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: |
package-lock.json
docs/package-lock.json

- name: Install clean packages
run: npm clean-install
Expand All @@ -55,6 +58,14 @@ jobs:
- name: Build
run: npm run build

- name: Build and verify the Developer Portal
if: matrix.node-version == '24'
working-directory: docs
run: |
npm ci
npm run build:site
npm run typecheck

- name: Verify SDK distribution
run: npm run check:sdk-dist

Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: |
package-lock.json
docs/package-lock.json

- name: Install clean packages
run: npm clean-install

- name: Build
run: npm run build

- name: Build the Developer Portal
working-directory: docs
run: |
npm ci
npm run build:site
npm run typecheck

- name: Check new SDK artifacts and retain published versions
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -105,6 +115,7 @@ jobs:
run: |
test -s dist/index.html || { echo "::error::dist/index.html is missing"; exit 1; }
test -s dist/decodebox.html || { echo "::error::dist/decodebox.html is missing - the download button would 404"; exit 1; }
test -s dist/docs/index.html || { echo "::error::dist/docs/index.html is missing"; exit 1; }
# The application must never call out to a third party at runtime. This is a
# coarse check, but it catches an accidental CDN reference before it ships.
if grep -rIloE 'https?://(cdn|unpkg|jsdelivr)' dist --include='*.js' --include='*.html' | head -1 | grep -q .; then
Expand Down Expand Up @@ -173,14 +184,19 @@ jobs:
# that finishes does the CDN start serving the new files. It usually
# takes a minute; it has taken twenty. Eight attempts over 160 seconds
# was calling that a failure, which is a check that cries wolf.
docs_url="${url%/}/docs/"
docs_body=$(mktemp)
trap 'rm -f "$docs_body"' EXIT
for attempt in $(seq 1 24); do
body=$(curl -fsSL --max-time 30 "$url" || true)
case "$body" in
*"$entry"*)
echo "$url is serving this build."
npm run check:sdk-dist -- dist "$url"
node scripts/check-sdk-browser.mjs "${url%/}/"
exit 0
if curl -fsSL --max-time 30 "$docs_url" -o "$docs_body" && cmp -s dist/docs/index.html "$docs_body"; then
echo "$url and $docs_url are serving this build."
npm run check:sdk-dist -- dist "$url"
node scripts/check-sdk-browser.mjs "${url%/}/"
exit 0
fi
;;
*src/app/main.tsx*)
# This one never resolves itself: it means Pages is pointed at
Expand All @@ -189,8 +205,8 @@ jobs:
exit 1
;;
esac
echo "Attempt $attempt/24: $url is not serving $entry yet."
echo "Attempt $attempt/24: the application and Developer Portal are not both serving this build yet."
sleep 20
done
echo "::error::$url did not serve $entry within eight minutes. gh-pages has the build - check whether GitHub's own 'pages build and deployment' run is still queued, and re-run this job once it has finished."
echo "::error::$url and $docs_url did not serve the expected build within eight minutes. gh-pages has the build - check whether GitHub's own 'pages build and deployment' run is still queued, and re-run this job once it has finished."
exit 1
6 changes: 6 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ https://groups.google.com/a/owasp.com/
# GitHub upload links (the README demo video) answer 404 to anonymous requests;
# GitHub signs them when it renders the page.
^https://github\.com/user-attachments/

# The portal build generates these references and validates their rendered links.
^file://.*/docs/content/(operations|sdk-reference)/index\.md$

# The Pages deployment verifies this URL after publishing the portal artifact.
^https://decodebox\.owasp\.org/docs/?$
32 changes: 9 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,18 @@ evidence you can inspect, and the steps that reach a layer can become an editabl
- **Capture the flag (CTF).** Search decoded layers for flag patterns, review ranked hints for
the next transformation, and copy the findings into a Markdown report.

## JavaScript SDK

Use the workbench’s operations, recipes and multilayer analysis in browsers or Java-enabled GraalJS.
**Official SDK deployment is pending.** Once published, add this snippet to an HTML page
and open the console to see `Hello`. The hosted SDK runs in the browser without a local build.

```html
<meta charset="utf-8">
<script src="https://decodebox.owasp.org/api.js"></script>
<script>
DecodeBox.ready.then(async () => {
const result = await DecodeBox.executeOperation("from-base64", "SGVsbG8=");
console.log(result); // Hello
});
</script>
```
## Documentation

The [SDK guide](docs/sdk/README.md) explains the distribution paths and versioning.
To use the SDK before deployment, follow
[local and offline setup](docs/sdk/README.md#local-development--offline-usage).
[DecodeBox Developer Portal](https://decodebox.owasp.org/docs)

## Development

Use Node.js 24, run `npm ci`, then `npm run dev`. The [development guide](docs/development.md)
covers regression tests and builds for the site, standalone application and SDK. See the
[documentation index](docs/README.md) for the project layout and API reference.
Use Node.js 24. Install dependencies and start the development server:

```bash
npm ci
npm run dev
```

## Standalone Edition

Expand All @@ -71,7 +57,7 @@ anyone with the link can read it. Report vulnerabilities privately through the

For decoding errors, include a small, non-sensitive sample, your recipe, and the expected result.
Contributions to operations should include test vectors. Follow the
[OWASP contributing guidelines](https://github.com/OWASP/.github/blob/master/CONTRIBUTING.md)
[OWASP contributing guidelines](https://raw.githubusercontent.com/OWASP/.github/master/CONTRIBUTING.md)
and [Code of Conduct](https://policy.owasp.org/operational/code-of-conduct).

## Project Leader
Expand Down
6 changes: 6 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.rspress/
.rspress-dev/
generated/
content/operations/
content/sdk-reference/
content/public/
43 changes: 35 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# DecodeBox documentation
# DecodeBox Developer Portal

Use the [workbench](https://decodebox.owasp.org/) to inspect data interactively, or embed the
same operations and analysis engine in an application.
The portal uses Rspress and is published under
[decodebox.owasp.org/docs](https://decodebox.owasp.org/docs).

- [Architecture](architecture.md) describes the workbench, worker, engine and runtime providers.
- [Development](development.md) covers local development, tests, builds and publishing.
- [JavaScript SDK](sdk/README.md) covers the hosted Quick Start, distribution paths and offline use.
- [API reference](sdk/api-reference.md) documents inputs, options, results and failure handling.
- [Integrations](sdk/integrations.md) covers browsers, TypeScript, GraalJS and ZAP.
## Local development

Use Node.js 24. From the repository root, install the application dependencies,
then start the documentation development server:

```bash
npm ci
cd docs
npm ci
npm run dev
```

Open the URL printed by Rspress at the `/docs/` path. Restart the server after
changing the SDK to regenerate the references and refresh the local SDK bundle.

## Production build

From the repository root:

```bash
npm run build
npm --prefix docs run build:site
npm run preview
```

The root build creates the application, standalone edition and official SDK.
The portal build generates SDK and operation Markdown from that SDK and places
the website under `dist/docs/`. Open `/docs/` on the Vite preview server to
preview the complete artifact with the SDK served from the same origin.

Edit the authored pages in `content/`. The build recreates the reference pages
and navigation, so changes to those belong in the SDK or generator.
24 changes: 0 additions & 24 deletions docs/architecture.md

This file was deleted.

36 changes: 36 additions & 0 deletions docs/content/guide/browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Browser integration

## Classic script

The hosted `/api.js` bundle exposes the global `DecodeBox` object. Use it with a classic script tag
and await `DecodeBox.ready` before calling the SDK.

```html
<script src="https://decodebox.owasp.org/api.js"></script>
<script type="module">
await DecodeBox.ready;
console.log(await DecodeBox.executeOperation("to-base64", "Hello")); // SGVsbG8=
</script>
```

The extensionless `/api` alias serves the same classic bundle and is used by the existing ZAP
add-on. SDK calls run in the application that loads the script.

## ES module

Import the SDK in an external module or a `<script type="module">` block.

```js
import DecodeBox from "https://decodebox.owasp.org/sdk/decodebox.mjs";

await DecodeBox.ready;
console.log(await DecodeBox.executeOperation("from-base64", "SGVsbG8=")); // Hello
```

For cross-origin module loading, the server must respond with a JavaScript MIME type and allow the
page's origin through CORS. If your site sets a Content Security Policy, permit the SDK's script
origin and load your own initialization code according to that policy. Use HTTPS or localhost for
operations that require Web Crypto.

For reproducible updates or offline use, choose a
[versioned bundle](./node.md#versioned-files-and-checksums) and serve it from your own site.
10 changes: 10 additions & 0 deletions docs/content/guide/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

The DecodeBox changelog tracks SDK and workbench changes together. GitHub releases include the
corresponding release notes and downloadable assets.

- [DecodeBox changelog](https://raw.githubusercontent.com/OWASP/DecodeBox/main/CHANGELOG.md)
- [DecodeBox releases](https://github.com/OWASP/DecodeBox/releases)

Read `DecodeBox.engineVersion` to identify the release in use. Read `DecodeBox.apiVersion` to
identify its SDK API version.
56 changes: 56 additions & 0 deletions docs/content/guide/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Examples

These examples assume you have loaded the [browser SDK](./browser.md) or imported the
[ES module](./node.md) as `DecodeBox`.

## Run one operation

`executeOperation` returns the resulting string. It rejects with a `DecodeBoxError` for invalid
input, unknown operations, execution failures, or limits.

```js
await DecodeBox.ready;
const encoded = await DecodeBox.executeOperation("to-base64", "Hello");
console.log(encoded); // SGVsbG8=
```

## Run a recipe

A recipe runs steps in sequence. Check the returned `error` field before using the output. Input
validation can also reject the call.

```js
const result = await DecodeBox.bake("Hello", [
{ opId: "to-base64" },
{ opId: "from-base64" },
]);

if (result.error) throw new Error(result.error.message);
console.log(result.output, result.durationMs); // Hello, then the elapsed time
```

## Detect a format

The detector returns candidates with a format, confidence, preview, and supporting evidence. An
empty array means it found no candidates.

```js
const candidates = await DecodeBox.detect("SGVsbG8sIHdvcmxkIQ==");
for (const { format, confidence, evidence } of candidates) {
console.log(format, confidence, evidence);
}
```

## Discover operation arguments

Use `getOperation(id)` to read the operation's argument names, types, and defaults. Use
`listOperations()` to discover the full catalogue.

```js
const operation = DecodeBox.getOperation("to-base64");
console.table(operation?.args ?? []);
```

When passing arguments to `executeOperation`, use the names from the operation metadata as keys.
Use a string, number, or boolean for a scalar argument and pass `{ value, format }` when specifying
the format of a `toggleString` argument. Omitted arguments use the SDK defaults.
16 changes: 16 additions & 0 deletions docs/content/guide/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Getting started

The OWASP DecodeBox JavaScript SDK runs the same encoding, decoding, and analysis operations as the
DecodeBox workbench. It runs in your environment and processes input locally.

- Follow the [quick start](./quick-start.md) to decode a Base64 string in your browser.
- Use the [browser integration guide](./browser.md) to load the classic script or import the ES
module.
- Use the [Node.js integration guide](./node.md) to work with a verified local bundle and TypeScript
declarations.
- See [examples](./examples.md) for recipes, format detection, and operation discovery.
- Browse the [SDK reference](../sdk-reference/index.md) and
[operation catalogue](../operations/index.md).

Use `DecodeBox.capabilities()` to see the current runtime's limits and available features. The SDK
reports its API version as `apiVersion` and the DecodeBox release version as `engineVersion`.
Loading
Loading