@stackso/core
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@stackso/core

@stackso/core provides a wrapper for the Stack API.

Install packages

pnpm i @stackso/core

Usage

Set environment variables:

STACK_API_KEY=<stack api key>

Usage

import { StackApiClient } from '@stackso/core'

const api = new StackApiClient({
  apiKey: process.env.STACK_API_KEY
});

await api.members.signup({
  email,
  password,
  communityLabel
});

Signup via wallet:

import { StackApiClient } from '@stackso/core';
import crypto from "crypto";

const api = new StackApiClient({
  apiKey: process.env.STACK_API_KEY
});

const communityLabel = "community-label";
const loginMessage = await api.messages.members.signupViaWallet({
  communityLabel
});

const signature = sign(loginMessage); // use wagmi or other library to get signed message

// Returns a JWT that can be used in header 
const { token } = await api.members.signupViaWallet({
  displayName,
  walletAddress,
  signature,
  communityLabel
});

Login via wallet:

import { StackApiClient } from '@stackso/core';
import crypto from "crypto";

let walletAddress; // set to the address signing in

const api = new StackApiClient({
  apiKey: process.env.STACK_API_KEY
});

const nonce = crypto.randomUUID();
const loginMessage = await api.messages.auth.loginViaWallet({
  nonce,
  walletAddress,
});

const signature = sign(loginMessage); // use wagmi or other library to get signed message


// Returns a JWT that can be used in header 
const { token } = await api.auth.loginViawWallet({
  walletAddress,
  signature,
  nonce,
});

/@stackso/core/

    Package Sidebar

    Install

    npm i @stackso/core

    Weekly Downloads

    1

    Version

    0.1.3

    License

    ISC

    Unpacked Size

    124 kB

    Total Files

    41

    Last publish

    Collaborators

    • marystackso
    • graemecode
    • cece_stack
    • volt99