diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 57fb9b6a..9e8daf67 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 5.1.3.2 + 5.1.4.1 diff --git a/LibationWinForms/Dialogs/Login/CaptchaDialog.resx b/LibationWinForms/Dialogs/Login/CaptchaDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/LibationWinForms/Dialogs/Login/CaptchaDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LibationWinForms/Dialogs/Login/MfaDialog.Designer.cs b/LibationWinForms/Dialogs/Login/MfaDialog.Designer.cs new file mode 100644 index 00000000..35043cef --- /dev/null +++ b/LibationWinForms/Dialogs/Login/MfaDialog.Designer.cs @@ -0,0 +1,112 @@ + +namespace LibationWinForms.Dialogs.Login +{ + partial class MfaDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.submitBtn = new System.Windows.Forms.Button(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton3 = new System.Windows.Forms.RadioButton(); + this.SuspendLayout(); + // + // submitBtn + // + this.submitBtn.Location = new System.Drawing.Point(14, 93); + this.submitBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.submitBtn.Name = "submitBtn"; + this.submitBtn.Size = new System.Drawing.Size(88, 27); + this.submitBtn.TabIndex = 3; + this.submitBtn.Text = "Submit"; + this.submitBtn.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Checked = true; + this.radioButton1.Location = new System.Drawing.Point(14, 14); + this.radioButton1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(242, 19); + this.radioButton1.TabIndex = 0; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Enter the OTP from the authenticator app"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(14, 40); + this.radioButton2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(172, 19); + this.radioButton2.TabIndex = 1; + this.radioButton2.Text = "Send an SMS to my number"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton3 + // + this.radioButton3.AutoSize = true; + this.radioButton3.Location = new System.Drawing.Point(14, 67); + this.radioButton3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.radioButton3.Name = "radioButton3"; + this.radioButton3.Size = new System.Drawing.Size(147, 19); + this.radioButton3.TabIndex = 2; + this.radioButton3.Text = "Call me on my number"; + this.radioButton3.UseVisualStyleBackColor = true; + // + // MfaDialog + // + this.AcceptButton = this.submitBtn; + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(398, 129); + this.Controls.Add(this.radioButton3); + this.Controls.Add(this.radioButton2); + this.Controls.Add(this.radioButton1); + this.Controls.Add(this.submitBtn); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MfaDialog"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Two-step verification"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button submitBtn; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.RadioButton radioButton2; + private System.Windows.Forms.RadioButton radioButton3; + } +} \ No newline at end of file diff --git a/LibationWinForms/Dialogs/Login/MfaDialog.cs b/LibationWinForms/Dialogs/Login/MfaDialog.cs new file mode 100644 index 00000000..dac51ab4 --- /dev/null +++ b/LibationWinForms/Dialogs/Login/MfaDialog.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace LibationWinForms.Dialogs.Login +{ + public partial class MfaDialog : Form + { + public MfaDialog(AudibleApi.MfaConfig mfaConfig) + { + InitializeComponent(); + + // optional string settings + if (!string.IsNullOrWhiteSpace(mfaConfig.Title)) + this.Text = mfaConfig.Title; + if (!string.IsNullOrWhiteSpace(mfaConfig.Button1Text)) + this.radioButton1.Text = mfaConfig.Button1Text; + if (!string.IsNullOrWhiteSpace(mfaConfig.Button2Text)) + this.radioButton2.Text = mfaConfig.Button2Text; + if (!string.IsNullOrWhiteSpace(mfaConfig.Button3Text)) + this.radioButton3.Text = mfaConfig.Button3Text; + + // mandatory values + radioButton1.Name = mfaConfig.Button1Name; + radioButton1.Tag = mfaConfig.Button1Value; + + radioButton2.Name = mfaConfig.Button2Name; + radioButton2.Tag = mfaConfig.Button2Value; + + radioButton3.Name = mfaConfig.Button3Name; + radioButton3.Tag = mfaConfig.Button3Value; + } + + public string SelectedName { get; private set; } + public string SelectedValue { get; private set; } + private void submitBtn_Click(object sender, EventArgs e) + { + var radioButtons = new[] { this.radioButton1, this.radioButton2, this.radioButton3 }; + var selected = radioButtons.Single(rb => rb.Checked); + + SelectedName = selected.Name; + SelectedValue = (string)selected.Tag; + + DialogResult = DialogResult.OK; + // Close() not needed for AcceptButton + } + } +} diff --git a/LibationWinForms/Dialogs/Login/MfaDialog.resx b/LibationWinForms/Dialogs/Login/MfaDialog.resx new file mode 100644 index 00000000..f298a7be --- /dev/null +++ b/LibationWinForms/Dialogs/Login/MfaDialog.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LibationWinForms/Dialogs/Login/WinformResponder.cs b/LibationWinForms/Dialogs/Login/WinformResponder.cs index d443f9d7..eaeae9f7 100644 --- a/LibationWinForms/Dialogs/Login/WinformResponder.cs +++ b/LibationWinForms/Dialogs/Login/WinformResponder.cs @@ -30,6 +30,14 @@ namespace LibationWinForms.Login return null; } + public (string name, string value) GetMfaChoice(MfaConfig mfaConfig) + { + using var dialog = new MfaDialog(mfaConfig); + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + return (dialog.SelectedName, dialog.SelectedValue); + return (null, null); + } + public (string email, string password) GetLogin() { using var dialog = new AudibleLoginDialog(_account); diff --git a/LibationWinForms/LibationWinForms.csproj b/LibationWinForms/LibationWinForms.csproj index eb26895b..8451cbbe 100644 --- a/LibationWinForms/LibationWinForms.csproj +++ b/LibationWinForms/LibationWinForms.csproj @@ -17,6 +17,12 @@ + + Form + + + MfaDialog.cs + True True diff --git a/WinFormsDesigner/Dialogs/Login/MfaDialog.Designer.cs b/WinFormsDesigner/Dialogs/Login/MfaDialog.Designer.cs new file mode 100644 index 00000000..28f469c4 --- /dev/null +++ b/WinFormsDesigner/Dialogs/Login/MfaDialog.Designer.cs @@ -0,0 +1,107 @@ + +namespace WinFormsDesigner.Dialogs.Login +{ + partial class MfaDialog + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.submitBtn = new System.Windows.Forms.Button(); + this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.radioButton2 = new System.Windows.Forms.RadioButton(); + this.radioButton3 = new System.Windows.Forms.RadioButton(); + this.SuspendLayout(); + // + // submitBtn + // + this.submitBtn.Location = new System.Drawing.Point(12, 81); + this.submitBtn.Name = "submitBtn"; + this.submitBtn.Size = new System.Drawing.Size(75, 23); + this.submitBtn.TabIndex = 3; + this.submitBtn.Text = "Submit"; + this.submitBtn.UseVisualStyleBackColor = true; + // + // radioButton1 + // + this.radioButton1.AutoSize = true; + this.radioButton1.Checked = true; + this.radioButton1.Location = new System.Drawing.Point(12, 12); + this.radioButton1.Name = "radioButton1"; + this.radioButton1.Size = new System.Drawing.Size(220, 17); + this.radioButton1.TabIndex = 0; + this.radioButton1.TabStop = true; + this.radioButton1.Text = "Enter the OTP from the authenticator app"; + this.radioButton1.UseVisualStyleBackColor = true; + // + // radioButton2 + // + this.radioButton2.AutoSize = true; + this.radioButton2.Location = new System.Drawing.Point(12, 35); + this.radioButton2.Name = "radioButton2"; + this.radioButton2.Size = new System.Drawing.Size(157, 17); + this.radioButton2.TabIndex = 1; + this.radioButton2.Text = "Send an SMS to my number"; + this.radioButton2.UseVisualStyleBackColor = true; + // + // radioButton3 + // + this.radioButton3.AutoSize = true; + this.radioButton3.Location = new System.Drawing.Point(12, 58); + this.radioButton3.Name = "radioButton3"; + this.radioButton3.Size = new System.Drawing.Size(128, 17); + this.radioButton3.TabIndex = 2; + this.radioButton3.Text = "Call me on my number"; + this.radioButton3.UseVisualStyleBackColor = true; + // + // MfaDialog + // + this.AcceptButton = this.submitBtn; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(341, 112); + this.Controls.Add(this.radioButton3); + this.Controls.Add(this.radioButton2); + this.Controls.Add(this.radioButton1); + this.Controls.Add(this.submitBtn); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MfaDialog"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Two-step verification"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Button submitBtn; + private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.RadioButton radioButton2; + private System.Windows.Forms.RadioButton radioButton3; + } +} \ No newline at end of file diff --git a/WinFormsDesigner/Dialogs/Login/MfaDialog.cs b/WinFormsDesigner/Dialogs/Login/MfaDialog.cs new file mode 100644 index 00000000..043275aa --- /dev/null +++ b/WinFormsDesigner/Dialogs/Login/MfaDialog.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WinFormsDesigner.Dialogs.Login +{ + public partial class MfaDialog : Form + { + public MfaDialog() + { + InitializeComponent(); + } + } +} diff --git a/WinFormsDesigner/Dialogs/Login/MfaDialog.resx b/WinFormsDesigner/Dialogs/Login/MfaDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/WinFormsDesigner/Dialogs/Login/MfaDialog.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinFormsDesigner/WinFormsDesigner.csproj b/WinFormsDesigner/WinFormsDesigner.csproj index da93d25b..8a05373d 100644 --- a/WinFormsDesigner/WinFormsDesigner.csproj +++ b/WinFormsDesigner/WinFormsDesigner.csproj @@ -107,6 +107,12 @@ CaptchaDialog.cs + + Form + + + MfaDialog.cs + Form @@ -185,6 +191,9 @@ ApprovalNeededDialog.cs + + MfaDialog.cs + ScanAccountsDialog.cs