@stacks/profile
Functions for manipulating user profiles.
Installation
npm install @stacks/profile
Get profile from token
import { extractProfile } from '@stacks/profile';
const token = '<insert profile token here>';
const profile = extractProfile(token);
Verify profile token
import { verifyProfileToken } from '@stacks/profile';
const token = '<insert profile token here>';
const publicKey = '<insert public key>';
const decodedToken = verifyProfileToken(token, publicKey);
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);
Profile to token
import { signProfileToken, verifyProfileToken, extractProfile } from '@stacks/profile';
const token = '<insert profile token here>';
const profile = extractProfile(token);
const privateKey = '<private key>';
const publicKey = '<public key>';
const signedToken = signProfileToken(profile, privateKey);
const decodedToken = verifyProfileToken(signedToken, publicKey);
Profile Validation
import { extractProfile, Profile } from '@stacks/profile';
const token = '<insert profile token here>';
const privateKey = '<private key>';
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);