diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..301466d --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,52 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: GitHub Pages deploy + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Install + run: npm install + - name: Build + run: npm run build-docs + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/ + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 2d229d6..c026f67 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist .env public .partykit/ +docs diff --git a/README.md b/README.md index 4839c2b..de9176e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,19 @@ [![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver&style=flat-square)](https://semver.org/) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -Link multiple devices via websocket. +Link multiple devices via websocket. Linking means that both devices share the +same AES key. -This depends on each device having a [keystore](https://github.com/fission-codes/keystore-idb) that stores the private keys. Also, you need a websocket server, for example [partykit](https://www.partykit.io/). +This depends on each device having a [keystore](https://github.com/fission-codes/keystore-idb) that stores the private keys. Also, you need a websocket server, +for example [partykit](https://www.partykit.io/). + +We have two devices, a parent and a child. To securely send an AES key to +another device, the parent first opens a websocket connection at a random URL. +The URL for the websocket needs to be transmitted out-of-band. + +When the new device (the child) connects to the websocket, it tells the parent +its public key. The parent then encrypts its AES key to the child's public key. +The child gets the key, which it is able to decrypt with its private key. ## install diff --git a/package.json b/package.json index cd1bc59..0b29879 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "build-cjs": "esbuild src/*.ts --format=cjs --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.cjs --sourcemap=inline", "build-esm": "tsc --project tsconfig.build.json", "build": "mkdir -p ./dist && rm -rf ./dist/* && npm run build-cjs && npm run build-esm", + "build-docs": "typedoc ./src/index.ts", "start": "concurrently --kill-others \"npx partykit dev\" \"npx vite\"", "preversion": "npm run lint", "version": "auto-changelog -p --template keepachangelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md", @@ -73,6 +74,7 @@ "preact": "^10.20.2", "tap-spec": "^5.0.0", "tape-run": "^11.0.0", + "typedoc": "^0.25.13", "typescript": "^5.4.4", "vite": "^5.2.10" }, diff --git a/src/index.ts b/src/index.ts index 206f75a..a14b4eb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,6 @@ export type Certificate = Awaited< * @param {Identity} identity The existing identity * @param {Crypto} oddCrypto A Crypto implementation from `odd` * @param {Object} opts Host, crypto, and a code for the websocket - * @param {Crypto} opts.oddCrypto An instance of odd crypto * @param {string} opts.host The address for your websocket * @param {string} opts.code A unique ID for the websocket connection. Should * be transmitted out of band to the new device.