CosmicLib is an attempt for converting URIs to Stellar transaction and back. It is part of an effort in implementing the CosmicLink protocol.
The CosmicLink class allows you to parse a link such as:
https://cosmic.link/?payment&amount=120&destination=you*example.com
and make it a transaction, sign it and send it. In the future, it will allow you to take a Stellar transaction and to generate a link from it, or to build a link through the dedicated builder.
Beside enabling everybody to produce cosmic links easily, the point of this library is enabling any webwallet to sign such links. The service at https://cosmic.link will offer users to select between Stellar Authenticator or their own compatible webwallet to sign cosmic links transactions. This way they won't have to copy their secret seeds to yet another service.
Because CosmicLink class works on the query part of the string, it is able to handle a custom URI scheme aswell like 'stellar:?payment&....' or a query on any webpage like 'example.org?createAccount&...'. This way if someone wants to make a try at implementing the protocol another way it's also open.
For the sake of simplicity, CosmicLink produces HTML nodes that describe the meaning of the transaction, format errors and the status of signing & sending operations. There's a few other functionalities to be implemented.
Here's the specs so far:
// --- Constructor ---
// new CosmicLink("url", "[userAccount]", "[network]")
//
// --- Formats -- -
// CosmicLink.url < The URL string
// CosmicLink.query < The query string
// CosmicLink.object < A simplified object representation of transaction
// CosmicLink.json < A stringified JSON of the object
// CosmicLink.transaction < A promise of the transaction
// CosmicLink.xdr < A promise of the transaction's XDR
//
// --- Datas ---
// CosmicLink.userAccount < User publicKey
// CosmicLink.aliases < Local aliases for public keys
// CosmicLink.server < Address of the horizon server
// CosmicLink.network < Test/Public/Private network
//
// --- Actions ---
// CosmicLink.resolve() < Resolve addresses and fetch sequence for offline signing
// CosmicLink.sign("seed") < Sign the transaction
// CosmicLink.send() < Send the transaction to the network
//
// --- Tools ---
// CosmicLink.builder < Builder akin to StellarSdk.TransactionBuilder
// CosmicLink.eventHandler < For onClick events on the HTML description
//
// --- HTML Nodes ---
// CosmicLink.transactionNode < HTML description of the transaction
// CosmicLink.errorNode < HTML node displaying parsing errors
// CosmicLink.signingNode < HTML box for the signing status
// CosmicLink.sendingNode < HTML box for the sending status
At this time I have nearly done implementation of the URL->transaction conversion.
I'm polishing signing & sending.
I'll release the first alpha in few days at github.com/misterticot/CosmicLib
I'll release alpha for https://cosmic.link & Stellar Authenticator around next week.
To be done before beta (hopefully end-march)
- Handling network switching
- Handling all transactions types (pathpayment & setoption is missing)
- Handle custom aliases for Stellar addresses (= contact name)
- Implement event handler
- Polishing wrong link detection
To be done before v1 (hopefully end-june)
- Implement transaction->url conversion
- Implement builder
- Implement multi-operation transactions
- Polishing user interface & transaction description
- Extensive testing & user report
- Internationalization
A month ago I wrote a proposal based on ideas shared here that led me to work on those projects:
https://galactictalk.org/d/819-a-standardized-way-of-handling-stellar-transactions