Skip to content

Commit

Permalink
feat: add bun as a supported runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 8, 2022
1 parent 9f10dbd commit 3a63631
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 3 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dist-browser-tests
tap/*.js
tap/run-*.mjs
*.bak
*.bun
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tap/.bun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~/.bun/bin/bun run tap/run-bun.ts
2 changes: 2 additions & 0 deletions tap/aes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
13 changes: 13 additions & 0 deletions tap/run-bun.ts
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 3a63631

Please sign in to comment.