rpc

package
v0.0.0-...-cfac496 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: GPL-2.0, GPL-3.0 Imports: 25 Imported by: 0

README

Package RPC

The rpc package contains the API handling routes that are served when the openx platform is run. It should ideally be run on the platform side (the website hosting the frontend) so that the frontend can make easy calls to localhost with minimal latency. It can also be run as a standalone repo with the risk of the platform's API being exposed to the wild and is not ideal to run a platform system.

Documentation

Local Documentation is provided via slate and can be accessed over at https://github.com/YaleOpenLab/openx-apidocs

Documentation

Index

Constants

View Source
const (
	// TellerUrl defines the teller URL to check. In future, would be an array
	TellerUrl = "https://localhost"
)

Variables

View Source
var AdminRPC = map[int][]string{
	1: {"/admin/kill", "POST", "nuke"},
	2: {"/admin/freeze", "GET"},
	3: {"/admin/gennuke", "POST"},
	5: {"/admin/platform/all", "GET"},
	6: {"/admin/list"},
	7: {"/admin/platform/new", "POST", "name", "code", "timeout"},
	8: {"/admin/sendmessage", "POST", "subject", "message", "recipient"},
	9: {"/admin/getallusers", "GET"},
}

AdminRPC is the list of all admin RPC endpoints

View Source
var AnchorRPC = map[int][]string{
	1: []string{"/user/anchorusd/deposit/intent", "GET"},
	2: []string{"/user/anchorusd/deposit/kyc", "GET"},
	3: []string{"/user/anchorusd/withdraw/intent", "GET"},
	4: []string{"/user/anchorusd/withdraw/kyc", "GET"},
	5: []string{"/user/anchorusd/kycinfo", "GET"},
	6: []string{"/user/anchorusd/kyc/register", "POST"},
}

AnchorRPC is a collection of all Anchor RPC endpoints and their required params

View Source
var CARPC = map[int][]string{
	1: []string{"/user/ca/search", "name", "birthyear"},
	2: []string{"/admin/ca/users/all"},
}

CARPC contains a list of all ComplyAdvantage related RPCs

View Source
var KillCode string

KillCode is a code that can immediately shut down the server in case of hacks / crises

View Source
var PlatformRPC = map[int][]string{
	0: []string{"/platform/getconsts"},
	1: []string{"/platform/user/retrieve", "key"},
	2: []string{"/platform/user/validate", "username", "token"},
	3: []string{"/platform/user/new", "username", "pwhash", "seedpwd", "email"},
	4: []string{"/platform/user/collision", "username"},
	5: []string{"/platforms/all"},
	6: []string{"/platform/email", "body", "to"},
}

PlatformRPC is a map that stores all handlers related to the platform

View Source
var StablecoinRPC = map[int][]string{
	1: []string{"/stablecoin/get", "GET", "seedpwd", "amount"},
	2: []string{"/anchor/get", "GET"},
}

StablecoinRPC is a collection of all stablecoin RPC endpoints and their required params

View Source
var UserRPC = map[int][]string{
	0:  []string{"/token"},
	1:  []string{"/user/validate", "GET"},
	2:  []string{"/user/balances", "GET"},
	3:  []string{"/user/balance/xlm", "GET"},
	4:  []string{"/user/balance/asset", "GET", "asset"},
	5:  []string{"/ipfs/getdata", "GET", "hash"},
	6:  []string{"/user/kyc", "GET", "userIndex"},
	7:  []string{"/user/sendxlm", "GET", "destination", "amount", "seedpwd"},
	8:  []string{"/user/notkycview", "GET"},
	9:  []string{"/user/kycview", "GET"},
	10: []string{"/user/askxlm", "GET"},
	11: []string{"/user/trustasset", "GET", "assetCode", "assetIssuer", "limit", "seedpwd"},
	12: []string{"/upload", "POST"},
	13: []string{"/platformemail", "GET"},
	16: []string{"/tellerping", "GET"},
	17: []string{"/user/increasetrustlimit", "GET", "trust", "seedpwd"},
	19: []string{"/user/sendrecovery", "GET", "email1", "email2", "email3"},
	20: []string{"/user/seedrecovery", "GET", "secret1", "secret2"},
	21: []string{"/user/newsecrets", "GET", "seedpwd", "email1", "email2", "email3"},
	22: []string{"/user/resetpwd", "GET", "seedpwd", "email"},
	23: []string{"/user/pwdreset", "GET", "pwhash", "email", "verificationCode"},
	24: []string{"/user/sweep", "GET", "seedpwd", "destination"},
	25: []string{"/user/sweepasset", "GET", "seedpwd", "destination", "assetName", "issuerPubkey"},
	26: []string{"/user/verifykyc", "GET", "selfie"},
	27: []string{"/user/giverating", "GET", "feedback", "userIndex"},
	28: []string{"/user/2fa/generate", "GET"},
	29: []string{"/user/2fa/authenticate", "GET", "password"},
	31: []string{"/user/reputation", "GET", "reputation"},
	32: []string{"/user/addseed", "GET", "encryptedseed", "seedpwd", "pubkey"},
	33: []string{"/user/latestblockhash", "GET"},
	34: []string{"/ipfs/putdata", "POST", "data"},
	35: []string{"/user/tc", "POST"},
	36: []string{"/user/progress", "POST", "progress"},
	37: []string{"/user/update", "POST"},
	38: []string{"/user/tellerfile", "GET"},

	30: []string{"/user/anchorusd/kyc", "GET", "name", "bdaymonth", "bdayday", "bdayyear", "taxcountry",
		"taxid", "addrstreet", "addrcity", "addrpostal", "addrregion", "addrcountry", "addrphone", "primaryphone", "gender"},
}

