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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@etherplay/alchemy

v0.0.16

Published

Alchemy Mechanism For Deterministic Account Generation - provides social login mechanisms including email OTP, OAuth (Google, Facebook, Auth0), and mnemonic phrase authentication

Readme

@etherplay/alchemy

Alchemy mechanism for deterministic account generation in the @etherplay/connect ecosystem. This package provides social login mechanisms including email OTP, OAuth (Google, Facebook, Auth0), and mnemonic phrase authentication using Alchemy's Account Kit infrastructure.

Installation

npm install @etherplay/alchemy
# or
pnpm add @etherplay/alchemy
# or
yarn add @etherplay/alchemy

Features

  • Email OTP Login: Authenticate users via email with one-time passwords
  • OAuth Support: Login via Google, Facebook, or Auth0 providers
  • Mnemonic Login: Direct authentication using BIP-39 mnemonic phrases
  • Deterministic Account Generation: Generate consistent accounts from social login credentials
  • Origin-Based Account Isolation: Create isolated session accounts per origin for security
  • Svelte Integration: Built-in Svelte store support for reactive state management

Peer Dependencies

This package requires Svelte 5.x as a peer dependency:

npm install svelte@^5.0.0

Usage

Basic Setup

import {createAlchemyConnection} from '@etherplay/alchemy';
import {EthereumWalletConnector} from '@etherplay/wallet-connector-ethereum';

const connector = new EthereumWalletConnector();

const connection = createAlchemyConnection({
	alchemy: {
		apiKey: 'YOUR_ALCHEMY_API_KEY',
		// Additional Alchemy configuration
	},
	accountGenerator: connector.accountGenerator,
	windowOrigin: window.location.origin,
	signingOrigin: 'https://your-app.com',
	autoInitialise: true,
});

// Subscribe to connection state changes (Svelte store)
connection.subscribe((state) => {
	console.log('Connection state:', state?.step);
});

Email OTP Login

// Start email authentication
await connection.connect({
	type: 'email',
	mode: 'otp',
	email: '[email protected]',
});

// After user receives OTP
await connection.provideOTP('123456');

OAuth Login (Google/Facebook)

// Using popup
await connection.connect({
	type: 'oauth',
	provider: {id: 'google'},
	usePopup: true,
});

// Then confirm the OAuth flow
await connection.confirmOAuth();

OAuth Login (Auth0)

await connection.connect({
	type: 'oauth',
	provider: {id: 'auth0', connection: 'your-auth0-connection'},
	usePopup: true,
});

Mnemonic Login

await connection.connect({
	type: 'mnemonic',
	mnemonic: 'your twelve word mnemonic phrase goes here and more words',
	index: 0,
});

Connection States

The connection follows a state machine with the following steps:

| Step | Description | | ------------------------- | ------------------------------------- | | Initialising | Connection is being initialized | | Initialised | Signer is ready | | MechanismToChoose | Waiting for mechanism selection | | MechanismChosen | Mechanism selected, processing | | EmailToProvide | Waiting for email input | | WaitingForOTP | Email sent, waiting for OTP | | VerifyingOTP | Verifying the provided OTP | | ConfirmOAuth | OAuth popup ready, needs confirmation | | WaitingForOAuthResponse | Waiting for OAuth provider response | | MnemonicIndexToProvide | Waiting for mnemonic index | | GeneratingAccount | Creating the account | | SignedIn | Successfully authenticated |

Origin Account Generation

Generate isolated accounts for specific origins:

connection.subscribe(async (state) => {
	if (state?.step === 'SignedIn') {
		const originAccount = await connection.generateOriginAccount('https://game.example.com', state.account);

		console.log('Origin account address:', originAccount.signer.address);
		console.log('Origin public key:', originAccount.signer.publicKey);
	}
});

Types

AlchemyMechanism

type AlchemyMechanism = EmailMechanism<string | undefined> | OauthMechanism | MnemonicMechanism<number | undefined>;

EtherplayAccount

type EtherplayAccount = {
	localAccount: {
		address: `0x${string}`;
		index: number;
		key: `0x${string}`;
	};
	signer: {
		mechanismUsed: AlchemyMechanism;
		user: AlchemyUser;
	};
	accountType: string;
};

OriginAccount

type OriginAccount = {
	address: `0x${string}`;
	signer: {
		origin: string;
		address: `0x${string}`;
		publicKey: `0x${string}`;
		privateKey: `0x${string}`;
		mnemonicKey: `0x${string}`;
	};
	metadata: {
		email?: string;
	};
	mechanismUsed: AlchemyMechanism | {type: string};
	savedPublicKeyPublicationSignature?: `0x${string}`;
	accountType: string;
};

AlchemyUser

type AlchemyUser = {
	email?: string;
	orgId: string;
	userId: string;
	address: `0x${string}`;
	credentialId?: string;
	idToken?: string;
	claims?: Record<string, unknown>;
};

API Reference

createAlchemyConnection

function createAlchemyConnection(settings: {
	alchemy: AlchemySettings;
	autoInitialise?: boolean;
	alwaysUsePopupForOAuth?: boolean;
	accountGenerator: AccountGenerator;
	windowOrigin: string;
	signingOrigin: string;
}): AlchemyConnectionStore;

AlchemyConnectionStore Methods

| Method | Description | | ---------------------------------------- | -------------------------------------------- | | subscribe | Subscribe to connection state changes | | connect(mechanism?) | Start authentication with optional mechanism | | confirmOAuth() | Confirm OAuth popup authentication | | provideEmail(email) | Provide email for OTP authentication | | provideOTP(otp) | Submit OTP code | | provideMnemonicIndex(index) | Provide account index for mnemonic | | generateOriginAccount(origin, account) | Generate origin-specific account | | completeOAuthWithBundle(...) | Complete OAuth with redirect bundle | | confirmOriginAccess() | Confirm cross-origin access |

Utility Functions

// Generate mnemonic from entropy key
fromEntropyKeyToMnemonic(key: `0x${string}`): string;

// Generate key from signature
fromSignatureToKey(signature: `0x${string}`): `0x${string}`;

// Message templates
originKeyMessage(origin: string): string;
localKeyMessage(): string;
originPublicKeyPublicationMessage(origin: string, publicKey: `0x${string}`): string;

Security Considerations

  • Local Key Message: Users should never sign the local key generation message outside of the Etherplay wallet
  • Origin Isolation: Each origin gets a unique derived account to prevent cross-site account correlation
  • OTP Verification: Email OTP provides secure passwordless authentication
  • OAuth Tokens: OAuth tokens are handled securely through Alchemy's infrastructure

Related Packages

License

MIT