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

@ethersphere/swarm-extension

v0.7.0

Published

JavaScript library for interaction with the Swarm browser extension

Downloads

4

Readme

Swarm Browser Extension JS Library

Library for interaction with the Swarm Browser Extension, from dApps or other browser extensions.

Installation

The library can be installed via npm:

npm install --save @ethersphere/swarm-extension

Usage

Swarm class

All interaction with the Swarm browser extension is established through the Swarm class:

import { Swarm } from '@fairdatasociety/swarm-extension'

By default the class will connect to the Swarm browser extension using its ID from the Google store. If you are running your version of the extension the class can be configured with a different extension ID.

const swarm = new Swarm() // Using the default Swarm ID from the Google store
const swarm = new Swarm('Swarm Extension ID...') // Using custom Swarm ID

To test if connection with the Swarm extension is established, call the echo method:

const text = await swarm.echo<string>('test')
console.log(text) // 'test'

Swarm class functionalities

Before interacting with the library, Dapp should register new session by calling:

await swarm.register()

or new session will be implicitly created when calling any method for the first time.

After registering a new session, session ID will be available as:

swarm.sessionId

There are four different objects available in the Swarm calass:

  • swarm.bzzLink - utility functions for converting bzz links
  • swarm.localStorage - methods for interacting with local storage
  • swarm.postageBatch - checking postage batch status
  • swarm.web2Helper - getting information about bee URL

Terminating connection

Once when the instance of the Swarm class is not needed anymore, connection with the extension can be terminated.

swarm.closeConnection()

Swarm HTML

To enable Swarm HTML features, include the swarm-html.js script into HTML page. For more details check Swarm HTML in the main readme

Development

To watch for changes in the source code and recompile the library on change:

npm start

Build

To build the library:

npm run build