HomeGuidesRecipesAPI Reference
HomeGuidesAPI ReferenceRecipes

Introduction

The Ownera sdk provides an easy to use set of APIs to work with Ownera FinP2P node for various use cases, the sdk handles most of the heavy lifting for executing operations on the FinP2P network, such as signature templates generation and signing, asset managements, escrow interface and more, creating a user with the sdk is simple as :

import {Sdk} from "@owneraio/finp2p-sdk-js";
import * as secp256k1 from 'secp256k1'; // this sample is using version "^3.7.1"
import * as crypto from 'crypto';


const sdk = new Sdk({ orgId: "ownera", owneraAPIAddress: "https://example.com/", owneraRASAddress: "" });

export const sign = (privKey: Buffer, hash: Buffer) => {
    const sigObj = secp256k1.sign(hash, privKey);
    return sigObj.signature.toString('hex');
}

const {private: privateKey, public: publicKey} = createCrypto();
export const signingMethod = (privateKey: Buffer) => (hash: string) => Promise.resolve(sign(privateKey, Buffer.from(hash, 'hex')));

(async function() {
    try {
        const user = await sdk.createUser({ withSignatureProvider: {
                publicKey: publicKey.toString('hex'),
                signingMethod: signingMethod(privateKey),
            }});
        const userData = await user.getData();
        console.log(userData);
    }catch (e) {
        console.error(e);
    }


})();

function createCrypto() {
    // generate private key
    let privKey;
    do {
        privKey = crypto.randomBytes(32);
    } while (!secp256k1.privateKeyVerify(privKey))

    // get the public key in a compressed format
    const pubKey = secp256k1.publicKeyCreate(privKey, true);
    return {private: privKey, public: pubKey};
};

Get started with the Owner JavaScript sdk now:

📘

Language support

Currently the sdk is provided only for JavaScript, additional programming languages support is expected in the future.