# profile | Stacks.js 1.4.1 Library Reference
Documentation for Stacks.js 1.4.1 Library Reference

# @stacks/profile

Functions for manipulating user profiles.

## Installation

    npm install @stacks/profile

## Index

### Classes

- Profile

### Functions

- extractProfile
- signProfileToken
- verifyProfileToken
- wrapProfileToken

## Functions

### extractProfile

- extractProfile(token: string, publicKeyOrAddress?: string | null): Record<string, any>

- - Defined in packages/profile/src/profileTokens.ts:138

  Extracts a profile from an encoded token and optionally verifies it, if `publicKeyOrAddress` is provided.

  throws

    {Error} - if the token isn't signed by the provided `publicKeyOrAddress`

  #### Parameters

  - ##### token: string

    the token to be extracted

  - ##### publicKeyOrAddress: string | null = null

    the public key or address of the keypair that is thought to have signed the token

  #### Returns Record<string, any>

  - the profile extracted from the encoded token

### signProfileToken

- signProfileToken(profile: any, privateKey: string, subject?: any, issuer?: any, signingAlgorithm?: string, issuedAt?: Date, expiresAt?: Date): string

- - Defined in packages/profile/src/profileTokens.ts:18

  Signs a profile token

  #### Parameters

  - ##### profile: any

    the JSON of the profile to be signed

  - ##### privateKey: string

    the signing private key

  - ##### Optional subject: any

    the entity that the information is about

  - ##### Optional issuer: any

    the entity that is issuing the token

  - ##### signingAlgorithm: string = 'ES256K'

    the signing algorithm to use

  - ##### issuedAt: Date = ...

    the time of issuance of the token

  - ##### expiresAt: Date = ...

    the time of expiration of the token

  #### Returns string

  - the signed profile token

### verifyProfileToken

- verifyProfileToken(token: string, publicKeyOrAddress: string): TokenInterface

- - Defined in packages/profile/src/profileTokens.ts:75

  Verifies a profile token

  throws

    {Error} - throws an error if token verification fails

  #### Parameters

  - ##### token: string

    the token to be verified

  - ##### publicKeyOrAddress: string

    the public key or address of the keypair that is thought to have signed the token

  #### Returns TokenInterface

  - the verified, decoded profile token

### wrapProfileToken

- wrapProfileToken(token: string): { decodedToken: TokenInterface; token: string }

- - Defined in packages/profile/src/profileTokens.ts:60

  Wraps a token for a profile token file

  #### Parameters

  - ##### token: string

    the token to be wrapped

  #### Returns { decodedToken: TokenInterface; token: string }

  - including `token` and `decodedToken`

  - ##### decodedToken: TokenInterface

  - ##### token: string

Generated using TypeDoc