mirror of
https://github.com/aljazceru/pubky-core.git
synced 2026-01-05 07:14:28 +01:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import test from 'tape'
|
|
|
|
import { PubkyClient, Keypair, PublicKey } from '../index.js'
|
|
|
|
test('public: put/get', async (t) => {
|
|
const client = new PubkyClient();
|
|
|
|
const keypair = Keypair.random();
|
|
|
|
const homeserver = PublicKey.from('8pinxxgqs41n4aididenw5apqp1urfmzdztr8jt4abrkdn435ewo');
|
|
await client.signup(keypair, homeserver);
|
|
|
|
const publicKey = keypair.public_key();
|
|
|
|
const body = Buffer.from(JSON.stringify({ foo: 'bar' }))
|
|
|
|
// PUT public data, by authorized client
|
|
await client.put(publicKey, "/pub/example.com/arbitrary", body);
|
|
|
|
|
|
// GET public data without signup or signin
|
|
{
|
|
const client = new PubkyClient();
|
|
|
|
let response = await client.get(publicKey, "/pub/example.com/arbitrary");
|
|
|
|
t.ok(Buffer.from(response).equals(body))
|
|
}
|
|
|
|
// // DELETE public data, by authorized client
|
|
// await client.delete(publicKey, "/pub/example.com/arbitrary");
|
|
//
|
|
//
|
|
// // GET public data without signup or signin
|
|
// {
|
|
// const client = new PubkyClient();
|
|
//
|
|
// let response = await client.get(publicKey, "/pub/example.com/arbitrary");
|
|
//
|
|
// t.notOk(response)
|
|
// }
|
|
})
|
|
|
|
test.skip("not found")
|
|
|
|
test.skip("unauthorized")
|