Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

External modules

"node_modules/@eximchain/api-types/spec/responses/index"

"node_modules/@eximchain/api-types/spec/responses/index":

"node_modules/@eximchain/api-types/spec/responses/responses"

"node_modules/@eximchain/api-types/spec/responses/responses":

HttpMethods

HttpMethods:

Namespace containing types for the key HTTP verbs. Each verb has a dedicated string literal type, and then HttpMethods.ANY allows any of those values.

ANY

ANY: POST | PUT | DELETE | GET | OPTIONS

DELETE

DELETE: "DELETE"

GET

GET: "GET"

OPTIONS

OPTIONS: "OPTIONS"

POST

POST: "POST"

PUT

PUT: "PUT"

ApiError

ApiError:

All error responses from our API will include a message key.

Error

Error: ErrorConstructor

message

message: string

name

name: string

Optional stack

stack: undefined | string

ErrorResponse

ErrorResponse:

Error response from our API. err will contain an ApiError, while data will be null.

data

data: null

err

ResponseOptions

ResponseOptions:

All possible options which can be fed into our shared response generator functions.

Optional errorResponseCode

errorResponseCode: undefined | number

Manually set an error code according to the situation.

Optional isCreate

isCreate: undefined | false | true

Will yield a 201 error code, following HTTP spec

Optional isErr

isErr: undefined | false | true

Optional isRead

isRead: undefined | false | true

If set & item was not found, will yield a proper 404 error code.

SuccessResponse

SuccessResponse<ResultType>:

Successful response from our API. data will contain the corresponding Result, err will be null.

Type parameters

  • ResultType

data

data: ResultType

err

err: null

ApiResponse

ApiResponse<ResponseType>: XOR<SuccessResponse<ResponseType>, ErrorResponse>

General shape which all responses from our API conform to. An object res where either res.data or res.err won't be null, depending on whether your call succeeded. Both will always be defined. Note that this just describes the body of the response. If there's an error, the error code will also be set to 4xx or 5xx, so your request tool will automatically detect there's an error.

Type parameters

  • ResponseType

MessageResponse

MessageResponse: ApiResponse<object>

Basic response which simply contains a message about the action that was taken.

MessageResult

MessageResult: object

Basic result which simply contains a message about the action that was taken.

Type declaration

  • message: string

isErrResponse

  • isErrResponse(val: any): boolean
  • Type guard; only returns true if object shape has a null data value and a non-null err value.

    Parameters

    • val: any

    Returns boolean

isHttpMethod

  • isHttpMethod(val: any): boolean
  • HttpMethods type is a union of string literals, rather than an enum, because these literals will not change over time. Enums make it easy to change values in the future, like if we restructure our API. For values which are an unchanging constants, simply specifying string literals still gives us the guarantee of no typos. It also means that we can satisfy the type by writing 'POST', rather than HttpMethods.POST.

    Parameters

    • val: any

    Returns boolean

isMessageResult

  • isMessageResult(val: any): boolean
  • Type guard; only returns true if res has a message key holding a string value.

    Parameters

    • val: any

    Returns boolean

isSuccessResponse

  • isSuccessResponse<ResultType>(val: any): boolean
  • Type guard; only returns true if object shape has a non-null data value and err has a null value.

    Type parameters

    • ResultType

    Parameters

    • val: any

    Returns boolean

newMessageResult

  • Factory function which accepts a string to produce a new message result.

    Parameters

    • message: string

    Returns MessageResult

response

  • Generalized function which uses the provided body to build a response object; prefer to instead use the more specific functions which will correctly set options for you.

    Depending on whether opts say it's an error, the final response body will either have res.data = JSON.stringify(body) or res.err = JSON.stringify(body). The other property will always be null. In the case of isErr without a more specific error code, return code is 500.

    Parameters

    Returns object

    • body: string
    • headers: object
      • Access-Control-Allow-Headers: string
      • Access-Control-Allow-Origin: string
      • Content-Type: string
    • statusCode: number

successResponse

  • Helper response function; correctly builds our response object for a successful 200 response. body will become the value in res.data, res.err will be null.

    Parameters

    Returns object

    • body: string
    • headers: object
      • Access-Control-Allow-Headers: string
      • Access-Control-Allow-Origin: string
      • Content-Type: string
    • statusCode: number

typeValidationErrMsg

  • typeValidationErrMsg(wrong: object, right: object): string[]
  • Given an object which is known to be the wrong shape, along with an object of the correct shape, this function iterates over every key on the correct object and includes an error message if that key is missing or of incorrect type on the wrong object.

    Parameters

    • wrong: object
    • right: object

    Returns string[]

unexpectedErrorResponse

  • Helper response function; correctly builds our response object in the case of some internal error. If a method we don't expect to throw an error suddenly does, then we should return this unexpectedErrorResponse(). This sets the return code to 500, which means "Internal Server Error".

    Parameters

    Returns object

    • body: string
    • headers: object
      • Access-Control-Allow-Headers: string
      • Access-Control-Allow-Origin: string
      • Content-Type: string
    • statusCode: number

userErrorResponse

  • Helper response function; correctly builds our response object in the case of a user error. This would include things like requests with invalid bodies. It sets the return code to 400, which means "Bad Request". res.data will be null, and res.err will be this body.

    Parameters

    Returns object

    • body: string
    • headers: object
      • Access-Control-Allow-Headers: string
      • Access-Control-Allow-Origin: string
      • Content-Type: string
    • statusCode: number

"node_modules/@eximchain/api-types/spec/validators/index"

"node_modules/@eximchain/api-types/spec/validators/index":

"node_modules/@eximchain/api-types/spec/validators/validators"

"node_modules/@eximchain/api-types/spec/validators/validators":

AtLeastOne

AtLeastOne<T, U>: Partial<T> & U[keyof U]

Convenient type which takes an interface and produces a type like , except that at least one of the properties must be specified. The second generic argument is what does the Typescript magic, user only specifies the interface, e.g.:

type DappUpdate = AtLeastOne<Dapp.Item.Core>

Taken from @jcalz on StackOverflow: https://stackoverflow.com/a/48244432/2128308

Type parameters

  • T

  • U

isBoolean

  • isBoolean(val: any): boolean
  • Type guard; returns true if maybe is a boolean, false otherwise.

    Parameters

    • val: any

    Returns boolean

isObject

  • isObject(val: any): boolean
  • Unofficial type guard, returns true if typeof maybe === 'object', false otherwise. Does not declare itself as enforcing type 'object' because then TS thinks the output can't have any other properties.

    Parameters

    • val: any

    Returns boolean

isString

  • isString(val: any): boolean
  • Type guard; returns true if maybe is a string, false otherwise.

    Parameters

    • val: any

    Returns boolean

keysAreBooleans

  • keysAreBooleans(val: any, keyNames: string[]): boolean
  • Helper validation function which checks whether all propertyNames are present on body and then checks that their values are booleans.

    Parameters

    • val: any
    • keyNames: string[]

    Returns boolean

keysAreStrings

  • keysAreStrings(val: any, keyNames: string[]): boolean
  • Helper validation function which checks whether all propertyNames are present on body and then checks that their values are strings.

    Parameters

    • val: any
    • keyNames: string[]

    Returns boolean

keysNonNull

  • keysNonNull(val: any, keyNames: string[]): boolean
  • Helper validation function; provide an object and a list of string keys, returns true if all are present & not null.

    Parameters

    • val: any
    • keyNames: string[]

    Returns boolean

keysValid

  • keysValid(val: any, keyNames: string[], isValid: function): boolean
  • Very flexible validation function which accepts an object to check, properties to inspect, and a test function to see if the value is correct. Only returns true if isVal(body.prop) returns true for every prop in propertyNames.

    Parameters

    • val: any
    • keyNames: string[]
    • isValid: function
        • (keyVal: any): boolean
        • Parameters

          • keyVal: any

          Returns boolean

    Returns boolean

"spec/dapp/chains"

"spec/dapp/chains":

Names

Names:

Ethereum

Ethereum: = "Ethereum"

EximGamma

EximGamma: = "EximGamma"

Eximchain

Eximchain: = "Eximchain"

Goerli

Goerli: = "Goerli"

Kovan

Kovan: = "Kovan"

Rinkeby

Rinkeby: = "Rinkeby"

Ropsten

Ropsten: = "Ropsten"

Details

Details:

displayName

displayName: string

genesisHash

genesisHash: string

id

id: number

name

name: Names

web3Url

web3Url: string

Ethereum

EximGamma

Eximchain

Goerli

Kovan

Rinkeby

Ropsten

allDetails

detailsById

  • detailsById(): object

detailsByName

  • detailsByName(): object

detailsFromName

  • detailsFromName(name: string): Details | null

detailsFromUrl

  • detailsFromUrl(url: string): Details | null

isName

  • isName(val: string): boolean

"spec/dapp/dapp"

"spec/dapp/dapp":

Item

Item:

All of the potential shapes for a DappItem at different points throughout our system, along with factory functions and type guards.

Api

Api:

Dapp representation returned from private reads and lists, includes everything from full plus some dapp management data.

Abi

Abi: string

ContractAddr

ContractAddr: string

CreationTime

CreationTime: string

DappName

DappName: string

DnsName

DnsName: string

GuardianURL

GuardianURL: string

OwnerEmail

OwnerEmail: string

State

State: States

Optional TargetRepoName

TargetRepoName: undefined | string

Optional TargetRepoOwner

TargetRepoOwner: undefined | string

Tier

Tier: Tiers

Web3URL

Web3URL: string

Core

Core:

All data required to render a dapp on DappHub; this is the dapp's shape when returned from the public view.

Abi

Abi: string

ContractAddr

ContractAddr: string

DappName

DappName: string

GuardianURL

GuardianURL: string

Web3URL

Web3URL: string

Full

Full:

Core data plus the dapp's tier and some optional info about the GitHub integration. This type applies to both enterprise and standard dapps.

Abi

Abi: string

ContractAddr

ContractAddr: string

DappName

DappName: string

GuardianURL

GuardianURL: string

Optional TargetRepoName

TargetRepoName: undefined | string

Optional TargetRepoOwner

TargetRepoOwner: undefined | string

Tier

Tier: Tiers

Web3URL

Web3URL: string

FullEnterprise

FullEnterprise:

Abi

Abi: string

ContractAddr

ContractAddr: string

DappName

DappName: string

GuardianURL

GuardianURL: string

TargetRepoName

TargetRepoName: string

TargetRepoOwner

TargetRepoOwner: string

Tier

Tier: Extract<Tiers, Enterprise>

Web3URL

Web3URL: string

FullHub

FullHub:

Abi

Abi: string

ContractAddr

ContractAddr: string

DappName

DappName: string

GuardianURL

GuardianURL: string

Optional TargetRepoName

TargetRepoName: undefined | string

Optional TargetRepoOwner

TargetRepoOwner: undefined | string

Tier

Tier: Exclude<Tiers, Enterprise>

Web3URL

Web3URL: string

isApi

  • isApi(val: any): boolean
  • Type guard; returns true if the argument satisfies Item.Api, otherwise false.

    Parameters

    • val: any

    Returns boolean

isCore

  • isCore(val: any): boolean
  • Type guard; returns true if the argument satisfies Item.Core, otherwise false.

    Parameters

    • val: any

    Returns boolean

isFull

  • isFull(val: any): boolean
  • Type guard; returns true if the argument satisfies Item.Full, otherwise false.

    Parameters

    • val: any

    Returns boolean

isFullEnterprise

  • isFullEnterprise(val: any): boolean

isFullHub

  • isFullHub(val: any): boolean

newApi

  • newApi(): Api
  • Factory to produce an empty Item.Api. Useful to get the interface's keys as a value. Note that the actual values on this object are not valid.

    Returns Api

newCore

  • Factory to produce an empty Item.Core. Useful to get the interface's keys as a value. Note that the actual values on this object are not valid.

    Returns Core

newFull

  • Factory to produce an empty Item.Full. Useful to get the interface's keys as a value. Note that the actual values on this object are not valid. It produces a standard dapp, so no GitHub config.

    Returns Full

newFullEnterprise

newFullHub

Operations

Operations:

CREATE

CREATE: = "create"

DELETE

DELETE: = "delete"

UPDATE

UPDATE: = "update"

States

States:

All possible values for the State of a Dapp as formatted from the API.

AVAILABLE

AVAILABLE: = "AVAILABLE"

BUILDING_DAPP

BUILDING_DAPP: = "BUILDING_DAPP"

CREATING

CREATING: = "CREATING"

DELETING

DELETING: = "DELETING"

DEPOSED

DEPOSED: = "DEPOSED"

FAILED

FAILED: = "FAILED"

Tiers

Tiers:

Possible Dapp tiers and their string name representations.

Enterprise

Enterprise: = "ENTERPRISE"

Professional

Professional: = "PROFESSIONAL"

Standard

Standard: = "STANDARD"

cleanName

  • cleanName(DappName: string): string
  • Given a potential DappName, applies a regex which outputs a valid DappName.

    Parameters

    • DappName: string

    Returns string

isState

  • isState(val: any): boolean
  • Type guard; only valid enum values within the States enum will return true.

    Parameters

    • val: any

    Returns boolean

isTiers

  • isTiers(val: any): boolean
  • Type guard; only valid enum values within the Tiers enum will return true.

    Parameters

    • val: any

    Returns boolean

"spec/methods/auth/auth"

"spec/methods/auth/auth":

BeginPassReset

BeginPassReset:

Initiate a password reset. This call will trigger an email containing the passwordResetCode which must be provided to confirm the reset.

Args

Args:

username

username: string

Response

Response: MessageResponse

Result

When successful, the message ought to say something like, "An email has been sent with a temporary password."

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.passReset}`

isArgs

  • isArgs(val: any): boolean

newArgs

BeginSetupAppMfa

BeginSetupAppMfa:

Begin Setup for App MFA

Args

Args:

refreshToken

refreshToken: string

Response

Response: ApiResponse<Result>

Result

Result: object

Returns secret code to enter into the MFA App.

Type declaration

  • secretCode: string

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.configureMfa}`

isArgs

  • isArgs(val: any): boolean

newArgs

ConfirmPassReset

ConfirmPassReset:

Conclude a password reset by supplying the code from the email along with a new password.

Args

Args:

newPassword

newPassword: string

passwordResetCode

passwordResetCode: string

username

username: string

Response

Response: MessageResponse

Result

Ought to tell them they can now log in with their new password.

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.passReset}`

isArgs

  • isArgs(val: any): boolean

newArgs

ConfirmSetupAppMfa

ConfirmSetupAppMfa:

Confirm Setup for App MFA

Args

Args:

mfaVerifyCode

mfaVerifyCode: string

refreshToken

refreshToken: string

Response

Response: MessageResponse

Result

When successful, the message ought to say something like, "Your MFA app has been successfully configured."

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.configureMfa}`

isArgs

  • isArgs(val: any): boolean

newArgs

Login

Login:

Main login call which either produces a user object and credentials, or returns a challenge.

Args

Args:

password

password: string

username

username: string

Response

Result

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.login}`

isArgs

  • isArgs(val: any): boolean

newArgs

MfaLoginChallenge

MfaLoginChallenge:

Corresponds to the challenge a user with MFA enabled gets to verify their MFA code.

Args

Args:

Note that the session here would be from a previous ChallengeResponse. This is not the Authorization token, these values are passed back and forth in each step of a Challenge Response interaction.

mfaLoginCode

mfaLoginCode: string

session

session: string

username

username: string

Response

Result

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.login}`

isArgs

  • isArgs(val: any): boolean

newArgs

NewPassChallenge

NewPassChallenge:

Corresponds to the initial challenge a user receives after making their account so they can create a new one.

Args

Args:

Note that the session here would be from a previous ChallengeResponse. This is not the Authorization token, these values are passed back and forth in each step of a Challenge Response interaction.

newPassword

newPassword: string

session

session: string

username

username: string

Response

Result

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.login}`

isArgs

  • isArgs(val: any): boolean

newArgs

Refresh

Refresh:

Refresh login call which only requires a token and ought to produce fresh credentials, unless it has been more than a month.

Args

Args:

refreshToken

refreshToken: string

Response

Result

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.login}`

isArgs

  • isArgs(val: any): boolean

newArgs

SelectMfaChallenge

SelectMfaChallenge:

Corresponds to the challenge a user with MFA enabled gets to verify their MFA code.

Args

Args:

Note that the session here would be from a previous ChallengeResponse. This is not the Authorization token, these values are passed back and forth in each step of a Challenge Response interaction.

mfaSelection

mfaSelection: MfaTypes

session

session: string

username

username: string

Response

Result

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.login}`

isArgs

  • isArgs(val: any): boolean

newArgs

SetMfaPreference

SetMfaPreference:

Sets user MFA preferences

Args

Args:

mfaEnabled

mfaEnabled: boolean

Optional preferredMfa

preferredMfa: MfaTypes

Response

Response: ApiResponse<Result>

Result

Result: object

Returns which MFA method (if any) is enabled

Type declaration

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.configureMfa}`

isArgs

  • isArgs(val: any): boolean

newArgs

SetupSmsMfa

SetupSmsMfa:

Setup Phone Number for SMS MFA

Args

Args:

phoneNumber

phoneNumber: string

Phone numbers must follow these formatting rules: A phone number must start with a plus (+) sign, followed immediately by the country code. A phone number can only contain the + sign and digits. You must remove any other characters from a phone number, such as parentheses, spaces, or dashes (-) before submitting the value to the service. For example, a United States-based phone number must follow this format: +14325551212. (Sourced from: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html)

Response

Response: MessageResponse

Result

When successful, the message ought to say something like, "Your phone number has been registered for SMS MFA."

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = `${authBasePath}/${ResourcePaths.configureMfa}`

isArgs

  • isArgs(val: any): boolean

newArgs

ResourcePaths

ResourcePaths:

Subpaths available on the auth endpoint. Built into an enum for easy change later on.

configureMfa

configureMfa: = "configure-mfa"

login

login: = "login"

passReset

passReset: = "password-reset"

UserOrChallengeResponse

UserOrChallengeResponse: ApiResponse<UserOrChallengeResult>

Decoded API response from a call to our login endpoint. It either contains successful authentication ora challenge for the user to respond to.

UserOrChallengeResult

UserOrChallengeResult: XOR<AuthData, Data>

Response from a call to our login endpoint. It either contains successful authentication or a challenge for the user to respond to.

Const authBasePath

authBasePath: string = `${apiBasePath}/${RootResources.auth}`

Baseline path from which more specific auth paths are built on top of.

"spec/methods/payment/payment"

"spec/methods/payment/payment":

Cancel

Cancel:

Cancel a given user's subscription to DappBot. This will immediately delete all the customer's dapps, zero out their dapp limits, cancel the subscription on Stripe, and leave the user in the CANCELLED state.

Result

Result:

cancelledSub

cancelledSub: Subscription

Args

Args: void

No body arguments required, user's email is inferred from Authorization token.

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: DELETE = "DELETE"

Const Path

Path: string = paymentBasePath

Read

Read:

Retrieve a given user's Stripe details, specifically their customer, subscription, and an invoice. If they're lapsed, then it's the most recent failed invoice. If they're active, it's the upcoming invoice. For all Stripe details, if this user does not have Stripe, they will be null.

Result

Result:

customer

customer: Customer | null

invoice

invoice: Invoice | null

subscription

subscription: Subscription | null

user

user: UserData | null

Args

Args: void

Body has no args, customer email is read via the Authorization token.

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: GET = "GET"

Const Path

Path: string = paymentBasePath

SignUp

SignUp:

Main method to create a new account. If called as an API customer, you can only create a trial account. Card info can only ever be plugged in through the DappBot web interface.

Args

Args:

The token here is produced by Stripe on dapp.bot and cannot be created by external API customers. If it is not provided, then the new account is automatically created with a two-week free trial that allows one standard dapp.

Optional coupon

coupon: undefined | string

email

email: string

Optional metadata

metadata: undefined | object

name

name: string

plans

Optional token

token: undefined | string

Result

Result:

stripeId

stripeId: string

subscriptionId

subscriptionId: string

user

user: UserData | null

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: POST = "POST"

Const Path

Path: string = paymentBasePath

isArgs

  • isArgs(val: any): boolean

newArgs

  • Factory to produce an Args object with empty strings for auth and a trial stripe plan. Useful for getting the correct shape as a value.

    Returns Args

StripeTypes

StripeTypes:

The subset of Stripe's types which we use, extracted into a convenient namespace. For more info about how the underlying objects look, check the official Stripe documentation -- it's excellent.

Card

Card: AllStripeTypes.ICard

Customer

Customer: AllStripeTypes.customers.ICustomer

Invoice

Invoice: AllStripeTypes.invoices.IInvoice

LineItem

LineItem: AllStripeTypes.invoices.IInvoiceLineItem

Subscription

Subscription: AllStripeTypes.subscriptions.ISubscription

SubscriptionState

SubscriptionState: AllStripeTypes.subscriptions.SubscriptionStatus

Const ValidSubscriptionStates

ValidSubscriptionStates: SubscriptionState[] = ['trialing','active']

Array of subscription states which translate to an active payment status for the underlying user.

UpdateCard

UpdateCard:

Used to update the customer's saved payment source, currently a credit card.

Args

Args:

Like with SignUp, this token can only be produced on the dapp.bot website using Stripe's client-side plugin. This method cannot be successfully called by external API customers.

token

token: string

Result

Result:

Optional retriedInvoice

retriedInvoice: Invoice

updatedCustomer

updatedCustomer: Customer

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: PUT = "PUT"

Const Path

Path: string = paymentBasePath

isArgs

  • isArgs(val: any): boolean

newArgs

  • Factory to produce an Args object with an empty string. Useful for getting the correct shape as a value, without having to hardcode strings.

    Returns Args

UpdatePlanCount

UpdatePlanCount:

Update the number of allowed dapps for each type. This method can only be called by active accounts with a working payment source. Your account's next invoice will be prorated to reflect the updated capacity.

Args

Args:

plans

Result

Result:

updatedSubscription

updatedSubscription: Subscription

updatedUser

updatedUser: UserData | null

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: PUT = "PUT"

Const Path

Path: string = paymentBasePath

isArgs

  • isArgs(val: any): boolean

newArgs

  • Factory to produce an Args object with one standard dapp. Useful for getting the correct shape as a value, without having to hardcode strings.

    Returns Args

StripePlans

StripePlans:

Listing of how many dapps a customer has allowed for each tier. Note that all must be specified, including 0 values, for safety.

enterprise

enterprise: number

professional

professional: number

standard

standard: number

Const paymentBasePath

paymentBasePath: string = `${apiBasePath}/${RootResources.payment}/stripe`

Const trialStripePlan

trialStripePlan: freeTierStripePlan = freeTierStripePlan

freeTierStripePlan

isStripePlans

  • isStripePlans(val: any): boolean

"spec/methods/private/private"

"spec/methods/private/private":

CreateDapp

CreateDapp:

Create a new dapp. Accepts all properties from a full DappItem, except for the name, which the API infers by the path.

Args

Args: Omit<Full, "DappName">

Response

Response: MessageResponse

Result

Message ought to be something like, "Your dapp has been successfully created."

Const HTTP

HTTP: POST = "POST"

Const Path

Path: DappPath = DappPath

Given a DappName, return the fully scoped private path to create it.

param

isArgs

  • isArgs(val: any): boolean
  • Type guard; only returns true if all Item.Full attributes other than DappName have been correctly set. The underlying guard verifies that if it's an Enterprise Dapp, the GitHub config is set.

    Parameters

    • val: any

    Returns boolean

newArgs

  • Factory to produce an Args object with an empty string. Useful for getting the correct shape as a value, without having to hardcode strings.

    Returns Args

DeleteDapp

DeleteDapp:

Delete an existing dapp. Its DappName will be reclaimed for other users. Only works if the caller is the dapp's owner.

Args

Args: void

Body requires no arguments, email and DappName are taken from Authorization & path respectively.

Response

Response: MessageResponse

Result

Message will say something (not exactly) like, "Your dapp has been successfully deleted."

Const HTTP

HTTP: DELETE = "DELETE"

Const Path

Path: DappPath = DappPath

Given a DappName, returns its fully scoped private path

param

ListDapps

ListDapps:

List all of the dapp's owned by the calling user in their API representation.

Result

Result:

count

count: number

items

items: Api[]

Args

Args: void

Body requires no arguments, email and DappName are taken from Authorization & path respectively.

Response

Response: ApiResponse<Result>

Const HTTP

HTTP: GET = "GET"

Const Path

Path: string = privateBasePath

ReadDapp

ReadDapp:

Retrieve the API representation of any given dapp. Will not succeed if the caller is not the owner of said dapp. Gracefully returns with itemExists === false if the dapp does not exist.

FoundResult

FoundResult:

exists

exists: true

item

item: Api

NotFoundResult

NotFoundResult:

exists

exists: false

item

item: null

Args

Args: void

Body requires no arguments, email and DappName are taken from Authorization & path respectively.

Response

Response: ApiResponse<Result>

Result

Const HTTP

HTTP: GET = "GET"

Const Path

Path: DappPath = DappPath

Given a DappName, returns its fully scoped private path

param

UpdateDapp

UpdateDapp:

Update an existing dapp. An existing Dapp can only have its ABI, ContractAddr, Web3URL, & GuardianURL modified. Only works if the caller is the dapp's owner.

Args

Args: AtLeastOne<Omit<Core, "DappName">>

Response

Response: MessageResponse

Result

Message will say something (not exactly) like, "Your dapp has been successfully updated."

Const HTTP

HTTP: PUT = "PUT"

Const Path

Path: DappPath = DappPath

Given a DappName, returns its fully scoped path

param

isArgs

  • isArgs(val: any): boolean
  • Type guard; only returns true if one of the valid Item.Core update attributes has been set.

    Parameters

    • val: any

    Returns boolean

newArgs

  • Factory to produce a sample Args object. As the argument only requires one to be set, this arg would set the Web3URL to a blank string.

    Returns Args

Const privateBasePath

privateBasePath: string = `${apiBasePath}/${RootResources.private}`

DappPath

  • DappPath(DappName: string): string

"spec/methods/public/public"

"spec/methods/public/public":

ViewDapp

ViewDapp:

Retrieve the publicly visible information about a Dapp, or put differently, the content required for it to render on DappHub.

FoundResult

FoundResult:

exists

exists: true

item

item: Core

NotFoundResult

NotFoundResult:

exists

exists: false

item

item: null

Args

Args: void

No body required, DappName is taken from the path.

Response

Response: ApiResponse<Result>

Result

Const HTTP

HTTP: GET = "GET"

Const Path

  • Path(DappName: string): string

Const publicBasePath

publicBasePath: string = `${apiBasePath}/${RootResources.public}`

"spec/user/user"

"spec/user/user":

Challenges

Challenges:

When a user logs in with their username & password, they may have to respond to a challenge in order to finish the auth loop. This is a collection of data types and helper functions related those ChallengeResponse interactions.

Types

Types:

Our internal key of possible challenges from Cognito. ForgotPassword and Default are constants we made up to control the client-side interface -- the former means we've begun a PassReset flow, the latter means there is no challenge at all. NewPasswordRequired and MFA-related challenges, however, are proper Cognito challenges. You can view the whole list of them at:

https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html#API_InitiateAuth_ResponseSyntax

AppMfa

AppMfa: = "SOFTWARE_TOKEN_MFA"

BeginForgotPassword

BeginForgotPassword: = "BEGIN_FORGOT_PASSWORD"

Default

Default: = "DEFAULT"

ForgotPassword

ForgotPassword: = "FORGOT_PASSWORD"

MfaSetup

MfaSetup: = "MFA_SETUP"

NewPasswordRequired

NewPasswordRequired: = "NEW_PASSWORD_REQUIRED"

SelectMfaType

SelectMfaType: = "SELECT_MFA_TYPE"

SmsMfa

SmsMfa: = "SMS_MFA"

Data

Data:

General response shape for all Challenges. They will always have a ChallengeName, and the Session key is a special value which must be passed back and forth throughout the Challenge-Response flow.

ChallengeName

ChallengeName: Types

ChallengeParameters

ChallengeParameters: object

Type declaration

  • [key: string]: string

Session

Session: string

MfaTypes

MfaTypes: SmsMfa | AppMfa

isData

  • isData(val: any): boolean
  • Type guard; only returns true if maybe fully satisfies Challenges.Data. Validates that the name is a valid value from Challenges.Types, that the session is a string, and that Data.ChallengeParameters has only string keys & string values.

    Parameters

    • val: any

    Returns boolean

isMfaTypes

  • isMfaTypes(val: any): boolean
  • Type guard; only valid values for the MfaTypes type will return true.

    Parameters

    • val: any

    Returns boolean

isTypes

  • isTypes(val: any): boolean
  • Type guard; only valid enum values within the Types enum will return true.

    Parameters

    • val: any

    Returns boolean

newData

  • Factory function to produce an empty ChallengeData object. Session is an empty string, the name is Types.Default, and ChallengeParameters is an empty object.

    Returns Data

CognitoAttributes

CognitoAttributes:

Collection of helper types describing attributes on a Cognito user. UserAttributes technically comes out of Cognito as a ListType, but we transform it on the server into a MapType which fits the UserAttributes spec.

ItemType

ItemType:

Name

Name: NameType

Optional Value

Value: ValueType

MFAOptionType

MFAOptionType:

Optional AttributeName

AttributeName: NameType

Optional DeliveryMedium

DeliveryMedium: DeliveryMediumType

DeliveryMediumType

DeliveryMediumType: "SMS" | "EMAIL" | string

ListType

ListType: ItemType[]

MFAOptionListType

MFAOptionListType: MFAOptionType[]

MapType

MapType: object

Type declaration

NameType

NameType: string

UserMFASettingListType

UserMFASettingListType: string[]

ValueType

ValueType: string

PaymentProvider

PaymentProvider:

All possible custom:payment_providers for a DappBot user. As of Fall 2019, the only options are they're paying with Stripe or they have an admin account.

ADMIN

ADMIN: = "ADMIN"

STRIPE

STRIPE: = "STRIPE"

PaymentStatus

PaymentStatus:

All possible custom:payment_statuses for a DappBot user. If all is well, they're ACTIVE. Once a payment fails, they're LAPSED. If it stays failed, the user eventually goes into FAILED. Their status will only be CANCELLED once they explicitly zero out their subscripton.

ACTIVE

ACTIVE: = "ACTIVE"

CANCELLED

CANCELLED: = "CANCELLED"

FAILED

FAILED: = "FAILED"

LAPSED

LAPSED: = "LAPSED"

AuthData

AuthData:

Object returned after successful login to DappBot. Authorization is the exact token which should go into the Authorization header (no Bearer). RefreshToken is used to get new Authorization after it expires at ExpiresAt, which is a date encoded as an ISO string.

Authorization

Authorization: string

ExpiresAt

ExpiresAt: string

RefreshToken

RefreshToken: string

User

User: UserData

UserAttributes

UserAttributes:

UserAttributes map including all of the custom properties we added to the Cognito user. The limit attributes all control how many dapps the user is allowed to make, payment_provider says whether they are using Stripe, payment_status says whether their payments are all up to date.

custom:enterprise_limit

custom:enterprise_limit: string

custom:payment_provider

custom:payment_provider: PaymentProvider

custom:payment_status

custom:payment_status: PaymentStatus

custom:professional_limit

custom:professional_limit: string

custom:standard_limit

custom:standard_limit: string

UserData

UserData:

DappBot User Record as defined by Cognito. This interface basically follows the default Cognito user, but we have enforced additional constraints on UserAttributes, which is otherwise an arbitrary set of key-val string pairs.

Email

Email: string

Optional MFAOptions

MFAOptions: MFAOptionListType

Optional PreferredMfaSetting

PreferredMfaSetting: undefined | string

UserAttributes

UserAttributes: UserAttributes

Optional UserMFASettingList

UserMFASettingList: UserMFASettingListType

Username

Username: string

authStatus

  • Given valid AuthData, return an object stating whether the data is active (authorized), stale (needs refresh), or empty (needs full login).

    Parameters

    Returns object

    • isActive: boolean
    • isEmpty: boolean
    • isStale: boolean

isAuthData

  • isAuthData(val: any): boolean
  • Type guard; only returns true if maybe fully satisfies the AuthData interface. Leverages isUserData to check AuthData.User. Checks that ExpiresAt is a valid ISO string, just checks the other two props are strings.

    Parameters

    • val: any

    Returns boolean

isUserAttributes

  • isUserAttributes(val: any): boolean
  • Validates that the enum values within UserAttributes are actually from the appropriate enums, validates that the limit values can be converted to non-negative integers.

    Parameters

    • val: any

    Returns boolean

isUserData

  • isUserData(val: any): boolean
  • Type guard; only returns true if maybe satisfies the UserData interface. Recursively verifies that maybe.UserAttributes verifies the UserAttributes interface.

    Parameters

    • val: any

    Returns boolean

newAuthData

  • Factory which produces an empty AuthData object. Leverages emptyUserData() for User key, ExpiresAt is now as an ISO string, Authorization & RefreshToken are empty strings.

    Returns AuthData

newUserAttributes

  • Factory to produce a blank UserAttributes object. For validity, it is configured as an active admin account with one standard dapp. These factories are convenient for getting blank objects of the correct type, or a list of the interface's keys as a value.

    Returns UserAttributes

newUserData

  • Factory to produce an empty UserData object. All string values are empty except for the UserAttributes, which simulate an admin account that is only allowed to make one standard dapp. These factories are convenient for getting blank objects or a list of the interface's keys as a value.

    Returns UserData

validatePassword

  • validatePassword(newPass: string): boolean
  • Validator function which returns true if the provided string has a length from 8-64 chars, has upper & lowercase characters, no whitespace, and a symbol. Otherwise returns false.

    Parameters

    • newPass: string

    Returns boolean

Generated using TypeDoc