Code Monkey home page Code Monkey logo

js-textile's Introduction

DEPRECATION NOTICE: Textile's hosted Hub infrastructure will be taken off-line on January 9th, 2023. At this time, all ThreadDB and Bucket data will no longer be available, and will subsequently be removed. See textileio/textile#578 for further details.

JS-Textile

Made by Textile Chat on Slack GitHub license Tests Review Docs

Typescript/Javascript libs for interacting with Textile APIs.

Go to the docs for more about Textile.

Join us on our public Discord server for news, discussions, and status updates.

Table of Contents

Install

npm install @textile/hub

Usage

We are shutting down our hosted Hub infrastructure. Please see this deprecation notice for details.

@textile/hub provides access to Textile APIs in apps based on API Keys. For details on getting keys, see textileio/textile or join our Discord.

Contributing

This project is no longer under active development. If you'd like to get something change/fixed/updated, here are some ways to make that happen:

  • Ask questions! We'll try to help. Be sure to drop a note (on the above issue) if there is anything you'd like to work on and we'll update the issue to let others know. Also get in touch on Slack.
  • Open issues, file issues, submit pull requests!
  • Perform code reviews. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
  • Take a look at the code. Contributions here that would be most helpful are top-level comments about how it should look based on your understanding. Again, the more eyes the better.
  • Add tests. There can never be enough tests.

Building docs

On mac, docs require gnu-sed.

brew install gnu-sed

Follow brew info gnu-sed instructions to make it default sed.

Install Docusaurus

cd website
npm install
cd ..

Update markdown

npm run docs

Run docs server

npm run serve:docs

Changelog

Changelog is published to Releases.

License

MIT

js-textile's People

Contributors

andrewxhill avatar asutula avatar carsonfarmer avatar deefactorial avatar dependabot-preview[bot] avatar dependabot[bot] avatar eightysteele avatar sanderpick avatar theefer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

js-textile's Issues

JS Threads: Thread Store

A threadstore is a collection of books for storing threads. A client needs a store to keep track of threads and logs to 'follow'. Even a client without write capabilities will need a store. This is a good starting place for developing Textile's threads protocol in Typescript/Javascript.

Requires

  • KeyBook
  • AddrBook
  • ThreadMetadata
  • HeadBook

https://github.com/textileio/go-textile-threads/blob/master/threadstore.go and https://github.com/textileio/go-textile-core/blob/master/threadstore/threadstore.go provides most of the prior art required to implement this. We also have https://github.com/textileio/go-textile-threads/tree/master/tstoreds which provides a good example of a datastore backed version.

Update types for Users API to v1.0.2

GetThreadReply now contains an isDB boolean, this should also be tested for.

message GetThreadReply {
    bytes ID = 1;
    string name = 2;
    bool isDB = 3;
}

Documentation for Context

Stealing some nice explanatory ideas from @andrewxhill ๐Ÿ‘

Context [...] allows you to shift what role you are using to hit the APIs. This is interesting because your app can use an API as you, the developer, with all your capabilities. or as Users of your app, which are sandboxed but can create threads/buckets of their own in that sandbox.

User token with the react-todo example

I am attempting to get the react-todo example running. I realized that it has a hardcoded token. What code do I need to add to get this example to work?

I have the CLI setup and have created account and user keys but I am not sure what to do next.

Make Context's mutable

It seems the 'overwrite' style usage of the Context API isn't very intuitive, so it would be a good idea to fix this. An obvious easier paths to make the Context mutate in place. This would also open up the door to 'hiding' this a bit more easily, as it isn't a pattern JS devs are familiar with.

Unable to access 'Files' collection

In the react-filebox example, the add_file action somehow is not able to get the Files collection, hence throwing the Unable to access 'Files' collection error.

port

grpc-web-client.umd.js:1 WebSocket connection to 'ws://127.0.0.1:6007/api.pb.API/NewStore' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Remove /examples folder

  • It's currently out of date
  • It seems the plan is to move all examples to textileio/js-examples

Outline steps to a js-textile implementation

Recent activity in Textileโ€™s public Slack channel, as well as external discussions with developers and other stakeholders has indicated an strong interest in having a Textile Javascript API. The specifics of such an API have yet to be established, but the general consensus is that one is needed to help support things like browser-based Textile apps, Node.js apps, and other use-cases. In this issue, we will outline some minimal requirements, and suggested โ€˜stepsโ€™ required to have a full-blown js-textile implementation.

Ideal Scenario

Ideally, we would have a single code-base that supports all necessary platforms (mobile, desktop/server, and browsers). This is currently almost possible thanks to various tools for cross-compiling Go code. On mobile Textile currently uses gomobile to build iOS and Android frameworks. On desktop/server, binaries are compiled using Goโ€™s built-in build tools and xgo. For browser support, Go now supports targeting WASM, and there has been some progress on the IPFS side of things. However, this is a) producing extremely large bundles, and b) not stable enough to actually for much of anything. Clearly this is a useful future target to track.

Reasonable First Steps

To get a working Textile Javascript implementation working sooner rather than later, some incremental steps are likely required, as a full blown Javascript port would be a major undertaking. For example, most of the packages outside of core are likely pretty easy to port to Javascript, but the core textile package is large, complex, and full of custom transport, service, and communication implementations. It would likely require a great deal of support from the core Textile developers. As such, the following outlines a way forward towards a full port, with the full port a very last step.

Step 1

js-textile-http-client

The first step, and one that is already underway along multiple fronts, is a โ€˜simpleโ€™ Textile JS HTTP Wrapper Client. This would provide access to an underlying textile-go nodeโ€™s REST API, adding various simplified APIs to support in-browser and programmatic desktop access. For the most part, the API would mimic the command-line and/or mobile APIs, with some browser-specific enhancements. Right now, this is the focus on the Textile JS efforts.

Step 2

js-textile

Phase 1

Given the steps involved in fulfilling Schemas and adding data to Threads, including the various communication protocols involved, a good next step would be to implement a light Textile client that supports data access only. This light client would likely start by supporting the following functionality:

  • Wallet init and account generation
  • Some minimal keypair tooling for secure storage of secrets
  • Wrap a js-ipfs peer (as we do in textile-go) for fetching data
  • Crypto and Protobuf tools for data extraction and minimal hash tree parsing

Essentially, the client would be able to access existing Textile data given a File hash or Thread id (this might be slightly harder). This would be useful for creating โ€˜publicโ€™ Textile Photos viewers, sharing data with non-Textile users, and other use-cases where encrypted data in Threads is needed. It would not support adding data to Textile/IPFS, nor would it support a full-blown peer with Thread updates, backup, p2p communications, etc.

Phase 2

As a quick โ€˜follow-onโ€™ to Step 2, we could facilitate building a Textile Javascript client that supports interacting with remote Cafes. Cafes provide http- and p2p-based access to most of the functionality that a Textile peer would need to participate fully in the Textile network. This means, some operations (wallet + account init, encryption/decryption, IPFS fetching, etc) could be done entirely locally based on work in Step 2, and others (thread updates and interactions, p2p messaging, thread and message outboxing/inboxing) could be done via Cafe REST and p2p APIs as part of work done in Step 3. This would still require extensive core Textile developer input/time, but would be significantly simpler than a full-blown Textile Javascript implementation, and would pave the way for Step 4, which would then incrementally move the remaining โ€˜remoteโ€™ pieces to local Javascript ports. The idea here would be to have something that supports almost everything a developer building on top of Textile could want in the browser, faster, and without many of the security considerations required from a full-blown Textile Javascript SDK.

Phase 3 (full implementation)

Full blown Textile Javascript node. Would require either a full Javascript port, or some sort of cross-compiling magic. This is likely a long ways off, and would require significant core developer time. Luckily, if we โ€˜tickโ€™ all the boxes in the previous steps, this should really just be porting over core Textile code from Go. Again, doing things incrementally like this means we can have a mostly full-blown Textile node in Javascript, and slowly port over additional pieces as it makes sense.
Specific deliverables here would include code parity with textile-go.

'Context' only refers to a type, but is being used as a value here.

Getting this in nodejs

import {Context} from '@textile/textile';
...
const ctx = new Context();

Screen Shot 2020-05-22 at 2 06 57 PM

just using the default tsconfig

{
  "compilerOptions": {
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "skipLibCheck": true,                     /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */
  }
}

JS IPFS Lite

A viable Textile Threads implementation in Javascript requires (at a minimum) Thread reading capabilities. This could be mostly done anonymously to begin with, and would therefore only require a minimal IPFS/Textile client. To accomplish this, we would need the equivalent of ipfs-lite in Javascript. This Epic will be used to track progress on this project.

This will likely be a one-sprint Epic. The prior-art is already there, so the biggest challenge is creating the types, putting the components together, and then finishing the actual ipfs-lite implementation.

Support multiple forms of input files

Since this is meant to be an isomorphic library, we'll need to support things like Buffer, ReadableStreams, AsyncIterators, etc as inputs to Buckets push APIs.

