0.7.0 • Published 11 months ago
@ssc-hermes/post v0.7.0
post
Create in-memory post objects. This does not handle persistence.
install
npm i -S @ssc-hermes/post
example
You need to supply a Fission Crypto
object, the hash of the previous message, the sequence of the current message, and the post content.
create
import { create } from '@ssc-hermes/post'
import { WnfsPost } from '@ssc-hermes/wnfs-post'
const wn = self.oddjs // `@oddjs/odd` is attached to `window` here
const wnfsPost = await WnfsPost.create(wn, { name: 'testing', creator: 'test' })
const file:File = document.querySelector('.file-input').files[0]
const post = await create(wnfsPost.crypto, file, {
seq: 0,
prev: null, // `prev` should be a hash of the previous message
text: 'a test post',
username: wnfsPost.username,
alt: 'testing'
})
// => {
// author: string,
// seq: number,
// prev: string|null,
// username: string,
// content: { type:string, text:string, alt:string, mentions: string[] }
// timestamp: number,
// signature: string
// }
// now do something with the post, and save the `file` somewhere.
// `mentions` is an array containing the hash of the file passed in
getId
Get a URL-safe hash of this post.
import { getId } from '@ssc-hermes/post'
const id = getId(post)
// 5olZOzr5xalmGXTxATl4Ldt4V0Z2Z8OrD3KxLTj-ngU
0.7.0
11 months ago
0.6.2
12 months ago
0.6.1
12 months ago
0.6.0
12 months ago
0.5.0
12 months ago
0.4.1
12 months ago
0.4.0
12 months ago
0.3.1
12 months ago
0.3.0
12 months ago
0.2.2
12 months ago
0.2.1
12 months ago
0.2.0
12 months ago
0.1.0
12 months ago
0.0.4
12 months ago
0.0.3
12 months ago
0.0.2
12 months ago
0.0.1
12 months ago