@stacks/profile
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
128386
2585
+ Added@stacks/transactions@2.0.1(transitive)
+ Added@types/elliptic@6.4.18(transitive)
+ Added@types/randombytes@2.0.3(transitive)
+ Added@types/sha.js@2.4.4(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedc32check@1.1.3(transitive)
+ Addedcross-sha256@1.2.0(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
- Removed@stacks/encryption@^2.0.0-beta.0
- Removedbitcoinjs-lib@^5.2.0
- Removed@stacks/encryption@2.0.1(transitive)
- Removed@types/node@10.12.18(transitive)
- Removedbech32@1.1.4(transitive)
- Removedbindings@1.5.0(transitive)
- Removedbip174@2.1.1(transitive)
- Removedbip32@2.0.6(transitive)
- Removedbip39@3.1.0(transitive)
- Removedbip66@1.1.5(transitive)
- Removedbitcoin-ops@1.4.1(transitive)
- Removedbitcoinjs-lib@5.2.0(transitive)
- Removedbs58@4.0.1(transitive)
- Removedbs58check@2.1.2(transitive)
- Removedcipher-base@1.0.6(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedcreate-hmac@1.1.7(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedhash-base@3.1.0(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedmerkle-lib@2.0.10(transitive)
- Removednan@2.22.0(transitive)
- Removedpushdata-bitcoin@1.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedtiny-secp256k1@1.1.7(transitive)
- Removedtypeforce@1.18.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvaruint-bitcoin@1.1.2(transitive)
- Removedwif@2.0.6(transitive)