Write to a thread

What would it take to write to a thread from js-textile land? This seems like a good first step since most JS applications won't keep a full account history. So, let's assume you've got a wallet account with a thread snapshot out on the network somewhere. To simply write a text message to that thread, you'd have to:

  1. Find the thread snapshot with the account address (perform a gossipsub search)
  2. From the snapshot, find the thread peers (this is really gonna require textileio/go-textile#538)
  3. From latest HEAD given by the snapshot, add a JOIN using our protobufjs lib, serialize it, and send it to each peer. (this will ideally be done w/ gossipsub, see textileio/go-textile#567)
  4. Same a 3, but this time add a TEXT with the message as body.
  5. See the message arrive on iOS, Android, CLI, Desktop
  6. Celebrate! (I really would)

cc @carsonfarmer @Gozala

Weekly Digest (12 May, 2020 - 19 May, 2020)

Here's the Weekly Digest for textileio/js-textile:


ISSUES

Last week 27 issues were created.
Of these, 21 issues have been closed and 6 issues are still open.

OPEN ISSUES

๐Ÿ’š #170 build(deps): bump google-protobuf from 3.11.4 to 3.12.0, by dependabot-preview[bot]
๐Ÿ’š #169 build(deps-dev): bump typedoc from 0.17.6 to 0.17.7, by dependabot-preview[bot]
๐Ÿ’š #159 build(deps-dev): bump typescript from 3.8.3 to 3.9.2, by dependabot-preview[bot]
๐Ÿ’š #157 Proposed simplification of users APIs, by carsonfarmer
๐Ÿ’š #156 Wrap a createThread method into the User API, by carsonfarmer
๐Ÿ’š #155 Export Threads Client from here, by carsonfarmer

CLOSED ISSUES

โค๏ธ #168 chore(deps): keeping close to all new threads releases, by andrewxhill
โค๏ธ #167 build(deps-dev): bump @textile/threads-core from 0.1.8 to 0.1.9, by dependabot-preview[bot]
โค๏ธ #166 build(deps): bump @textile/threads-client from 0.3.2 to 0.3.3, by dependabot-preview[bot]
โค๏ธ #165 build(deps): bump @textile/context from 0.2.1 to 0.2.2, by dependabot-preview[bot]
โค๏ธ #164 build(deps): bump @textile/threads-id from 0.0.6 to 0.0.7, by dependabot-preview[bot]
โค๏ธ #163 chore(deps): update latest threads and grpc libs, by andrewxhill
โค๏ธ #162 build(deps-dev): bump @typescript-eslint/parser from 2.31.0 to 2.33.0, by dependabot-preview[bot]
โค๏ธ #161 build(deps-dev): bump @typescript-eslint/eslint-plugin from 2.31.0 to 2.33.0, by dependabot-preview[bot]
โค๏ธ #160 build(deps-dev): bump @textile/threads-core from 0.1.6 to 0.1.7, by dependabot-preview[bot]
โค๏ธ #158 chore(deps): update textile libs w/ new fixes, by andrewxhill
โค๏ธ #154 Fully isolate user context, by carsonfarmer
โค๏ธ #153 fix(ci): dont attempt review step on merge to master, by andrewxhill
โค๏ธ #152 fix(exports): add context back, by andrewxhill
โค๏ธ #151 chore(deps): adds external context dep, by andrewxhill
โค๏ธ #150 chore(deps): adds external context dep, by andrewxhill
โค๏ธ #149 build(deps-dev): bump @typescript-eslint/eslint-plugin from 2.31.0 to 2.32.0, by dependabot-preview[bot]
โค๏ธ #148 build(deps-dev): bump @typescript-eslint/parser from 2.31.0 to 2.32.0, by dependabot-preview[bot]
โค๏ธ #147 build(deps-dev): bump ts-loader from 7.0.2 to 7.0.4, by dependabot-preview[bot]
โค๏ธ #146 build(deps-dev): bump @textile/threads-core from 0.1.5 to 0.1.6, by dependabot-preview[bot]
โค๏ธ #145 build(deps): bump @textile/threads-id from 0.0.3 to 0.0.4, by dependabot-preview[bot]
โค๏ธ #144 build(deps): bump @textile/threads-client from 0.3.0-rc.0 to 0.3.0, by dependabot-preview[bot]

NOISY ISSUE

๐Ÿ”ˆ #151 chore(deps): adds external context dep, by andrewxhill
It received 7 comments.


PULL REQUESTS

Last week, 12 pull requests were created, updated or merged.

UPDATED PULL REQUEST

Last week, 4 pull requests were updated.
๐Ÿ’› #170 build(deps): bump google-protobuf from 3.11.4 to 3.12.0, by dependabot-preview[bot]
๐Ÿ’› #169 build(deps-dev): bump typedoc from 0.17.6 to 0.17.7, by dependabot-preview[bot]
๐Ÿ’› #159 build(deps-dev): bump typescript from 3.8.3 to 3.9.2, by dependabot-preview[bot]
๐Ÿ’› #157 Proposed simplification of users APIs, by carsonfarmer

MERGED PULL REQUEST

Last week, 8 pull requests were merged.
๐Ÿ’œ #168 chore(deps): keeping close to all new threads releases, by andrewxhill
๐Ÿ’œ #163 chore(deps): update latest threads and grpc libs, by andrewxhill
๐Ÿ’œ #158 chore(deps): update textile libs w/ new fixes, by andrewxhill
๐Ÿ’œ #154 Fully isolate user context, by carsonfarmer
๐Ÿ’œ #153 fix(ci): dont attempt review step on merge to master, by andrewxhill
๐Ÿ’œ #152 fix(exports): add context back, by andrewxhill
๐Ÿ’œ #151 chore(deps): adds external context dep, by andrewxhill
๐Ÿ’œ #147 build(deps-dev): bump ts-loader from 7.0.2 to 7.0.4, by dependabot-preview[bot]


COMMITS

Last week there were 19 commits.
๐Ÿ› ๏ธ Merge pull request #168 from textileio/andrew/keeping-it-tight chore(deps): keeping close to all new threads releases by andrewxhill
๐Ÿ› ๏ธ fix(deps): upgrade client Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ fix(deps): add version flex Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ chore(deps): keeping close to all new threads releases Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ Merge pull request #163 from textileio/andrew/dependency-roundup chore(deps): update latest threads and grpc libs by andrewxhill
๐Ÿ› ๏ธ chore(deps): update latest threads and grpc libs Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ Merge pull request #158 from textileio/andrew/add-context-fixes chore(deps): update textile libs w/ new fixes by andrewxhill
๐Ÿ› ๏ธ chore(deps): update textile libs w/ new fixes Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ Merge pull request #154 from textileio/carson/isolate-user Fully isolate user context by carsonfarmer
๐Ÿ› ๏ธ test: fully isolate user context Signed-off-by: Carson Farmer [email protected] by carsonfarmer
๐Ÿ› ๏ธ Merge pull request #153 from textileio/andrew/fix-review-steps fix(ci): dont attempt review step on merge to master by andrewxhill
๐Ÿ› ๏ธ fix(ci): dont attempt review step on merge to master Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ Merge pull request #152 from textileio/andrew/include-context-in-exports fix(exports): add context back by andrewxhill
๐Ÿ› ๏ธ build(deps-dev): bump ts-loader from 7.0.2 to 7.0.4 Bumps ts-loader from 7.0.2 to 7.0.4. - Release notes - Changelog - Commits Signed-off-by: dependabot-preview[bot] [email protected] by dependabot-preview[bot]
๐Ÿ› ๏ธ fix(exports): add context back Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ Merge pull request #151 from textileio/andrew/update-new-context-api2 chore(deps): adds external context dep by andrewxhill
๐Ÿ› ๏ธ chore: cleanup context usage and fix unwanted mutations Signed-off-by: Carson Farmer [email protected] by carsonfarmer
๐Ÿ› ๏ธ chore(deps): adds external context dep Signed-off-by: andrew [email protected] by andrewxhill
๐Ÿ› ๏ธ fix(deps): adds loglevel Signed-off-by: andrew [email protected] by andrewxhill


CONTRIBUTORS

Last week there were 3 contributors.
๐Ÿ‘ค andrewxhill
๐Ÿ‘ค carsonfarmer
๐Ÿ‘ค dependabot-preview[bot]


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were 5 releases.
๐Ÿš€ v0.1.5 v0.1.5
๐Ÿš€ v0.1.4 v0.1.4
๐Ÿš€ v0.1.3 v0.1.3
๐Ÿš€ v0.1.2 v0.1.2
๐Ÿš€ v0.1.1 v0.1.1


That's all for last week, please ๐Ÿ‘€ Watch and โญ Star the repository textileio/js-textile to receive next weekly updates. ๐Ÿ˜ƒ

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. ๐Ÿ“†

js-textile project v1

This is a meta Epic to help track progress needed to get to a working Javascript implementation of the Textile node.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.