diff --git a/.filenesting.json b/.filenesting.json new file mode 100644 index 0000000..0b71966 --- /dev/null +++ b/.filenesting.json @@ -0,0 +1,3 @@ +{ + "help":"https://go.microsoft.com/fwlink/?linkid=866610" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a30d25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..457950b --- /dev/null +++ b/Main.cs @@ -0,0 +1,214 @@ +using ManagedCommon; +using Wox.Plugin; +using System.IO; +using System.Text.Json; +using System.Web; +using System.Windows; +using OtpNet; + +namespace PowerToysRunTOTP +{ + public class Struct + { + public String Name { get; set; } + public String Key { get; set; } + } + + public class Main : IPlugin + { + + private string ConfigPath = Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%") + "\\Microsoft\\PowerToys\\PowerToys Run\\Settings\\Plugins\\Zapic.Plugin.TOTP\\TOTPList.json"; + private string IconCopy { get; set; } + private string IconAdd { get; set; } + private string IconWarn { get; set; } + + private PluginInitContext? Context { get; set; } + public string Name => "TOTP"; + + public string Description => "TOTP Code Generator"; + + public List Query(Query query) + { + if (query.Search.StartsWith("otpauth://totp/")) { + var list = new List(); + try { + var link = new Uri(query.Search); + var name = link.LocalPath.ToString().Substring(1); + var queries = HttpUtility.ParseQueryString(link.Query); + var sercet = queries.Get("secret") ?? throw new Exception(); + list.Add(new Result { + Title = name, + SubTitle = "Add to list", + IcoPath = IconAdd, + Action = (e) => { + var list = loadConfig(); + list.Add(new Struct { + Key = sercet, + Name = name + }); + saveConfig(list); + return true; + } + }); + } catch (Exception) { } + return list; + } + if (query.Search.StartsWith("otpauth-migration://offline?")) { + var uri = new Uri(query.Search); + var queries = HttpUtility.ParseQueryString(uri.Query); + var payload = queries.Get("data") ?? throw new Exception(); + var decoded = Payload.Parser.ParseFrom(Convert.FromBase64String(payload)); + + + return new List { + new Result { + Title = "Add " + decoded.OtpParameters.Count() + " items to list", + SubTitle = "From Google Authenticator App, batch " + (decoded.BatchIndex + 1).ToString() + " / " + decoded.BatchSize, + IcoPath = IconAdd, + Action = (e) => { + var list = loadConfig(); + foreach (var item in decoded.OtpParameters) { + var key = Base32Encoding.ToString(item.Secret.ToByteArray()); + if (list.Find(it => it.Key.Equals(key)) != null) continue; + var name = ""; + if (item.Issuer.Length == 0) { + name = item.Name; + } else if (item.Name.Length == 0) { + name = item.Issuer + ": "; + } else { + name = item.Issuer + ": " + item.Name; + } + list.Add(new Struct{ + Name = name, + Key = key + }); + } + saveConfig(list); + return true; + } + } + }; + } + List totpList; + try { + totpList = loadConfig(); + } catch (Exception ex) { + return new List { + new Result { + Title = ex.Message, + SubTitle = "Error when try to load config", + IcoPath = IconWarn + } + }; + } + var result = new List(); + + totpList.ForEach(totp => + { + if (query.Search.Length != 0 && !totp.Name.ToLower().Contains(query.Search.ToLower())) return; + var totpInst = new Totp(Base32Encoding.ToBytes(totp.Key)); + result.Add(new Result { + Title = totpInst.ComputeTotp() + " - " + totp.Name, + SubTitle = "Copy to clipboard - Expired in " + totpInst.RemainingSeconds().ToString() + "s", + IcoPath = IconCopy, + Action = (e) => { + Clipboard.SetText(totpInst.ComputeTotp()); + return true; + } + }); + }); + if (result.Count == 0 && query.RawQuery.StartsWith(query.ActionKeyword)) { + if (totpList.Count == 0) + { + result.Add(new Result + { + Title = "No TOTP found in config", + SubTitle = "Add TOTP to plugin by paste your setup link(totp://) first", + IcoPath = IconWarn, + Action = (e) => + { + return false; + } + }); + } + else { + result.Add(new Result + { + Title = "No matching result", + SubTitle = "Leave it blank to show all items", + IcoPath = IconWarn, + Action = (e) => + { + return false; + } + }); + } + } + return result; + } + + public void Init(PluginInitContext context) + { + Context = context; + Context.API.ThemeChanged += OnThemeChanged; + UpdateIconPath(Context.API.GetCurrentTheme()); + } + + private void UpdateIconPath(Theme theme) + { + if (theme == Theme.Light || theme == Theme.HighContrastWhite) { + IconCopy = "images/copy-light.png"; + IconAdd = "images/add-light.png"; + IconWarn = "images/warn-light.png"; + } else { + IconCopy = "images/copy-dark.png"; + IconAdd = "images/add-dark.png"; + IconWarn = "images/warn-dark.png"; + } + } + + private void OnThemeChanged(Theme currentTheme, Theme newTheme) + { + UpdateIconPath(newTheme); + } + + private List loadConfig() { + var fileInfo = new FileInfo(ConfigPath); + if (!fileInfo.Exists) + { + if (!fileInfo.Directory!.Exists) + { + Directory.CreateDirectory(fileInfo.Directory!.FullName); + } + var newFile = File.Create(ConfigPath); + var options = new JsonSerializerOptions { WriteIndented = true }; + JsonSerializer.Serialize(newFile, new List(), options); + newFile.Dispose(); + } + var file = File.OpenRead(ConfigPath); + var result = JsonSerializer.Deserialize>(file); + if (result == null) + { + throw new Exception("Failed to load config: Result is null"); + } + file.Dispose(); + return result; + } + + private void saveConfig(List list) + { + var fileInfo = new FileInfo(ConfigPath); + if (!fileInfo.Exists) + { + if (!fileInfo.Directory!.Exists) + { + Directory.CreateDirectory(fileInfo.Directory!.FullName); + } + } + var file = File.Open(ConfigPath, FileMode.Create); + var options = new JsonSerializerOptions { WriteIndented = true }; + JsonSerializer.Serialize(file, list, options); + file.Dispose(); + } + } +} \ No newline at end of file diff --git a/OtpauthMigration.cs b/OtpauthMigration.cs new file mode 100644 index 0000000..5877bd1 --- /dev/null +++ b/OtpauthMigration.cs @@ -0,0 +1,943 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: i/i.proto +// +#pragma warning disable 1591, 0612, 3021, 8981 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +namespace PowerToysRunTOTP +{ + + /// Holder for reflection information generated from i/i.proto + public static partial class IReflection + { + + #region Descriptor + /// File descriptor for i/i.proto + public static pbr::FileDescriptor Descriptor + { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static IReflection() + { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CglpL2kucHJvdG8SEW90cGF1dGhfbWlncmF0aW9uIqcFCgdQYXlsb2FkEkAK", + "Dm90cF9wYXJhbWV0ZXJzGAEgAygLMigub3RwYXV0aF9taWdyYXRpb24uUGF5", + "bG9hZC5PdHBQYXJhbWV0ZXJzEg8KB3ZlcnNpb24YAiABKAUSEgoKYmF0Y2hf", + "c2l6ZRgDIAEoBRITCgtiYXRjaF9pbmRleBgEIAEoBRIQCghiYXRjaF9pZBgF", + "IAEoBRrwAQoNT3RwUGFyYW1ldGVycxIOCgZzZWNyZXQYASABKAwSDAoEbmFt", + "ZRgCIAEoCRIOCgZpc3N1ZXIYAyABKAkSNwoJYWxnb3JpdGhtGAQgASgOMiQu", + "b3RwYXV0aF9taWdyYXRpb24uUGF5bG9hZC5BbGdvcml0aG0SNQoGZGlnaXRz", + "GAUgASgOMiUub3RwYXV0aF9taWdyYXRpb24uUGF5bG9hZC5EaWdpdENvdW50", + "EjAKBHR5cGUYBiABKA4yIi5vdHBhdXRoX21pZ3JhdGlvbi5QYXlsb2FkLk90", + "cFR5cGUSDwoHY291bnRlchgHIAEoAyJ5CglBbGdvcml0aG0SGQoVQUxHT1JJ", + "VEhNX1VOU1BFQ0lGSUVEEAASEgoOQUxHT1JJVEhNX1NIQTEQARIUChBBTEdP", + "UklUSE1fU0hBMjU2EAISFAoQQUxHT1JJVEhNX1NIQTUxMhADEhEKDUFMR09S", + "SVRITV9NRDUQBCJVCgpEaWdpdENvdW50EhsKF0RJR0lUX0NPVU5UX1VOU1BF", + "Q0lGSUVEEAASEwoPRElHSVRfQ09VTlRfU0lYEAESFQoRRElHSVRfQ09VTlRf", + "RUlHSFQQAiJJCgdPdHBUeXBlEhgKFE9UUF9UWVBFX1VOU1BFQ0lGSUVEEAAS", + "EQoNT1RQX1RZUEVfSE9UUBABEhEKDU9UUF9UWVBFX1RPVFAQAmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::PowerToysRunTOTP.Payload), global::PowerToysRunTOTP.Payload.Parser, new[]{ "OtpParameters", "Version", "BatchSize", "BatchIndex", "BatchId" }, null, new[]{ typeof(global::PowerToysRunTOTP.Payload.Types.Algorithm), typeof(global::PowerToysRunTOTP.Payload.Types.DigitCount), typeof(global::PowerToysRunTOTP.Payload.Types.OtpType) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::PowerToysRunTOTP.Payload.Types.OtpParameters), global::PowerToysRunTOTP.Payload.Types.OtpParameters.Parser, new[]{ "Secret", "Name", "Issuer", "Algorithm", "Digits", "Type", "Counter" }, null, null, null, null)}) + })); + } + #endregion + + } + #region Messages + public sealed partial class Payload : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Payload()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor + { + get { return global::PowerToysRunTOTP.IReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor + { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Payload() + { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Payload(Payload other) : this() + { + otpParameters_ = other.otpParameters_.Clone(); + version_ = other.version_; + batchSize_ = other.batchSize_; + batchIndex_ = other.batchIndex_; + batchId_ = other.batchId_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Payload Clone() + { + return new Payload(this); + } + + /// Field number for the "otp_parameters" field. + public const int OtpParametersFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_otpParameters_codec + = pb::FieldCodec.ForMessage(10, global::PowerToysRunTOTP.Payload.Types.OtpParameters.Parser); + private readonly pbc::RepeatedField otpParameters_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public pbc::RepeatedField OtpParameters + { + get { return otpParameters_; } + } + + /// Field number for the "version" field. + public const int VersionFieldNumber = 2; + private int version_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int Version + { + get { return version_; } + set + { + version_ = value; + } + } + + /// Field number for the "batch_size" field. + public const int BatchSizeFieldNumber = 3; + private int batchSize_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int BatchSize + { + get { return batchSize_; } + set + { + batchSize_ = value; + } + } + + /// Field number for the "batch_index" field. + public const int BatchIndexFieldNumber = 4; + private int batchIndex_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int BatchIndex + { + get { return batchIndex_; } + set + { + batchIndex_ = value; + } + } + + /// Field number for the "batch_id" field. + public const int BatchIdFieldNumber = 5; + private int batchId_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int BatchId + { + get { return batchId_; } + set + { + batchId_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) + { + return Equals(other as Payload); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Payload other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + if (ReferenceEquals(other, this)) + { + return true; + } + if (!otpParameters_.Equals(other.otpParameters_)) return false; + if (Version != other.Version) return false; + if (BatchSize != other.BatchSize) return false; + if (BatchIndex != other.BatchIndex) return false; + if (BatchId != other.BatchId) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() + { + int hash = 1; + hash ^= otpParameters_.GetHashCode(); + if (Version != 0) hash ^= Version.GetHashCode(); + if (BatchSize != 0) hash ^= BatchSize.GetHashCode(); + if (BatchIndex != 0) hash ^= BatchIndex.GetHashCode(); + if (BatchId != 0) hash ^= BatchId.GetHashCode(); + if (_unknownFields != null) + { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() + { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) + { +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); +#else + otpParameters_.WriteTo(output, _repeated_otpParameters_codec); + if (Version != 0) { + output.WriteRawTag(16); + output.WriteInt32(Version); + } + if (BatchSize != 0) { + output.WriteRawTag(24); + output.WriteInt32(BatchSize); + } + if (BatchIndex != 0) { + output.WriteRawTag(32); + output.WriteInt32(BatchIndex); + } + if (BatchId != 0) { + output.WriteRawTag(40); + output.WriteInt32(BatchId); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } +#endif + } + +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) + { + otpParameters_.WriteTo(ref output, _repeated_otpParameters_codec); + if (Version != 0) + { + output.WriteRawTag(16); + output.WriteInt32(Version); + } + if (BatchSize != 0) + { + output.WriteRawTag(24); + output.WriteInt32(BatchSize); + } + if (BatchIndex != 0) + { + output.WriteRawTag(32); + output.WriteInt32(BatchIndex); + } + if (BatchId != 0) + { + output.WriteRawTag(40); + output.WriteInt32(BatchId); + } + if (_unknownFields != null) + { + _unknownFields.WriteTo(ref output); + } + } +#endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() + { + int size = 0; + size += otpParameters_.CalculateSize(_repeated_otpParameters_codec); + if (Version != 0) + { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Version); + } + if (BatchSize != 0) + { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(BatchSize); + } + if (BatchIndex != 0) + { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(BatchIndex); + } + if (BatchId != 0) + { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(BatchId); + } + if (_unknownFields != null) + { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Payload other) + { + if (other == null) + { + return; + } + otpParameters_.Add(other.otpParameters_); + if (other.Version != 0) + { + Version = other.Version; + } + if (other.BatchSize != 0) + { + BatchSize = other.BatchSize; + } + if (other.BatchIndex != 0) + { + BatchIndex = other.BatchIndex; + } + if (other.BatchId != 0) + { + BatchId = other.BatchId; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) + { +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); +#else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + otpParameters_.AddEntriesFrom(input, _repeated_otpParameters_codec); + break; + } + case 16: { + Version = input.ReadInt32(); + break; + } + case 24: { + BatchSize = input.ReadInt32(); + break; + } + case 32: { + BatchIndex = input.ReadInt32(); + break; + } + case 40: { + BatchId = input.ReadInt32(); + break; + } + } + } +#endif + } + +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) + { + uint tag; + while ((tag = input.ReadTag()) != 0) + { + switch (tag) + { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + { + otpParameters_.AddEntriesFrom(ref input, _repeated_otpParameters_codec); + break; + } + case 16: + { + Version = input.ReadInt32(); + break; + } + case 24: + { + BatchSize = input.ReadInt32(); + break; + } + case 32: + { + BatchIndex = input.ReadInt32(); + break; + } + case 40: + { + BatchId = input.ReadInt32(); + break; + } + } + } + } +#endif + + #region Nested types + /// Container for nested types declared in the Payload message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static partial class Types + { + public enum Algorithm + { + [pbr::OriginalName("ALGORITHM_UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("ALGORITHM_SHA1")] Sha1 = 1, + [pbr::OriginalName("ALGORITHM_SHA256")] Sha256 = 2, + [pbr::OriginalName("ALGORITHM_SHA512")] Sha512 = 3, + [pbr::OriginalName("ALGORITHM_MD5")] Md5 = 4, + } + + public enum DigitCount + { + [pbr::OriginalName("DIGIT_COUNT_UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("DIGIT_COUNT_SIX")] Six = 1, + [pbr::OriginalName("DIGIT_COUNT_EIGHT")] Eight = 2, + } + + public enum OtpType + { + [pbr::OriginalName("OTP_TYPE_UNSPECIFIED")] Unspecified = 0, + [pbr::OriginalName("OTP_TYPE_HOTP")] Hotp = 1, + [pbr::OriginalName("OTP_TYPE_TOTP")] Totp = 2, + } + + public sealed partial class OtpParameters : pb::IMessage +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage +#endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OtpParameters()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor + { + get { return global::PowerToysRunTOTP.Payload.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor + { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public OtpParameters() + { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public OtpParameters(OtpParameters other) : this() + { + secret_ = other.secret_; + name_ = other.name_; + issuer_ = other.issuer_; + algorithm_ = other.algorithm_; + digits_ = other.digits_; + type_ = other.type_; + counter_ = other.counter_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public OtpParameters Clone() + { + return new OtpParameters(this); + } + + /// Field number for the "secret" field. + public const int SecretFieldNumber = 1; + private pb::ByteString secret_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public pb::ByteString Secret + { + get { return secret_; } + set + { + secret_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 2; + private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Name + { + get { return name_; } + set + { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "issuer" field. + public const int IssuerFieldNumber = 3; + private string issuer_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string Issuer + { + get { return issuer_; } + set + { + issuer_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "algorithm" field. + public const int AlgorithmFieldNumber = 4; + private global::PowerToysRunTOTP.Payload.Types.Algorithm algorithm_ = global::PowerToysRunTOTP.Payload.Types.Algorithm.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::PowerToysRunTOTP.Payload.Types.Algorithm Algorithm + { + get { return algorithm_; } + set + { + algorithm_ = value; + } + } + + /// Field number for the "digits" field. + public const int DigitsFieldNumber = 5; + private global::PowerToysRunTOTP.Payload.Types.DigitCount digits_ = global::PowerToysRunTOTP.Payload.Types.DigitCount.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::PowerToysRunTOTP.Payload.Types.DigitCount Digits + { + get { return digits_; } + set + { + digits_ = value; + } + } + + /// Field number for the "type" field. + public const int TypeFieldNumber = 6; + private global::PowerToysRunTOTP.Payload.Types.OtpType type_ = global::PowerToysRunTOTP.Payload.Types.OtpType.Unspecified; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::PowerToysRunTOTP.Payload.Types.OtpType Type + { + get { return type_; } + set + { + type_ = value; + } + } + + /// Field number for the "counter" field. + public const int CounterFieldNumber = 7; + private long counter_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public long Counter + { + get { return counter_; } + set + { + counter_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) + { + return Equals(other as OtpParameters); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(OtpParameters other) + { + if (ReferenceEquals(other, null)) + { + return false; + } + if (ReferenceEquals(other, this)) + { + return true; + } + if (Secret != other.Secret) return false; + if (Name != other.Name) return false; + if (Issuer != other.Issuer) return false; + if (Algorithm != other.Algorithm) return false; + if (Digits != other.Digits) return false; + if (Type != other.Type) return false; + if (Counter != other.Counter) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() + { + int hash = 1; + if (Secret.Length != 0) hash ^= Secret.GetHashCode(); + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (Issuer.Length != 0) hash ^= Issuer.GetHashCode(); + if (Algorithm != global::PowerToysRunTOTP.Payload.Types.Algorithm.Unspecified) hash ^= Algorithm.GetHashCode(); + if (Digits != global::PowerToysRunTOTP.Payload.Types.DigitCount.Unspecified) hash ^= Digits.GetHashCode(); + if (Type != global::PowerToysRunTOTP.Payload.Types.OtpType.Unspecified) hash ^= Type.GetHashCode(); + if (Counter != 0L) hash ^= Counter.GetHashCode(); + if (_unknownFields != null) + { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() + { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) + { +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); +#else + if (Secret.Length != 0) { + output.WriteRawTag(10); + output.WriteBytes(Secret); + } + if (Name.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Name); + } + if (Issuer.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Issuer); + } + if (Algorithm != global::OtpauthMigration.Payload.Types.Algorithm.Unspecified) { + output.WriteRawTag(32); + output.WriteEnum((int) Algorithm); + } + if (Digits != global::OtpauthMigration.Payload.Types.DigitCount.Unspecified) { + output.WriteRawTag(40); + output.WriteEnum((int) Digits); + } + if (Type != global::OtpauthMigration.Payload.Types.OtpType.Unspecified) { + output.WriteRawTag(48); + output.WriteEnum((int) Type); + } + if (Counter != 0L) { + output.WriteRawTag(56); + output.WriteInt64(Counter); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } +#endif + } + +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) + { + if (Secret.Length != 0) + { + output.WriteRawTag(10); + output.WriteBytes(Secret); + } + if (Name.Length != 0) + { + output.WriteRawTag(18); + output.WriteString(Name); + } + if (Issuer.Length != 0) + { + output.WriteRawTag(26); + output.WriteString(Issuer); + } + if (Algorithm != global::PowerToysRunTOTP.Payload.Types.Algorithm.Unspecified) + { + output.WriteRawTag(32); + output.WriteEnum((int)Algorithm); + } + if (Digits != global::PowerToysRunTOTP.Payload.Types.DigitCount.Unspecified) + { + output.WriteRawTag(40); + output.WriteEnum((int)Digits); + } + if (Type != global::PowerToysRunTOTP.Payload.Types.OtpType.Unspecified) + { + output.WriteRawTag(48); + output.WriteEnum((int)Type); + } + if (Counter != 0L) + { + output.WriteRawTag(56); + output.WriteInt64(Counter); + } + if (_unknownFields != null) + { + _unknownFields.WriteTo(ref output); + } + } +#endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() + { + int size = 0; + if (Secret.Length != 0) + { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(Secret); + } + if (Name.Length != 0) + { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (Issuer.Length != 0) + { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Issuer); + } + if (Algorithm != global::PowerToysRunTOTP.Payload.Types.Algorithm.Unspecified) + { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int)Algorithm); + } + if (Digits != global::PowerToysRunTOTP.Payload.Types.DigitCount.Unspecified) + { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int)Digits); + } + if (Type != global::PowerToysRunTOTP.Payload.Types.OtpType.Unspecified) + { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int)Type); + } + if (Counter != 0L) + { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Counter); + } + if (_unknownFields != null) + { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(OtpParameters other) + { + if (other == null) + { + return; + } + if (other.Secret.Length != 0) + { + Secret = other.Secret; + } + if (other.Name.Length != 0) + { + Name = other.Name; + } + if (other.Issuer.Length != 0) + { + Issuer = other.Issuer; + } + if (other.Algorithm != global::PowerToysRunTOTP.Payload.Types.Algorithm.Unspecified) + { + Algorithm = other.Algorithm; + } + if (other.Digits != global::PowerToysRunTOTP.Payload.Types.DigitCount.Unspecified) + { + Digits = other.Digits; + } + if (other.Type != global::PowerToysRunTOTP.Payload.Types.OtpType.Unspecified) + { + Type = other.Type; + } + if (other.Counter != 0L) + { + Counter = other.Counter; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) + { +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); +#else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Secret = input.ReadBytes(); + break; + } + case 18: { + Name = input.ReadString(); + break; + } + case 26: { + Issuer = input.ReadString(); + break; + } + case 32: { + Algorithm = (global::OtpauthMigration.Payload.Types.Algorithm) input.ReadEnum(); + break; + } + case 40: { + Digits = (global::OtpauthMigration.Payload.Types.DigitCount) input.ReadEnum(); + break; + } + case 48: { + Type = (global::OtpauthMigration.Payload.Types.OtpType) input.ReadEnum(); + break; + } + case 56: { + Counter = input.ReadInt64(); + break; + } + } + } +#endif + } + +#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) + { + uint tag; + while ((tag = input.ReadTag()) != 0) + { + switch (tag) + { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: + { + Secret = input.ReadBytes(); + break; + } + case 18: + { + Name = input.ReadString(); + break; + } + case 26: + { + Issuer = input.ReadString(); + break; + } + case 32: + { + Algorithm = (global::PowerToysRunTOTP.Payload.Types.Algorithm)input.ReadEnum(); + break; + } + case 40: + { + Digits = (global::PowerToysRunTOTP.Payload.Types.DigitCount)input.ReadEnum(); + break; + } + case 48: + { + Type = (global::PowerToysRunTOTP.Payload.Types.OtpType)input.ReadEnum(); + break; + } + case 56: + { + Counter = input.ReadInt64(); + break; + } + } + } + } +#endif + + } + + } + #endregion + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/PowertoysRunTOTP.csproj b/PowertoysRunTOTP.csproj new file mode 100644 index 0000000..3d92df0 --- /dev/null +++ b/PowertoysRunTOTP.csproj @@ -0,0 +1,47 @@ + + + + net6.0-windows + true + enable + enable + AnyCPU;x64 + False + Debug;Release + + + + + + + + + + + + ..\libs\PowerToys.Common.UI.dll + False + + + ..\libs\PowerToys.ManagedCommon.dll + False + + + ..\libs\Wox.Infrastructure.dll + False + + + ..\libs\Wox.Plugin.dll + False + + + + + + Always + + + Always + + + diff --git a/PowertoysRunTOTP.sln b/PowertoysRunTOTP.sln new file mode 100644 index 0000000..154d7fc --- /dev/null +++ b/PowertoysRunTOTP.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32519.379 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowertoysRunTOTP", "PowertoysRunTOTP.csproj", "{77086A85-21D3-4278-919E-AC6E883B1D27}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {77086A85-21D3-4278-919E-AC6E883B1D27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77086A85-21D3-4278-919E-AC6E883B1D27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77086A85-21D3-4278-919E-AC6E883B1D27}.Debug|x64.ActiveCfg = Debug|x64 + {77086A85-21D3-4278-919E-AC6E883B1D27}.Debug|x64.Build.0 = Debug|x64 + {77086A85-21D3-4278-919E-AC6E883B1D27}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77086A85-21D3-4278-919E-AC6E883B1D27}.Release|Any CPU.Build.0 = Release|Any CPU + {77086A85-21D3-4278-919E-AC6E883B1D27}.Release|x64.ActiveCfg = Release|x64 + {77086A85-21D3-4278-919E-AC6E883B1D27}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {48723466-E489-4F02-9FBB-9E027F3B7ECD} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..a2d5272 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Powertoys Run TOTP Plugin +A plugin help you to copy your two-factor verify code in Powertoys Run + + +## Screenshot +![screenshot](./assets/screenshot.png) + +## Installtion +1. Download plugin from Release +2. Extract it to `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins` + +## Usage +1. Add account +Plugin support standard OTPAuth URI (starts with `otpauth://`) and Google Authenticator Export URI(starts with `otpauth-migration://`), you can paste it to search bar and you will see option to add it to list. +You can use QRCode scanner to resolve QRCode to link, Accounts with same key in list will not be added. +You can also add manually by edit config file in `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Zapic.Plugin.TOTP\TOTPList.json`: + ```json + [ + { + "Name": "Github: Hello", + "Key": "12313" + }, + { + "Name": "Twitter: @Hello", + "Key": "12313213" + } + ] + ``` + Change to config file will be applied immediately. + +2. Delete account +There is no way to delete account by GUI. +You can edit file in `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Settings\Plugins\Zapic.Plugin.TOTP\TOTPList.json` to delete account you don't want. +Change to config file will be applied immediately. + +## Build Plugin +1. Clone repo +2. Use "Publish" to build plugin and copy dependcies +3. Use `ILRepack` to bundle all dependcies to single file(Powertoys doesn't support load dll by PTRun plugin). + ``` + ILRepack.exe /lib:"C:\Program Files\Microsoft Visual Studio\2022\Community\dotnet\runtime\shared\Microsoft.NETCore.App\6.0.16" /out:PowerToysRunTOTP.dll PowertoysRunTOTP\bin\Release\net6.0-windows\publish\win-x64\PowerToysRunTOTP.dll PowertoysRunTOTP\bin\Release\net6.0-windows\publish\win-x64\Otp.NET.dll PowertoysRunTOTP\bin\Release\net6.0-windows\publish\win-x64\Google.Protobuf.dll + ``` +4. Use ILRepack generate `PowerToysRunTOTP.dll` to replace orignal out. diff --git a/assets/screenshot.png b/assets/screenshot.png new file mode 100644 index 0000000..182cc7e Binary files /dev/null and b/assets/screenshot.png differ diff --git a/images/add-dark.png b/images/add-dark.png new file mode 100644 index 0000000..2627860 Binary files /dev/null and b/images/add-dark.png differ diff --git a/images/add-light.png b/images/add-light.png new file mode 100644 index 0000000..0a9bcdc Binary files /dev/null and b/images/add-light.png differ diff --git a/images/copy-dark.png b/images/copy-dark.png new file mode 100644 index 0000000..be9db40 Binary files /dev/null and b/images/copy-dark.png differ diff --git a/images/copy-light.png b/images/copy-light.png new file mode 100644 index 0000000..645e399 Binary files /dev/null and b/images/copy-light.png differ diff --git a/images/icon-dark.png b/images/icon-dark.png new file mode 100644 index 0000000..5a923eb Binary files /dev/null and b/images/icon-dark.png differ diff --git a/images/icon-light.png b/images/icon-light.png new file mode 100644 index 0000000..e387f20 Binary files /dev/null and b/images/icon-light.png differ diff --git a/images/warn-dark.png b/images/warn-dark.png new file mode 100644 index 0000000..7eba4c5 Binary files /dev/null and b/images/warn-dark.png differ diff --git a/images/warn-light.png b/images/warn-light.png new file mode 100644 index 0000000..f5492fb Binary files /dev/null and b/images/warn-light.png differ diff --git a/libs/PowerToys.Common.UI.dll b/libs/PowerToys.Common.UI.dll new file mode 100644 index 0000000..a8c1120 Binary files /dev/null and b/libs/PowerToys.Common.UI.dll differ diff --git a/libs/PowerToys.ManagedCommon.dll b/libs/PowerToys.ManagedCommon.dll new file mode 100644 index 0000000..dac3678 Binary files /dev/null and b/libs/PowerToys.ManagedCommon.dll differ diff --git a/libs/Wox.Infrastructure.dll b/libs/Wox.Infrastructure.dll new file mode 100644 index 0000000..37b0d9f Binary files /dev/null and b/libs/Wox.Infrastructure.dll differ diff --git a/libs/Wox.Plugin.dll b/libs/Wox.Plugin.dll new file mode 100644 index 0000000..c3fb9cf Binary files /dev/null and b/libs/Wox.Plugin.dll differ diff --git a/plugin.json b/plugin.json new file mode 100644 index 0000000..2121ab8 --- /dev/null +++ b/plugin.json @@ -0,0 +1,14 @@ +{ + "ID": "EF1F634F20484459A3679B4FE7B07998", + "Disabled": false, + "ActionKeyword": "TOTP", + "Name": "PowerToysRunTOTP", + "Author": "Zapic", + "Version": "1.0.0", + "Language": "csharp", + "Website": "https://github.com/naari3/PowerToysRunPluginSample", + "ExecuteFileName": "PowerToysRunTOTP.dll", + "IsGlobal": false, + "IcoPathDark": "images\\icon-dark.png", + "IcoPathLight": "images\\icon-light.png" +} \ No newline at end of file