npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oip-npm

v1.6.13

Published

Node JS Module interface to publish messages to the Florincoin Blockchain.

Downloads

33

Readme

npm version

OIP-NPM

OIP-NPM is an easy to use Node.js module to help with publishing to OIP media formats. It publishes the OIP metadata to the Florincoin blockchain using predefined metadata templates.

Installation

Import OIP-NPM into your existing application using the following below.

$ npm install oip-npm --save

Usage

Starting Off

To start off, you will need to import LibaryDJS into your application, then set it up using the example below.

var oip041 = require('oip-npm');

var oip = new oip041({
     host: 'localhost', # Information about your local Florincoin RPC
     port: 18322,
     username: 'florincoinrpc', 
     password: 'password'
});

Main Functions

Publish Media:

publishArtifact(oipArtifact, callback): Validates and publishes a submitted OIP-041 artifact:

var oip041 = require('oip-npm');

var oip = new oip041({
     host: 'localhost', # Information about your local Florincoin RPC
     port: 18322,
     username: 'florincoinrpc', 
     password: 'password'
});

// The artifact to publish in OIP-041 format.
var artifact = {
  "oip-041": {
    "artifact": {
      "publisher": "FD6qwMcfpnsKmoL2kJSfp1czBMVicmkK1Q",
      "timestamp": 1481419390,
      "type": "music",
      "info": {
        "title": "Test Artifact",
        "description": "Testing publishing from OIP-NPM",
        "year": "2016",
        "extraInfo": {}
      },
      "storage":{
      "network": "IPFS",
      "location": "QmPukCZKeJD4KZFtstpvrguLaq94rsWfBxLU1QoZxvgRxA",
      "files": [
            {
              "dname": "Skipping Stones",
              "fame": "1 - Skipping Stones.mp3",
              "fsize": 6515667,
              "type": "album track",
              "duration": 1533.603293
            }
          ]},
      "payment": {
      }
    }
  }
}

oip.publishArtifact(artifact, function(response){
	if (res.success)
		// Successful
	else
		// Not successful, usually because the submitted JSON is malformed.

	console.log(response);
})

After processing the publishArtifact function will return a response as follows:

{
	"success": true, 					# This variable is set dependant on if the API call was successful or not.
	"message": "tx1,tx2,tx3,tx4,tx5",	# This variable will be filled in on success. If success is false, `error` will be used instead of `message`.
}

Announce Publisher:

announcePublisher(publisherJSON, callback): Changes the ownership of an artifact from your publisher to another user. transferOwnership function example:

// The artifact txid that we are transfering
var publisherJSON = {"oip-publisher":{"name":"Publisher Name","address":"FLO Address","emailmd5":"","bitmessage":""}};

oip.announcePublisher(originalTX, function(response){
	if (res.success)
		// Successful
	else
		// Not successful, usually because the lack of callback or title.

	console.log(response);
})

After processing the announcePublisher function will return a response as follows:

{
	"success": true, 	# This variable is set dependant on if the API call was successful or not.
	"message": "txid"	# This variable will be filled in on success. If success is false, `error` will be used instead of `message`.
}

Edit Media:

editArtifact(newOIPArtifact, callback): The Edit Artifact function accepts data in the OIP-041 Edit format (example below) along with data in the standard OIP-041 schema (same as publishArtifact but with an added txid field inside the data at oip-041.artifact.txid). It calculates what information is new and publish that to the Florincoin blockchain. Example Edit code:

// The artifact txid that we are editting
// The updated artifact in OIP-041 format.
var artifact = {
  "oip-041": {
    "artifact": {
      "txid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "publisher": "FD6qwMcfpnsKmoL2kJSfp1czBMVicmkK1Q",
      "timestamp": 1481419391,
      "type": "music",
      "info": {
        "title": "Test Artifact (edit)",
        "description": "Testing editting from OIP-NPM",
        "year": "2016",
        "extraInfo": {}
      },
      "storage":{
      "network": "IPFS",
      "location": "QmPukCZKeJD4KZFtstpvrguLaq94rsWfBxLU1QoZxvgRxA",
      "files": [
            {
              "dname": "Skipping Stones",
              "fame": "1 - Skipping Stones.mp3",
              "fsize": 6515667,
              "type": "album track",
              "duration": 1533
            }
          ]},
      "payment": {
      }
    }
  }
}

oip.editArtifact(artifact, originalTX, function(response){
	if (res.success)
		// Successful
	else
		// Not successful, usually because the submitted JSON is malformed.

	console.log(response);
})

After processing the editArtifact function will return a response in a callback as follows:

{
	"success": true, 					# This variable is set dependant on if the API call was successful or not.
	"message": "tx1,tx2,tx3,tx4,tx5",	# This variable will be filled in on success. If success is false, `error` will be used instead of `message`.
}

Remove Media:

deactivateArtifact(txid, title, callback): Deactivates an artifact in LibraryD. This will cause the artifact to stop showing up in the browser, however it does NOT remove the previously published data from the blockchain. Any information previously published will be accessable for as long as Florincoin exists. Example deactivation of an artifact:

// The artifact txid that we are editting
var originalTX = "XXXXXXXXXXXXX";
// The updated artifact in OIP-041 format.
var title = "Test Artifact"

oip.deactivateArtifact(originalTX, title, function(response){
	if (res.success)
		// Successful
	else
		// Not successful, usually because the lack of callback or title.

	console.log(response);
})

After processing the deactivateArtifact API endpoint will return a response as follows:

{
	"success": true, 	# This variable is set dependant on if the API call was successful or not.
	"message": "txid"	# This variable will be filled in on success. If success is false, `error` will be used instead of `message`.
}

Transfer Artifact:

transferArtifact(txid, newOwner, callback): Changes the ownership of an artifact from your publisher to another user. transferArtifact function example:

// The artifact txid that we are transfering
var originalTX = "XXXXXXXXXXXXX";
// Your publisher address
var origOwner = "XXXXXXXXXXXXX";
// The updated artifact in OIP-041 format.
var newOwner = "XXXXXXXXXXXXX"; // This needs to be a florincoin address that is a registered publisher. If it is not a registered publisher it will fail.

oip.transferOwnership(originalTX, origOrner, newOwner, function(response){
	if (res.success)
		// Successful
	else
		// Not successful, usually because the lack of callback or title.

	console.log(response);
})

After processing the transferArtifact function will return a response as follows:

{
	"success": true, 	# This variable is set dependant on if the API call was successful or not.
	"message": "txid"	# This variable will be filled in on success. If success is false, `error` will be used instead of `message`.
}

OIP Artifact Formats

You can find more information about the OIP-041 standard here: https://github.com/dloa/media-protocol

License

This module uses the MIT License. This can be found inside the file named LICENSE