Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages.

License

Notifications You must be signed in to change notification settings

pradel/sign-in-with-stacks

Repository files navigation

sign-in-with-stacks

Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages.

Documentation

Head to the documentation to read and learn more about the package.

Installation

npm install sign-in-with-stacks

Usage

On the client create a message and sign it with the user's wallet.

import { createSiwsMessage, generateSiwsNonce } from "sign-in-with-stacks";
import { STACKS_MAINNET } from "@stacks/network";
import { openSignatureRequestPopup } from "@stacks/connect";

const message = createSiwsMessage({
  address: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM",
  chainId: STACKS_MAINNET.chainId,
  domain: "example.com",
  nonce: generateSiwsNonce(),
  uri: "https://example.com/path",
  version: "1",
});

await openSignatureRequestPopup({
  message,
  onFinish: async ({ signature }) => {
    // Pass the signature to your backend
  },
});

On the backend verify the signature, can be used with any framework, next-auth, better-auth, express, etc.

import { verifySiwsMessage } from "sign-in-with-stacks";
import { STACKS_MAINNET } from "@stacks/network";

const valid = verifySiwsMessage({
  message,
  signature,
  nonce: "your-nonce",
});

Plugins

Examples

Credits

The first version of this library is a port of the view siwe implementation.

About

Sign-in with Stacks is a library for creating and verifying Sign-In with Stacks messages.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •