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

@holo-host/holo-key-manager-js-client

v0.0.7

Published

A JavaScript client API for managing Holo keys

Downloads

14

Readme

Holo Key Manager JS Client

This JavaScript client library facilitates interactions with the Holo Key Manager, streamlining user signup processes and other key management functionalities. For full functionality, ensure the Holo Key Manager browser extension is installed.

Prerequisites

Before using this library, install the Holo Key Manager extension for your browser:

Installation

To install the Holo Key Manager JS Client, you can use npm, yarn, or pnpm as follows:

  • Using npm:

    npm install @holo-host/holo-key-manager-js-client
  • Using yarn:

    yarn add @holo-host/holo-key-manager-js-client
  • Using pnpm:

    pnpm add @holo-host/holo-key-manager-js-client

Usage

To use the library, import and initialize the Holo Key Manager JS Client with your application's details. Then, use the signUp method to initiate the signup process.

Basic Setup

import createHoloKeyManager from '@holo-host/holo-key-manager-js-client';

const holoKeyManagerConfig = {
	happId: 'your-happId',
	happName: 'your-happName',
	happLogo: 'https://example.com/happLogo.png',
	happUiUrl: 'https://example.com/ui',
	requireRegistrationCode: true,
	requireRegistrationCode: true
};
const initiateSignUp = async () => {
	const { signUp } = createHoloKeyManager(holoKeyManagerConfig);
	try {
		const { email, registrationCode, pubKey } = await signUp();
		console.log(
			'SignUp successful. Email:',
			email,
			'Registration Code:',
			registrationCode,
			'Public Key:',
			pubKey
		);
	} catch (error) {
		handleError(error);
	}
};

const initiateSignIn = async () => {
	const { signIn } = createHoloKeyManager(holoKeyManagerConfig);
	try {
		const { pubKey } = await signIn();
		console.log('SignIn successful. Public Key:', pubKey);
	} catch (error) {
		handleError(error);
	}
};

const initiateSignOut = async () => {
	const { signOut } = createHoloKeyManager(holoKeyManagerConfig);
	try {
		await signOut();
		console.log('SignOut successful');
	} catch (error) {
		handleError(error);
	}
};

const initiateSignMessage = async (message: Uint8Array) => {
	const { signMessage } = createHoloKeyManager(holoKeyManagerConfig);
	try {
		const signedMessage = await signMessage(message);
		console.log('Message signed successfully:', signedMessage);
	} catch (error) {
		handleError(error);
	}
};

Error Handling

const handleError = (error) => {
	const errorMessage = getGenericErrorMessage(error);
	console.error(errorMessage);
};

const getGenericErrorMessage = (error) => {
	const errorMessages = {
		'not installed': 'Install the Holo Key Manager extension in Chrome/Edge to proceed.',
		NeedsSetup:
			'Instruct the user to set up the extension, grant necessary permissions, and then reload the page.',
		NoKeyForHapp: 'No existing key found for this happ; initiate the signup flow.',
		AppNotAuthenticated: 'App is not authenticated. Please sign in.',
		ExtensionNotAuthenticated: 'Extension is not authenticated. Please sign in to extension.'
	};

	return (
		Object.entries(errorMessages).find(([key, message]) => error.message.includes(key))?.[1] ||
		'An unknown error occurred.'
	);
};

API reference

class HoloKeyManagerExtensionClient {
    constructor({happId: string, happName: String, happLogo: Url, happUiUrl: Url, requireRegistrationCode: boolean, requireEmail:boolean})

    async signIn(): Promise<pubKey: Uint8Array> {} // throws errors

    async signUp(): Promise<{ email?: string, registration_code?: string, pubkey: Uint8Array }> {} // returns Promise of email and registration code if required in constructor, throws errors
    async logOut() {} // throws errors

    async signMessage(payload: Uint8Array): Promise<Uint8Array> {} // returns Promise of signature, throws errors

    on('authorized', (Uint8Array, boolean) => void): UnsubscribeFunction {}
    on('rejected', () => void): UnsubscribeFunction {}
}

type UnsubscribeFunction = () => void;