🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@bsv/gasp

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bsv/gasp - npm Package Compare versions

Comparing version
1.2.0
to
1.2.2
+10
-2
dist/cjs/package.json
{
"name": "@bsv/gasp",
"version": "1.2.0",
"version": "1.2.2",
"type": "commonjs",
"description": "Graph Aware Sync Protocol",
"repository": {
"type": "git",
"url": "https://github.com/bsv-blockchain/gasp-core"
},
"homepage": "https://github.com/bsv-blockchain/gasp-core#readme",
"bugs": {
"url": "https://github.com/bsv-blockchain/gasp-core/issues"
},
"files": [

@@ -41,4 +49,4 @@ "dist",

"dependencies": {
"@bsv/sdk": "^1.6.12"
"@bsv/sdk": "^2.0.0"
}
}
{
"name": "@bsv/gasp",
"version": "1.2.0",
"version": "1.2.2",
"type": "module",
"description": "Graph Aware Sync Protocol",
"repository": {
"type": "git",
"url": "https://github.com/bsv-blockchain/gasp-core"
},
"homepage": "https://github.com/bsv-blockchain/gasp-core#readme",
"bugs": {
"url": "https://github.com/bsv-blockchain/gasp-core/issues"
},
"main": "dist/cjs/mod.js",

@@ -56,4 +64,4 @@ "module": "dist/esm/mod.js",

"dependencies": {
"@bsv/sdk": "^1.6.12"
"@bsv/sdk": "^2.0.0"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

/**
* Represents the initial request made under the Graph Aware Sync Protocol.
*/
export type GASPInitialRequest = {
/** GASP version. Currently 1. */
version: number;
/** An optional timestamp (UNIX-1970-seconds) of the last time these two parties synced */
since: number;
};
/**
* Represents the initial response made under the Graph Aware Sync Protocol.
*/
export type GASPInitialResponse = {
/** A list of outputs witnessed by the recipient since the initial request's timestamp. If not provided, a complete list of outputs since the beginning of time is returned. Unconfirmed (non-timestamped) UTXOs are always returned. */
UTXOList: Array<{
txid: string;
outputIndex: number;
}>;
/** A timestamp from when the responder wants to receive UTXOs in the other direction, back from the requester. */
since: number;
};
/** Represents the subsequent message sent in reply to the initial response. */
export type GASPInitialReply = {
/** A list of outputs (excluding outputs received from the Initial Response), and ONLY after the timestamp from the initial response. We don't need to send back things from the initial response, since those were already seen by the counterparty. */
UTXOList: Array<{
txid: string;
outputIndex: number;
}>;
};
/**
* Represents an output, its encompassing transaction, and the associated metadata, together with references to inputs and their metadata.
*/
export type GASPNode = {
/** The graph ID to which this node belongs. */
graphID: string;
/** The Bitcoin transaction in rawTX format. */
rawTx: string;
/** The index of the output in the transaction. */
outputIndex: number;
/** A BUMP proof for the transaction, if it is in a block. */
proof?: string;
/** Metadata associated with the transaction, if it was requested. */
txMetadata?: string;
/** Metadata associated with the output, if it was requested. */
outputMetadata?: string;
/** A mapping of transaction inputs to metadata hashes, if metadata was requested. */
inputs?: Record<string, {
hash: string;
}>;
};
/**
* Denotes which input transactions are requested, and whether metadata needs to be sent.
*/
export type GASPNodeResponse = {
requestedInputs: Record<string, {
metadata: boolean;
}>;
};
/**
* Facilitates the finding of UTXOs, determination of needed inputs, temporary graph management, and eventual graph finalization.
*/
export interface GASPStorage {
/**
* Returns an array of transaction outpoints that are currently known to be unspent (given an optional timestamp).
* Non-confirmed (non-timestamped) outputs should always be returned, regardless of the timestamp.
* @returns A promise for an array of objects, each containing txid and outputIndex properties.
*/
findKnownUTXOs: (since: number) => Promise<Array<{
txid: string;
outputIndex: number;
}>>;
/**
* For a given txid and output index, returns the associated transaction, a merkle proof if the transaction is in a block, and metadata if if requested. If no metadata is requested, metadata hashes on inputs are not returned.
* @param txid The transaction ID for the node to hydrate.
* @param outputIndex The output index for the node to hydrate.
* @param metadata Whether transaction and output metadata should be returned.
* @returns The hydrated GASP node, with or without metadata.
*/
hydrateGASPNode: (graphID: string, txid: string, outputIndex: number, metadata: boolean) => Promise<GASPNode>;
/**
* For a given node, returns the inputs needed to complete the graph, including whether updated metadata is requested for those inputs.
* @param tx The node for which needed inputs should be found.
* @returns A promise for a mapping of requested input transactions and whether metadata should be provided for each.
*/
findNeededInputs: (tx: GASPNode) => Promise<GASPNodeResponse | void>;
/**
* Appends a new node to a temporary graph.
* @param tx The node to append to this graph.
* @param spentBy Unless this is the same node identified by the graph ID, denotes the TXID and input index for the node which spent this one, in 36-byte format.
* @throws If the node cannot be appended to the graph, either because the graph ID is for a graph the recipient does not want or because the graph has grown to be too large before being finalized.
*/
appendToGraph: (tx: GASPNode, spentBy?: string) => Promise<void>;
/**
* Checks whether the given graph, in its current state, makes reference only to transactions that are proven in the blockchain, or already known by the recipient to be valid.
* @param graphID The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
* @throws If the graph is not well-anchored.
*/
validateGraphAnchor: (graphID: string) => Promise<void>;
/**
* Deletes all data associated with a temporary graph that has failed to sync, if the graph exists.
* @param graphID The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
*/
discardGraph: (graphID: string) => Promise<void>;
/**
* Finalizes a graph, solidifying the new UTXO and its ancestors so that it will appear in the list of known UTXOs.
* @param graphID The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
*/
finalizeGraph: (graphID: string) => Promise<void>;
}
/**
* The communications mechanism between a local GASP instance and a foreign GASP instance.
*/
export interface GASPRemote {
/** Given an outgoing initial request, send the request to the foreign instance and obtain their initial response. */
getInitialResponse: (request: GASPInitialRequest) => Promise<GASPInitialResponse>;
/** Given an outgoing initial response, obtain the reply from the foreign instance. */
getInitialReply: (response: GASPInitialResponse) => Promise<GASPInitialReply>;
/** Given an outgoing txid, outputIndex and optional metadata, request the associated GASP node from the foreign instane. */
requestNode: (graphID: string, txid: string, outputIndex: number, metadata: boolean) => Promise<GASPNode>;
/** Given an outgoing node, send the node to the foreign instance and determine which additional inputs (if any) they request in response. */
submitNode: (node: GASPNode) => Promise<GASPNodeResponse | void>;
}
export declare class GASPVersionMismatchError extends Error {
code: 'ERR_GASP_VERSION_MISMATCH';
currentVersion: number;
foreignVersion: number;
constructor(message: string, currentVersion: number, foreignVersion: number);
}
/**
* Main class implementing the Graph Aware Sync Protocol.
*/
export declare class GASP implements GASPRemote {
version: number;
storage: GASPStorage;
remote: GASPRemote;
lastInteraction: number;
logPrefix: string;
log: boolean;
unidirectional: boolean;
/**
*
* @param storage The GASP Storage interface to use
* @param remote The GASP Remote interface to use
* @param lastInteraction The timestamp when we last interacted with this remote party
* @param logPrefix Optional prefix for log messages
* @param log Whether to log messages
* @param unidirectional Whether to disable the "reply" side and do pull-only
*/
constructor(storage: GASPStorage, remote: GASPRemote, lastInteraction?: number, logPrefix?: string, log?: boolean, unidirectional?: boolean);
private logData;
private validateTimestamp;
/**
* Computes a 36-byte structure from a transaction ID and output index.
* @param txid The transaction ID.
* @param index The output index.
* @returns A string representing the 36-byte structure.
*/
private compute36ByteStructure;
/**
* Deconstructs a 36-byte structure into a transaction ID and output index.
* @param outpoint The 36-byte structure.
* @returns An object containing the transaction ID and output index.
*/
private deconstruct36ByteStructure;
/**
* Computes the transaction ID for a given transaction.
* @param tx The transaction string.
* @returns The computed transaction ID.
*/
private computeTXID;
/**
* Synchronizes the transaction data between the local and remote participants.
*/
sync(): Promise<void>;
/**
* Builds the initial request for the sync process.
* @returns A promise for the initial request object.
*/
buildInitialRequest(since: number): Promise<GASPInitialRequest>;
/**
* Builds the initial response based on the received request.
* @param request The initial request object.
* @returns A promise for an initial response
*/
getInitialResponse(request: GASPInitialRequest): Promise<GASPInitialResponse>;
/**
* Builds the initial reply based on the received response.
* @param response The initial response object.
* @returns A promise for an initial reply
*/
getInitialReply(response: GASPInitialResponse): Promise<GASPInitialReply>;
/**
* Provides a requested node to a foreign instance who requested it.
*/
requestNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode>;
/**
* Provides a set of inputs we care about after processing a new incoming node.
* Also finalizes or discards a graph if no additional data is requested from the foreign instance.
*/
submitNode(node: GASPNode): Promise<GASPNodeResponse | void>;
/**
* Handles the completion of a newly-synced graph
* @param {string} graphID The ID of the newly-synced graph
*/
completeGraph(graphID: string): Promise<void>;
/**
* Processes an incoming node from the remote participant.
* @param node The incoming GASP node.
* @param spentBy The 36-byte structure of the node that spent this one, if applicable.
*/
private processIncomingNode;
/**
* Processes an outgoing node to the remote participant.
* @param node The outgoing GASP node.
*/
private processOutgoingNode;
}
export * from './GASP';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet