Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stacks/profile

Package Overview
Dependencies
Maintainers
0
Versions
655
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/profile

Library for Stacks profiles

  • 6.14.1-next.38
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.6K
decreased by-3.47%
Maintainers
0
Weekly downloads
 
Created
Source

@stacks/profile

Functions for manipulating user profiles.

Installation

npm install @stacks/profile

Get profile from token

import { extractProfile } from '@stacks/profile';

// Token received after signin in browser using auth or connect package
const token = '<insert profile token here>';

const profile = extractProfile(token);
// profile

Verify profile token

import { verifyProfileToken } from '@stacks/profile';

// Token received after signin in browser using auth or connect package
const token = '<insert profile token here>';
const publicKey = '<insert public key>';

const decodedToken = verifyProfileToken(token, publicKey);
// decodedToken if verified successfully
// Otherwise throws an error if token verification fails

Make zonefile

import { makeProfileZoneFile } from '@stacks/profile';

const fileUrl = 'https://_example_.s3.amazonaws.com/naval.id/profile.json';
const origin = 'naval.id';
const zoneFile = makeProfileZoneFile(origin, fileUrl);
// zoneFile contents

Profile to token

import { signProfileToken, verifyProfileToken, extractProfile } from '@stacks/profile';

// Token received after signin in browser using auth or connect
const token = '<insert profile token here>';
const profile = extractProfile(token);
// warning: Do not expose your private key by hard coding in code. Use env variables to load private keys.
const privateKey = '<private key>'; // process.env.privateKey
const publicKey = '<public key>';

const signedToken = signProfileToken(profile, privateKey);
const decodedToken = verifyProfileToken(signedToken, publicKey);
// decodedToken if verified successfully
// Otherwise throws an error if token verification fails

Profile Validation

import { extractProfile, Profile } from '@stacks/profile';

// Token received after signin in browser using auth or connect
const token = '<insert profile token here>';
// warning: Do not expose your private key by hard coding in code. Use env variables to load private keys.
const privateKey = '<private key>'; // process.env.privateKey
const publicKey = '<public key>';

const profile = extractProfile(token);

const profileObject = new Profile(profile);
console.log(profileObject);

const validationResults = Profile.validateSchema(profile);
console.log(validationResults.valid);

const profileJson = profileObject.toJSON();
console.log(profileJson);

const tokenRecords = profileObject.toToken(privateKey);
console.log(tokenRecords);

const profileFromToken = Profile.fromToken(tokenRecords, publicKey);
console.log(profileFromToken);

Keywords

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc