Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidateAndFillCtxFromUser = func(ctx context.Context, ctxKey interface{}) (value interface{}, err error) { switch ctxKey { case formats.SignalBackupDBPasswordCtxKey: if val := ctx.Value(ctxKey); val != nil && val.(string) != "" { return val, nil } // Not hidden like a normal password, shown in the clear, because: // 1. This password isn't something a user chooses, so giving it away gives away nothing but the user's password // 2. This password isn't useful without the encrypted backup // 3. Under what circumstances does your attacker have your back up and have visibility of your screen, but can't see what you're physically typing via a keylogger or their eyes? var password string err := survey.AskOne(&survey.Input{ Message: "The Signal backup password (a bunch of numbers)", Help: `This is not the PIN code that Signal makes you type in every once in a while. This is the password that they tell you once when you turn on back ups. It's only numbers, and is pretty long. You may have screenshotted it. If you lost it, you'll need to disable backups on your Android phone, then turn them back on and grab the new backup file.`, }, &password, survey.WithValidator(survey.Required)) return numbersOnly(password), err case formats.MyPhoneNumberCtxKey: if val := ctx.Value(ctxKey); val != nil && val.(string) != "" { return val, nil } var phoneNumber string err := survey.AskOne(&survey.Input{ Message: "Your phone number, without the country code", }, &phoneNumber, survey.WithValidator(survey.Required)) return numbersOnly(phoneNumber), err default: return nil, fmt.Errorf("unknown context key (%v) is required. Consider setting cmd.ValidateAndFillCtxFromUser to be your own function that calls the original function, and adds support for your custom context keys", ctxKey) } }
ValidateAndFillCtxFromUser is a variable that can be overwritten, and that will be called with every context key that's required for every MsgFormat in the conversion path. Even if a context key is present in the context, this function will still be called, allowing you to perform validation here. This function can ask a user to enter in some data needed to proceed with a conversion, or throw errors
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.