generated from nichoth/template-ts-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,92 @@ | ||
# ailuropoda | ||
|
||
Implementing bamboo. | ||
Implementing [bamboo](https://github.com/AljoschaMeyer/bamboo), using only browser compatible cryptography. | ||
|
||
## install | ||
|
||
```sh | ||
npm i -S @bicycle-codes/ailuropoda | ||
``` | ||
|
||
## use | ||
|
||
```js | ||
import { | ||
create as createMsg, | ||
SignedPost, | ||
lipmaaLink, | ||
createBatch, | ||
getLipmaaPath, | ||
isValid, | ||
verifyLipmaas | ||
} from '@bicycle-codes/ailuropoda' | ||
``` | ||
|
||
## example | ||
|
||
Use the function `createBatch` to create a list with lipmaa links. | ||
|
||
See [the diagram](https://github.com/AljoschaMeyer/bamboo?tab=readme-ov-file#links-and-entry-verification) of the list structure. | ||
|
||
```ts | ||
import { Identity, create as createID } from '@bicycle-codes/identity' | ||
import { createCryptoComponent } from '@ssc-half-light/node-components' | ||
import { createBatch } from '@bicycle-codes/ailuropoda' | ||
|
||
const alicesCrytpo = await createCryptoComponent() | ||
const alice = await createID(alicesCrytpo, { | ||
humanName: 'alice', | ||
humanReadableDeviceName: 'computer' | ||
}) | ||
|
||
const newMsgs = [ | ||
{ content: { text: 'hello 1' } }, | ||
{ content: { text: 'hello 2' } }, | ||
{ content: { text: 'hello 3' } }, | ||
{ content: { text: 'hello 4' } }, | ||
{ content: { text: 'hello 5' } } | ||
] | ||
|
||
const list = await createBatch(alice, alicesCrytpo, { | ||
// we are just using an in-memory array of messages | ||
getKeyFromIndex: async (i:number, msgs:SignedPost[]) => { | ||
const msg = msgs[i] | ||
if (!msg) return null | ||
return msg.metadata.key | ||
} | ||
}, newMsgs) // pass in a list with message content | ||
``` | ||
|
||
## API | ||
|
||
### create | ||
Create a message. | ||
|
||
```ts | ||
async function create ( | ||
user:Identity, | ||
crypto:Implementation, | ||
opts:{ | ||
content:Content, | ||
limpaalink?:string|null, // <-- the key of the lipmaa message | ||
seq:number, | ||
prev:SignedPost|null|undefined, | ||
} | ||
):Promise<SignedPost> | ||
``` | ||
|
||
```js | ||
import { create as createMsg } from '@bicycle-codes/ailuropoda' | ||
const post = await createMsg( | ||
alice, | ||
alicesCrytpo, | ||
{ | ||
seq: 1, | ||
prev: null, | ||
content: { | ||
text: 'hello' | ||
} | ||
} | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters