Installation
Currently, the following modules need to be installed:
- @spatium/sdk: The main package for Spatium SDK, which includes the protocol logic and essential cryptography.
- @spatium/signer-client: An auxiliary package that contains specific components for working with the SDK and Spatium Signer Service.
Access
Both packages are available in the private NPM registry of Spatium. Access credentials can be obtained directly from the Spatium team:
npm login --scope=@spatium --registry=https://files.spatium.net/repository/npm-public-sdk
npm notice Log in on https://files.spatium.net/repository/npm-public-sdk
Username: sdk-distribution-user
Password:
Email: (this IS public)
Logged in as sdk-distribution-user on https://files.spatium.net/repository/npm-public-sdk.
Installation
Yarn:
To install correctly, add the following to .yarnrc
:
Then, in project, run:
NPM:
To install correctly, add the following to .npmrc
:
Then, in project, run:
Connection
The following snippet allows you to verify a connection by registering a new secret pair and synchronizing the public key.
import {
uuid,
randomBytes,
generateDistributedSecret,
syncDistributedEcdsaKey,
} from '@spatium/sdk';
import { SignerClient, ServiceStorage } from '@spatium/signer-client';
const test = async () => {
const client = '783c8beb-5820-40a7-84f8-776acb67407c';
const secretId = '205ad897-1def-47d3-8b4e-24a49f7deb3e';
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJtaXNzaW9ucyI6WyJyZWFkIiwid3JpdGUiXSwiaWF0IjoxNjgzOTY1NDI4fQ.-O3z_QIDTnbj2MhcDEcN9JN6et6YDIE-b3kh3fhMYrg';
const storage = new ServiceStorage('https://cloud.spatium.net/storage/v1', token, client);
const signer = new SignerClient('https://cloud.spatium.net/signer/v1', token, client, storage, 10 * 1000);
try {
await signer.connect(10 * 1000);
await generateDistributedSecret(signer, secretId);
const publicKey = await syncDistributedEcdsaKey(signer, secretId, uuid(randomBytes), 'secp256k1', 0, 0);
console.log('Your public key is', publicKey);
} finally {
await signer.disconnect();
}
};