Skip to content

Instantly share code, notes, and snippets.

@zone117x
Created March 7, 2019 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zone117x/24397b47cd7fde5644a18a82fc377091 to your computer and use it in GitHub Desktop.
Save zone117x/24397b47cd7fde5644a18a82fc377091 to your computer and use it in GitHub Desktop.
blockstack.d.ts
/// <reference types="bigi" />
/// <reference types="node" />
/// <reference types="bn.js" />
declare module "errors" {
export const ERROR_CODES: {
MISSING_PARAMETER: string;
REMOTE_SERVICE_ERROR: string;
INVALID_STATE: string;
NO_SESSION_DATA: string;
UNKNOWN: string;
};
type ErrorType = {
code: string;
parameter?: string;
message: string;
};
export class BlockstackError extends Error {
message: string;
code: string;
parameter?: string;
constructor(error: ErrorType);
toString(): string;
}
export class InvalidParameterError extends BlockstackError {
constructor(parameter: string, message?: string);
}
export class MissingParameterError extends BlockstackError {
constructor(parameter: string, message?: string);
}
export class RemoteServiceError extends BlockstackError {
response: Response;
constructor(response: Response, message?: string);
}
export class InvalidDIDError extends BlockstackError {
constructor(message?: string);
}
export class NotEnoughFundsError extends BlockstackError {
leftToFund: number;
constructor(leftToFund: number);
}
export class InvalidAmountError extends BlockstackError {
fees: number;
specifiedAmount: number;
constructor(fees: number, specifiedAmount: number);
}
export class LoginFailedError extends BlockstackError {
constructor(reason: string);
}
export class SignatureVerificationError extends BlockstackError {
constructor(reason: string);
}
export class InvalidStateError extends BlockstackError {
constructor(message: string);
}
export class NoSessionDataError extends BlockstackError {
constructor(message: string);
}
}
declare module "logger" {
export const levels: string[];
export class Logger {
static error(message: string): void;
static warn(message: string): void;
static info(message: string): void;
static debug(message: string): void;
static logMessage(level: string, message: string): string;
static shouldLog(level: string): boolean;
}
}
declare module "network" {
import bitcoinjs from 'bitcoinjs-lib';
import bigi from 'bigi';
export type UTXO = {
value?: number;
confirmations?: number;
tx_hash: string;
tx_output_n: number;
};
export class BitcoinNetwork {
broadcastTransaction(transaction: string): Promise<any>;
getBlockHeight(): Promise<number>;
getTransactionInfo(txid: string): Promise<{
block_height: number;
}>;
getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
}
export class BlockstackNetwork {
blockstackAPIUrl: string;
broadcastServiceUrl: string;
layer1: any;
DUST_MINIMUM: number;
includeUtxoMap: {
[address: string]: UTXO[];
};
excludeUtxoSet: Array<UTXO>;
btc: BitcoinNetwork;
MAGIC_BYTES: string;
constructor(apiUrl: string, broadcastServiceUrl: string, bitcoinAPI: BitcoinNetwork, network?: bitcoinjs.Network);
coerceAddress(address: string): string;
getDefaultBurnAddress(): string;
/**
* Get the price of a name via the legacy /v1/prices API endpoint.
* @param {String} fullyQualifiedName the name to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
* @private
*/
getNamePriceV1(fullyQualifiedName: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* Get the price of a namespace via the legacy /v1/prices API endpoint.
* @param {String} namespaceID the namespace to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
* @private
*/
getNamespacePriceV1(namespaceID: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* Get the price of a name via the /v2/prices API endpoint.
* @param {String} fullyQualifiedName the name to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
* @private
*/
getNamePriceV2(fullyQualifiedName: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* Get the price of a namespace via the /v2/prices API endpoint.
* @param {String} namespaceID the namespace to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
* @private
*/
getNamespacePriceV2(namespaceID: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* Get the price of a name.
* @param {String} fullyQualifiedName the name to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }, where
* .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and
* .amount encodes the number of units, in the smallest denominiated amount
* (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS,
* .amount will be microStacks)
*/
getNamePrice(fullyQualifiedName: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* Get the price of a namespace
* @param {String} namespaceID the namespace to query
* @return {Promise} a promise to an Object with { units: String, amount: BigInteger }, where
* .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and
* .amount encodes the number of units, in the smallest denominiated amount
* (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS,
* .amount will be microStacks)
*/
getNamespacePrice(namespaceID: string): Promise<{
units: string;
amount: bigi;
}>;
/**
* How many blocks can pass between a name expiring and the name being able to be
* re-registered by a different owner?
* @param {string} fullyQualifiedName unused
* @return {Promise} a promise to the number of blocks
*/
getGracePeriod(fullyQualifiedName?: string): Promise<number>;
/**
* Get the names -- both on-chain and off-chain -- owned by an address.
* @param {String} address the blockchain address (the hash of the owner public key)
* @return {Promise} a promise that resolves to a list of names (Strings)
*/
getNamesOwned(address: string): Promise<string[]>;
/**
* Get the blockchain address to which a name's registration fee must be sent
* (the address will depend on the namespace in which it is registered.)
* @param {String} namespace the namespace ID
* @return {Promise} a promise that resolves to an address (String)
*/
getNamespaceBurnAddress(namespace: string): Promise<string>;
/**
* Get WHOIS-like information for a name, including the address that owns it,
* the block at which it expires, and the zone file anchored to it (if available).
* @param {String} fullyQualifiedName the name to query. Can be on-chain of off-chain.
* @return {Promise} a promise that resolves to the WHOIS-like information
*/
getNameInfo(fullyQualifiedName: string): Promise<any>;
/**
* Get the pricing parameters and creation history of a namespace.
* @param {String} namespaceID the namespace to query
* @return {Promise} a promise that resolves to the namespace information.
*/
getNamespaceInfo(namespaceID: string): Promise<any>;
/**
* Get a zone file, given its hash. Throws an exception if the zone file
* obtained does not match the hash.
* @param {String} zonefileHash the ripemd160(sha256) hash of the zone file
* @return {Promise} a promise that resolves to the zone file's text
*/
getZonefile(zonefileHash: string): Promise<string>;
/**
* Get the status of an account for a particular token holding. This includes its total number of
* expenditures and credits, lockup times, last txid, and so on.
* @param {String} address the account
* @param {String} tokenType the token type to query
* @return {Promise} a promise that resolves to an object representing the state of the account
* for this token
*/
getAccountStatus(address: string, tokenType: string): Promise<any>;
/**
* Get a page of an account's transaction history.
* @param {String} address the account's address
* @param {number} page the page number. Page 0 is the most recent transactions
* @return {Promise} a promise that resolves to an Array of Objects, where each Object encodes
* states of the account at various block heights (e.g. prior balances, txids, etc)
*/
getAccountHistoryPage(address: string, page: number): Promise<any[]>;
/**
* Get the state(s) of an account at a particular block height. This includes the state of the
* account beginning with this block's transactions, as well as all of the states the account
* passed through when this block was processed (if any).
* @param {String} address the account's address
* @param {Integer} blockHeight the block to query
* @return {Promise} a promise that resolves to an Array of Objects, where each Object encodes
* states of the account at this block.
*/
getAccountAt(address: string, blockHeight: number): Promise<any[]>;
/**
* Get the set of token types that this account owns
* @param {String} address the account's address
* @return {Promise} a promise that resolves to an Array of Strings, where each item encodes the
* type of token this account holds (excluding the underlying blockchain's tokens)
*/
getAccountTokens(address: string): Promise<string[]>;
/**
* Get the number of tokens owned by an account. If the account does not exist or has no
* tokens of this type, then 0 will be returned.
* @param {String} address the account's address
* @param {String} tokenType the type of token to query.
* @return {Promise} a promise that resolves to a BigInteger that encodes the number of tokens
* held by this account.
*/
getAccountBalance(address: string, tokenType: string): Promise<bigi>;
/**
* Performs a POST request to the given URL
* @param {String} endpoint the name of
* @param {String} body [description]
* @return {Promise<Object|Error>} Returns a `Promise` that resolves to the object requested.
* In the event of an error, it rejects with:
* * a `RemoteServiceError` if there is a problem
* with the transaction broadcast service
* * `MissingParameterError` if you call the function without a required
* parameter
*
* @private
*/
broadcastServiceFetchHelper(endpoint: string, body: any): Promise<any | Error>;
/**
* Broadcasts a signed bitcoin transaction to the network optionally waiting to broadcast the
* transaction until a second transaction has a certain number of confirmations.
*
* @param {string} transaction the hex-encoded transaction to broadcast
* @param {string} transactionToWatch the hex transaction id of the transaction to watch for
* the specified number of confirmations before broadcasting the `transaction`
* @param {number} confirmations the number of confirmations `transactionToWatch` must have
* before broadcasting `transaction`.
* @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
* `transaction_hash` key containing the transaction hash of the broadcasted transaction.
*
* In the event of an error, it rejects with:
* * a `RemoteServiceError` if there is a problem
* with the transaction broadcast service
* * `MissingParameterError` if you call the function without a required
* parameter
* @private
*/
broadcastTransaction(transaction: string, transactionToWatch?: string, confirmations?: number): Promise<any>;
/**
* Broadcasts a zone file to the Atlas network via the transaction broadcast service.
*
* @param {String} zoneFile the zone file to be broadcast to the Atlas network
* @param {String} transactionToWatch the hex transaction id of the transaction
* to watch for confirmation before broadcasting the zone file to the Atlas network
* @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
* `transaction_hash` key containing the transaction hash of the broadcasted transaction.
*
* In the event of an error, it rejects with:
* * a `RemoteServiceError` if there is a problem
* with the transaction broadcast service
* * `MissingParameterError` if you call the function without a required
* parameter
* @private
*/
broadcastZoneFile(zoneFile?: string, transactionToWatch?: string): Promise<any>;
/**
* Sends the preorder and registration transactions and zone file
* for a Blockstack name registration
* along with the to the transaction broadcast service.
*
* The transaction broadcast:
*
* * immediately broadcasts the preorder transaction
* * broadcasts the register transactions after the preorder transaction
* has an appropriate number of confirmations
* * broadcasts the zone file to the Atlas network after the register transaction
* has an appropriate number of confirmations
*
* @param {String} preorderTransaction the hex-encoded, signed preorder transaction generated
* using the `makePreorder` function
* @param {String} registerTransaction the hex-encoded, signed register transaction generated
* using the `makeRegister` function
* @param {String} zoneFile the zone file to be broadcast to the Atlas network
* @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
* `transaction_hash` key containing the transaction hash of the broadcasted transaction.
*
* In the event of an error, it rejects with:
* * a `RemoteServiceError` if there is a problem
* with the transaction broadcast service
* * `MissingParameterError` if you call the function without a required
* parameter
* @private
*/
broadcastNameRegistration(preorderTransaction: string, registerTransaction: string, zoneFile: string): Promise<any>;
getFeeRate(): Promise<number>;
countDustOutputs(): void;
getUTXOs(address: string): Promise<Array<UTXO>>;
/**
* This will modify the network's utxo set to include UTXOs
* from the given transaction and exclude UTXOs *spent* in
* that transaction
* @param {String} txHex - the hex-encoded transaction to use
* @return {void} no return value, this modifies the UTXO config state
* @private
*/
modifyUTXOSetFrom(txHex: string): void;
resetUTXOs(address: string): void;
getConsensusHash(): Promise<any>;
getTransactionInfo(txHash: string): Promise<{
block_height: number;
}>;
getBlockHeight(): Promise<number>;
getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
}
export class LocalRegtest extends BlockstackNetwork {
constructor(apiUrl: string, broadcastServiceUrl: string, bitcoinAPI: BitcoinNetwork);
getFeeRate(): Promise<number>;
}
export class BitcoindAPI extends BitcoinNetwork {
bitcoindUrl: string;
bitcoindCredentials: {
username: string;
password: string;
};
importedBefore: any;
constructor(bitcoindUrl: string, bitcoindCredentials: {
username: string;
password: string;
});
broadcastTransaction(transaction: string): Promise<any>;
getBlockHeight(): Promise<any>;
getTransactionInfo(txHash: string): Promise<{
block_height: number;
}>;
getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
}
export class InsightClient extends BitcoinNetwork {
apiUrl: string;
constructor(insightUrl?: string);
broadcastTransaction(transaction: string): Promise<any>;
getBlockHeight(): Promise<any>;
getTransactionInfo(txHash: string): Promise<{
block_height: number;
}>;
getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
}
export class BlockchainInfoApi extends BitcoinNetwork {
utxoProviderUrl: string;
constructor(blockchainInfoUrl?: string);
getBlockHeight(): Promise<any>;
getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
getTransactionInfo(txHash: string): Promise<{
block_height: number;
}>;
broadcastTransaction(transaction: string): Promise<string>;
}
export const network: {
BlockstackNetwork: typeof BlockstackNetwork;
LocalRegtest: typeof LocalRegtest;
BlockchainInfoApi: typeof BlockchainInfoApi;
BitcoindAPI: typeof BitcoindAPI;
InsightClient: typeof InsightClient;
defaults: {
LOCAL_REGTEST: LocalRegtest;
MAINNET_DEFAULT: BlockstackNetwork;
};
};
}
declare module "config" {
const config: {
network: import("network").BlockstackNetwork;
logLevel: string;
};
export { config };
}
declare module "dids" {
export function makeDIDFromAddress(address: string): string;
export function makeDIDFromPublicKey(publicKey: string): string;
export function getDIDType(decentralizedID: string): string;
export function getAddressFromDID(decentralizedID: string): string;
}
declare module "auth/authConstants" {
export const BLOCKSTACK_HANDLER = "blockstack";
export const BLOCKSTACK_STORAGE_LABEL = "blockstack";
export const DEFAULT_BLOCKSTACK_HOST = "https://browser.blockstack.org/auth";
export const DEFAULT_SCOPE: string[];
export const BLOCKSTACK_APP_PRIVATE_KEY_LABEL = "blockstack-transit-private-key";
export const BLOCKSTACK_DEFAULT_GAIA_HUB_URL = "https://hub.blockstack.org";
export const DEFAULT_CORE_NODE = "https://core.blockstack.org";
export const NAME_LOOKUP_PATH = "/v1/names";
export const LOCALSTORAGE_SESSION_KEY = "blockstack-session";
}
declare module "auth/appConfig" {
/**
* Configuration data for the current app.
*
* On browser platforms, creating an instance of this
* class without any arguments will use
* `window.location.origin` as the app domain.
* On non-browser platforms, you need to
* specify an app domain as the first argument.
* @type {AppConfig}
*/
export class AppConfig {
/**
* Blockstack apps are uniquely identified by their app domain.
* @type {string}
*/
appDomain: string;
/**
* An array of string representing permissions requested by the app.
* @type {[Array<string>}
*/
scopes: Array<string>;
/**
* Path on app domain to redirect users to after authentication. The
* authentication response token will be postpended in a query.
* @type {string}
*/
redirectPath: string;
/**
* Path relative to app domain of app's manifest file.
*
* This file needs to have CORS headers set so that it can be fetched
* from any origin. Typically this means return the header `Access-Control-Allow-Origin: *`.
* @type {string}
*/
manifestPath: string;
/**
* The URL of Blockstack core node to use for this app. If this is
* `null`, the core node specified by the user or default core node
* will be used.
* @type {string}
*/
coreNode: string;
/**
* The URL of a web-based Blockstack Authenticator to use in the event
* the user doesn't have Blockstack installed on their machine. If this
* is not specified, the current default in this library will be used.
* @type {string}
*/
authenticatorURL?: string;
/**
* @param {Array<string>} scopes - permissions this app is requesting
* @param {string} appDomain - the app domain
* @param {string} redirectPath - path on app domain to redirect users to after authentication
* @param {string} manifestPath - path relative to app domain of app's manifest file
* @param {string} coreNode - override the default or user selected core node
* @param {string} authenticatorURL - the web-based fall back authenticator
*/
constructor(scopes?: Array<string>, appDomain?: string, redirectPath?: string, manifestPath?: string, coreNode?: string | null, authenticatorURL?: string);
/**
* The location to which the authenticator should
* redirect the user.
* @returns {string} - URI
*/
redirectURI(): string;
/**
* The location of the app's manifest file.
* @returns {string} - URI
*/
manifestURI(): string;
}
}
declare module "keys" {
export function getEntropy(numberOfBytes: number): Buffer;
export function makeECPrivateKey(): string;
export function publicKeyToAddress(publicKey: string): string;
export function getPublicKeyFromPrivate(privateKey: string): string;
}
declare module "encryption/ec" {
import BN from 'bn.js';
export type CipherObject = {
iv: string;
ephemeralPK: string;
cipherText: string;
mac: string;
wasString: boolean;
};
export function getHexFromBN(bnInput: BN): string;
/**
* Encrypt content to elliptic curve publicKey using ECIES
* @param {String} publicKey - secp256k1 public key hex string
* @param {String | Buffer} content - content to encrypt
* @return {Object} Object containing (hex encoded):
* iv (initialization vector), cipherText (cipher text),
* mac (message authentication code), ephemeral public key
* wasString (boolean indicating with or not to return a buffer or string on decrypt)
* @private
*/
export function encryptECIES(publicKey: string, content: string | Buffer): CipherObject;
/**
* Decrypt content encrypted using ECIES
* @param {String} privateKey - secp256k1 private key hex string
* @param {Object} cipherObject - object to decrypt, should contain:
* iv (initialization vector), cipherText (cipher text),
* mac (message authentication code), ephemeralPublicKey
* wasString (boolean indicating with or not to return a buffer or string on decrypt)
* @return {Buffer} plaintext
* @throws {Error} if unable to decrypt
* @private
*/
export function decryptECIES(privateKey: string, cipherObject: CipherObject): Buffer | string;
/**
* Sign content using ECDSA
* @private
* @param {String} privateKey - secp256k1 private key hex string
* @param {Object} content - content to sign
* @return {Object} contains:
* signature - Hex encoded DER signature
* public key - Hex encoded private string taken from privateKey
* @private
*/
export function signECDSA(privateKey: string, content: string | Buffer): {
publicKey: string;
signature: string;
};
/**
* Verify content using ECDSA
* @param {String | Buffer} content - Content to verify was signed
* @param {String} publicKey - secp256k1 private key hex string
* @param {String} signature - Hex encoded DER signature
* @return {Boolean} returns true when signature matches publickey + content, false if not
* @private
*/
export function verifyECDSA(content: string | ArrayBuffer | Buffer, publicKey: string, signature: string): boolean;
}
declare module "auth/authMessages" {
import 'cross-fetch/polyfill';
type AuthMetadata = {
email?: string;
profileUrl?: string;
};
/**
* Generates a ECDSA keypair to
* use as the ephemeral app transit private key
* @param {SessionData} session - session object in which key will be stored
* @return {String} the hex encoded private key
* @private
*/
export function generateTransitKey(): string;
/**
* Generates an authentication request that can be sent to the Blockstack
* browser for the user to approve sign in. This authentication request can
* then be used for sign in by passing it to the `redirectToSignInWithAuthRequest`
* method.
*
* *Note: This method should only be used if you want to roll your own authentication
* flow. Typically you'd use `redirectToSignIn` which takes care of this
* under the hood.*
*
* @param {String} transitPrivateKey - hex encoded transit private key
* @param {String} redirectURI - location to redirect user to after sign in approval
* @param {String} manifestURI - location of this app's manifest file
* @param {Array<String>} scopes - the permissions this app is requesting
* @param {String} appDomain - the origin of this app
* @param {Number} expiresAt - the time at which this request is no longer valid
* @param {Object} extraParams - Any extra parameters you'd like to pass to the authenticator.
* Use this to pass options that aren't part of the Blockstack auth spec, but might be supported
* by special authenticators.
* @return {String} the authentication request
* @private
*/
export function makeAuthRequestImpl(transitPrivateKey: string, redirectURI: string, manifestURI: string, scopes: Array<string>, appDomain: string, expiresAt: number, extraParams?: any): string;
/**
* Encrypts the private key for decryption by the given
* public key.
* @param {String} publicKey [description]
* @param {String} privateKey [description]
* @return {String} hex encoded ciphertext
* @private
*/
export function encryptPrivateKey(publicKey: string, privateKey: string): string | null;
/**
* Decrypts the hex encrypted private key
* @param {String} privateKey the private key corresponding to the public
* key for which the ciphertext was encrypted
* @param {String} hexedEncrypted the ciphertext
* @return {String} the decrypted private key
* @throws {Error} if unable to decrypt
*
* @private
*/
export function decryptPrivateKey(privateKey: string, hexedEncrypted: string): string | null;
/**
* Generates a signed authentication response token for an app. This
* token is sent back to apps which use contents to access the
* resources and data requested by the app.
*
* @param {String} privateKey the identity key of the Blockstack ID generating
* the authentication response
* @param {Object} profile the profile object for the Blockstack ID
* @param {String} username the username of the Blockstack ID if any, otherwise `null`
* @param {AuthMetadata} metadata an object containing metadata sent as part of the authentication
* response including `email` if requested and available and a URL to the profile
* @param {String} coreToken core session token when responding to a legacy auth request
* or `null` for current direct to gaia authentication requests
* @param {String} appPrivateKey the application private key. This private key is
* unique and specific for every Blockstack ID and application combination.
* @param {Number} expiresAt an integer in the same format as
* `new Date().getTime()`, milliseconds since the Unix epoch
* @param {String} transitPublicKey the public key provide by the app
* in its authentication request with which secrets will be encrypted
* @param {String} hubUrl URL to the write path of the user's Gaia hub
* @param {String} blockstackAPIUrl URL to the API endpoint to use
* @param {String} associationToken JWT that binds the app key to the identity key
* @return {String} signed and encoded authentication response token
* @private
*/
export function makeAuthResponse(privateKey: string, profile: {}, username: string, metadata: AuthMetadata, coreToken?: string, appPrivateKey?: string, expiresAt?: number, transitPublicKey?: string, hubUrl?: string, blockstackAPIUrl?: string, associationToken?: string): string;
}
declare module "utils" {
import { ECPair } from 'bitcoinjs-lib';
export const BLOCKSTACK_HANDLER = "blockstack";
/**
* Time
* @private
*/
export function nextYear(): Date;
export function nextMonth(): Date;
export function nextHour(): Date;
/**
* Query Strings
* @private
*/
export function updateQueryStringParameter(uri: string, key: string, value: string): string;
/**
* Versioning
* @param {string} v1 - the left half of the version inequality
* @param {string} v2 - right half of the version inequality
* @returns {bool} iff v1 >= v2
* @private
*/
export function isLaterVersion(v1: string, v2: string): boolean;
export function hexStringToECPair(skHex: string): ECPair;
export function ecPairToHexString(secretKey: ECPair): string;
export function ecPairToAddress(keyPair: ECPair): string;
/**
* UUIDs
* @private
*/
export function makeUUID4(): string;
/**
* Checks if both urls pass the same origin check & are absolute
* @param {[type]} uri1 first uri to check
* @param {[type]} uri2 second uri to check
* @return {Boolean} true if they pass the same origin check
* @private
*/
export function isSameOriginAbsoluteUrl(uri1: string, uri2: string): boolean;
}
declare module "auth/authProvider" {
/**
* Retrieves the authentication request from the query string
* @return {String|null} the authentication request or `null` if
* the query string parameter `authRequest` is not found
* @private
*/
export function getAuthRequestFromURL(): string;
/**
* Fetches the contents of the manifest file specified in the authentication request
*
* @param {String} authRequest encoded and signed authentication request
* @return {Promise<Object|String>} Returns a `Promise` that resolves to the JSON
* object manifest file unless there's an error in which case rejects with an error
* message.
* @private
*/
export function fetchAppManifest(authRequest: string): Promise<any>;
/**
* Redirect the user's browser to the app using the `redirect_uri`
* specified in the authentication request, passing the authentication
* response token as a query parameter.
*
* @param {String} authRequest encoded and signed authentication request token
* @param {String} authResponse encoded and signed authentication response token
* @return {void}
* @throws {Error} if there is no redirect uri
* @private
*/
export function redirectUserToApp(authRequest: string, authResponse: string): void;
}
declare module "auth/authSession" {
import 'cross-fetch/polyfill';
/**
* Create an authentication token to be sent to the Core API server
* in order to generate a Core session JWT.
*
* @param {String} appDomain The unique application identifier (e.g. foo.app, www.foo.com, etc).
* @param {Array} appMethods The list of API methods this application will need.
* @param {String} appPrivateKey The application-specific private key
* @param {String|null} blockchainID This is the blockchain ID of the requester
* @param {String} thisDevice Identifier of the current device
*
* @return {String} a JWT signed by the app's private key
* @deprecated
* @private
*/
export function makeCoreSessionRequest(appDomain: string, appMethods: Array<string>, appPrivateKey: string, blockchainID?: string, thisDevice?: string): any;
/**
* Send Core a request for a session token.
*
* @param {String} coreHost host name of the core node
* @param {Number} corePort port number of the core node
* @param {String} coreAuthRequest a signed JWT encoding the authentication request
* @param {String} apiPassword the API password for Core
*
* @return {Promise} the resolves to a JWT signed with the Core API server's private key
* that authorizes the bearer to carry out the requested operations and rejects
* with an error message otherwise
* @deprecated
* @private
*/
export function sendCoreSessionRequest(coreHost: string, corePort: number, coreAuthRequest: string, apiPassword: string): Promise<any>;
/**
* Get a core session token. Generate an auth request, sign it, send it to Core,
* and get back a session token.
*
* @param {String} coreHost Core API server's hostname
* @param {Number} corePort Core API server's port number
* @param {String} apiPassword core api password
* @param {String} appPrivateKey Application's private key
* @param {String} blockchainId blockchain ID of the user signing in.
* `null` if user has no blockchain ID
* @param {String} authRequest authentication request token
* @param {String} deviceId identifier for the current device
*
* @return {Promise} a Promise that resolves to a Core session token or rejects
* with an error message.
* @deprecated
* @private
*/
export function getCoreSession(coreHost: string, corePort: number, apiPassword: string, appPrivateKey: string, blockchainId?: string, authRequest?: string, deviceId?: string): Promise<any>;
}
declare module "auth/authVerification" {
/**
* Checks if the ES256k signature on passed `token` match the claimed public key
* in the payload key `public_keys`.
*
* @param {String} token encoded and signed authentication token
* @return {Boolean} Returns `true` if the signature matches the claimed public key
* @throws {Error} if `token` contains multiple public keys
* @private
*/
export function doSignaturesMatchPublicKeys(token: string): boolean;
/**
* Makes sure that the identity address portion of
* the decentralized identifier passed in the issuer `iss`
* key of the token matches the public key
*
* @param {String} token encoded and signed authentication token
* @return {Boolean} if the identity address and public keys match
* @throws {Error} if ` token` has multiple public keys
* @private
*/
export function doPublicKeysMatchIssuer(token: string): boolean;
/**
* Looks up the identity address that owns the claimed username
* in `token` using the lookup endpoint provided in `nameLookupURL`
* to determine if the username is owned by the identity address
* that matches the claimed public key
*
* @param {String} token encoded and signed authentication token
* @param {String} nameLookupURL a URL to the name lookup endpoint of the Blockstack Core API
* @return {Promise<Boolean>} returns a `Promise` that resolves to
* `true` if the username is owned by the public key, otherwise the
* `Promise` resolves to `false`
* @private
*/
export function doPublicKeysMatchUsername(token: string, nameLookupURL: string): Promise<boolean>;
/**
* Checks if the if the token issuance time and date is after the
* current time and date.
*
* @param {String} token encoded and signed authentication token
* @return {Boolean} `true` if the token was issued after the current time,
* otherwise returns `false`
* @private
*/
export function isIssuanceDateValid(token: string): boolean;
/**
* Checks if the expiration date of the `token` is before the current time
* @param {String} token encoded and signed authentication token
* @return {Boolean} `true` if the `token` has not yet expired, `false`
* if the `token` has expired
*
* @private
*/
export function isExpirationDateValid(token: string): boolean;
/**
* Makes sure the `manifest_uri` is a same origin absolute URL.
* @param {String} token encoded and signed authentication token
* @return {Boolean} `true` if valid, otherwise `false`
* @private
*/
export function isManifestUriValid(token: string): boolean;
/**
* Makes sure the `redirect_uri` is a same origin absolute URL.
* @param {String} token encoded and signed authentication token
* @return {Boolean} `true` if valid, otherwise `false`
* @private
*/
export function isRedirectUriValid(token: string): boolean;
/**
* Verify authentication request is valid. This function performs a number
* of checks on the authentication request token:
* * Checks that `token` has a valid issuance date & is not expired
* * Checks that `token` has a valid signature that matches the public key it claims
* * Checks that both the manifest and redirect URLs are absolute and conform to
* the same origin policy
*
* @param {String} token encoded and signed authentication request token
* @return {Promise} that resolves to true if the auth request
* is valid and false if it does not. It rejects with a String if the
* token is not signed
* @private
*/
export function verifyAuthRequest(token: string): Promise<boolean>;
/**
* Verify the authentication request is valid and
* fetch the app manifest file if valid. Otherwise, reject the promise.
* @param {String} token encoded and signed authentication request token
* @return {Promise} that resolves to the app manifest file in JSON format
* or rejects if the auth request or app manifest file is invalid
* @private
*/
export function verifyAuthRequestAndLoadManifest(token: string): Promise<any>;
/**
* Verify the authentication response is valid
* @param {String} token the authentication response token
* @param {String} nameLookupURL the url use to verify owner of a username
* @return {Promise} that resolves to true if auth response
* is valid and false if it does not
* @private
*/
export function verifyAuthResponse(token: string, nameLookupURL: string): Promise<boolean>;
}
declare module "profiles/profileTokens" {
/**
* Signs a profile token
* @param {Object} profile - the JSON of the profile to be signed
* @param {String} privateKey - the signing private key
* @param {Object} subject - the entity that the information is about
* @param {Object} issuer - the entity that is issuing the token
* @param {String} signingAlgorithm - the signing algorithm to use
* @param {Date} issuedAt - the time of issuance of the token
* @param {Date} expiresAt - the time of expiration of the token
* @returns {Object} - the signed profile token
*/
export function signProfileToken(profile: any, privateKey: string, subject?: any | null, issuer?: any | null, signingAlgorithm?: string, issuedAt?: Date, expiresAt?: Date): any;
/**
* Wraps a token for a profile token file
* @param {String} token - the token to be wrapped
* @returns {Object} - including `token` and `decodedToken`
*/
export function wrapProfileToken(token: string): {
token: string;
decodedToken: any;
};
/**
* Verifies a profile token
* @param {String} token - the token to be verified
* @param {String} publicKeyOrAddress - the public key or address of the
* keypair that is thought to have signed the token
* @returns {Object} - the verified, decoded profile token
* @throws {Error} - throws an error if token verification fails
*/
export function verifyProfileToken(token: string, publicKeyOrAddress: string): any;
/**
* Extracts a profile from an encoded token and optionally verifies it,
* if `publicKeyOrAddress` is provided.
* @param {String} token - the token to be extracted
* @param {String} publicKeyOrAddress - the public key or address of the
* keypair that is thought to have signed the token
* @returns {Object} - the profile extracted from the encoded token
* @throws {Error} - if the token isn't signed by the provided `publicKeyOrAddress`
*/
export function extractProfile(token: string, publicKeyOrAddress?: string | null): {};
}
declare module "profiles/services/serviceUtils" {
export function containsValidProofStatement(searchText: string, name?: string | null): boolean;
export function containsValidAddressProofStatement(proofStatement: string, address: string): boolean;
}
declare module "profiles/services/service" {
import 'cross-fetch/polyfill';
export class Service {
static validateProof(proof: any, ownerAddress: string, name?: string): Promise<any>;
static getBaseUrls(): string[];
static getProofIdentity(searchText: string): string;
static getProofStatement(searchText: string): string;
static shouldValidateIdentityInBody(): boolean;
static prefixScheme(proofUrl: string): string;
static getProofUrl(proof: any): string;
}
}
declare module "profiles/services/facebook" {
import { Service } from "profiles/services/service";
class Facebook extends Service {
static getProofUrl(proof: any): any;
static normalizeUrl(proof: any): any;
static getProofStatement(searchText: string): string;
}
export { Facebook };
}
declare module "profiles/services/github" {
import { Service } from "profiles/services/service";
class Github extends Service {
static getBaseUrls(): string[];
static normalizeUrl(proof: any): string;
static getProofUrl(proof: any): string;
}
export { Github };
}
declare module "profiles/services/twitter" {
import { Service } from "profiles/services/service";
class Twitter extends Service {
static getBaseUrls(): string[];
static normalizeUrl(proof: any): string;
static getProofStatement(searchText: string): string;
}
export { Twitter };
}
declare module "profiles/services/instagram" {
import { Service } from "profiles/services/service";
class Instagram extends Service {
static getBaseUrls(): string[];
static getProofUrl(proof: any): any;
static normalizeUrl(proof: any): any;
static shouldValidateIdentityInBody(): boolean;
static getProofIdentity(searchText: string): string;
static getProofStatement(searchText: string): string;
}
export { Instagram };
}
declare module "profiles/services/hackerNews" {
import { Service } from "profiles/services/service";
class HackerNews extends Service {
static getBaseUrls(): string[];
static getProofUrl(proof: any): string;
static normalizeUrl(proof: any): string;
static getProofStatement(searchText: string): string;
}
export { HackerNews };
}
declare module "profiles/services/linkedIn" {
import { Service } from "profiles/services/service";
class LinkedIn extends Service {
static getBaseUrls(): string[];
static getProofUrl(proof: any): any;
static normalizeUrl(proof: any): string;
static shouldValidateIdentityInBody(): boolean;
static getProofIdentity(searchText: string): string;
static getProofStatement(searchText: string): string;
}
export { LinkedIn };
}
declare module "profiles/services/index" {
import { Service } from "profiles/services/service";
interface ValidateProofService {
validateProof(proof: any, ownerAddress: string, name?: string): Promise<any>;
getProofUrl(proof: any): string;
getProofStatement(searchText: string): string;
normalizeUrl(proof: any): string;
getProofIdentity(searchText: string): string;
}
export const profileServices: {
[serviceName: string]: Service & ValidateProofService;
};
export { containsValidProofStatement, containsValidAddressProofStatement } from "profiles/services/serviceUtils";
}
declare module "profiles/profileProofs" {
/**
* Validates the social proofs in a user's profile. Currently supports validation of
* Facebook, Twitter, GitHub, Instagram, LinkedIn and HackerNews accounts.
*
* @param {Object} profile The JSON of the profile to be validated
* @param {string} ownerAddress The owner bitcoin address to be validated
* @param {string} [name=null] The Blockstack name to be validated
* @returns {Promise} that resolves to an array of validated proof objects
*/
export function validateProofs(profile: any, ownerAddress: string, name?: string): Promise<any[]>;
}
declare module "profiles/profileZoneFiles" {
export function makeProfileZoneFile(origin: string, tokenFileUrl: string): any;
export function getTokenFileUrl(zoneFileJson: any): string | null;
export function resolveZoneFileToProfile(zoneFile: any, publicKeyOrAddress: string): Promise<{}>;
}
declare module "profiles/profile" {
export class Profile {
_profile: {
[key: string]: any;
};
constructor(profile?: {});
toJSON(): {
[key: string]: any;
};
toToken(privateKey: string): any;
static validateSchema(profile: any, strict?: boolean): any;
static fromToken(token: string, publicKeyOrAddress?: string | null): Profile;
static makeZoneFile(domainName: string, tokenFileURL: string): any;
static validateProofs(domainName: string): Promise<any[]>;
}
}
declare module "profiles/profileSchemas/personLegacy" {
export function getPersonFromLegacyFormat(profile: any): {
['@type']: string;
account?: any[];
name?: string;
description?: string;
address?: {
['@type']: string;
addressLocality: string;
};
image?: any[];
website?: {
['@type']: string;
url: string;
}[];
};
}
declare module "profiles/profileSchemas/personUtils" {
export function getName(profile: any): any;
export function getGivenName(profile: any): any;
export function getFamilyName(profile: any): any;
export function getDescription(profile: any): any;
export function getAvatarUrl(profile: any): string;
export function getVerifiedAccounts(profile: any, verifications?: any[]): any[];
export function getOrganizations(profile: any): any;
export function getConnections(profile: any): any[];
export function getAddress(profile: any): any;
export function getBirthDate(profile: any): any;
}
declare module "profiles/profileSchemas/person" {
import { Profile } from "profiles/profile";
export class Person extends Profile {
constructor(profile?: {});
static validateSchema(profile: any, strict?: boolean): any;
static fromToken(token: string, publicKeyOrAddress?: string | null): Person;
static fromLegacyFormat(legacyProfile: any): Person;
toJSON(): {
profile: {
[key: string]: any;
};
name: any;
givenName: any;
familyName: any;
description: any;
avatarUrl: string;
verifiedAccounts: any[];
address: any;
birthDate: any;
connections: any[];
organizations: any;
};
profile(): {
[key: string]: any;
};
name(): any;
givenName(): any;
familyName(): any;
description(): any;
avatarUrl(): string;
verifiedAccounts(verifications?: any[]): any[];
address(): any;
birthDate(): any;
connections(): any[];
organizations(): any;
}
}
declare module "profiles/profileSchemas/organization" {
import { Profile } from "profiles/profile";
export class Organization extends Profile {
constructor(profile?: {});
static validateSchema(profile: any, strict?: boolean): any;
static fromToken(token: string, publicKeyOrAddress?: string | null): Organization;
}
}
declare module "profiles/profileSchemas/creativework" {
import { Profile } from "profiles/profile";
export class CreativeWork extends Profile {
constructor(profile?: {});
static validateSchema(profile: any, strict?: boolean): any;
static fromToken(token: string, publicKeyOrAddress?: string | null): CreativeWork;
}
}
declare module "profiles/profileSchemas/personZoneFiles" {
export function resolveZoneFileToPerson(zoneFile: any, publicKeyOrAddress: string, callback: (profile: any) => void): void;
}
declare module "profiles/profileSchemas/index" {
export { Person } from "profiles/profileSchemas/person";
export { Organization } from "profiles/profileSchemas/organization";
export { CreativeWork } from "profiles/profileSchemas/creativework";
export { getPersonFromLegacyFormat } from "profiles/profileSchemas/personLegacy";
export { resolveZoneFileToPerson } from "profiles/profileSchemas/personZoneFiles";
}
declare module "profiles/profileLookup" {
/**
* Look up a user profile by blockstack ID
*
* @param {string} username - The Blockstack ID of the profile to look up
* @param {string} [zoneFileLookupURL=null] - The URL
* to use for zonefile lookup. If falsey, lookupProfile will use the
* blockstack.js getNameInfo function.
* @returns {Promise} that resolves to a profile object
*/
export function lookupProfile(username: string, zoneFileLookupURL?: string): Promise<any>;
}
declare module "profiles/index" {
export { Profile } from "profiles/profile";
export { Person, Organization, CreativeWork, resolveZoneFileToPerson } from "profiles/profileSchemas/index";
export { signProfileToken, wrapProfileToken, verifyProfileToken, extractProfile } from "profiles/profileTokens";
export { validateProofs } from "profiles/profileProofs";
export { profileServices, containsValidProofStatement, containsValidAddressProofStatement } from "profiles/services/index";
export { makeProfileZoneFile, getTokenFileUrl, resolveZoneFileToProfile } from "profiles/profileZoneFiles";
export { lookupProfile } from "profiles/profileLookup";
}
declare module "storage/hub" {
import { UserSession } from "auth/userSession";
export const BLOCKSTACK_GAIA_HUB_LABEL = "blockstack-gaia-hub-config";
export type GaiaHubConfig = {
address: string;
url_prefix: string;
token: string;
server: string;
};
export function uploadToGaiaHub(filename: string, contents: any, hubConfig: GaiaHubConfig, contentType?: string): Promise<string>;
export function getFullReadUrl(filename: string, hubConfig: GaiaHubConfig): string;
export function connectToGaiaHub(gaiaHubUrl: string, challengeSignerHex: string, associationToken?: string): Promise<GaiaHubConfig>;
/**
* These two functions are app-specific connections to gaia hub,
* they read the user data object for information on setting up
* a hub connection, and store the hub config to localstorage
* @param {UserSession} caller - the instance calling this function
* @private
* @returns {Promise} that resolves to the new gaia hub connection
*/
export function setLocalGaiaHubConnection(caller: UserSession): Promise<GaiaHubConfig>;
export function getOrSetLocalGaiaHubConnection(caller: UserSession): Promise<GaiaHubConfig>;
export function getBucketUrl(gaiaHubUrl: string, appPrivateKey: string): Promise<string>;
}
declare module "auth/sessionData" {
import { GaiaHubConfig } from "storage/hub";
export type SessionOptions = {
appPrivateKey?: string;
username?: string;
identityAddress?: string;
coreNode?: string;
hubUrl?: string;
userData?: any;
transitKey?: string;
localStorageKey?: string;
storeOptions?: {
localStorageKey?: string;
};
};
export class SessionData {
version: string;
appPrivateKey?: string;
identityAddress?: string;
username?: string;
coreNode?: string;
hubUrl?: string;
transitKey?: string;
userData?: any;
gaiaHubConfig?: GaiaHubConfig;
constructor(options: SessionOptions);
getGaiaHubConfig(): GaiaHubConfig;
setGaiaHubConfig(config: GaiaHubConfig): void;
static fromJSON(json: any): SessionData;
toString(): string;
}
}
declare module "auth/sessionStore" {
import { SessionData, SessionOptions } from "auth/sessionData";
/**
* An abstract class representing the SessionDataStore interface.
* @type {SessionData}
*/
export class SessionDataStore {
constructor(sessionOptions?: SessionOptions);
getSessionData(): SessionData;
setSessionData(session: SessionData): boolean;
deleteSessionData(): boolean;
}
/**
* Stores session data in the instance of this class.
* @type {InstanceDataStore}
*/
export class InstanceDataStore extends SessionDataStore {
sessionData?: SessionData;
constructor(sessionOptions?: SessionOptions);
getSessionData(): SessionData;
setSessionData(session: SessionData): boolean;
deleteSessionData(): boolean;
}
/**
* Stores session data in browser a localStorage entry.
* @type {LocalStorageStore}
*/
export class LocalStorageStore extends SessionDataStore {
key: string;
constructor(sessionOptions?: SessionOptions);
getSessionData(): SessionData;
setSessionData(session: SessionData): boolean;
deleteSessionData(): boolean;
}
}
declare module "storage/index" {
import { connectToGaiaHub, uploadToGaiaHub, BLOCKSTACK_GAIA_HUB_LABEL } from "storage/hub";
import { UserSession } from "auth/userSession";
export type PutFileOptions = {
encrypt?: boolean | string;
sign?: boolean;
contentType?: string;
};
/**
* Encrypts the data provided with the app public key.
* @param {String|Buffer} content - data to encrypt
* @param {Object} [options=null] - options object
* @param {String} options.publicKey - the hex string of the ECDSA public
* key to use for encryption. If not provided, will use user's appPublicKey.
* @return {String} Stringified ciphertext object
*/
export function encryptContent(content: string | Buffer, options?: {
publicKey?: string;
}): string;
/**
* Decrypts data encrypted with `encryptContent` with the
* transit private key.
* @param {String|Buffer} content - encrypted content.
* @param {Object} [options=null] - options object
* @param {String} options.privateKey - the hex string of the ECDSA private
* key to use for decryption. If not provided, will use user's appPrivateKey.
* @return {String|Buffer} decrypted content.
*/
export function decryptContent(content: string, options?: {
privateKey?: string;
}): string | Buffer;
/**
* Retrieves the specified file from the app's data store.
* @param {String} path - the path to the file to read
* @param {Object} [options=null] - options object
* @param {Boolean} [options.decrypt=true] - try to decrypt the data with the app private key
* @param {String} options.username - the Blockstack ID to lookup for multi-player storage
* @param {Boolean} options.verify - Whether the content should be verified, only to be used
* when `putFile` was set to `sign = true`
* @param {String} options.app - the app to lookup for multi-player storage -
* defaults to current origin
* @param {String} [options.zoneFileLookupURL=null] - The URL
* to use for zonefile lookup. If falsey, this will use the
* blockstack.js's getNameInfo function instead.
* @returns {Promise} that resolves to the raw data in the file
* or rejects with an error
*/
export function getFile(path: string, options?: {
decrypt?: boolean;
verify?: boolean;
username?: string;
app?: string;
zoneFileLookupURL?: string;
}): Promise<string | ArrayBuffer>;
/**
* Stores the data provided in the app's data store to to the file specified.
* @param {String} path - the path to store the data in
* @param {String|Buffer} content - the data to store in the file
* @param {Object} [options=null] - options object
* @param {Boolean|String} [options.encrypt=true] - encrypt the data with the app public key
* or the provided public key
* @param {Boolean} [options.sign=false] - sign the data using ECDSA on SHA256 hashes with
* the app private key
* @param {String} [options.contentType=''] - set a Content-Type header for unencrypted data
* @return {Promise} that resolves if the operation succeed and rejects
* if it failed
*/
export function putFile(path: string, content: string | Buffer, options?: {
encrypt?: boolean | string;
sign?: boolean;
contentType?: string;
}): Promise<{}>;
/**
* List the set of files in this application's Gaia storage bucket.
* @param {function} callback - a callback to invoke on each named file that
* returns `true` to continue the listing operation or `false` to end it
* @return {Promise} that resolves to the number of files listed
*/
export function listFiles(callback: (name: string) => boolean): Promise<number>;
/**
* Deletes the specified file from the app's data store. Currently not implemented.
* @param {String} path - the path to the file to delete
* @returns {Promise} that resolves when the file has been removed
* or rejects with an error
* @private
*/
export function deleteFile(path: string): void;
/**
* Fetch the public read URL of a user file for the specified app.
* @param {String} path - the path to the file to read
* @param {String} username - The Blockstack ID of the user to look up
* @param {String} appOrigin - The app origin
* @param {String} [zoneFileLookupURL=null] - The URL
* to use for zonefile lookup. If falsey, this will use the
* blockstack.js's getNameInfo function instead.
* @return {Promise<string>} that resolves to the public read URL of the file
* or rejects with an error
*/
export function getUserAppFileUrl(path: string, username: string, appOrigin: string, zoneFileLookupURL?: string | undefined): Promise<string | null>;
/**
* Encrypts the data provided with the app public key.
* @param {UserSession} caller - the instance calling this method
* @param {String|Buffer} content - data to encrypt
* @param {Object} [options=null] - options object
* @param {String} options.publicKey - the hex string of the ECDSA public
* key to use for encryption. If not provided, will use user's appPublicKey.
* @return {String} Stringified ciphertext object
* @private
*/
export function encryptContentImpl(caller: UserSession, content: string | Buffer, options?: {
publicKey?: string;
}): string;
/**
* Decrypts data encrypted with `encryptContent` with the
* transit private key.
* @param {UserSession} caller - the instance calling this method
* @param {String|Buffer} content - encrypted content.
* @param {Object} [options=null] - options object
* @param {String} options.privateKey - the hex string of the ECDSA private
* key to use for decryption. If not provided, will use user's appPrivateKey.
* @return {String|Buffer} decrypted content.
* @private
*/
export function decryptContentImpl(caller: UserSession, content: string, options?: {
privateKey?: string;
}): string | Buffer;
export type GetFileOptions = {
decrypt?: boolean;
verify?: boolean;
username?: string | null;
app?: string | null;
zoneFileLookupURL?: string | null;
};
/**
* Retrieves the specified file from the app's data store.
* @param {UserSession} caller - instance calling this method
* @param {String} path - the path to the file to read
* @param {Object} [options=null] - options object
* @param {Boolean} [options.decrypt=true] - try to decrypt the data with the app private key
* @param {String} options.username - the Blockstack ID to lookup for multi-player storage
* @param {Boolean} options.verify - Whether the content should be verified, only to be used
* when `putFile` was set to `sign = true`
* @param {String} options.app - the app to lookup for multi-player storage -
* defaults to current origin
* @param {String} [options.zoneFileLookupURL=null] - The URL
* to use for zonefile lookup. If falsey, this will use the
* blockstack.js's getNameInfo function instead.
* @returns {Promise} that resolves to the raw data in the file
* or rejects with an error
* @private
*/
export function getFileImpl(caller: UserSession, path: string, options?: GetFileOptions): Promise<string | ArrayBuffer>;
/**
* Stores the data provided in the app's data store to to the file specified.
* @param {UserSession} caller - instance calling this method
* @param {String} path - the path to store the data in
* @param {String|Buffer} content - the data to store in the file
* @param {Object} [options=null] - options object
* @param {Boolean|String} [options.encrypt=true] - encrypt the data with the app public key
* or the provided public key
* @param {Boolean} [options.sign=false] - sign the data using ECDSA on SHA256 hashes with
* the app private key
* @param {String} [options.contentType=''] - set a Content-Type header for unencrypted data
* @return {Promise} that resolves if the operation succeed and rejects
* if it failed
* @private
*/
export function putFileImpl(caller: UserSession, path: string, content: string | Buffer, options?: PutFileOptions): Promise<{}>;
/**
* Get the app storage bucket URL
* @param {String} gaiaHubUrl - the gaia hub URL
* @param {String} appPrivateKey - the app private key used to generate the app address
* @returns {Promise} That resolves to the URL of the app index file
* or rejects if it fails
*/
export function getAppBucketUrl(gaiaHubUrl: string, appPrivateKey: string): Promise<string>;
/**
* List the set of files in this application's Gaia storage bucket.
* @param {UserSession} caller - instance calling this method
* @param {function} callback - a callback to invoke on each named file that
* returns `true` to continue the listing operation or `false` to end it
* @return {Promise} that resolves to the number of files listed
* @private
*/
export function listFilesImpl(caller: UserSession, callback: (name: string) => boolean): Promise<number>;
export { connectToGaiaHub, uploadToGaiaHub, BLOCKSTACK_GAIA_HUB_LABEL };
}
declare module "auth/userSession" {
import { AppConfig } from "auth/appConfig";
import { SessionOptions } from "auth/sessionData";
import { SessionDataStore } from "auth/sessionStore";
import { PutFileOptions, GetFileOptions } from "storage/index";
/**
* Represents an instance of a signed in user for a particular app.
*
* A signed in user has access to two major pieces of information
* about the user, the user's private key for that app and the location
* of the user's gaia storage bucket for the app.
*
* A user can be signed in either directly through the interactive
* sign in process or by directly providing the app private key.
* @type {UserSession}
*/
export class UserSession {
appConfig: AppConfig;
store: SessionDataStore;
constructor(options?: {
appConfig?: AppConfig;
sessionStore?: SessionDataStore;
sessionOptions?: SessionOptions;
});
/**
* Generates an authentication request and redirects the user to the Blockstack
* browser to approve the sign in request.
*
* Please note that this requires that the web browser properly handles the
* `blockstack:` URL protocol handler.
*
* Most applications should use this
* method for sign in unless they require more fine grained control over how the
* authentication request is generated. If your app falls into this category,
* use `generateAndStoreTransitKey`, `makeAuthRequest`,
* and `redirectToSignInWithAuthRequest` to build your own sign in process.
*
* @return {void}
*/
redirectToSignIn(): void;
/**
* Redirects the user to the Blockstack browser to approve the sign in request
* given.
*
* The user is redirected to the authenticator URL specified in the `AppConfig`
* if the `blockstack:` protocol handler is not detected.
* Please note that the protocol handler detection
* does not work on all browsers.
* @param {String} authRequest - the authentication request generated by `makeAuthRequest`
* @return {void}
*/
redirectToSignInWithAuthRequest(authRequest: string): void;
/**
* Generates an authentication request that can be sent to the Blockstack
* browser for the user to approve sign in. This authentication request can
* then be used for sign in by passing it to the `redirectToSignInWithAuthRequest`
* method.
*
* *Note: This method should only be used if you want to roll your own authentication
* flow. Typically you'd use `redirectToSignIn` which takes care of this
* under the hood.*
* @param {string} transitKey - hex-encoded transit key
* @param {Number} expiresAt - the time at which this request is no longer valid
* @param {Object} extraParams - Any extra parameters you'd like to pass to the authenticator.
* Use this to pass options that aren't part of the Blockstack auth spec, but might be supported
* by special authenticators.
* @return {String} the authentication request
* @private
*/
makeAuthRequest(transitKey: string, expiresAt?: number, extraParams?: any): string;
/**
* Generates a ECDSA keypair to
* use as the ephemeral app transit private key
* and store in the session
* @return {String} the hex encoded private key
*
*/
generateAndStoreTransitKey(): string;
/**
* Retrieve the authentication token from the URL query
* @return {String} the authentication token if it exists otherwise `null`
*/
getAuthResponseToken(): string;
/**
* Check if there is a authentication request that hasn't been handled.
* @return {Boolean} `true` if there is a pending sign in, otherwise `false`
*/
isSignInPending(): boolean;
/**
* Check if a user is currently signed in.
* @return {Boolean} `true` if the user is signed in, `false` if not.
*/
isUserSignedIn(): boolean;
/**
* Try to process any pending sign in request by returning a `Promise` that resolves
* to the user data object if the sign in succeeds.
*
* @param {String} authResponseToken - the signed authentication response token
* @return {Promise} that resolves to the user data object if successful and rejects
* if handling the sign in request fails or there was no pending sign in request.
*/
handlePendingSignIn(authResponseToken?: string): Promise<{
username: any;
profile: any;
decentralizedID: any;
identityAddress: string;
appPrivateKey: any;
coreSessionToken: any;
authResponseToken: string;
hubUrl: string;
gaiaAssociationToken: any;
}>;
/**
* Retrieves the user data object. The user's profile is stored in the key `profile`.
* @return {Object} User data object.
*/
loadUserData(): any;
/**
* Sign the user out
* @return {void}
*/
signUserOut(): void;
/**
* Encrypts the data provided with the app public key.
* @param {String|Buffer} content - data to encrypt
* @param {Object} [options=null] - options object
* @param {String} options.publicKey - the hex string of the ECDSA public
* key to use for encryption. If not provided, will use user's appPrivateKey.
* @return {String} Stringified ciphertext object
*/
encryptContent(content: string | Buffer, options?: {
publicKey?: string;
}): string;
/**
* Decrypts data encrypted with `encryptContent` with the
* transit private key.
* @param {String|Buffer} content - encrypted content.
* @param {Object} [options=null] - options object
* @param {String} options.privateKey - the hex string of the ECDSA private
* key to use for decryption. If not provided, will use user's appPrivateKey.
* @return {String|Buffer} decrypted content.
*/
decryptContent(content: string, options?: {
privateKey?: string;
}): string | Buffer;
/**
* Stores the data provided in the app's data store to to the file specified.
* @param {String} path - the path to store the data in
* @param {String|Buffer} content - the data to store in the file
* @param {Object} [options=null] - options object
* @param {Boolean|String} [options.encrypt=true] - encrypt the data with the app private key
* or the provided public key
* @param {Boolean} [options.sign=false] - sign the data using ECDSA on SHA256 hashes with
* the app private key
* @return {Promise} that resolves if the operation succeed and rejects
* if it failed
*/
putFile(path: string, content: string | Buffer, options?: PutFileOptions): Promise<{}>;
/**
* Retrieves the specified file from the app's data store.
* @param {String} path - the path to the file to read
* @param {Object} [options=null] - options object
* @param {Boolean} [options.decrypt=true] - try to decrypt the data with the app private key
* @param {String} options.username - the Blockstack ID to lookup for multi-player storage
* @param {Boolean} options.verify - Whether the content should be verified, only to be used
* when `putFile` was set to `sign = true`
* @param {String} options.app - the app to lookup for multi-player storage -
* defaults to current origin
* @param {String} [options.zoneFileLookupURL=null] - The URL
* to use for zonefile lookup. If falsey, this will use the
* blockstack.js's getNameInfo function instead.
* @returns {Promise} that resolves to the raw data in the file
* or rejects with an error
*/
getFile(path: string, options?: GetFileOptions): Promise<string | ArrayBuffer>;
/**
* List the set of files in this application's Gaia storage bucket.
* @param {function} callback - a callback to invoke on each named file that
* returns `true` to continue the listing operation or `false` to end it
* @return {Promise} that resolves to the number of files listed
*/
listFiles(callback: (name: string) => boolean): Promise<number>;
/**
* Deletes the specified file from the app's data store. Currently not implemented.
* @param {String} path - the path to the file to delete
* @returns {Promise} that resolves when the file has been removed
* or rejects with an error
* @private
*/
deleteFile(path: string): void;
}
}
declare module "auth/authApp" {
import { UserSession } from "auth/userSession";
/**
* Check if a user is currently signed in.
* @method isUserSignedIn
* @return {Boolean} `true` if the user is signed in, `false` if not.
*/
export function isUserSignedIn(): boolean;
/**
* Generates an authentication request and redirects the user to the Blockstack
* browser to approve the sign in request.
*
* Please note that this requires that the web browser properly handles the
* `blockstack:` URL protocol handler.
*
* Most applications should use this
* method for sign in unless they require more fine grained control over how the
* authentication request is generated. If your app falls into this category,
* use `makeAuthRequest` and `redirectToSignInWithAuthRequest` to build your own sign in process.
*
* @param {String} [redirectURI=`${window.location.origin}/`]
* The location to which the identity provider will redirect the user after
* the user approves sign in.
* @param {String} [manifestURI=`${window.location.origin}/manifest.json`]
* Location of the manifest file.
* @param {Array} [scopes=DEFAULT_SCOPE] Defaults to requesting write access to
* this app's data store.
* An array of strings indicating which permissions this app is requesting.
* @return {void}
*/
export function redirectToSignIn(redirectURI?: string, manifestURI?: string, scopes?: Array<string>): void;
/**
* Check if there is a authentication request that hasn't been handled.
* @return {Boolean} `true` if there is a pending sign in, otherwise `false`
*/
export function isSignInPending(): boolean;
/**
* Try to process any pending sign in request by returning a `Promise` that resolves
* to the user data object if the sign in succeeds.
*
* @param {String} nameLookupURL - the endpoint against which to verify public
* keys match claimed username
* @param {String} authResponseToken - the signed authentication response token
* @param {String} transitKey - the transit private key that corresponds to the transit public key
* that was provided in the authentication request
* @return {Promise} that resolves to the user data object if successful and rejects
* if handling the sign in request fails or there was no pending sign in request.
*/
export function handlePendingSignIn(nameLookupURL?: string, authResponseToken?: string, transitKey?: string): Promise<{
username: any;
profile: any;
decentralizedID: any;
identityAddress: string;
appPrivateKey: any;
coreSessionToken: any;
authResponseToken: string;
hubUrl: string;
gaiaAssociationToken: any;
}>;
/**
* Retrieves the user data object. The user's profile is stored in the key `profile`.
* @return {Object} User data object.
*/
export function loadUserData(): any;
/**
* Sign the user out and optionally redirect to given location.
* @param {String} [redirectURL=null] Location to redirect user to after sign out.
* @return {void}
*/
export function signUserOut(redirectURL?: string | null): void;
/**
* Generates an authentication request that can be sent to the Blockstack
* browser for the user to approve sign in. This authentication request can
* then be used for sign in by passing it to the `redirectToSignInWithAuthRequest`
* method.
*
* *Note: This method should only be used if you want to roll your own authentication
* flow. Typically you'd use `redirectToSignIn` which takes care of this
* under the hood.*
*
* @param {String} transitPrivateKey - hex encoded transit private key
* @param {String} redirectURI - location to redirect user to after sign in approval
* @param {String} manifestURI - location of this app's manifest file
* @param {Array<String>} scopes - the permissions this app is requesting
* @param {String} appDomain - the origin of this app
* @param {Number} expiresAt - the time at which this request is no longer valid
* @param {Object} extraParams - Any extra parameters you'd like to pass to the authenticator.
* Use this to pass options that aren't part of the Blockstack auth spec, but might be supported
* by special authenticators.
* @return {String} the authentication request
*/
export function makeAuthRequest(transitPrivateKey: string, redirectURI: string, manifestURI: string, scopes: Array<string>, appDomain: string, expiresAt: number, extraParams?: any): string;
/**
* Redirects the user to the Blockstack browser to approve the sign in request
* given.
*
* The user is redirected to the `blockstackIDHost` if the `blockstack:`
* protocol handler is not detected. Please note that the protocol handler detection
* does not work on all browsers.
* @param {UserSession} caller - the instance calling this method
* @param {String} authRequest - the authentication request generated by `makeAuthRequest`
* @param {String} blockstackIDHost - the URL to redirect the user to if the blockstack
* protocol handler is not detected
* @return {void}
* @private
*/
export function redirectToSignInWithAuthRequestImpl(caller: UserSession, authRequest: string): void;
/**
* Generates an authentication request and redirects the user to the Blockstack
* browser to approve the sign in request.
*
* Please note that this requires that the web browser properly handles the
* `blockstack:` URL protocol handler.
*
* Most web applications should use this
* method for sign in unless they require more fine grained control over how the
* authentication request is generated. If your app falls into this category,
* use `makeAuthRequest`,
* and `redirectToSignInWithAuthRequest` to build your own sign in process.
* @param {UserSession} caller - the instance calling this function
* @return {void}
* @private
*/
export function redirectToSignInImpl(caller: UserSession): void;
/**
* Try to process any pending sign in request by returning a `Promise` that resolves
* to the user data object if the sign in succeeds.
*
* @param {UserSession} caller - the instance calling this function
* @param {String} authResponseToken - the signed authentication response token
* @return {Promise} that resolves to the user data object if successful and rejects
* if handling the sign in request fails or there was no pending sign in request.
* @private
*/
export function handlePendingSignInImpl(caller: UserSession, authResponseToken: string): Promise<{
username: any;
profile: any;
decentralizedID: any;
identityAddress: string;
appPrivateKey: any;
coreSessionToken: any;
authResponseToken: string;
hubUrl: string;
gaiaAssociationToken: any;
}>;
/**
* Retrieves the user data object. The user's profile is stored in the key `profile`.
*
* @param {UserSession} caller - the instance calling this function
* @return {Object} User data object.
* @private
*/
export function loadUserDataImpl(caller: UserSession): any;
/**
* Redirects the user to the Blockstack browser to approve the sign in request
* given.
*
* The user is redirected to the `blockstackIDHost` if the `blockstack:`
* protocol handler is not detected. Please note that the protocol handler detection
* does not work on all browsers.
* @param {String} authRequest - the authentication request generated by `makeAuthRequest`
* @param {String} blockstackIDHost - the URL to redirect the user to if the blockstack
* protocol handler is not detected
* @return {void}
*/
export function redirectToSignInWithAuthRequest(authRequest: string, blockstackIDHost?: string): void;
}
declare module "auth/index" {
export { AppConfig } from "auth/appConfig";
export { makeAuthResponse } from "auth/authMessages";
export { getAuthRequestFromURL, fetchAppManifest, redirectUserToApp } from "auth/authProvider";
export { makeCoreSessionRequest, sendCoreSessionRequest, getCoreSession } from "auth/authSession";
export { verifyAuthRequest, verifyAuthResponse, isExpirationDateValid, isIssuanceDateValid, doPublicKeysMatchUsername, doPublicKeysMatchIssuer, doSignaturesMatchPublicKeys, isManifestUriValid, isRedirectUriValid, verifyAuthRequestAndLoadManifest } from "auth/authVerification";
export { isUserSignedIn, redirectToSignIn, redirectToSignInWithAuthRequest, isSignInPending, handlePendingSignIn, loadUserData, signUserOut } from "auth/authApp";
}
declare module "operations/signers" {
import bitcoinjs from 'bitcoinjs-lib';
export interface TransactionSigner {
/**
* @returns version number of the signer, currently, should always be 1
* @private
*/
signerVersion(): number;
/**
* @returns a string representing the transaction signer's address
* (usually Base58 check encoding)
* @private
*/
getAddress(): Promise<string>;
/**
* Signs a transaction input
* @param {TransactionBuilder} transaction - the transaction to sign
* @param {number} inputIndex - the input on the transaction to sign
* @private
*/
signTransaction(transaction: bitcoinjs.TransactionBuilder, inputIndex: number): Promise<void>;
}
/**
* Class representing a transaction signer for pubkeyhash addresses
* (a.k.a. single-sig addresses)
* @private
*/
export class PubkeyHashSigner implements TransactionSigner {
ecPair: bitcoinjs.ECPair;
constructor(ecPair: bitcoinjs.ECPair);
static fromHexString(keyHex: string): PubkeyHashSigner;
signerVersion(): number;
getAddress(): Promise<string>;
signTransaction(transaction: bitcoinjs.TransactionBuilder, inputIndex: number): Promise<void>;
}
}
declare module "operations/utils" {
import bitcoinjs from 'bitcoinjs-lib';
import { TransactionSigner } from "operations/signers";
import { UTXO } from "network";
export const DUST_MINIMUM = 5500;
export function hash160(buff: Buffer): Buffer;
export function hash128(buff: Buffer): Buffer;
export function getTransactionInsideBuilder(txBuilder: bitcoinjs.TransactionBuilder): bitcoinjs.Transaction;
export function estimateTXBytes(txIn: bitcoinjs.Transaction | bitcoinjs.TransactionBuilder, additionalInputs: number, additionalOutputs: number): number;
export function sumOutputValues(txIn: bitcoinjs.Transaction | bitcoinjs.TransactionBuilder): number;
export function decodeB40(input: string): string;
/**
* Adds UTXOs to fund a transaction
* @param {TransactionBuilder} txBuilderIn - a transaction builder object to add the inputs to. this
* object is _always_ mutated. If not enough UTXOs exist to fund, the tx builder object
* will still contain as many inputs as could be found.
* @param {Array<{value: number, tx_hash: string, tx_output_n}>} utxos - the utxo set for the
* payer's address.
* @param {number} amountToFund - the amount of satoshis to fund in the transaction. the payer's
* utxos will be included to fund up to this amount of *output* and the corresponding *fees*
* for those additional inputs
* @param {number} feeRate - the satoshis/byte fee rate to use for fee calculation
* @param {boolean} fundNewFees - if true, this function will fund `amountToFund` and any new fees
* associated with including the new inputs.
* if false, this function will fund _at most_ `amountToFund`
* @returns {number} - the amount of leftover change (in satoshis)
* @private
*/
export function addUTXOsToFund(txBuilderIn: bitcoinjs.TransactionBuilder, utxos: Array<UTXO>, amountToFund: number, feeRate: number, fundNewFees?: boolean): number;
export function signInputs(txB: bitcoinjs.TransactionBuilder, defaultSigner: TransactionSigner, otherSigners?: Array<{
index: number;
signer: TransactionSigner;
}>): Promise<bitcoinjs.TransactionBuilder>;
}
declare module "operations/skeletons" {
import bitcoin from 'bitcoinjs-lib';
import BigInteger from 'bigi';
type AmountTypeV1 = number;
type AmountTypeV2 = {
units: string;
amount: BigInteger;
};
type AmountType = AmountTypeV1 | AmountTypeV2;
export class BlockstackNamespace {
namespaceID: string;
version: number;
lifetime: number;
coeff: number;
base: number;
buckets: Array<number>;
nonalphaDiscount: number;
noVowelDiscount: number;
constructor(namespaceID: string);
check(): boolean;
setVersion(version: number): void;
setLifetime(lifetime: number): void;
setCoeff(coeff: number): void;
setBase(base: number): void;
setBuckets(buckets: Array<number>): void;
setNonalphaDiscount(nonalphaDiscount: number): void;
setNoVowelDiscount(noVowelDiscount: number): void;
toHexPayload(): string;
}
export function makePreorderSkeleton(fullyQualifiedName: string, consensusHash: string, preorderAddress: string, burnAddress: string, burn: AmountType, registerAddress?: string): bitcoin.Transaction;
export function makeRegisterSkeleton(fullyQualifiedName: string, ownerAddress: string, valueHash?: string, burnTokenAmountHex?: string): bitcoin.Transaction;
export function makeRenewalSkeleton(fullyQualifiedName: string, nextOwnerAddress: string, lastOwnerAddress: string, burnAddress: string, burn: AmountType, valueHash?: string): bitcoin.Transaction;
export function makeTransferSkeleton(fullyQualifiedName: string, consensusHash: string, newOwner: string, keepZonefile?: boolean): bitcoin.Transaction;
export function makeUpdateSkeleton(fullyQualifiedName: string, consensusHash: string, valueHash: string): bitcoin.Transaction;
export function makeRevokeSkeleton(fullyQualifiedName: string): bitcoin.Transaction;
export function makeNamespacePreorderSkeleton(namespaceID: string, consensusHash: string, preorderAddress: string, registerAddress: string, burn: AmountType): bitcoin.Transaction;
export function makeNamespaceRevealSkeleton(namespace: BlockstackNamespace, revealAddress: string): bitcoin.Transaction;
export function makeNamespaceReadySkeleton(namespaceID: string): bitcoin.Transaction;
export function makeNameImportSkeleton(name: string, recipientAddr: string, zonefileHash: string): bitcoin.Transaction;
export function makeAnnounceSkeleton(messageHash: string): bitcoin.Transaction;
export function makeTokenTransferSkeleton(recipientAddress: string, consensusHash: string, tokenType: string, tokenAmount: BigInteger, scratchArea: string): bitcoin.Transaction;
}
declare module "operations/txbuild" {
import BigInteger from 'bigi';
import { BlockstackNamespace } from "operations/skeletons";
import { TransactionSigner } from "operations/signers";
/**
* Estimates cost of a preorder transaction for a domain name.
* @param {String} fullyQualifiedName - the name to preorder
* @param {String} destinationAddress - the address to receive the name (this
* must be passed as the 'registrationAddress' in the register transaction)
* @param {String} paymentAddress - the address funding the preorder
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the preorder. This includes a 5500 satoshi dust output for the preorder.
* Even though this is a change output, the payer must supply enough funds
* to generate this output, so we include it in the cost.
* @private
*/
function estimatePreorder(fullyQualifiedName: string, destinationAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of a register transaction for a domain name.
* @param {String} fullyQualifiedName - the name to register
* @param {String} registerAddress - the address to receive the name
* @param {String} paymentAddress - the address funding the register
* @param {Boolean} includingZonefile - whether or not we will broadcast
* a zonefile hash as part of the register
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the register.
* @private
*/
function estimateRegister(fullyQualifiedName: string, registerAddress: string, paymentAddress: string, includingZonefile?: boolean, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of an update transaction for a domain name.
* @param {String} fullyQualifiedName - the name to update
* @param {String} ownerAddress - the owner of the name
* @param {String} paymentAddress - the address funding the update
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the update.
* @private
*/
function estimateUpdate(fullyQualifiedName: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of an transfer transaction for a domain name.
* @param {String} fullyQualifiedName - the name to transfer
* @param {String} destinationAddress - the next owner of the name
* @param {String} ownerAddress - the current owner of the name
* @param {String} paymentAddress - the address funding the transfer
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the transfer.
* @private
*/
function estimateTransfer(fullyQualifiedName: string, destinationAddress: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of an transfer transaction for a domain name.
* @param {String} fullyQualifiedName - the name to renew
* @param {String} destinationAddress - the next owner of the name
* @param {String} ownerAddress - the current owner of the name
* @param {String} paymentAddress - the address funding the transfer
* @param {Boolean} includingZonefile - whether or not we will broadcast a zonefile hash
in the renewal operation
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the transfer.
* @private
*/
function estimateRenewal(fullyQualifiedName: string, destinationAddress: string, ownerAddress: string, paymentAddress: string, includingZonefile?: boolean, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of a revoke transaction for a domain name.
* @param {String} fullyQualifiedName - the name to revoke
* @param {String} ownerAddress - the current owner of the name
* @param {String} paymentAddress the address funding the revoke
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund the
* revoke.
* @private
*/
function estimateRevoke(fullyQualifiedName: string, ownerAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of a namespace preorder transaction for a namespace
* @param {String} namespaceID - the namespace to preorder
* @param {String} revealAddress - the address to receive the namespace (this
* must be passed as the 'revealAddress' in the namespace-reveal transaction)
* @param {String} paymentAddress - the address funding the preorder
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address.
* @returns {Promise} - a promise which resolves to the satoshi cost to fund
* the preorder. This includes a 5500 satoshi dust output for the preorder.
* Even though this is a change output, the payer must supply enough funds
* to generate this output, so we include it in the cost.
* @private
*/
function estimateNamespacePreorder(namespaceID: string, revealAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates cost of a namesapce reveal transaction for a namespace
* @param {BlockstackNamespace} namespace - the namespace to reveal
* @param {String} revealAddress - the address to receive the namespace
* (this must have been passed as 'revealAddress' to a prior namespace
* preorder)
* @param {String} paymentAddress - the address that pays for this transaction
* @param {Number} paymentUtxos - the number of UTXOs we expect will be required
* from the payment address
* @returns {Promise} - a promise which resolves to the satoshi cost to
* fund the reveal. This includes a 5500 satoshi dust output for the
* preorder. Even though this is a change output, the payer must have
* enough funds to generate this output, so we include it in the cost.
* @private
*/
function estimateNamespaceReveal(namespace: BlockstackNamespace, revealAddress: string, paymentAddress: string, paymentUtxos?: number): Promise<number>;
/**
* Estimates the cost of a namespace-ready transaction for a namespace
* @param {String} namespaceID - the namespace to ready
* @param {Number} revealUtxos - the number of UTXOs we expect will
* be required from the reveal address
* @returns {Promise} - a promise which resolves to the satoshi cost to
* fund this namespacey-ready transaction.
* @private
*/
function estimateNamespaceReady(namespaceID: string, revealUtxos?: number): Promise<number>;
/**
* Estimates the cost of a name-import transaction
* @param {String} name - the fully-qualified name
* @param {String} recipientAddr - the recipient
* @param {String} zonefileHash - the zone file hash
* @param {Number} importUtxos - the number of UTXOs we expect will
* be required from the importer address
* @returns {Promise} - a promise which resolves to the satoshi cost
* to fund this name-import transaction
* @private
*/
function estimateNameImport(name: string, recipientAddr: string, zonefileHash: string, importUtxos?: number): Promise<number>;
/**
* Estimates the cost of an announce transaction
* @param {String} messageHash - the hash of the message
* @param {Number} senderUtxos - the number of utxos we expect will
* be required from the importer address
* @returns {Promise} - a promise which resolves to the satoshi cost
* to fund this announce transaction
* @private
*/
function estimateAnnounce(messageHash: string, senderUtxos?: number): Promise<number>;
/**
* Estimates the cost of a token-transfer transaction
* @param {String} recipientAddress - the recipient of the tokens
* @param {String} tokenType - the type of token to spend
* @param {Object} tokenAmount - a 64-bit unsigned BigInteger encoding the number of tokens
* to spend
* @param {String} scratchArea - an arbitrary string to store with the transaction
* @param {Number} senderUtxos - the number of utxos we expect will
* be required from the importer address
* @param {Number} additionalOutputs - the number of outputs we expect to add beyond
* just the recipient output (default = 1, if the token owner is also the bitcoin funder)
* @returns {Promise} - a promise which resolves to the satoshi cost to
* fund this token-transfer transaction
* @private
*/
function estimateTokenTransfer(recipientAddress: string, tokenType: string, tokenAmount: BigInteger, scratchArea: string, senderUtxos?: number, additionalOutputs?: number): Promise<number>;
/**
* Generates a preorder transaction for a domain name.
* @param {String} fullyQualifiedName - the name to pre-order
* @param {String} destinationAddress - the address to receive the name (this
* must be passed as the 'registrationAddress' in the register transaction)
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key used to fund the transaction or a transaction signer object
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makePreorder(fullyQualifiedName: string, destinationAddress: string, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates an update transaction for a domain name.
* @param {String} fullyQualifiedName - the name to update
* @param {String | TransactionSigner} ownerKeyIn - a hex string of the
* owner key, or a transaction signer object. This will provide one
* UTXO input, and also recieve a dust output.
* @param {String | TransactionSigner} paymentKeyIn - a hex string, or a
* transaction signer object, of the private key used to fund the
* transaction's txfees
* @param {String} zonefile - the zonefile data to update (this will be hashed
* to include in the transaction), the zonefile itself must be published
* after the UPDATE propagates.
* @param {String} valueHash - if given, this is the hash to store (instead of
* zonefile). zonefile will be ignored if this is given.
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeUpdate(fullyQualifiedName: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, zonefile: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a register transaction for a domain name.
* @param {String} fullyQualifiedName - the name to register
* @param {String} registerAddress - the address to receive the name (this
* must have been passed as the 'destinationAddress' in the preorder transaction)
* this address will receive a dust UTXO
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key (or a TransactionSigner object) used to fund the
* transaction (this *must* be the same as the payment address used
* to fund the preorder)
* @param {String} zonefile - the zonefile data to include (this will be hashed
* to include in the transaction), the zonefile itself must be published
* after the UPDATE propagates.
* @param {String} valueHash - the hash of the zone file data to include.
* It will be used instead of zonefile, if given
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeRegister(fullyQualifiedName: string, registerAddress: string, paymentKeyIn: string | TransactionSigner, zonefile?: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a transfer transaction for a domain name.
* @param {String} fullyQualifiedName - the name to transfer
* @param {String} destinationAddress - the address to receive the name.
* this address will receive a dust UTXO
* @param {String | TransactionSigner} ownerKeyIn - a hex string of
* the current owner's private key (or a TransactionSigner object)
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key used to fund the transaction (or a
* TransactionSigner object)
* @param {Boolean} keepZonefile - if true, then preserve the name's zone file
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeTransfer(fullyQualifiedName: string, destinationAddress: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, keepZonefile?: boolean, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a revoke transaction for a domain name.
* @param {String} fullyQualifiedName - the name to revoke
* @param {String | TransactionSigner} ownerKeyIn - a hex string of
* the current owner's private key (or a TransactionSigner object)
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key used to fund the transaction (or a
* TransactionSigner object)
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeRevoke(fullyQualifiedName: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a renewal transaction for a domain name.
* @param {String} fullyQualifiedName - the name to transfer
* @param {String} destinationAddress - the address to receive the name after renewal
* this address will receive a dust UTXO
* @param {String | TransactionSigner} ownerKeyIn - a hex string of
* the current owner's private key (or a TransactionSigner object)
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key used to fund the renewal (or a TransactionSigner
* object)
* @param {String} zonefile - the zonefile data to include, if given (this will be hashed
* to include in the transaction), the zonefile itself must be published
* after the RENEWAL propagates.
* @param {String} valueHash - the raw zone file hash to include (this will be used
* instead of zonefile, if given).
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeRenewal(fullyQualifiedName: string, destinationAddress: string, ownerKeyIn: string | TransactionSigner, paymentKeyIn: string | TransactionSigner, zonefile?: string, valueHash?: string, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a namespace preorder transaction for a namespace
* @param {String} namespaceID - the namespace to pre-order
* @param {String} revealAddress - the address to receive the namespace (this
* must be passed as the 'revealAddress' in the namespace-reveal transaction)
* @param {String | TransactionSigner} paymentKeyIn - a hex string of
* the private key used to fund the transaction (or a
* TransactionSigner object)
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeNamespacePreorder(namespaceID: string, revealAddress: string, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a namespace reveal transaction for a namespace
* @param {BlockstackNamespace} namespace - the namespace to reveal
* @param {String} revealAddress - the address to receive the namespace (this
* must be passed as the 'revealAddress' in the namespace-reveal transaction)
* @param {String | TransactionSigner} paymentKeyIn - a hex string (or
* a TransactionSigner object) of the private key used to fund the
* transaction
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeNamespaceReveal(namespace: BlockstackNamespace, revealAddress: string, paymentKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a namespace ready transaction for a namespace
* @param {String} namespaceID - the namespace to launch
* @param {String | TransactionSigner} revealKeyIn - the private key
* of the 'revealAddress' used to reveal the namespace
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function *does not* perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeNamespaceReady(namespaceID: string, revealKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a name import transaction for a namespace
* @param {String} name - the name to import
* @param {String} recipientAddr - the address to receive the name
* @param {String} zonefileHash - the hash of the zonefile to give this name
* @param {String | TransactionSigner} importerKeyIn - the private key
* that pays for the import
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function does not perform the requisite safety checks -- please see
* the safety module for those.
* @private
*/
function makeNameImport(name: string, recipientAddr: string, zonefileHash: string, importerKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates an announce transaction
* @param {String} messageHash - the hash of the message to send. Should be
* an already-announced zone file hash
* @param {String | TransactionSigner} senderKeyIn - the private key
* that pays for the transaction. Should be the key that owns the
* name that the message recipients subscribe to
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* this function does not perform the requisite safety checks -- please see the
* safety module for those.
* @private
*/
function makeAnnounce(messageHash: string, senderKeyIn: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a token-transfer transaction
* @param {String} recipientAddress - the address to receive the tokens
* @param {String} tokenType - the type of tokens to send
* @param {Object} tokenAmount - the BigInteger encoding of an unsigned 64-bit number of
* tokens to send
* @param {String} scratchArea - an arbitrary string to include with the transaction
* @param {String | TransactionSigner} senderKeyIn - the hex-encoded private key to send
* the tokens
* @param {String | TransactionSigner} btcFunderKeyIn - the hex-encoded private key to fund
* the bitcoin fees for the transaction. Optional -- if not passed, will attempt to
* fund with sender key.
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* This function does not perform the requisite safety checks -- please see the
* safety module for those.
* @private
*/
function makeTokenTransfer(recipientAddress: string, tokenType: string, tokenAmount: BigInteger, scratchArea: string, senderKeyIn: string | TransactionSigner, btcFunderKeyIn?: string | TransactionSigner, buildIncomplete?: boolean): Promise<string>;
/**
* Generates a bitcoin spend to a specified address. This will fund up to `amount`
* of satoshis from the payer's UTXOs. It will generate a change output if and only
* if the amount of leftover change is *greater* than the additional fees associated
* with the extra output. If the requested amount is not enough to fund the transaction's
* associated fees, then this will reject with a InvalidAmountError
*
* UTXOs are selected largest to smallest, and UTXOs which cannot fund the fees associated
* with their own input will not be included.
*
* If you specify an amount > the total balance of the payer address, then this will
* generate a maximum spend transaction
*
* @param {String} destinationAddress - the address to receive the bitcoin payment
* @param {String | TransactionSigner} paymentKeyIn - the private key
* used to fund the bitcoin spend
* @param {number} amount - the amount in satoshis for the payment address to
* spend in this transaction
* @param {boolean} buildIncomplete - optional boolean, defaults to false,
* indicating whether the function should attempt to return an unsigned (or not fully signed)
* transaction. Useful for passing around a TX for multi-sig input signing.
* @returns {Promise} - a promise which resolves to the hex-encoded transaction.
* @private
*/
function makeBitcoinSpend(destinationAddress: string, paymentKeyIn: string | TransactionSigner, amount: number, buildIncomplete?: boolean): Promise<string>;
export const transactions: {
makeRenewal: typeof makeRenewal;
makeUpdate: typeof makeUpdate;
makePreorder: typeof makePreorder;
makeRegister: typeof makeRegister;
makeTransfer: typeof makeTransfer;
makeRevoke: typeof makeRevoke;
makeNamespacePreorder: typeof makeNamespacePreorder;
makeNamespaceReveal: typeof makeNamespaceReveal;
makeNamespaceReady: typeof makeNamespaceReady;
makeBitcoinSpend: typeof makeBitcoinSpend;
makeNameImport: typeof makeNameImport;
makeAnnounce: typeof makeAnnounce;
makeTokenTransfer: typeof makeTokenTransfer;
BlockstackNamespace: typeof BlockstackNamespace;
estimatePreorder: typeof estimatePreorder;
estimateRegister: typeof estimateRegister;
estimateTransfer: typeof estimateTransfer;
estimateUpdate: typeof estimateUpdate;
estimateRenewal: typeof estimateRenewal;
estimateRevoke: typeof estimateRevoke;
estimateNamespacePreorder: typeof estimateNamespacePreorder;
estimateNamespaceReveal: typeof estimateNamespaceReveal;
estimateNamespaceReady: typeof estimateNamespaceReady;
estimateNameImport: typeof estimateNameImport;
estimateAnnounce: typeof estimateAnnounce;
estimateTokenTransfer: typeof estimateTokenTransfer;
};
}
declare module "operations/safety" {
function isNameValid(fullyQualifiedName?: string): Promise<boolean>;
function isNamespaceValid(namespaceID: string): Promise<boolean>;
function isNameAvailable(fullyQualifiedName: string): Promise<boolean>;
function isNamespaceAvailable(namespaceID: string): Promise<boolean>;
function ownsName(fullyQualifiedName: string, ownerAddress: string): Promise<boolean>;
function revealedNamespace(namespaceID: string, revealAddress: string): Promise<boolean>;
function namespaceIsReady(namespaceID: string): Promise<any>;
function namespaceIsRevealed(namespaceID: string): Promise<boolean>;
function isInGracePeriod(fullyQualifiedName: string): Promise<boolean>;
function addressCanReceiveName(address: string): Promise<boolean>;
function isAccountSpendable(address: string, tokenType: string, blockHeight: number): Promise<boolean>;
export const safety: {
addressCanReceiveName: typeof addressCanReceiveName;
isInGracePeriod: typeof isInGracePeriod;
ownsName: typeof ownsName;
isNameAvailable: typeof isNameAvailable;
isNameValid: typeof isNameValid;
isNamespaceValid: typeof isNamespaceValid;
isNamespaceAvailable: typeof isNamespaceAvailable;
revealedNamespace: typeof revealedNamespace;
namespaceIsReady: typeof namespaceIsReady;
namespaceIsRevealed: typeof namespaceIsRevealed;
isAccountSpendable: typeof isAccountSpendable;
};
}
declare module "operations/index" {
export { makePreorderSkeleton } from "operations/skeletons";
export { transactions } from "operations/txbuild";
export * from "operations/utils";
export * from "operations/signers";
export { safety } from "operations/safety";
}
declare module "encryption/wallet" {
/**
* Encrypt a raw mnemonic phrase to be password protected
* @param {string} phrase - Raw mnemonic phrase
* @param {string} password - Password to encrypt mnemonic with
* @return {Promise<Buffer>} The encrypted phrase
* @private
*/
export function encryptMnemonic(phrase: string, password: string): Promise<Buffer>;
/**
* Encrypt a raw mnemonic phrase with a password
* @param {string | Buffer} data - Buffer or hex-encoded string of the encrypted mnemonic
* @param {string} password - Password for data
* @return {Promise<string>} the raw mnemonic phrase
* @private
*/
export function decryptMnemonic(data: (string | Buffer), password: string): Promise<string>;
}
declare module "wallet" {
import { BIP32 } from 'bip32';
export type IdentityKeyPair = {
key: string;
keyID: string;
address: string;
appsNodeKey: string;
salt: string;
};
/**
* The BlockstackWallet class manages the hierarchical derivation
* paths for a standard blockstack client wallet. This includes paths
* for bitcoin payment address, blockstack identity addresses, blockstack
* application specific addresses.
* @private
*/
export class BlockstackWallet {
rootNode: BIP32;
constructor(rootNode: BIP32);
toBase58(): string;
/**
* Initialize a blockstack wallet from a seed buffer
* @param {Buffer} seed - the input seed for initializing the root node
* of the hierarchical wallet
* @return {BlockstackWallet} the constructed wallet
*/
static fromSeedBuffer(seed: Buffer): BlockstackWallet;
/**
* Initialize a blockstack wallet from a base58 string
* @param {string} keychain - the Base58 string used to initialize
* the root node of the hierarchical wallet
* @return {BlockstackWallet} the constructed wallet
*/
static fromBase58(keychain: string): BlockstackWallet;
/**
* Initialize a blockstack wallet from an encrypted phrase & password. Throws
* if the password is incorrect. Supports all formats of Blockstack phrases.
* @param {string} data - The encrypted phrase as a hex-encoded string
* @param {string} password - The plain password
* @return {Promise<BlockstackWallet>} the constructed wallet
*/
static fromEncryptedMnemonic(data: string, password: string): Promise<BlockstackWallet>;
/**
* Generate a BIP-39 12 word mnemonic
* @return {Promise<string>} space-separated 12 word phrase
*/
static generateMnemonic(): string;
/**
* Encrypt a mnemonic phrase with a password
* @param {string} mnemonic - Raw mnemonic phrase
* @param {string} password - Password to encrypt mnemonic with
* @return {Promise<string>} Hex-encoded encrypted mnemonic
*/
static encryptMnemonic(mnemonic: string, password: string): Promise<string>;
getIdentityPrivateKeychain(): BIP32;
getBitcoinPrivateKeychain(): BIP32;
getBitcoinNode(addressIndex: number, chainType?: string): BIP32;
getIdentityAddressNode(identityIndex: number): BIP32;
static getAppsNode(identityNode: BIP32): BIP32;
/**
* Get a salt for use with creating application specific addresses
* @return {String} the salt
*/
getIdentitySalt(): string;
/**
* Get a bitcoin receive address at a given index
* @param {number} addressIndex - the index of the address
* @return {String} address
*/
getBitcoinAddress(addressIndex: number): string;
/**
* Get the private key hex-string for a given bitcoin receive address
* @param {number} addressIndex - the index of the address
* @return {String} the hex-string. this will be either 64
* characters long to denote an uncompressed bitcoin address, or 66
* characters long for a compressed bitcoin address.
*/
getBitcoinPrivateKey(addressIndex: number): string;
/**
* Get the root node for the bitcoin public keychain
* @return {String} base58-encoding of the public node
*/
getBitcoinPublicKeychain(): BIP32;
/**
* Get the root node for the identity public keychain
* @return {String} base58-encoding of the public node
*/
getIdentityPublicKeychain(): BIP32;
static getNodeFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): BIP32;
/**
* Get a bitcoin address given a base-58 encoded bitcoin node
* (usually called the account node)
* @param {String} keychainBase58 - base58-encoding of the node
* @param {number} addressIndex - index of the address to get
* @param {String} chainType - either 'EXTERNAL_ADDRESS' (for a
* "receive" address) or 'CHANGE_ADDRESS'
* @return {String} the address
*/
static getAddressFromBitcoinKeychain(keychainBase58: string, addressIndex: number, chainType?: string): string;
/**
* Get a ECDSA private key hex-string for an application-specific
* address.
* @param {String} appsNodeKey - the base58-encoded private key for
* applications node (the `appsNodeKey` return in getIdentityKeyPair())
* @param {String} salt - a string, used to salt the
* application-specific addresses
* @param {String} appDomain - the appDomain to generate a key for
* @return {String} the private key hex-string. this will be a 64
* character string
*/
static getLegacyAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string;
static getAddressFromBIP32Node(node: BIP32): string;
/**
* Get a ECDSA private key hex-string for an application-specific
* address.
* @param {String} appsNodeKey - the base58-encoded private key for
* applications node (the `appsNodeKey` return in getIdentityKeyPair())
* @param {String} salt - a string, used to salt the
* application-specific addresses
* @param {String} appDomain - the appDomain to generate a key for
* @return {String} the private key hex-string. this will be a 64
* character string
*/
static getAppPrivateKey(appsNodeKey: string, salt: string, appDomain: string): string;
/**
* Get the keypair information for a given identity index. This
* information is used to obtain the private key for an identity address
* and derive application specific keys for that address.
* @param {number} addressIndex - the identity index
* @param {boolean} alwaysUncompressed - if true, always return a
* private-key hex string corresponding to the uncompressed address
* @return {Object} an IdentityKeyPair type object with keys:
* .key {String} - the private key hex-string
* .keyID {String} - the public key hex-string
* .address {String} - the identity address
* .appsNodeKey {String} - the base-58 encoding of the applications node
* .salt {String} - the salt used for creating app-specific addresses
*/
getIdentityKeyPair(addressIndex: number, alwaysUncompressed?: boolean): IdentityKeyPair;
}
}
declare module "encryption/index" {
export { encryptECIES, decryptECIES, signECDSA, verifyECDSA, CipherObject, getHexFromBN } from "encryption/ec";
export { encryptMnemonic, decryptMnemonic } from "encryption/wallet";
}
declare module "index" {
export * from "auth/index";
export * from "profiles/index";
export * from "storage/index";
export { makeDIDFromAddress, makeDIDFromPublicKey, getDIDType, getAddressFromDID } from "dids";
export { getEntropy, makeECPrivateKey, publicKeyToAddress, getPublicKeyFromPrivate } from "keys";
export { nextYear, nextMonth, nextHour, makeUUID4, updateQueryStringParameter, isLaterVersion, isSameOriginAbsoluteUrl, hexStringToECPair, ecPairToHexString, ecPairToAddress } from "utils";
export { transactions, safety, TransactionSigner, PubkeyHashSigner, addUTXOsToFund, estimateTXBytes } from "operations/index";
export { BlockstackWallet, IdentityKeyPair } from "wallet";
export { network } from "network";
export { decodeToken } from 'jsontokens';
export { config } from "config";
export { encryptMnemonic, decryptMnemonic } from "encryption/index";
export { UserSession } from "auth/userSession";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment