@keeex/afterbc
v2.2.3
Published
Provide and parse string that indicate a "not before" date.
Downloads
7
Readme
@keeex/afterbc
Library that provide strings that could not have existed before the time of the call.
The first version is based on the Bitcoin blockchain and BlockCypher. It returns the last block hash value, providing a string that effectively could not be guessed beforehand.
This value, combined with proper timestamping that provide a "not after" date can provide a limited timeframe for the creation of any associated data.
Usage
The library exposes two functions as the default export. A quick example follows:
import {getAfterString, parseAfterString} from "@keeex/afterbc";
const main = async() => {
const str = await getAfterString();
// At this point the value of str can be embedded in any data to be
// timestamped
const ouptut = await parseAfterString(str);
// output contains a `date` property that is a JavaScript Date
console.log("Returned string date: ", output.date);
// it also contains a `checkUrl` property that provides third-party
// verification
console.log("Check URL: ", output.checkUrl);
}
Restrictions
The output is limited to the resolution of the source. In this case, bitcoin blocks are only created once in a while.
The library manages a cache that should be acceptable for any given source. Multiple calls that uses the same source will use that cache and avoid hitting the underlying service.
In the future, this library might support multiple data providers; the output string is made in a way that allow transparent handling of these future sources. Any string produced in the past should be handled appropriately to some extent.
We currently depend on BlockCypher's API to provide this service.