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

@etherspot/remote-signer

v0.0.1

Published

Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler

Downloads

6

Readme

RemoteSigner SDK

  • RemoteSigner SDK is a fully open source SDK which let's dapp developers easily get building with SessionKey Signature enabled Modular Smart Accounts.
  • The SDK makes it incredibly easy to get up and running with using Sessionkey based Signature from remote signer and send the UserOp to the bundler.
  • Session-Key-Signer is hosted in AWS cloud environment which stores the sessionKeys and backend infra service to sign using the privateKey associated with the sessionKey. Signed UserOp is sent to the Etherspot Bundler

Modules and functions in Remote-Signer

Usage

  • remote signer need to provide the necessary parameters
    1. account
    2. chainId
    3. apiKey
    4. sessionKey

The signUserOperation function will handle the signing process and return the signed user operation.

import { signUserOperation } from './path/to/remote-signer';

const extendedLocalAccount: ExtendedLocalAccount = await toRemoteSigner({
    account: createLocalAccount(etherspotWalletAddress),
    chainId: chainId,
    apiKey: apiKey,
    sessionKey: sessionKey
});

SessionKey Format

  • SessionKeys are stored in AWS Secrets in this format

  • SessionKey is stored as a secret with secretName: sessionKey-${account}

  • account is the EtherspotWalletAddress

  • an account can have multiple sessionkeys under a chainId

    {
      1: [
          {
            chainId,
            account,
            apiKey,
            publicKey,
            privateKey,
            nonce,
            validUntil,
            validAfter
        }
      ],
      100: [
            {
            chainId,
            account,
            apiKey,
            publicKey,
            privateKey,
            nonce,
            validUntil,
            validAfter
          },
          {
            chainId,
            account,
            apiKey,
            publicKey,
            privateKey,
            nonce,
            validUntil,
            validAfter
          }
      ],
    }

RemoteSigner - Deep dive

remote-signer-deepdive

Remote Signer SDK - Usage

developers can do remote sign an UserOp using SessionKeys and send the signedUserOp to Etherspot Bundler

Background

  1. RemoteSignerSDK is used to sign a userOp via SessionKeys of the etherspot-wallet
  2. SessionKeys are maintained in a remote secured cloud environment
  3. Signing with SessionKey needs the user to call a secured API call to etherspot-permissions-backend
  4. API request sent to remote service authenticates using apiKey and sessionKey and looksup for ther privateKey (ECDSA) associated with the sessionKey
  • userOp
  • apiKey
  • sessionKey
  • chainId
  1. Signer API (etherspot-permissions-backend) will sign the UserOp and return the signedUserOp data
  2. SignedUserOp can be sent to the EtherspotBunder for further verification, validation and execution by entryPoint

Remote Signer Usage

  1. remote-signer-sdk is to be installed from the npm public repo
  2. refer to the script below to use the remote-signer for a functionality of erc20 transfer to a recipient
  3. remote-signer is meant to be operated on etherspot-modular-account which must have corresponding validator module installed where the validation happens
  4. RemoteSigner will perform validations offchain and onchain on validity of sessionKey

Sample Usage Script: session-key-signer-script-for-erc20-transfer

SDK Functions

  1. toRemoteSigner

    • Initialize an ExtendedLocalAccount which is an extended version of Viem's LocalAccount

    • This is a closure created with functions to sign the Userop using SessionKey of the etherspotWalletAddress

      const extendedLocalAccount: ExtendedLocalAccount = await toRemoteSigner({
          account: createLocalAccount(etherspotWalletAddress),
          chainId: chainId,
          apiKey: apiKey,
          sessionKey: sessionKey
      });
      
      const op = await generateSignedUserOp();
      
      const signedUserOp: UserOperation = await extendedLocalAccount.signUserOpWithRemoteSigner(op);
  2. signUserOp

    • extracts the sessionKey Data and privateKey from Cloud KMS Storage

    • sign the userOp using the privateKey associated with SessionKey

      const externalViemAccount = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as string as Hex);
        const bundlerProvider = new EtherspotBundler(chainId, bundlerApiKey);
        const remoteSignerSdk = await RemoteSignerSdk.create(externalViemAccount, {
          etherspotWalletAddress: etherspotWalletAddress,
          chainId: chainId,
          apiKey: apiKey,
          sessionKey: sessionKey,
          bundlerProvider: bundlerProvider
        });
      const signedUserOp = await remoteSignerSdk.signUserOp(op);

API Endpoints use for query and signing by SessionKeys

  1. getSessionKey

      let url = `<permissionedBackendURL>/account/getSessionKey?account=${accountAddress}&chainId=${chainId}&apiKey=${apiKey}&sessionKey=${sessionKey}`;
    
      response = await fetch(url, {
          method: 'GET',
          headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json',
          },
      });
  2. SignUserOp with SessionKey

    let url = `<permissionedBackendURL>/account/signUserOp?account=${accountAddress}&chainId=${chainId}&sessionKey=${sessionKey}&apiKey=${apiKey}`;
    
    response = await fetch(url, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(deepHexlify(await resolveProperties(userOp))),
    });