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:
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.
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.
Type guard; only valid values for the
MfaTypes type will return true.
Type guard; only valid enum values within the
Types enum will return true.
Factory function to produce an empty ChallengeData
object. Session is an empty string, the name is
Types.Default, and ChallengeParameters is an
empty object.
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.
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.
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.
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.
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.
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.
Given valid AuthData, return an object stating whether the data is active (authorized), stale (needs refresh), or empty (needs full login).
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.
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.
Type guard; only returns true if maybe satisfies
the UserData interface. Recursively verifies that
maybe.UserAttributes verifies the UserAttributes
interface.
Factory which produces an empty AuthData object.
Leverages emptyUserData() for User key,
ExpiresAt is now as an ISO string, Authorization
& RefreshToken are empty strings.
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.
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.
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.
Generated using TypeDoc
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.