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

@evan.network/edge-server-seed

v1.9.0

Published

evan.network edge server

Downloads

4

Readme

EdgeServer

An ActionHero with built-in blochchain and evan.network infrastructure for developers to implement their own Smart Agents on top of. Also has REDIS built in.

To install:

(assuming you have node and NPM installed)

npm install

To Run:

npm start

To Test:

npm test

SmartAgents

SmartAgents work more or less the same as the SmartAgents in vanilla ActionHero, with two exceptions:

  • there is the api.redis object available for local storage

  • there is the api.bcc object available that serves as the interface to the blockchain-core

  • the agents that perform transactions or need to access encrypted data have to configure the necessary keys in the base level ethAccounts and encryptionKeys config mappings

    ethAccounts: {
        'accountID' : 'privatekey',
    },
    encryptionKeys: {
        'hash':'encryptionkey',
    }

The hash to index for encryptionKeys is constructed by the blockchain core in different ways for the different puposes, But usually it is just a SHA3 hash of an accountID or of a descriptive string.

Register SmartAgent

For registering a SmartAgent, create an initializer and add something like in the example below. This creates a new instance of your SmartAgent and makes it available for other actionhero components at the api (in this case at api.smartAgentTest. As this SmartAgent extends api.smartAgents.SmartAgent, it will have a property called runtime, that can be used for interaction with evan.network (see API documentation for details).

const { api, Initializer } = require('actionhero')

module.exports = class SmartAgentTestInitializer extends Initializer {
  constructor () {
    super()
    this.name = 'smart-agent-test'
    this.loadPriority = 4100
    this.startPriority = 4100
    this.stopPriority = 4100
  }

  async initialize () {
    if (api.config.smartAgentTest.disabled) {
      return
    }

    // specialize from blockchain smart agent library
    class SmartAgentTest extends api.smartAgents.SmartAgent {
      async initialize () {
        await super.initialize()
      }
    }

    // start the initialization code
    const smartAgentTest = new SmartAgentTest(api.config.smartAgentTest)
    await smartAgentTest.initialize()

    // objects and values used outside initializer
    api.smartAgentTest = smartAgentTest
  }
}

Auth middleware

By default, the edge-server-seed registers the ensureEvanAuth authentication header that checks a signed message with a provided evan account. So the action can only be executed, when the Authorization header with the correct information was passed (getSmartAgentAuthHeaders). You can use this middleware like below:

const { Action } = require('actionhero')

class Authenticated extends Action {
  constructor () {
    super()
    this.name = 'authenticated'
    this.description = 'Will check if message is signed properly, will throw error if not.'
    this.outputExample = {
      isAuthenticated: true
    }

    this.middleware = ['ensureEvanAuth']
  }

  async run ({ response }) {
    response.isAuthenticated = true
  }
}

module.exports = Authenticated

The latest updates of the @evan.network/api-blockchain-core also provide the possibility to check if the passed EvanAuth address is allowed to interact on behalf of the passed EvanIdentity. To enable this check, you need to register your own authentication middleware from your smart agent instance and pass a valid @evan.network/api-blockchain-core runtime.

  • initializer
api.testSmartAgent = new api.smartAgents.SmartAgent({ ... })
await api.testSmartAgent.initialize()
api.testSmartAgent.registerAuthMiddleware('ensureTestAuth', api.testSmartAgent.runtime)
  • action
const { Action } = require('actionhero')

class Authenticated extends Action {
  constructor () {
    super()
    this.name = 'authenticated'
    this.description = 'Will check if message is signed properly, will throw error if not.'
    this.outputExample = {
      isAuthenticated: true
    }

    this.middleware = ['ensureTestAuth']
  }

  async run ({ response, evanAuth }) {
    console.log(evanAuth.EvanIdentity)
    response.isAuthenticated = true
  }
}

module.exports = Authenticated