Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oasis-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oasis-api

A JavaScript proxy for the Oasis API. To be used only in the browser.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

OASIS API

This package is for client applications to connect and work with the OASIS API Various oasis-api functions and services can be accessed with this API such as Authentication, Karma, Avatars.

Each function call you make returns a promise of an object which is in this form: {error: boolean, data: object}.

object values error: true when response from api fails data: response gotten from server.

Getting started

To get started with this package run

npm install oasis-api

This installs the package to your project. To use it in the Application, it can be imported by

import oasis from "oasis-api"

Auth

The Auth class handles the authentication of the oasis-api. It can be imported by:

import { Auth } from "oasis-api"

Login

To login use this code:

import { Auth } from "oasis-api";

const oasisAuth = new Auth();

oasisAuth.login({
  username: "email@test.com",
  password: "testpass",
}).then((res)=>{
  if(res.error){
    // Error
  }
  else // No error
}).catch((err)=>{
  console.log(err)
})

Signup

For signup, use this code snippet:

import { Auth } from "oasis-api";

const oasisAuth = new Auth();

const data = await OasisAuth.signup({
  firstName: "test",
  lastName: "test",
  email: "test@email.com",
  password: "test",
  confirmPassword: "test",
  acceptTerms: true,
  avatarType: "User",
  title: "Mr",
});

Logout

This logs a user out and revokes his token

import { Auth } from "oasis-api";

const oasisAuth = new Auth();

const data = await OasisAuth.logout();

Forgot password

import { Auth } from "oasis-api";

const oasisAuth = new Auth();

const data = await OasisAuth.forgotPassword({ email: "test@test.com" });

Get user

This function is used when trying to get a currently logged in user. Code snippet:

import { Auth } from "oasis-api";

const oasisAuth = new Auth();

const data = await OasisAuth.getUser();

Avatar

This class manages a user's avatar from adding Karma, deleting and updating avatar, etc,

import { Avatar } from "oasis-api"

get

This function gets an avatar when its ID is provided

import { Avatar } from "oasis-api";
const avatar = new Avatar();

const res = await avatar.get();

Get All

This function returns all registered avatars

import { Avatar } from "oasis-api";
const avatar = new Avatar();

const res = await avatar.getAll();

update

This updates the avatar with the given ID. User must be logged in & authenticated for this method to work.

avatar.update(data, id).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

the parameter data should be of this shape

  "title": "string",
  "firstName": "string",
  "lastName": "string",
  "avatarType": "string",
  "email": "user@example.com",
  "password": "string",
  "confirmPassword": "string"
}

delete

This updates the avatar with the given ID. User must be logged in & authenticated for this method to work.

avatar.delete(id).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

addKarma

Adds karma to avatar. User must be logged in & authenticated for this method to work.

avatar.addKarma(id, data).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Avatar id data schema

  "karmaType": "string",
  "karmaSourceType": "string",
  "karamSourceTitle": "string",
  "karmaSourceDesc": "string"
}

removeKarma

Removes karma to avatar. User must be logged in & authenticated for this method to work.

avatar.removeKarma(id, data).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Avatar id data schema

  "karmaType": "string",
  "karmaSourceType": "string",
  "karamSourceTitle": "string",
  "karmaSourceDesc": "string"
}

Data

loadHolon

Load's a holon data object for the given id.

const data = new oasis.Data()
data.loadHolon(id).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Holon id

loadAllHolons

Load's all holon data object for the given id.

const data = new oasis.Data()
data.loadAllHolons().then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

saveHolon

saves holon data object.

const data = new oasis.Data()
data.saveHolon(data).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

deleteHolon

deletes a holon data object for the given id.

const data = new oasis.Data()
data.deleteHolon(id).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Holon id

Karma

getKarmaForAvatar

gets karma value of an avatar

const karma = new oasis.Karma()
karma.getKarmaForAvatar(id).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Avatar id

removeKarmaForAvatar

removes karma value of an avatar

const karma = new oasis.Karma()
karma.getKarmaForAvatar(id, data).then(()=>{
  //pass
}).catch((err)=>{
  // pass
})

params id: Avatar id data schema:

const data={
      karmaType: string,
      karmaSourceType: string,
      karamSourceTitle: string,
      karmaSourceDesc: string,
}

getKarmaAkashicRecordsForAvatar

oasis.Karma.getKarmaAkashicRecordsForAvatar(id) params id: Avatar id

Holochain

getHolochainAgentIdForAvatar

oasis.Holochain.getHolochainAgentIdForAvatar(id) params id: holochain id

getHolochainAgentPrivateKeyForAvatar

oasis.Holochain.getHolochainAgentPrivateKeyForAvatar(id) params id: avatar id

getAvatarIdForHolochainAgentId

oasis.Holochain.getAvatarIdForHolochainAgentId(id) params id: agent id

getHoloFuelBalanceForAgentId

oasis.Holochain.getHoloFuelBalanceForAgentId(id) params id: agent id

getHoloFuelBalanceForAvatar

oasis.Holochain.getHoloFuelBalanceForAvatar(id) params id: avatar id

getHoloFuelBalanceForAvatar

oasis.Holochain.getHoloFuelBalanceForAvatar(data) params data schema: {agentId: string, avatarId: string}

NFT

createPurchase

oasis.NFT.createPurchase(data) params data schema

nftProvider: number,
     solanaExchange: {
       fromAccount: {
         publicKey: string,
       },
       toAccount: {
         publicKey: string,
       },
       memoText: string,
       amount: number,
       mintAccount: {
         publicKey: string,
       },
     },
     cargoExchange: {
       saleId: string,
     },
   }

getOlandPrice

oasis.NFT.createPurchase(count, couponCode)

purchaseOLAND

oasis.NFT.purchaseOLAND(data) params data schema

{
     olandId: "",
     avatarId: "",
     avatarUsername: "",
     tiles: "",
     walletAddress: "",
     cargoSaleId: "",
}

Solona

mint

oasis.Solana.mint(data)

exchange

oasis.Solana.exchange(data) params data schema

{
      fromAccount: {
        publicKey: "",
      },
      toAccount: {
        publicKey: "",
      },
      memoText: "",
      amount: 0,
      mintAccount: {
        publicKey: "",
      },
    }

Keywords

FAQs

Package last updated on 12 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc