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

@stacks/profile

Package Overview
Dependencies
Maintainers
8
Versions
655
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/profile - npm Package Compare versions

Comparing version 2.0.0-beta.0 to 2.0.0-beta.1

14

dist/esm/profileTokens.js

@@ -1,6 +0,4 @@

import { Buffer } from '@stacks/common';
import { ECPair } from 'bitcoinjs-lib';
import { decodeToken, SECP256K1Client, TokenSigner, TokenVerifier } from 'jsontokens';
import { nextYear, makeUUID4 } from '@stacks/common';
import { ecPairToAddress } from '@stacks/encryption';
import { getAddressFromPublicKey } from '@stacks/transactions';
export function signProfileToken(profile, privateKey, subject, issuer, signingAlgorithm = 'ES256K', issuedAt = new Date(), expiresAt = nextYear()) {

@@ -60,13 +58,7 @@ if (signingAlgorithm !== 'ES256K') {

const issuerPublicKey = payload.issuer.publicKey;
const publicKeyBuffer = Buffer.from(issuerPublicKey, 'hex');
const compressedKeyPair = ECPair.fromPublicKey(publicKeyBuffer, { compressed: true });
const compressedAddress = ecPairToAddress(compressedKeyPair);
const uncompressedKeyPair = ECPair.fromPublicKey(publicKeyBuffer, { compressed: false });
const uncompressedAddress = ecPairToAddress(uncompressedKeyPair);
const address = getAddressFromPublicKey(issuerPublicKey);
if (publicKeyOrAddress === issuerPublicKey) {
}
else if (publicKeyOrAddress === compressedAddress) {
else if (publicKeyOrAddress === address) {
}
else if (publicKeyOrAddress === uncompressedAddress) {
}
else {

@@ -73,0 +65,0 @@ throw new Error('Token issuer public key does not match the verifying value');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractProfile = exports.verifyProfileToken = exports.wrapProfileToken = exports.signProfileToken = void 0;
const jsontokens_1 = require("jsontokens");
const common_1 = require("@stacks/common");
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
const jsontokens_1 = require("jsontokens");
const common_2 = require("@stacks/common");
const encryption_1 = require("@stacks/encryption");
function signProfileToken(profile, privateKey, subject, issuer, signingAlgorithm = 'ES256K', issuedAt = new Date(), expiresAt = common_2.nextYear()) {
const transactions_1 = require("@stacks/transactions");
function signProfileToken(profile, privateKey, subject, issuer, signingAlgorithm = 'ES256K', issuedAt = new Date(), expiresAt = common_1.nextYear()) {
if (signingAlgorithm !== 'ES256K') {

@@ -22,3 +20,3 @@ throw new Error('Signing algorithm not supported');

const payload = {
jti: common_2.makeUUID4(),
jti: common_1.makeUUID4(),
iat: issuedAt.toISOString(),

@@ -66,13 +64,7 @@ exp: expiresAt.toISOString(),

const issuerPublicKey = payload.issuer.publicKey;
const publicKeyBuffer = common_1.Buffer.from(issuerPublicKey, 'hex');
const compressedKeyPair = bitcoinjs_lib_1.ECPair.fromPublicKey(publicKeyBuffer, { compressed: true });
const compressedAddress = encryption_1.ecPairToAddress(compressedKeyPair);
const uncompressedKeyPair = bitcoinjs_lib_1.ECPair.fromPublicKey(publicKeyBuffer, { compressed: false });
const uncompressedAddress = encryption_1.ecPairToAddress(uncompressedKeyPair);
const address = transactions_1.getAddressFromPublicKey(issuerPublicKey);
if (publicKeyOrAddress === issuerPublicKey) {
}
else if (publicKeyOrAddress === compressedAddress) {
else if (publicKeyOrAddress === address) {
}
else if (publicKeyOrAddress === uncompressedAddress) {
}
else {

@@ -79,0 +71,0 @@ throw new Error('Token issuer public key does not match the verifying value');

{
"name": "@stacks/profile",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"description": "Library for Stacks profiles",

@@ -39,5 +39,4 @@ "keywords": [

"@stacks/common": "^2.0.0-beta.0",
"@stacks/encryption": "^2.0.0-beta.0",
"@stacks/network": "^1.2.2",
"bitcoinjs-lib": "^5.2.0",
"@stacks/transactions": "^2.0.0-beta.1",
"jsontokens": "^3.0.0",

@@ -65,3 +64,3 @@ "schema-inspector": "^2.0.1",

"unpkg": "dist/index.umd.js",
"gitHead": "6d58c4273399a3644351d0fa822d6b94091679c1"
"gitHead": "49425044179afac8fbedda2d57fe081950580bbd"
}

@@ -1,7 +0,5 @@

import { Buffer } from '@stacks/common';
import { ECPair } from 'bitcoinjs-lib';
import { decodeToken, SECP256K1Client, TokenSigner, TokenVerifier } from 'jsontokens';
import { TokenInterface } from 'jsontokens/lib/decode';
import { nextYear, makeUUID4 } from '@stacks/common';
import { ecPairToAddress } from '@stacks/encryption';
import { getAddressFromPublicKey } from '@stacks/transactions';

@@ -108,15 +106,8 @@ /**

const issuerPublicKey = (payload.issuer as Record<string, string>).publicKey;
const publicKeyBuffer = Buffer.from(issuerPublicKey, 'hex');
const address = getAddressFromPublicKey(issuerPublicKey);
const compressedKeyPair = ECPair.fromPublicKey(publicKeyBuffer, { compressed: true });
const compressedAddress = ecPairToAddress(compressedKeyPair);
const uncompressedKeyPair = ECPair.fromPublicKey(publicKeyBuffer, { compressed: false });
const uncompressedAddress = ecPairToAddress(uncompressedKeyPair);
if (publicKeyOrAddress === issuerPublicKey) {
// pass
} else if (publicKeyOrAddress === compressedAddress) {
} else if (publicKeyOrAddress === address) {
// pass
} else if (publicKeyOrAddress === uncompressedAddress) {
// pass
} else {

@@ -123,0 +114,0 @@ throw new Error('Token issuer public key does not match the verifying value');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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