@stacks/profile
Advanced tools
Comparing version 6.17.0 to 7.0.0-next.70
@@ -1,2 +0,2 @@ | ||
import { FetchFn } from '@stacks/network'; | ||
import { ClientParam } from '@stacks/common'; | ||
import { PublicPersonProfile } from './types'; | ||
@@ -52,2 +52,5 @@ export declare class Profile { | ||
export declare function getTokenFileUrl(zoneFileJson: any): string | null; | ||
export declare function resolveZoneFileToProfile(zoneFile: any, publicKeyOrAddress: string, fetchFn?: FetchFn): Promise<Record<string, any>>; | ||
export declare function resolveZoneFileToProfile(opts: { | ||
zoneFile: any; | ||
publicKeyOrAddress: string; | ||
} & ClientParam): Promise<Record<string, any>>; |
@@ -1,8 +0,7 @@ | ||
import { signProfileToken, extractProfile } from './profileTokens'; | ||
import { extractProfile, signProfileToken } from './profileTokens'; | ||
import { getPersonFromLegacyFormat } from './profileSchemas'; | ||
import { getName, getFamilyName, getGivenName, getAvatarUrl, getDescription, getVerifiedAccounts, getAddress, getBirthDate, getConnections, getOrganizations, } from './profileSchemas/personUtils'; | ||
import { getAddress, getAvatarUrl, getBirthDate, getConnections, getDescription, getFamilyName, getGivenName, getName, getOrganizations, getVerifiedAccounts, } from './profileSchemas/personUtils'; | ||
import { makeZoneFile, parseZoneFile } from 'zone-file'; | ||
import * as inspector from 'schema-inspector'; | ||
import { Logger } from '@stacks/common'; | ||
import { createFetchFn } from '@stacks/network'; | ||
import { Logger, defaultClientOpts } from '@stacks/common'; | ||
const schemaDefinition = { | ||
@@ -245,7 +244,8 @@ type: 'object', | ||
} | ||
export function resolveZoneFileToProfile(zoneFile, publicKeyOrAddress, fetchFn = createFetchFn()) { | ||
export function resolveZoneFileToProfile(opts) { | ||
const api = defaultClientOpts(opts.client); | ||
return new Promise((resolve, reject) => { | ||
let zoneFileJson = null; | ||
try { | ||
zoneFileJson = parseZoneFile(zoneFile); | ||
zoneFileJson = parseZoneFile(opts.zoneFile); | ||
if (!zoneFileJson.hasOwnProperty('$origin')) { | ||
@@ -264,3 +264,3 @@ zoneFileJson = null; | ||
try { | ||
return resolve(Person.fromLegacyFormat(JSON.parse(zoneFile)).profile()); | ||
return resolve(Person.fromLegacyFormat(JSON.parse(opts.zoneFile)).profile()); | ||
} | ||
@@ -272,3 +272,4 @@ catch (error) { | ||
if (tokenFileUrl) { | ||
fetchFn(tokenFileUrl) | ||
api | ||
.fetch(tokenFileUrl) | ||
.then(response => response.text()) | ||
@@ -278,3 +279,3 @@ .then(responseText => JSON.parse(responseText)) | ||
const tokenRecords = responseJson; | ||
const profile = extractProfile(tokenRecords[0].token, publicKeyOrAddress); | ||
const profile = extractProfile(tokenRecords[0].token, opts.publicKeyOrAddress); | ||
resolve(profile); | ||
@@ -281,0 +282,0 @@ }) |
@@ -1,2 +0,2 @@ | ||
import { FetchFn } from '@stacks/network'; | ||
import { FetchFn } from '@stacks/common'; | ||
export declare function resolveZoneFileToPerson(zoneFile: any, publicKeyOrAddress: string, callback: (profile: any) => void, fetchFn?: FetchFn): void; |
@@ -1,2 +0,2 @@ | ||
import { createFetchFn } from '@stacks/network'; | ||
import { createFetchFn } from '@stacks/common'; | ||
import { parseZoneFile } from 'zone-file'; | ||
@@ -36,5 +36,5 @@ import { getTokenFileUrl, Person } from '../profile'; | ||
fetchFn(tokenFileUrl) | ||
.then(response => response.text()) | ||
.then(responseText => JSON.parse(responseText)) | ||
.then(responseJson => { | ||
.then((response) => response.text()) | ||
.then((responseText) => JSON.parse(responseText)) | ||
.then((responseJson) => { | ||
const tokenRecords = responseJson; | ||
@@ -45,3 +45,3 @@ const token = tokenRecords[0].token; | ||
}) | ||
.catch(error => { | ||
.catch((error) => { | ||
console.warn(error); | ||
@@ -48,0 +48,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { FetchFn } from '@stacks/network'; | ||
import { ClientParam } from '@stacks/common'; | ||
import { PublicPersonProfile } from './types'; | ||
@@ -52,2 +52,5 @@ export declare class Profile { | ||
export declare function getTokenFileUrl(zoneFileJson: any): string | null; | ||
export declare function resolveZoneFileToProfile(zoneFile: any, publicKeyOrAddress: string, fetchFn?: FetchFn): Promise<Record<string, any>>; | ||
export declare function resolveZoneFileToProfile(opts: { | ||
zoneFile: any; | ||
publicKeyOrAddress: string; | ||
} & ClientParam): Promise<Record<string, any>>; |
@@ -33,3 +33,2 @@ "use strict"; | ||
const common_1 = require("@stacks/common"); | ||
const network_1 = require("@stacks/network"); | ||
const schemaDefinition = { | ||
@@ -276,7 +275,8 @@ type: 'object', | ||
exports.getTokenFileUrl = getTokenFileUrl; | ||
function resolveZoneFileToProfile(zoneFile, publicKeyOrAddress, fetchFn = (0, network_1.createFetchFn)()) { | ||
function resolveZoneFileToProfile(opts) { | ||
const api = (0, common_1.defaultClientOpts)(opts.client); | ||
return new Promise((resolve, reject) => { | ||
let zoneFileJson = null; | ||
try { | ||
zoneFileJson = (0, zone_file_1.parseZoneFile)(zoneFile); | ||
zoneFileJson = (0, zone_file_1.parseZoneFile)(opts.zoneFile); | ||
if (!zoneFileJson.hasOwnProperty('$origin')) { | ||
@@ -295,3 +295,3 @@ zoneFileJson = null; | ||
try { | ||
return resolve(Person.fromLegacyFormat(JSON.parse(zoneFile)).profile()); | ||
return resolve(Person.fromLegacyFormat(JSON.parse(opts.zoneFile)).profile()); | ||
} | ||
@@ -303,3 +303,4 @@ catch (error) { | ||
if (tokenFileUrl) { | ||
fetchFn(tokenFileUrl) | ||
api | ||
.fetch(tokenFileUrl) | ||
.then(response => response.text()) | ||
@@ -309,3 +310,3 @@ .then(responseText => JSON.parse(responseText)) | ||
const tokenRecords = responseJson; | ||
const profile = (0, profileTokens_1.extractProfile)(tokenRecords[0].token, publicKeyOrAddress); | ||
const profile = (0, profileTokens_1.extractProfile)(tokenRecords[0].token, opts.publicKeyOrAddress); | ||
resolve(profile); | ||
@@ -312,0 +313,0 @@ }) |
@@ -1,2 +0,2 @@ | ||
import { FetchFn } from '@stacks/network'; | ||
import { FetchFn } from '@stacks/common'; | ||
export declare function resolveZoneFileToPerson(zoneFile: any, publicKeyOrAddress: string, callback: (profile: any) => void, fetchFn?: FetchFn): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveZoneFileToPerson = void 0; | ||
const network_1 = require("@stacks/network"); | ||
const common_1 = require("@stacks/common"); | ||
const zone_file_1 = require("zone-file"); | ||
const profile_1 = require("../profile"); | ||
const profileTokens_1 = require("../profileTokens"); | ||
function resolveZoneFileToPerson(zoneFile, publicKeyOrAddress, callback, fetchFn = (0, network_1.createFetchFn)()) { | ||
function resolveZoneFileToPerson(zoneFile, publicKeyOrAddress, callback, fetchFn = (0, common_1.createFetchFn)()) { | ||
let zoneFileJson = null; | ||
@@ -39,5 +39,5 @@ try { | ||
fetchFn(tokenFileUrl) | ||
.then(response => response.text()) | ||
.then(responseText => JSON.parse(responseText)) | ||
.then(responseJson => { | ||
.then((response) => response.text()) | ||
.then((responseText) => JSON.parse(responseText)) | ||
.then((responseJson) => { | ||
const tokenRecords = responseJson; | ||
@@ -48,3 +48,3 @@ const token = tokenRecords[0].token; | ||
}) | ||
.catch(error => { | ||
.catch((error) => { | ||
console.warn(error); | ||
@@ -51,0 +51,0 @@ }); |
{ | ||
"name": "@stacks/profile", | ||
"version": "6.17.0", | ||
"version": "7.0.0-next.70+0adf46c4", | ||
"description": "Library for Stacks profiles", | ||
@@ -23,5 +23,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@stacks/common": "^6.16.0", | ||
"@stacks/network": "^6.17.0", | ||
"@stacks/transactions": "^6.17.0", | ||
"@stacks/common": "^7.0.0-next.70+0adf46c4", | ||
"@stacks/network": "^7.0.0-next.70+0adf46c4", | ||
"@stacks/transactions": "^7.0.0-next.70+0adf46c4", | ||
"jsontokens": "^4.0.1", | ||
@@ -61,3 +61,3 @@ "schema-inspector": "^2.0.2", | ||
}, | ||
"gitHead": "626e1ca12e300838504dc35b32bfae7a0ebfe109" | ||
"gitHead": "0adf46c4eadac85f234140dc2df0e5d06b0ca775" | ||
} |
@@ -1,15 +0,15 @@ | ||
import { signProfileToken, extractProfile } from './profileTokens'; | ||
import { extractProfile, signProfileToken } from './profileTokens'; | ||
import { getPersonFromLegacyFormat } from './profileSchemas'; | ||
import { | ||
getName, | ||
getFamilyName, | ||
getGivenName, | ||
getAddress, | ||
getAvatarUrl, | ||
getDescription, | ||
getVerifiedAccounts, | ||
getAddress, | ||
getBirthDate, | ||
getConnections, | ||
getDescription, | ||
getFamilyName, | ||
getGivenName, | ||
getName, | ||
getOrganizations, | ||
getVerifiedAccounts, | ||
} from './profileSchemas/personUtils'; | ||
@@ -25,4 +25,3 @@ | ||
import { Logger } from '@stacks/common'; | ||
import { createFetchFn, FetchFn } from '@stacks/network'; | ||
import { ClientParam, Logger, defaultClientOpts } from '@stacks/common'; | ||
import { PublicPersonProfile } from './types'; | ||
@@ -342,10 +341,13 @@ | ||
export function resolveZoneFileToProfile( | ||
zoneFile: any, | ||
publicKeyOrAddress: string, | ||
fetchFn: FetchFn = createFetchFn() | ||
opts: { | ||
zoneFile: any; | ||
publicKeyOrAddress: string; | ||
} & ClientParam | ||
): Promise<Record<string, any>> { | ||
const api = defaultClientOpts(opts.client); | ||
return new Promise((resolve, reject) => { | ||
let zoneFileJson = null; | ||
try { | ||
zoneFileJson = parseZoneFile(zoneFile); | ||
zoneFileJson = parseZoneFile(opts.zoneFile); | ||
if (!zoneFileJson.hasOwnProperty('$origin')) { | ||
@@ -363,3 +365,3 @@ zoneFileJson = null; | ||
try { | ||
return resolve(Person.fromLegacyFormat(JSON.parse(zoneFile)).profile()); | ||
return resolve(Person.fromLegacyFormat(JSON.parse(opts.zoneFile)).profile()); | ||
} catch (error) { | ||
@@ -371,3 +373,4 @@ return reject(error); | ||
if (tokenFileUrl) { | ||
fetchFn(tokenFileUrl) | ||
api | ||
.fetch(tokenFileUrl) | ||
.then(response => response.text()) | ||
@@ -377,3 +380,3 @@ .then(responseText => JSON.parse(responseText)) | ||
const tokenRecords = responseJson; | ||
const profile = extractProfile(tokenRecords[0].token, publicKeyOrAddress); | ||
const profile = extractProfile(tokenRecords[0].token, opts.publicKeyOrAddress); | ||
resolve(profile); | ||
@@ -380,0 +383,0 @@ }) |
@@ -1,3 +0,2 @@ | ||
// @ts-ignore: Could not find a declaration file for module | ||
import { createFetchFn, FetchFn } from '@stacks/network'; | ||
import { createFetchFn, FetchFn } from '@stacks/common'; | ||
import { parseZoneFile } from 'zone-file'; | ||
@@ -51,5 +50,5 @@ | ||
fetchFn(tokenFileUrl) | ||
.then(response => response.text()) | ||
.then(responseText => JSON.parse(responseText)) | ||
.then(responseJson => { | ||
.then((response: any) => response.text()) | ||
.then((responseText: any) => JSON.parse(responseText)) | ||
.then((responseJson: any) => { | ||
const tokenRecords = responseJson; | ||
@@ -61,3 +60,3 @@ const token = tokenRecords[0].token; | ||
}) | ||
.catch(error => { | ||
.catch((error: any) => { | ||
console.warn(error); | ||
@@ -64,0 +63,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
1127854
3480
1
2
+ Added@stacks/common@7.0.2(transitive)
+ Added@stacks/network@7.0.2(transitive)
+ Added@stacks/transactions@7.0.2(transitive)
- Removed@stacks/common@6.16.0(transitive)
- Removed@stacks/network@6.17.0(transitive)
- Removed@stacks/transactions@6.17.0(transitive)
- Removed@types/bn.js@5.1.6(transitive)
- Removed@types/node@18.19.65(transitive)
- Removedundici-types@5.26.5(transitive)