@stackso/core
v0.1.3
Published
NodeJS SDK to interact with the Stack API
Downloads
5
Keywords
Readme
@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,
});