npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@owneraio/finp2p-sdk-js

v0.20.3

Published

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 m

Downloads

214

Readme

FinP2P SDK 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.

Ownera API service

The purpose of this sdk is to provide an interface to the Ownera APIs.
It covers the following:

It exposes types for Typescript.

To build the lib/ and use the package, just run yarn build.

Usage

Core

SDK

import { Sdk } from "@owneraio/finp2p-sdk-js";

const sdk = new Sdk({
  orgId: "myOrdId",
  owneraAPIAddress: "https://my-ownera-node.io",
  owneraRASAddress: "https://my-ownera-reg-app-store.io",
  authConfig: { 
    apiKey: "<my-api-key>",
    secret: { 
      type: 1|2, 
      raw: "<my-stringified-private-key>",
    },
  },
  custodyAdapterBaseURL: "<optional-custody-url>",
});

Inner Properties:

Inner functions:

Create asset

Returns Promise with AssetInterface

Usage example:

    const { email, name, phoneNumber } = payload.user;
    let issuer;

    const users = await sdk.owneraAPI.query.getUsers({});
    issuer = users.filter((o) => o.email === email)[0];

    if (!issuer) {
        const { id, publicKey } = await Custody.createAccount({
            name,
            phoneNumber,
        });
        
        const user = await sdk.createUser({
            withSignatureProvider: {
                publicKey,
                signingMethod: signingMethod({ id, custody: sdk.owneraAPI.custodyAdapter! }),
            },
        });

        issuer = await user.getData();
    }


  // Create Asset
    const createdAsset = await sdk.createAsset({
        name: "Asset Name",
        type: "company",
        verifiers: [
            {
                id: "1",
                name: "Accreditation",
                provider: "OTHER",
            },
        ],
        issuerId: issuer.id,
        denomination: {
            type: "fiat",
            code: "USD"
        }});
    
    // get asset data
    const createdAssetInfo = await createdAsset.getData();

Create user

Returns Promise with UserInterface

Usage example:

    // Create signing method using custody adapter
    const signingMethod = (custody: CustodyAdapter, id: string) => async (hash: string) => {
      let attempt = 0;
      let signatureResponse = await custody.createSignature({ id, hash });
      const signatureId = signatureResponse.id;
      const doRetry = !["FAILED", "COMPLETED"].includes(signatureResponse.status);
      while (doRetry && attempt < 10) {
        signatureResponse = await custody.getSignature({ signatureId });
        attempt = attempt + 1;
      }
    
      if (doRetry && attempt === 10) {
        throw {
          code: 408,
          name: "SignatureError",
          message: "Timeout - unable to get signature",
          data: signatureResponse,
        };
      }
    
      if (signatureResponse.status === "FAILED") {
        throw {
          code: 500,
          name: "SignatureError",
          message: "Failure - unable to get signature",
          data: signatureResponse,
        };
      }
    
      return Promise.resolve(signatureResponse.signature);
    };
    
    // Create user 
    const uniqueIdentifier = Date.now();
    const account = await sdk.owneraAPI.custodyAdapter!.createAccount({
      uniqueIdentifier,
      name: `${uniqueIdentifier} custody account`,
    });
    
    const user = await sdk.createUser({
      withSignatureProvider: {
        publicKey: account.publicKey,
        signingMethod: signingMethod(sdk.owneraAPI.custodyAdapter!, account.id),
      },
    });

Get Asset

Returns AssetInterface

Usage example:

    const assetInterface = await getAsset({ assetId });
    const asset = await assetInterface.getData();

Get User

Returns Promise with UserInterface

Usage example:

    const publicKey = "<your-public-key>";
    type signingMeth = (r: {custody: CustodyAdapter, id: string}): (hash: string, details?: SignatureDetails) => Promise<string>;
    const signingMethod: signingMeth = (r: {custody: CustodyAdapter, id: string}) => {/* Your signingMethod implementation */};

    const user = await getSdk().getUser({
        userId: r.userId,
        withSignatureProvider: {
            publicKey: userData.publicKey,
            signingMethod: signingMethod({
                custody: getSdk().owneraAPI.custodyAdapter!,
                id: investorCustodyAccountId,
            }),
        },
    });
user = await sdk.getUser({ userId: profile.id });

#### [Get Organization](./classes/sdk.md#getorganization)
Returns [OrganizationInterface](./interfaces/organizationinterface.md)

Usage example:
```typescript
    // get organization API
    const org = sdk.getOrganization({ });

Another examples

More extended recipes you can check here