Split blockstack.js into 6 separate modules & repos. See the overly colorful chart below for the gist of it. If you prefer a longer text explanation, scroll past for more details.
Most dApp libraries understand that you don’t necessarily want or need to do everything that a decentralized ecosystem offers, just some of it. For Ethereum, you have something like the EthereumJS libraries. For Bitcoin, you’ve got BitcoinJS’s various libraries. Likewise, underlying changes to something such as Gaia shouldn’t require major changes throughout the whole library. Rather, we should have individual modules for individual facets of Blockstack. My proposal for these is:
blockstack-auth: Handles the asynchronous auth flow. Has tighter couplings to the Browser, and will likely need changes as Browser changes.
blockstack-storage: Handles all things Gaia. Has tight couplings with it, and should be the only thing that needs to change if Gaia has changes.
blockstack-profile: Handles user profiles and settings. dApp developers may use this if they want to fetch things like user settings and email. Browser implementations will use this for making changes to the profile. Directly uses
blockstack-storageto fetch and save the profile.
blockstack-wallet: Handles generation, encryption, decryption, and signing with the user’s private keys. This library would only be used by a Browser implementation, there should be little to no use cases for it in a dApp.
blockstack-transaction: Not yet needed. This would craft and validate stacks transactions to be signed asynchronously in the browser implementation, when the token is live and tradeable.
blockstack-common: Everything that needs to be shared between these 5. Ideally this is as minimal as possible, just constants and utility functions.
These libraries combined would be used in
blockstack.js to expose their functionality. The
blockstack.js module could insulate some API changes in the sub-modules to maintain a stable API. However, application developers should reasonably be able to grab any of these individual modules if they only want to use certain facets of Blockstack, but I think ultimately we’d do well to deprecate the monolith module and have people grab modules as-needed.