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

@marigold-dev/tzsafe-signature

v1.0.0

Published

Verifying signatures that are coming from TzSafe

Downloads

3

Readme

TzSafe Signature

This library allows you to verify signatures that represent a single owner on TzSafe. You probably know that to sign a message, you need to use a public key, but in the case of abstracted account (contract acting as a wallet), there's no public key. There are 2 way of doing it:

  1. To be able to sign messages and receive an immediate response, we forward it to a wallet owned by an owner currently connected to TzSafe App. From a Dapp point of view, it means that you'll receive a sign message but you can't verify as you don't know which owners’ address signed it. With this library, we take care of the verification for you! Note that the owner of TzSafe can change. Therefore, please always verify the obtained signature.
  2. The other signing method is the proof-of-event challenge, following TZIP-27. The signature produced by this method serves as an agreement among owners and is less affected by owner changes. However, the response time for receiving signatures might be longer for DApps. Please refer to TZIP-27 for more details.

This library helps you handle the first case.

:warning: This library only supports mainnet and ghostnet

How to install it ?

npm i @marigold-dev/tzsafe-signature

How to use it ?

Validate a signature

import { verify, SignatureResult } from "@marigold-dev/tzsafe-signature";

async function itWorks() {
  const [result, _reason] = await verify({
    messageByte:
      "05010000004254657a6f73205369676e6564204d6573736167653a206d79646170702e636f6d20323032312d30312d31345431353a31363a30345a2048656c6c6f20776f726c6421",
    contractAddress: "KT1XfFwTyoUVkZY7TT8erDaWK6UPkN87TKJn",
    signature:
      "edsigu5npnN9QaZCNgrTMKW2YhghDzJhcp9zE69QEjAbHW9kLvtcCh2QzHLzEJ52woWjWEMW5yvqGdLpaCqUdCDMxvY7H7vARxb",
    rpc: "https://ghostnet.tezos.marigold.dev",
  });

  if (result === SignatureResult.VALID) {
    console.log("Valid");
  } else {
    console.log("Not valid");
  }
}

itWorks();

Error occurred

import { verify, SignatureResult } from "@marigold-dev/tzsafe-signature";

async function itFails() {
  const [result, reason] = await verify({
    messageByte: "",
    contractAddress: "KT1XfFwTyoUVkZY7TT8erDaWK6UPkN87TKJn",
    signature: "",
    rpc: "http not an url",
  });

  if (result === SignatureResult.RPC_ERROR) {
    console.log("Error:", reason);
  }
}

itFails();