Skip to content

Commit

Permalink
add example as text
Browse files Browse the repository at this point in the history
  • Loading branch information
nichoth committed Apr 22, 2024
1 parent a28a27b commit 25dfbd6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Connect two devices, a phone and computer, for example. They must both know `cod
```js
import { program as Program } from '@oddjs/odd'
import { create as createID } from '@bicycle-codes/identity'
import { Parent } from '@bicycle-codes/link'

const program = await Program({
namespace: {
Expand Down Expand Up @@ -63,7 +64,10 @@ const newIdentity = await Parent(myId, crypto, {

...On a different machine...

```js
```js
import { program as Program } from '@oddjs/odd'
import { Child } from '@bicycle-codes/link'

const program = await Program({
namespace: {
name: 'link-example',
Expand All @@ -81,7 +85,29 @@ const { identity, certificate } = await Child(crypto, {

Both machines now have an ID that looks like this:

![Screenshot of identity](image.png)
```js
{
"username": "vnhq32ybnanplsklhfd2cd6cdqaoeygl",
"humanName": "alice",
"rootDID": "did:key:z13V3Sog2YaU...",
"devices": {
"vnhq32ybnanplsklhfd2cd6cdqaoeygl": {
"aes": "Cj1XnlPQA35VroF...",
"name": "vnhq32ybnanplsklhfd2cd6cdqaoeygl",
"humanReadableName": "phone",
"did": "did:key:z13V3Sog2Y...",
"exchange": "MIIBIjANBgkqhkiG..."
},
"5ngvlbhsrfvpua3qnhllakwnnd2tzwzo": {
"name": "5ngvlbhsrfvpua3qnhllakwnnd2tzwzo",
"humanReadableName": "computer",
"aes": "oAbLoAtJawSbA3r2tI4BDEmb...",
"did": "did:key:z13V3Sog2YaUKhdGCmg...",
"exchange": "MIIBIjANBgkqhkiG9w0BAQEFA..."
}
}
}
```

### serverside
This depends on a websocket server existing. We provide the export
Expand Down
Binary file removed image.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "eslint \"./**/*.{ts,js}\"",
"build-tests": "esbuild test/index.ts --target=es2020 --bundle --keep-names > test/test-bundle.js",
"test": "npm run lint && npm run build && npm run build-tests && npm run test-tape-run",
"test-tape-run": "concurrently --kill-others \"npx partykit dev\" \"cat test/index.html | npx tape-run --input=html --static=test | npx tap-spec\"",
"test-tape-run": "concurrently --kill-signal=SIGINT --kill-others \"npx partykit dev\" \"cat test/index.html | npx tape-run --input=html --static=test | npx tap-spec\"",
"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",
Expand Down

0 comments on commit 25dfbd6

Please sign in to comment.