@synonymdev/react-native-pubky

0.4.0 • Public • Published

react-native-pubky

React Native implementation of pubky

Installation

npm install @synonymdev/react-native-pubky

Implementation Status

Implemented Methods

  • [x] auth: Authentication functionality.
  • [x] parseAuthUrl: Method to decode an authUrl.
  • [x] publish: Functionality to publish content.
  • [x] resolve: Functionality to resolve content.

Methods to be Implemented

  • [ ] signIn: Sign-in to a homeserver.
  • [ ] signUp: Sign-up to a homeserver and update Pkarr accordingly.
  • [ ] signOut: Sign-out from a homeserver.
  • [ ] put: Upload a small payload to a given path.
  • [ ] get: Download a small payload from a given path relative to a pubky author.

Usage

Auth

import { auth } from '@synonymdev/react-native-pubky';

const authRes = await auth(
  'pubkyauth:///?caps=/pub/pubky.app/:rw,/pub/foo.bar/file:r&secret=U55XnoH6vsMCpx1pxHtt8fReVg4Brvu9C0gUBuw-Jkw&relay=http://167.86.102.121:4173/',
  'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
);
if (authRes.isErr()) {
  console.log(authRes.error.message);
  return;
}
console.log(authRes.value);

parseAuthUrl

import { parseAuthUrl } from '@synonymdev/react-native-pubky';

const pubkyAuthUrl = 'pubkyauth:///?relay=https://demo.httprelay.io/link&capabilities=/pub/pubky.app:rw,/pub/example.com/nested:rw&secret=FyzJ3gJ1W7boyFZC1Do9fYrRmDNgCLNRwEu_gaBgPUA';
const parseRes = await parseAuthUrl(pubkyAuthUrl);
if (parseRes.isErr()) {
  console.log(parseRes.error.message);
  return;
}
console.log(parseRes.value);

publish

import { publish } from '@synonymdev/react-native-pubky';

const publishRes = await publish(
  'recordnametest',
  'recordcontenttest',
  'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
);
if (publishRes.isErr()) {
  console.log(publishRes.error.message);
  return;
}
console.log(publishRes.value);

resolve

import { resolve } from '@synonymdev/react-native-pubky';

const resolveRes = await resolve(
  'z4e8s17cou9qmuwen8p1556jzhf1wktmzo6ijsfnri9c4hnrdfty'
);
if (resolveRes.isErr()) {
  console.log(resolveRes.error.message);
  return;
}
console.log(resolveRes.value);

Local Installation

  1. Clone & npm install:
git clone git@github.com:pubky/react-native-pubky.git && cd react-native-pubky && npm i
  1. Delete the rust/pubky directory to prevent a memory error (This step will be removed once pubky is public).
  2. Yarn add it to your project:
yarn add path/to/react-native-pubky

Update Bindings

After making changes to any of the Rust files, the bindings will need to be updated. To do this, run the following command:

npm run update-bindings

Finally, ensure that PubkyModule.kt, Pubky.swift, Pubky.mm & src/index.tsx are updated accordingly based on the changes made to the Rust files.

License

MIT


Resources

Package Sidebar

Install

npm i @synonymdev/react-native-pubky

Weekly Downloads

40

Version

0.4.0

License

MIT

Unpacked Size

189 MB

Total Files

41

Last publish

Collaborators

  • jools.weedcoder
  • thisispav
  • shacollision
  • flaviomoceri
  • amirramfa
  • tipogi
  • limpbrains
  • catch-21
  • dzdidi_restored
  • pwltr
  • miguelmedeirosweb
  • bitcoinerrorlog
  • jayvdb
  • coreyphillips
  • nzh