README
Truestamp JS
Description
A tiny zero-dependency Truestamp SDK written in Typescript that supports ES Modules, UMD, and CommonJS loaders and runs in Deno, Node.js, and modern browsers.
EXPERIMENTAL
This software is still in development and is intended to be used by developers invited to create a Truestamp test account. If you'd like to learn more, or join the developer program, please visit www.truestamp.com.
Features
- Tiny library size
- No external dependencies
- Built with Typescript
- Promise based API
- Supports Deno (ESM), Node.js (CommonJS), and modern browsers (ESM, UMD)
- SkyPack CDN support
- JSDELIVR CDN support
- UNPKG CDN support
API Documentation
Usage
Here are some simple usage examples. Additional example code can be found in the
/examples
directory.
Node.js (CommonJS)
Setup Node.js
In your NPM project directory.
npm install @truestamp/truestamp-js --save
Require the @truestamp/truestamp-js
CommonJS module in your project and
initialize it with your accessToken.
Node.js Example
const Truestamp = require("@truestamp/truestamp-js");
const TruestampClient = new Truestamp({ accessToken: "%yourAccessToken%" });
TruestampClient.getHealth()
.then((data) => console.log(data))
.catch((err) => console.log(err));
Deno (ES Modules)
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
Setup Deno
Import the @truestamp/truestamp-js
ESM module in your project via
SkyPack and initialize it with your
accessToken.
SkyPack Package Info
https://www.skypack.dev/view/@truestamp/truestamp-js
It is recommended to used a
pinned version
of the library when using SkyPack in production. Also, note the ?dts
suffix on
the URL to get the
SkyPack Automatic TypeScript
Declarations for Deno.
Deno Example
// Note the `?dts` param to provide the proper typings for Deno
import Truestamp from "https://cdn.skypack.dev/@truestamp/truestamp-js?dts";
const TruestampClient = new Truestamp({
accessToken: "%yourAccessToken%",
});
const hb = await TruestampClient.getHealth();
console.log(hb);
Browser (UMD)
Warning: Do not expose your Truestamp access token in code shipped to browser clients over the web!
You can use a <script>
tag in the browser to load a specific version of the
library from several supported CDN's. Replace the pinned version in the link
with the version you use in your app. You can use the ES Modules or UMD builds
for browser support.
<!-- load from JSDELIVR CDN latest (using latest not recommended for production use, pin a version) -->
<!-- See : https://www.jsdelivr.com/package/npm/@truestamp/truestamp-js -->
<script src="https://cdn.jsdelivr.net/npm/@truestamp/truestamp-js@latest/dist/truestamp.umd.min.js"></script>
The JS files available for each version can be browsed at JSDELIVR
<!-- load from UNPKG CDN latest (using latest not recommended for production use, pin a version) -->
<!-- See : https://unpkg.com/browse/@truestamp/truestamp-js/ -->
<script src="https://unpkg.com/@truestamp/truestamp-js"></script>
Example Code
There are working code examples for Deno, Node.js, and the Web in the /examples directory. Take a look at the examples/README.md for usage instructions.
Contributing
We'd love you to join our network of contributors. Please read CONTRIBUTING.md for help getting started.
Releasing
- Commit changes, merge PR's to
main
branch - Bump
version
field inpackage.json
- Cut a new release
- New release will trigger workflow to build, test, and publish package to Github Package Registry and NPM.js.
Code of Conduct
We expect all members of the community to respect our Code of Conduct at all times.
Legal
Copyright © 2021 Truestamp Inc. All Rights Reserved.