UserRPC is a collection of all user RPC endpoints and their required params

Functions

func PostAndSend

func PostAndSend(w http.ResponseWriter, r *http.Request, body string, payload io.Reader)

PostAndSend is a handler that POSTs data and returns the response

func PostAndSendCA

func PostAndSendCA(w http.ResponseWriter, r *http.Request, body string, payload io.Reader)

PostAndSendCA is a handler that POSTs data and returns the response

func PostRequestCA

func PostRequestCA(body string, payload io.Reader) ([]byte, error)

PostRequestCA is a handler that makes it easy to send out POST requests

func StartServer

func StartServer(portx int, insecure bool)

StartServer starts the server on the passed port and mode (http / https)

func ValidateSeedPwd

func ValidateSeedPwd(w http.ResponseWriter, r *http.Request, encryptedSeed []byte, userPublickey string) (string, error)

ValidateSeedPwd validates only the seedpwd and not the username / pwhash

Types

type AnchorIntentResponse

type AnchorIntentResponse struct {
	Type       string `json:"type"`
	Url        string `json:"url"`
	Identifier string `json:"identifier"`
}

AnchorIntentResponse defines the intent response struct for AnchorUSD

func GetAndReturnIdentifier

func GetAndReturnIdentifier(w http.ResponseWriter, r *http.Request, body string) (AnchorIntentResponse, error)

GetAndReturnIdentifier is a handler that makes a get request and returns json data

type CAResponse

type CAResponse struct {
	Code    int    `json:"code"`
	Status  string `json:"string"`
	Content struct {
		Data struct {
			Id         int64  `json:"id"`
			Ref        string `json:"ref"`
			Searcherid int64  `json:"searcher_id"`
			Assigneeid int64  `json:"assignee_id"`
			Filters    struct {
				Birthyear      int64    `json:"birth_year"`
				Countrycodes   []int    `json:"country_codes"`
				Removedeceased int      `json:"remove_deceased"`
				Types          []string `json:"types"`
				Exactmatch     bool     `json:"exact_match"`
				Fuzziness      float64  `json:"fuzziness"`
			}

			Matchstatus   string   `json:"match_status"`
			Risklevel     string   `json:"risk_level"`
			Searchterm    string   `json:"search_term"`
			Submittedterm string   `json:"submitted_term"`
			Clientref     string   `json:"client_ref"`
			Totalhits     int      `json:"total_hits"`
			Updatedat     string   `json:"updated_at"`
			Createdat     string   `json:"created_at"`
			Tags          []string `json:"tags"`
			Limit         int      `json:"limit"`
			Offset        int      `json:"offset"`
			Shareurl      string   `json:"share_url"`
			Hits          []struct {
				Doc struct {
					Aka []struct {
						Name string `json:"name"`
					} `json:"aka"`
					Assets []struct {
						Publicurl string `json:"public_url"`
						Source    string `json:"source"`
						Type      string `json:"type"`
					} `json:"assets"`
					Entitytype string `json:"entity_type"`
					Fields     []struct {
						Name   string `json:"name"`
						Source string `json:"source"`
						Tag    string `json:"tag"`
						Value  string `json:"value"`
					} `json:"fields"`
					Id    string
					Media []struct {
						Date    string `json:"date"`
						Snippet string `json:"snippet"`
						Title   string `json:"title"`
						Url     string `json:"url"`
					} `json:"media"`
					Name    string   `json:"name"`
					Sources []string `json:"sources"`
					Types   []string `json:"types"`
				} `json:"doc"`
				Matchtypes    []string `json:"match_types"`
				Score         float64  `json:"score"`
				Matchstatus   string   `json:"match_status"`
				Iswhitelisted bool     `json:"is_whitelisted"`
			} `json:"hits"`
		} `json:"data"`
	} `json:"content"`
}

CAResponse defines a struct that ComplyAdvantage returns

type GenAccessTokenReturn

type GenAccessTokenReturn struct {
	Token string
}

GenAccessTokenReturn is the struct defined for returning access tokens

type GetAnchorResponse

type GetAnchorResponse struct {
	Txhash string // this tx hash is for the sent xlm, not for the received anchorUSD
}

GetAnchorResponse is a wrapper around the txhash for sent XLM

type KycResponse

type KycResponse struct {
	Status string // the status whether the kyc verification request was succcessful or not
	Reason string // the reason why the person was rejected (OFAC blacklist, sanctioned individual, etc)
}

KycResponse is a wrapper around status and reason for KYC responses

type OpensolarConstReturn

type OpensolarConstReturn struct {
	PlatformPublicKey   string
	PlatformSeed        string
	PlatformEmail       string
	PlatformEmailPass   string
	StablecoinCode      string
	StablecoinPublicKey string
	AnchorUSDCode       string
	AnchorUSDAddress    string
	AnchorUSDTrustLimit float64
	AnchorAPI           string
	Mainnet             bool
	DbDir               string
}

OpensolarConstReturn is a struct that can be used to export consts from openx

type PlatformEmailResponse

type PlatformEmailResponse struct {
	Email string
}

PlatformEmailResponse is a structure used to contain the platform's email response

type SeedResponse

type SeedResponse struct {
	Seed string
}

SeedResponse is a wrapper around the Seed

type SnUser

type SnUser struct {
	Name       string
	PublicKey  string
	Reputation float64
}

SnUser defines a sanitized user

type TwoFAResponse

type TwoFAResponse struct {
	ImageData string
}

TwoFAResponse is a wrapper around the QRCode data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL