helpers

package
v0.0.0-...-f886bfe Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PurposeType = []string{
	"ADD_PRIMARY_EMAIL",
	"ADD_MOBILE_NUMBER",
	"VERIFY_EMAIL_FOR_WALLET_RESTORATION",
	"ADD_WALLET_THIRD_SHARD",
	"VERIFY_EMAIL_OTP",
	"VERIFY_MOBILE_OTP",
	"VERIFY_MOBILE_FOR_WALLET_RESTORATION",
}

Functions

func ConvertPemToPublicKey

func ConvertPemToPublicKey(publicKeyPem string) (*rsa.PublicKey, error)

converts pem format to rsa public key

func ErrMissingField

func ErrMissingField(field string) *logical.Response

ErrMissingField returns a logical response error that prints a consistent error message for when a required field is missing.

func GenerateOTP

func GenerateOTP(length int) (string, error)

GenerateOTP - generate random number of length passed

func New

func New(text string) error

New returns an error that formats as the given text.

func NewUUID

func NewUUID() string

NewUUID returns a globally unique random generated guid

func StringInSlice

func StringInSlice(a string, list []string) bool

func UUIDExists

func UUIDExists(ctx context.Context, req *logical.Request, uuid string) bool

UUIDExists checks if uuid exists or not

func ValidateData

func ValidateData(ctx context.Context, req *logical.Request, uuid string, derivationPath string) error

ValidateData - validates data provided provided to create signature

func ValidateFields

func ValidateFields(req *logical.Request, data *framework.FieldData) error

ValidateFields verifies that no bad arguments were given to the request.

func ValidationErr

func ValidationErr(msg string) error

ValidationErr returns an error that corresponds to a validation error.

func VerifyECDSASignedMessage

func VerifyECDSASignedMessage(signature string, rawData string, publickKeyHash string) bool

func VerifyJWTSignature

func VerifyJWTSignature(jwtToken string, dataToValidate map[string]string, publicKeyEncoded string, algorithm string) (bool, string)

func VerifyRSASignedMessage

func VerifyRSASignedMessage(signatureEncoded string, data string, publicKeyEncoded string) bool

verifies if data is signed using passed public key

func VerifyTokenClaims

func VerifyTokenClaims(tokenClaims jwt.MapClaims, unsignedData map[string]string) bool

Types

type GuardianEmails

type GuardianEmails struct {
	IsVerified bool   `json:"isVerified"`
	Value      string `json:"value"`
}

type LastRecoverySaveLocation

type LastRecoverySaveLocation struct {
	GoogleDriveFileId string `json:"googleDriveFileId"`
	IcloudFileId      string `json:"icloudFileId"`
	LocalFileId       string `json:"localFileId"`
}

type MAILFormatUpdates

type MAILFormatUpdates struct {
	To                    string
	Purpose               string
	MFASource             string
	TimeOfInitiation      string
	WalletAddress         string
	RestorationIdentifier string
	WalletIdentifier      string
}

type MailFormatGuardian

type MailFormatGuardian struct {
	To                    string
	Purpose               string
	WalletIdentifier      string
	GuardianIdentifier    string
	MFASource             string
	TimeOfInitiation      string
	TimeOfRestoration     string
	UserEmail             string
	WalletAddress         string
	RestorationIdentifier string
}
type MailFormatGuardianAdditionLink struct {
	To               string
	Purpose          string
	MFASource        string
	WalletIdentifier string
	Path             string
	UserEmail        string
	WalletAddress    string
}

type MailFormatGuardianVerified

type MailFormatGuardianVerified struct {
	To            string
	Purpose       string
	MFASource     string
	WalletAddress string
}

type MailFormatVerification

type MailFormatVerification struct {
	To            string
	Otp           string
	Purpose       string
	MFASource     string // enum
	WalletAddress string
}

type MailFormatVetoed

type MailFormatVetoed struct {
	To             string
	Purpose        string
	GuardianVetoed string
	MFASource      string
	VetoTime       string
	WalletAddress  string
}

type RecoveryDetails

type RecoveryDetails struct {
	ThirdShard                           string `json:"thirdShard"`
	RsaEncryptedMnemonicEncryptionAESKey string `json:"rsaEncryptedMnemonicEncryptionAESKey"`
}

type RestorationIdentifiers

type RestorationIdentifiers struct {
	UserRestorationIdentifier     string   `json:"userRestorationIdentifier"`
	GuardianRestorationIdentifier []string `json:"guardianRestorationIdentifier"`
}

type User

type User struct {
	Username   string `json:"username"`
	UUID       string `json:"uuid"`
	Mnemonic   string `json:"mnemonic"`
	Passphrase string `json:"passphrase"`
}

User -- stores data related to user

type UserDetails

type UserDetails struct {
	UserEmail                            string                   `json:"useremail"`
	UnverifiedUserEmail                  string                   `json:"tempuseremail"`
	Guardians                            []string                 `json:"guardians"`
	UnverifiedGuardians                  []string                 `json:"unverifiedGuardians"`
	GuardianEmailOTPGenerateTimestamp    []int64                  `json:"guardianEmailOTPGenerateTimestamp"`
	GuardiansAddLinkInitiation           []int64                  `json:"guardiansAddLinkInitiation"`
	GuardiansUpdateStatus                []bool                   `json:"guardiansUpdateStatus"`
	UserMobile                           string                   `json:"usermobile"`
	UnverifiedUserMobile                 string                   `json:"tempusermobile"`
	UserRSAPublicKey                     string                   `json:"userRSAPublicKey"`
	UserECDSAPublicKey                   string                   `json:"userECDSAPublicKey"`
	WalletThirdShard                     string                   `json:"secret"`
	LastRecoverySavedAt                  LastRecoverySaveLocation `json:"lastRecoverySavedAt"`
	UnverifiedWalletThirdShard           string                   `json:"unverifiedSecret"`
	Identifier                           string                   `json:"identifier"`
	IsRestoreInProgress                  bool                     `json:"isrestoreinprogress"`
	EmailVerificationState               bool                     `json:"emailverificationstate"`
	MobileVerificationState              bool                     `json:"mobileverificationstate"`
	PrimaryEmailVerificationOTP          string                   `json:"primaryEmailVerificationOTP"`
	GuardianIdentifiers                  []string                 `json:"guardianIdentifiers"`
	MobileVerificationOTP                string                   `json:"mobileverificationotp"`
	PrimaryEmailOTPGenerateTimestamp     int64                    `json:"primaryEmailOTPGenerateTimestamp"`
	MobileOTPGenerateTimestamp           int64                    `json:"mobileotpgeneratedtimestamp"`
	RestoreInitiationTimestamp           int64                    `json:"restoreinitiationtimestamp"`
	WalletIdentifierStoredAt             string                   `json:"walletIdentifierStoredAt"`
	SignedConsentForPrivateKey           string                   `json:"signedConsentForPrivateKey"`
	SignedConsentForMnemonics            string                   `json:"signedConsentForMnemonics"`
	LastVetoedBy                         string                   `json:"lastVetoedBy"`
	RsaEncryptedMnemonicEncryptionAESKey string                   `json:"rsaEncryptedMnemonicEncryptionAESKey"`
	UserWalletAddress                    string                   `json:"userWalletAddress"`
	LastVetoedAt                         int64                    `json:"lastVetoedAt"`
}

type VaultStatus

type VaultStatus struct {
	Identifier                 string                   `json:"identifier"`
	UserEmail                  string                   `json:"userEmail"`
	Guardians                  []GuardianEmails         `json:"guardians"`
	UserMobile                 string                   `json:"userMobile"`
	UserRSAPublicKey           bool                     `json:"userRSAPublicKey"`
	UserECDSAPublicKey         bool                     `json:"userECDSAPublicKey"`
	WalletThirdShard           bool                     `json:"secret"`
	LastRecoverySavedAt        LastRecoverySaveLocation `json:"lastRecoverySavedAt"`
	IsRestoreInProgress        bool                     `json:"isRestoreInProgress"`
	RestoreInitiationTimestamp int64                    `json:"restoreInitiationTimestamp"`
	RestoreCompletionTimestamp int64                    `json:"restoreCompletionTimestamp"`
	SignedConsentForPrivateKey bool                     `json:"signedConsentForPrivateKey"`
	SignedConsentForMnemonics  bool                     `json:"signedConsentForMnemonics"`
	LastVetoedBy               string                   `json:"lastVetoedBy"`
	LastVetoedAt               int64                    `json:"lastVetoedAt"`
	RestorationLockedUntil     int64                    `json:"restorationLockedUntil"`
}

type WalletIdentifierStorage

type WalletIdentifierStorage struct {
	WalletIdentifier string `json:"walletIdentifier"`
}

Jump to

Keyboard shortcuts

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