diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7677dac3c3..e060e8c5ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,6 +120,37 @@ jobs: - name: Test Deno run: npm run tap:deno + bun: + needs: + - build + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v3 + - run: curl https://bun.sh/install | bash + - name: Load cached dist + uses: actions/cache@v3 + id: dist + with: + path: dist + key: ${{ needs.build.outputs.cache-key }} + - name: Abort if dist isn't cached + if: ${{ steps.dist.outputs.cache-hit != 'true' }} + uses: actions/github-script@v6 + with: + script: core.setFailed('dist cache hit failed') + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: lts/hydrogen # 18 + cache: 'npm' + check-latest: true + - name: Install dependencies + run: npm clean-install + - name: Test Bun + run: npm run tap:bun + workers: needs: - build @@ -250,11 +281,12 @@ jobs: prepare-release: needs: - browsers + - bun - deno + - edge-runtime - electron - node - workers - - edge-runtime runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && github.repository == 'panva/jose' }} steps: diff --git a/.gitignore b/.gitignore index 3e215e3d0f..bf4ffa8ece 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dist-browser-tests tap/*.js tap/run-*.mjs *.bak +*.bun diff --git a/README.md b/README.md index 40d318bb44..3cac871025 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jose -> "JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, and other Web-interoperable runtimes. +> "JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes. ## Implemented specs & features @@ -83,6 +83,7 @@ import * as jose from 'https://deno.land/x/jose/index.ts' The supported JavaScript runtimes include ones that support the utilized Web API globals and standard built-in objects or are Node.js These are _(this is not an exhaustive list)_: +- [Bun](https://github.com/panva/jose/issues/471) - [Browsers](https://github.com/panva/jose/issues/263) - [Cloudflare Workers](https://github.com/panva/jose/issues/265) - [Deno](https://github.com/panva/jose/issues/266) diff --git a/package.json b/package.json index 3f1e729815..acfac1018f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "jose", "version": "4.10.4", - "description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, and other Web-interoperable runtimes", + "description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes", "keywords": [ "browser", + "bun", "cloudflare", "compact", "decode", @@ -77,6 +78,7 @@ "exports": { ".": { "types": "./dist/types/index.d.ts", + "bun": "./dist/browser/index.js", "deno": "./dist/browser/index.js", "browser": "./dist/browser/index.js", "worker": "./dist/browser/index.js", @@ -125,6 +127,7 @@ "test": "ava", "format": "prettier --loglevel silent --write ./test ./tap ./src ./tools ./cookbook", "tap:browsers": "./tap/.browsers.sh", + "tap:bun": "./tap/.bun.sh", "tap:deno": "./tap/.deno.sh", "tap:edge-runtime": "./tap/.edge-runtime.sh", "tap:electron": "./tap/.electron.sh", diff --git a/tap/.bun.sh b/tap/.bun.sh new file mode 100755 index 0000000000..123c5a83e5 --- /dev/null +++ b/tap/.bun.sh @@ -0,0 +1 @@ +~/.bun/bin/bun run tap/run-bun.ts diff --git a/tap/aes.ts b/tap/aes.ts index ec4e9c1d47..b28fb1dba2 100644 --- a/tap/aes.ts +++ b/tap/aes.ts @@ -55,6 +55,8 @@ export default (QUnit: QUnit, lib: typeof jose) => { if (works) { test(title(vector), execute) + + // TODO: https://github.com/oven-sh/bun/issues/1466 test(title(vector, 'empty cleartext'), emptyClearText) } else { test(title(vector), async (t) => { diff --git a/tap/run-bun.ts b/tap/run-bun.ts new file mode 100644 index 0000000000..3bf95a10b7 --- /dev/null +++ b/tap/run-bun.ts @@ -0,0 +1,13 @@ +import QUnit from 'qunit' +import run from './run.js' +// @ts-ignore +import * as lib from '#dist/webapi' + +const stats: QUnit.DoneDetails = await new Promise((resolve) => { + run(QUnit, lib, resolve) +}) + +if (stats?.failed !== 0) { + // @ts-ignore + process.exit(1) +}