{"_id":"@daviortega/js-oip","_rev":"2-d7fb5d4e9b1dde9ed7530ddb6ff3b858","name":"@daviortega/js-oip","dist-tags":{"latest":"2.4.6-0"},"versions":{"2.4.5":{"name":"@daviortega/js-oip","version":"2.4.5","description":"A Javascript Library to fully interact with the Open Index Protocol","main":"lib/index.js","private":false,"scripts":{"test":"npm run test:unit && npm run test:format","test:flo":"jest test/unit/modules/flo","test:unit":"jest test/unit --detectOpenHandles --verbose","test:integration":"jest test/integration --detectOpenHandles --verbose","test:format":"standard","compile":"babel -d lib/ src/","prepublishOnly":"npm run test && npm run compile","code-format":"standard --fix","prepush":"npm run compile && npm run generate-docs","generate-docs":"jsdoc --readme ./README.md -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/oipwg/js-oip.git"},"keywords":["OIP","Index","Flo","Artifact","Publisher","Retailer","Affiliate"],"author":{"name":"Ryan Chacon","email":"ryan@alexandria.io"},"license":"MIT","bugs":{"url":"https://github.com/oipwg/js-oip/issues"},"homepage":"https://github.com/oipwg/js-oipx#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/node":"^7.2.0","@babel/plugin-proposal-export-default-from":"^7.2.0","@babel/preset-env":"^7.0.0-beta.51","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","jest":"^24.8.0","jest-expect-message":"^1.0.2","jsdoc":"^3.6.3","jsdoc-template":"git+https://github.com/oipwg/jsdoc-template.git","standard":"^12.0.1"},"dependencies":{"axios":"^0.19.0","bitcoinjs-lib":"^5.1.7","bitcoinjs-message":"^2.0.0","coinselect":"^3.1.11","fcoin":"^1.0.0-beta.34","insight-explorer":"^1.0.10","ipfs-http-client":"^28.0.0","node-localstorage":"^1.3.1","rfc6902":"^3.0.1","varuint-bitcoin":"^1.1.0","wif":"^2.0.6"},"jest":{"testEnvironment":"node","setupTestFrameworkScriptFile":"jest-expect-message"},"standard":{"env":["jest"],"ignore":["/lib/*","/docs/*"]},"gitHead":"2a56cb37bc4bf178666dfe68d3b0f84cba4fbb72","_id":"@daviortega/js-oip@2.4.5","_nodeVersion":"12.13.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-pH90CO4XFwaegcZyo7YDtMIJHW4uWCsgUJ7jIOw4uQOrht31a/FQHVUnFWQYQyE4wcb62KxpwbIsI9TxGxogmg==","shasum":"4572e55097af487d42e6a3906f54d2154d2cc121","tarball":"https://registry.npmjs.org/@daviortega/js-oip/-/js-oip-2.4.5.tgz","fileCount":53,"unpackedSize":274536,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiDE1CRA9TVsSAnZWagAAv0MP/3JvzAaqqp5e501BcENh\nJzXqvCudmLsVJA8HIs54F+8Lg4ck+of9B4Nrhm+a+CNm5EZhkvsAxU43G3WF\nt97fGysbFkANzORilX5rgyRb5iDk3oxcSR823RPQL7Sa9Mt5bsFFDI/od+qr\n5+JaWcxnH5mWaDBAVGv8hy3dIfzrLwhXL4MUwkQBDkCN9BZIo6KDI/0xHi4g\nKdhw2lbXTRfI6bwjDVH/lqRDAoK/Gg0/M791ZVh1aUJ9WT8lw8HOwwML3kut\nFi+ukALvGJ53Jr6NTQPxrDBms6mr0049hVS0vYykzT4+AnXZAXYX0iWATt0L\nqSqX30mbPLmQBXfQcQ2hUaBcb1rYFUskKQ0zUDtyKaUnEg5DzUAnHOw88Cnk\nT16eFYoKPJSW2PTBee9Tm+2+vRMSKjIDD6gM5uazSfRc2jVNXsPA/qlVHF4z\nXYxLnz/wl8clx/HSlqbKsv6aE2MCNgq2Q0nzTnPCIRKe1vSfc0q2GmsGXBba\nvzec+egZ2xjOJo824S2eI5UKWQ8902/7LqEZul0F2O55MJhnpsZ2mIb7yd8d\nLWbRP8Nxwa/7vfLCEe6p4Cg2pER8pSFbxKTnKLNu7PmzXUA4kaqkRYY1Em/j\nbqI7zQbaiA2wppESiASxCGib2yCPbOVPwPRPi67cAA9ncicO1aADspoAgDHx\njPhr\r\n=NRWa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFkV3xBv6ok+c+/Wl2SqbtL611VaPZ9N9KXAoIdXL2WSAiBzLyGTti7iC4MO6TeeyaZ7FD9o5K6c5gFzDmgHqz24YQ=="}]},"maintainers":[{"name":"daviortega","email":"davi.github@gmail.com"}],"_npmUser":{"name":"daviortega","email":"davi.github@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-oip_2.4.5_1585983796868_0.22759363598254057"},"_hasShrinkwrap":false},"2.4.6-0":{"name":"@daviortega/js-oip","version":"2.4.6-0","description":"A Javascript Library to fully interact with the Open Index Protocol","main":"lib/index.js","private":false,"scripts":{"test":"npm run test:unit && npm run test:format","test:flo":"jest test/unit/modules/flo","test:unit":"jest test/unit --detectOpenHandles --verbose","test:integration":"jest test/integration --detectOpenHandles --verbose","test:format":"standard","compile":"babel -d lib/ src/","prepublishOnly":"npm run test && npm run compile","code-format":"standard --fix","prepush":"npm run compile && npm run generate-docs","generate-docs":"jsdoc --readme ./README.md -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/oipwg/js-oip.git"},"keywords":["OIP","Index","Flo","Artifact","Publisher","Retailer","Affiliate"],"author":{"name":"Ryan Chacon","email":"ryan@alexandria.io"},"license":"MIT","bugs":{"url":"https://github.com/oipwg/js-oip/issues"},"homepage":"https://github.com/oipwg/js-oipx#readme","devDependencies":{"@babel/cli":"^7.2.0","@babel/core":"^7.2.0","@babel/node":"^7.2.0","@babel/plugin-proposal-export-default-from":"^7.2.0","@babel/preset-env":"^7.0.0-beta.51","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","jest":"^24.8.0","jest-expect-message":"^1.0.2","jsdoc":"^3.6.3","jsdoc-template":"git+https://github.com/oipwg/jsdoc-template.git","standard":"^12.0.1"},"dependencies":{"@oipwg/insight-explorer":"^2.0.0-beta.0","axios":"^0.19.0","bitcoinjs-lib":"^5.1.7","bitcoinjs-message":"^2.0.0","coinselect":"^3.1.11","core-js":"^2.6.11","fcoin":"^1.0.0-beta.34","ipfs-http-client":"^28.0.0","node-localstorage":"^1.3.1","rfc6902":"^3.0.1","varuint-bitcoin":"^1.1.0","wif":"^2.0.6"},"jest":{"testEnvironment":"node","setupTestFrameworkScriptFile":"jest-expect-message"},"standard":{"env":["jest"],"ignore":["/lib/*","/docs/*"]},"gitHead":"1da1b9f4d6177bcb75884e7f5ca84fabf2d2e3a6","_id":"@daviortega/js-oip@2.4.6-0","_nodeVersion":"12.13.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-WOR35NKPSlkm6/Mg5dEVqQAG4rGKKLDuO/INqBT1Yg7ZWh6eSM3GI+IK79IIXXOEG9s5VjnEcVpv3p+oF8ebJw==","shasum":"843d6abcb585a1d1a5d883aa89131df846e6ab62","tarball":"https://registry.npmjs.org/@daviortega/js-oip/-/js-oip-2.4.6-0.tgz","fileCount":53,"unpackedSize":276618,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiD4GCRA9TVsSAnZWagAAnFMQAJkjTtb4SInS7QhaPnUV\nZ6TeiDrp7p1jq2Gkoqgf4HR38tLpox11tgJhnlO0JoRHRCB0azb1QWHh3JJo\n6NpOR+Mc6WArLN2KoF/iCilsbTXvmbDMnrcOLx5TB3PO8PkiYT3e3G6nBDKh\n0U1xxlOS6zEFy9KmQvKU06WuEK+TDONXmK0MR3HPswHHY5pUdW4MuZhcKi/F\nzH65LL+r/6BfesNH+OFgV3JyCJ1JTzVNpf1Qgy2wwHusf7aVl4N49hdX7vSj\nsSwygT0exUxJsP0N6AuaFTF+/7wbgohKITS2odZ5KIGoWdwhqkkqwfSy/f9Q\n2Hxvm6XlCRcV976z+02jTN5ZrIqsvyf6kk78w0VsS+MHG/t7PYV9bh0OCUuV\ng4IEMyqgowNotw9D9CLfiPB6iCR4TrhD/J60VvG30SH2xddFiuVzPGibaqiM\nSV2mvyd/UrTW9EE7kqIGXTCvufwG1Al6hb89v9Nkpt+FSYidDKgrgX1yDrSO\n6+3BnsY/J8lp1qUh85Le+oxbU4HiAHCVJ8L83FFimREuDpsvSOqem8h5xthQ\nnPbXUGUDqTjHUmndtB1FWgrbcQ8ovA5MdIy1O91yaaMV9i7rIVu2LL6MQTCn\nNHkyIHvDm6gwRCIaEnoKBUMZGfoBsayU8FPI0lgdhIPTVCrweOuEB3tTsw3W\nSYK3\r\n=dbDR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICFy7YQeqxXwp2cjeycTWxNGcYd3sNaa7rkM1WFBYFlzAiEA+k4eW1ULEXdI/InUEppip5wiHcK6nT4z1ginRpAgA54="}]},"maintainers":[{"name":"daviortega","email":"davi.github@gmail.com"}],"_npmUser":{"name":"daviortega","email":"davi.github@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-oip_2.4.6-0_1585987078125_0.05619012337574891"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-04T07:03:16.587Z","2.4.5":"2020-04-04T07:03:17.044Z","modified":"2022-04-05T03:10:38.018Z","2.4.6-0":"2020-04-04T07:57:58.304Z"},"maintainers":[{"name":"daviortega","email":"davi.github@gmail.com"}],"description":"A Javascript Library to fully interact with the Open Index Protocol","homepage":"https://github.com/oipwg/js-oipx#readme","keywords":["OIP","Index","Flo","Artifact","Publisher","Retailer","Affiliate"],"repository":{"type":"git","url":"git+https://github.com/oipwg/js-oip.git"},"author":{"name":"Ryan Chacon","email":"ryan@alexandria.io"},"bugs":{"url":"https://github.com/oipwg/js-oip/issues"},"license":"MIT","readme":"[![npm version](https://badge.fury.io/js/js-oip.svg)](https://badge.fury.io/js/js-oip)\n[![Build Status](https://travis-ci.org/oipwg/js-oip.svg?branch=master)](https://travis-ci.org/oipwg/js-oip)\n\n# js-oip\nThe `js-oip` is a javascript module that allows you to easily interact with the Open Index using the Open Index Protocol.\n\n## Table of Contents\n* [Installation Instructions](https://github.com/oipwg/js-oip/#installation-instructions)\n* [Getting Started](https://github.com/oipwg/js-oip/#getting-started)\n    * [Formal OIP Definitions](https://github.com/oipwg/js-oip/#formal-oip-definitions)\n        * [OIP](https://github.com/oipwg/js-oip/#oip)\n        * [floData](https://github.com/oipwg/js-oip/#flodata)\n        * [Record](https://github.com/oipwg/js-oip/#record)\n        * [Artifact](https://github.com/oipwg/js-oip/#artifact)\n        * [Multipart](https://github.com/oipwg/js-oip/#multipart)\n    * [Using the HTTP API to interact with an OIP Daemon](https://github.com/oipwg/js-oip/#using-the-http-api-to-interact-with-an-oip-daemon)\n        * [Spawn a DaemonApi](https://github.com/oipwg/js-oip/#spawn-a-daemonapi)\n        * [Get an Artifact Record from the Open Index](https://github.com/oipwg/js-oip/#get-an-artifact-record-from-the-open-index)\n        * [Get latest Artifact Records](https://github.com/oipwg/js-oip/#get-latest-artifact-records)\n        * [Search Artifact Records](https://github.com/oipwg/js-oip/#search-artifact-records)\n        * [Create a complex search query](https://github.com/oipwg/js-oip/#create-a-complex-search-query)\n        * [Get multiparts](https://github.com/oipwg/js-oip/#get-multiparts)\n        * [Search floData](https://github.com/oipwg/js-oip/#search-flodata)\n        * [Get floData](https://github.com/oipwg/js-oip/#get-flodata)\n    * [Using the OIP API to publish records to the Open Index](https://github.com/oipwg/js-oip/#using-the-oip-api-to-publish-records-to-the-open-index)\n        * [Importing the OIP API](https://github.com/oipwg/js-oip/#importing-the-oip-api)\n        * [Publishing an Artifact Record](https://github.com/oipwg/js-oip/#publishing-an-artifact-record)\n        * [Using MultipartX and MPSingle](https://github.com/oipwg/js-oip/#using-multipartx-and-mpsingle)\n        * [Publish using an RPC Wallet](https://github.com/oipwg/js-oip/#publish-using-an-rpc-wallet)\n    * [Adding files to IPFS](https://github.com/oipwg/js-oip/#adding-files-to-ipfs)\n    * [Creating an Artifact Record](https://github.com/oipwg/js-oip/#creating-an-artifact-record)\n        * [Using the Artifact Decoder](https://github.com/oipwg/js-oip/#using-the-artifact-decoder)\n    * [Networks](https://github.com/oipwg/js-oip/#networks)\n    * [Importing submodules](https://github.com/oipwg/js-oip/#importing-submodules)\n* [API Documentation](https://github.com/oipwg/js-oip/#api-documentation)\n* [License](https://github.com/oipwg/js-oip/#license)\n\n## Installation Instructions\nMake sure you have the latest version of npm and nodejs installed. Instructions on installing the latest versions can be found on nodesource: [nodesource](https://github.com/nodesource/distributions#debinstall).\n\nYou can install the latest version by running the following `npm install` command.\n```bash\n$ npm install --save js-oip\n```\nor with yarn.\n```bash\n$ yarn add js-oip\n```\n## Getting Started\nThis module is based entirely around the Open Index Protocol. To read in depth material about this protocol, please refer to the [OIP Wiki](https://oip.wiki).\n\n### Formal OIP Definitions\nIt will be helpful to understand certain terms used throughout this module.\n#### OIP\n*\"The Open Index Protocol (OIP) is a specification for a worldwide database for decentralized publishing, distribution and payments. OIP uses distributed networking and peer-to-peer technology to operate with no central authority: content indexing, file storage/distribution and transaction management are carried out collectively by the network.\"*\n#### floData\nThe Open Index 'sits' on top of the [FLO Blockchain](https://www.flo.cash/) (formerly known as Florincoin). FLO is a fork of Litecoin, itelf a fork of Bitcoin. FLO operates in\nalmost the exact same way except for certain key elements, one of those being floData.\n\nfloData is arbitrary text data appended to the end of a FLO transaction. Allowing up to 1040 bytes of data to be appended onto a transaction,\nthe FLO chain is a perfect fit for the Open Index use case. We use this extra field as an immutable record holder of data. Using the OIP,\nusers can serialize/format their data and push it to the blockchain where it remains unchangeable and decentralized. Using our \nmodules/libraries we can then retrieve this information from the blockchain and use it to populate our own apps.\n\nFor a live example, check out [this transaction](https://livenet.flocha.in/tx/6ffbffd475c7eabe0acc664087ac56c13ac7c2084746619182b360c2f19e430e) on the FLO chain. \nIn the Details section at the bottom we see a floData field containing text that begins with 'oip-mp'. This is an example of data that was serialized with the Open Index Protocol\nand pushed to the chain. The '-mp' refers to the fact that its a multipart which we'll get to in a sec.\n#### Record\nBy our current definition a Record is a piece of data that was serialized with the OIP and pushed to the blockchain and indexed by an OIP Daemon.\nThe major types of Records will be: Artifact, Publisher, Platform, Influencer, and Autominers (\"spartanbots\"). Currently, only Artifact Records\nare in main implementation so that's all we'll focus on for now.\n#### Artifact\nAn Artifact [Record] is a piece of data published to the Index. It typically contains the IPFS locations to the raw data published (mp3, mp4, mpeg, mov, etc), \nas well as the metadata about the raw data. Artifact types can range from image, movie, audio, text, etc. Any digital form of data can be published as an artifact.\nThink of an Artifact as a piece of content. Similiar to how one would upload a piece of content to YouTube, so one would 'upload' a piece of content to the Open Index, \nbut in our case, we use the word 'Artifact' instead of 'content'.\n#### Multipart\nA Multipart is a term that relates to a Record on the FLO Chain that is split up into chunks or pieces. As stated previously, the FLO Chain allows\nfor 1040 bytes of data to be appended to a transaction. If when a Record is being pushed to the chain is more than 1040 bytes, it gets split up into mulitple\nparts and gets sent as multiple transactions. We use a special serialization format for multiparts that allows us to easily retrieve all pieces of a Record back with ease.\nYou can tell if a record was published in multiple parts if the floData in which it is contained in begins with 'oip-mp' (open index protocl multipart). \n## Using the HTTP API to interact with an OIP Daemon\n### Spawn a DaemonApi\nFirst we must import the DaemonApi from the module and then initialize it with the 'new' keyword. For these examples we will be using es6 import syntax.\nAlso note the object deconstruction import. \n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\n```\n### Spawn a DaemonApi with a custom OIPd server\nOIPd refers to an Open Index Protocol Daemon. Our current implementation is in golang and can be found [here](https://github.com/oipwg/oip).\nIf for instance, we are running a daemon locally, we hit the endpoints it exposes by pointing our DaemonApi to the URL its running at.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi('http://localhost:1606')\n``` \n\nAlternatively you can manually set the URL:\n```javascript\nlet api = new DaemonApi()\napi.setUrl('http://localhost:1606')\nconsole.log(api.getUrl())\n```\n### Get an Artifact Record from the Open Index\nOnce we have our Daemon Api spawned, we can use its methods to retrieve data back from the Index. In this example we'll get back an Artifact Record.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet txid = 'cc9a11050acdc4401aec3f40c4cce123d99c0f2c27d4403ae4a2536ee38a4716'\nlet {success, error, artifact} = await api.getArtifact(txid)\nconsole.log(artifact instanceof Artifact) //true\nconsole.log(artifact instanceof Record) //true\n```\n### Get latest Artifact Records\nSimiliarly, we can get back just the latest Artifact Records.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nconst limit = 50\nlet {success, artifacts, error} = await api.getLatestArtifacts(limit)\n```\n### Search Artifact Records\nOr we can search for Artifacts with a text query. In this example we are searching for Artifacts that contain the text: 'ryan' in it.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet query = 'ryan'\nlet {success, error, artifacts} = await api.searchArtifacts(query)\n```\n### Create a complex search query\nWe can even create complex search queries, searching on certain fields using AND, OR, or NOT. For examples on how \nto do this please refer to the our [query documentation](https://oipwg.github.io/js-oip/global.html#queryObject). But essentially \nwhat it comes out to is creating a query as such: `(artifact.type:\"research\" OR artifact.type:\"music\") AND artifact.info.year:\"2017\"`. Plugging that into \nDaemonApi.searchArtifact(query) will get you the results you can intuit from that complex query.\n### Get multiparts\nFor a brief descrpition of what a multipart is, navigate [here](https://github.com/oipwg/js-oip/#multipart). \nThis first example gets all multiparts back by given the method the txid of the first multipart, known as the `reference` txid.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet reference = '8c204c5f39'\nlet {success, multiparts, error} = await api.getMultiparts(reference)\n```\nOr alternatively, you can retrieve just a single multipart.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet txid = 'f550b9739e7453224075630d44cba24c31959af913aeb7cb364a563f96f54548'\nlet {success, multipart, error} = await api.getMultipart(txid)\n```\n### Search floData\n[The OIP Daemon](https://github.com/oipwg/oip) indexes *not only* data serialized using the OIP, but all floData found on the FLO Chain. \nUsing this method we can search for text found within any TX's floData field. Again, Ryan seems like a cool guy so we'll search for his name.\nNote here how we're going to receive back transactions (`txs`) that contain the floData and not just the floData itself.\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet query = 'ryan'\nlet {success, txs, error} = await api.searchFloData(q)\n```\n### Get floData\nOr if we know the txid of the floData we want we can do:\n```javascript\nimport {DaemonApi} from 'js-oip'\n\nlet api = new DaemonApi()\nlet txid = '83452d60230d3c2c69000c2a79da79fe60cdf63012f946ac46e6df3409fb1fa7'\nlet {success, tx, error} = await api.getFloData(txid)\n```\n## Using the OIP API to publish records to the Open Index\nThis is where this module gets kind of fun. We can use the OIP API to send data to the FLO Chain... where it stays... forever! =O Become immortal. Use the Open Index Protocol.\n### Importing the OIP API\nTwo important things: This module accepts two arguments, a wif and a network. We take care of the network details so all\nyou have to do is specify whether you want mainnet (default) or testnet by giving it `'mainnet'` or `'testnet'` as a string argument. If nothing is passed\nit will default to mainnet. \n\nThe WIF, or the first argument passed to the module, stands for [Wallet Import Format](https://en.bitcoin.it/wiki/Wallet_import_format). It's essentially your private key. It's needed to sign\ntransactions and Records going out to the blockchain. If you need to generate a WIF, you can do so by generating an ECPair (Elliptic Curve Pair), generally known as a just a key-pair. \nThis [module](https://github.com/bitcoinjs/bitcoinjs-lib) allows you to easily to that - just make sure you pass in the correct network parameters (which you can get from one of our [submodules](https://github.com/oipwg/js-oip/#importing-submodules)).\n```javascript\nimport {OIP} from 'js-oip'\n\nlet wif = '5HueCGU8rMjxEXxiPuD5BDk_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_u4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'\nlet oip = new OIP(wif, 'testnet')\n```\n### Publishing an Artifact Record\nis super easy!\n```javascript\nimport {OIP} from 'js-oip'\n\nlet artifact = new Artifact(someValidArtifactJSON)\nlet results = await OIP.publish(artifact)\n//results can be either a txid or an array of transcation ids\n```\n### Using MultipartX and MPSingle\nMultipartX is a Multipart Converter (X). It can take in either string data (a stringified Record) or an array of multiparts, known as\nMultipart Singles (MPSingle)s. Using MultipartX, you can take a large Record and convert it into valid parts that can be published independently to the blockchain. Or \nyou can take MPSingles and form them back into the original Record (in JSON/string format).\n\nSee how to [import submodules](https://github.com/oipwg/js-oip/#importing-submodules) to import these two classes.\n\nTaken straight from one of our tests:\n```javascript\nimport {DaemonApi} from 'js-oip'\nimport {MultipartX} from 'js-oip/modules'\n\n\nlet assembled = '{\"oip-041\":{\"artifact\":{\"type\":\"Audio-Basic\",\"info\":{\"extraInfo\":{\"genre\":\"Acoustic\"},\"title\":\"Visionen_von_Marie\"},\"storage\":{\"network\":\"IPFS\",\"files\":[{\"fname\":\"Visionen_von_Marie.mp3\",\"fsize\":3771195,\"type\":\"Audio\",\"duration\":187}],\"location\":\"QmZCcTJJUG2Dp1uLsMhe9bSWZbWp5hCprfjfBtJiLU67bf\"},\"payment\":{\"fiat\":\"USD\",\"scale\":\"1000:1\",\"maxdisc\":30,\"promoter\":15,\"retailer\":15,\"sugTip\":[],\"addresses\":[]},\"timestamp\":1532864918,\"publisher\":\"F95Q4zxMiafqyZDBaJRuLNyvGD7dCwjezX\"},\"signature\":\"IK9mtLY+sugytM4URKiRyRxUVtkeZGT5JaVYSw3tqlhnboRJo1HFcEv6mQjbUmkjVZ8TOgOilaBPZD+Kyj2E1sM=\"}}'\nlet ref = 'd148b56799'\nlet results = await DaemonApi.getMultiparts(ref)\nlet mps = results.multiparts\n\nlet mpx = new MultipartX(mps)\nexpect(mpx.toString()).toEqual(assembled)\nexpect(mpx.getMultiparts().length).toEqual(2) //this would return an array of two MPSingle[s]\n```\n### Publish using an RPC Wallet\nYou can publish an Artifact using an RPC Wallet instead of the built in Web Explorer Wallet by including RPC settings as a third parameter when initializing OIP. After that, just use the OIP class like normal.\n\n```javascript\nimport {OIP} from 'js-oip'\n\nlet wif = '5HueCGU8rMjxEXxiPuD5BDk_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_u4MkFqeZyd4dZ1jvhTVqvbTLvyTJ'\nlet oip = new OIP(wif, \"testnet\", {\n    rpc: {\n        port: 17313,\n        host: \"127.0.0.1\",\n        username: \"username\",\n        password: \"password\"\n    }\n})\n\nlet artifact = new Artifact(someValidArtifactJSON)\nlet results = await OIP.publish(artifact)\n```\n\n## Adding files to IPFS\n[IPFS](https://ipfs.io/) is a peer-to-peer file transfer network (techincally a 'hypermedia protocol'). Anyway's we need IPFS for \nthe actual storage of raw data and they let us have that for free and in a decentralized manner. Perfect! To create a valid Artifact, you need to include\nthe address or location of the files which your Record contains. Using the `ipfs-http-api`, we can add a file to IPFS and get back its location. \nThis module is just a wrapper around their API. \n\nTo see what formats the IPFS API accepts files in, please see: [their documentation](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add).\n\nOther methods and classes for IPFS coming soon...\n\n```javascript\nimport {IpfsHttpApi} from 'js-oip'\n\nlet file = ipfsFormattedFile\n\nlet options = {\n\tfilename: \"someFileName.mp4\",\n\tfilesize: 777,\n\thost: 'ipfs-dev.alexandria.io',\n\tport: 443,\n\tprotocol: 'https',\n\toip_auth: {\n\t\taddress:\"oNRs1nuR1vUAjWJwhMtxJPQoTFAm9MWz1G\",\n\t\tmessage:'1534278675842{\"oip042\":{}}',\n\t\tsignature:\"Hw2iuomv/fhYYoKX8bNroVXmOvbh/e9gqZjP+I9kZymHD72mqtDw1qjN6/Qh4nhTDOHI8mkxbWtsaLSTuCkSihU=\"\n\t}\n}\n\nlet fileUploader = new IpfsHttpApi(file, options)\nlet response = await fileUploader.start()\n```\n## Creating an Artifact Record\nTo see the current spec, refer to [the wiki](https://oip.wiki/Message_protocol#Artifact_Publish).\n```javascript\nimport {Artifact} from 'js-oip/modules/records/artifact'\n\nlet artifact = new Artifact(artifactJSON)\nlet {success} = artifact.isValid())\n``` \n### Using the Artifact Decoder\nWhile it may be necessary to import the Artifact module directly, we recommend using an Artifact Decoder which will parse a JSON Artifact\nand return an Artifact based on its type. Currently there are only a few unique types, but as more get added it will be a good habit to use this function\ninstead of an Artifact constructor.\n```javascript\nimport {decodeArtifact} from 'js-oip'\n\nlet artifact = decodeArtifact(artifactJSON)\nlet {success} = artifact.isValid()\n```\n## Networks\nTo import our current Coin Network modules. Use these to generate ECPairs and much more! Currently just contains the FLO and FLO_testnet networks.\n```javascript\nimport {Networks} from 'js-oip'\n```\n## Importing submodules\nTo import Records or other modules directly.\n```javascript\nimport * as modules from 'js-oip/modules'\n```\n```javascript\nimport {Records} from 'js-oip/modules'\n```\n```javascript\nimport {ArtifactFile} from 'js-oip/modules'\n```\n```javascript\nimport {MultipartX} from 'js-oip/modules'\n```\n```javascript\nimport {MPSingle} from 'js-oip/modules'\n```\n```javascript\nimport {Artifact} from 'js-oip/modules/records'\n```\n```javascript\nimport {Artifact} from 'js-oip/modules/records/artifact'\n```\n\nYou get the jist. You can import everything (*) from `js-oip/[folder]` where folder is `modules`, `decoders`, `core`, or `config` to see what else lies in this library.\n\n## API Documentation\nFor further documentation on use cases and methods, please see the [official documentation page](https://oipwg.github.io/js-oip/)\n## License\nMIT License\n\nCopyright (c) 2019 Open Index Protocol Working Group\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","readmeFilename":"README.md"}