diff --git a/Socialvoid.png b/Socialvoid.png new file mode 100644 index 0000000..7bfa7cd Binary files /dev/null and b/Socialvoid.png differ diff --git a/Socialvoid.sln b/Socialvoid.sln new file mode 100644 index 0000000..dd41f31 --- /dev/null +++ b/Socialvoid.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Socialvoid", "Socialvoid\Socialvoid.csproj", "{6CB5C21A-EB16-48D6-B98A-F18D7CE46785}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBD}") = "Tests", "Tests\Tests.csproj", "{2EFF7FAB-7794-4BFA-AB48-998ADADC45A9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6CB5C21A-EB16-48D6-B98A-F18D7CE46785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CB5C21A-EB16-48D6-B98A-F18D7CE46785}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CB5C21A-EB16-48D6-B98A-F18D7CE46785}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CB5C21A-EB16-48D6-B98A-F18D7CE46785}.Release|Any CPU.Build.0 = Release|Any CPU + {2EFF7FAB-7794-4BFA-AB48-998ADADC45A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EFF7FAB-7794-4BFA-AB48-998ADADC45A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EFF7FAB-7794-4BFA-AB48-998ADADC45A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EFF7FAB-7794-4BFA-AB48-998ADADC45A9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Socialvoid/Client/HttpClientMessageHandler.cs b/Socialvoid/Client/HttpClientMessageHandler.cs new file mode 100644 index 0000000..c71bead --- /dev/null +++ b/Socialvoid/Client/HttpClientMessageHandler.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Buffers; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Microsoft; +using Microsoft.VisualStudio.Threading; +using Nerdbank.Streams; +using StreamJsonRpc; +using StreamJsonRpc.Protocol; + +/// +/// A that sends requests and receives responses over HTTP using . +/// +/// +/// See the spec for JSON-RPC over HTTP here: https://www.jsonrpc.org/historical/json-rpc-over-http.html. +/// Only the POST method is supported. +/// +public class HttpClientMessageHandler : IJsonRpcMessageHandler +{ + #nullable enable + private static readonly ReadOnlyCollection AllowedContentTypes = new ReadOnlyCollection(new string[] + { + "application/json-rpc", + "application/json", + "application/jsonrequest", + }); + + /// + /// The Content-Type header to use in requests. + /// + private static readonly MediaTypeHeaderValue ContentTypeHeader = new MediaTypeHeaderValue(AllowedContentTypes[0]); + + /// + /// The Accept header to use in requests. + /// + private static readonly MediaTypeWithQualityHeaderValue AcceptHeader = new MediaTypeWithQualityHeaderValue(AllowedContentTypes[0]); + + private readonly HttpClient httpClient; + private readonly Uri requestUri; + private readonly AsyncQueue incomingMessages = new AsyncQueue(); + + /// + /// Backing field for the property. + /// + private TraceSource traceSource = new TraceSource(nameof(JsonRpc)); + + /// + /// Initializes a new instance of the class + /// with the default . + /// + /// The to use for transmitting JSON-RPC requests. + /// The URI to POST to where the entity will be the JSON-RPC message. + public HttpClientMessageHandler(HttpClient httpClient, Uri requestUri) + : this(httpClient, requestUri, new JsonMessageFormatter()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The to use for transmitting JSON-RPC requests. + /// The URI to POST to where the entity will be the JSON-RPC message. + /// The message formatter. + public HttpClientMessageHandler(HttpClient httpClient, Uri requestUri, IJsonRpcMessageFormatter formatter) + { + this.httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); + this.requestUri = requestUri ?? throw new ArgumentNullException(nameof(requestUri)); + this.Formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); + } + + /// + /// Event IDs raised to our . + /// + public enum TraceEvent + { + /// + /// An HTTP response with an error status code was received. + /// + HttpErrorStatusCodeReceived, + } + + /// + /// Gets or sets the used to trace details about the HTTP transport operations. + /// + /// The value can never be null. + /// Thrown by the setter if a null value is provided. + public TraceSource TraceSource + { + get => this.traceSource; + set + { + Requires.NotNull(value, nameof(value)); + this.traceSource = value; + } + } + + /// + public bool CanRead => true; + + /// + public bool CanWrite => true; + + /// + public IJsonRpcMessageFormatter Formatter { get; } + + /// + public async ValueTask ReadAsync(CancellationToken cancellationToken) + { + var response = await this.incomingMessages.DequeueAsync(cancellationToken).ConfigureAwait(false); + + var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + using (var sequence = new Sequence()) + { +#if NETCOREAPP2_1 + int bytesRead; + do + { + var memory = sequence.GetMemory(4096); + bytesRead = await responseStream.ReadAsync(memory, cancellationToken).ConfigureAwait(false); + sequence.Advance(bytesRead); + } + while (bytesRead > 0); +#else + var buffer = ArrayPool.Shared.Rent(4096); + try + { + int bytesRead; + while (true) + { + bytesRead = await responseStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); + if (bytesRead == 0) + { + break; + } + + var memory = sequence.GetMemory(bytesRead); + buffer.AsMemory(0, bytesRead).CopyTo(memory); + sequence.Advance(bytesRead); + } + } + finally + { + ArrayPool.Shared.Return(buffer); + } +#endif + + return this.Formatter.Deserialize(sequence); + } + } + + /// + public async ValueTask WriteAsync(JsonRpcMessage content, CancellationToken cancellationToken) + { + // Cast here because we only support transmitting requests anyway. + var contentAsRequest = (JsonRpcRequest)content; + + // The JSON-RPC over HTTP spec requires that we supply a Content-Length header, so we have to serialize up front + // in order to measure its length. + using (var sequence = new Sequence()) + { + this.Formatter.Serialize(sequence, content); + + var requestMessage = new HttpRequestMessage(HttpMethod.Post, this.requestUri); + requestMessage.Headers.Accept.Add(AcceptHeader); + requestMessage.Content = new StreamContent(sequence.AsReadOnlySequence.AsStream()); + requestMessage.Content.Headers.ContentType = ContentTypeHeader; + requestMessage.Content.Headers.ContentLength = sequence.Length; + + var response = await this.httpClient.SendAsync(requestMessage, cancellationToken).ConfigureAwait(false); + if (response.IsSuccessStatusCode) + { + VerifyThrowStatusCode(contentAsRequest.IsResponseExpected ? HttpStatusCode.OK : HttpStatusCode.NoContent, response.StatusCode); + } + else + { + this.TraceSource.TraceEvent(TraceEventType.Error, (int)TraceEvent.HttpErrorStatusCodeReceived, "Received HTTP {0} {1} response to JSON-RPC request for method \"{2}\".", (int)response.StatusCode, response.StatusCode, contentAsRequest.Method); + } + + // The response is expected to be a success code, or an error code with a content-type that we can deserialize. + if (response.IsSuccessStatusCode || (response.Content?.Headers.ContentType?.MediaType is string mediaType && AllowedContentTypes.Contains(mediaType))) + { + // Some requests don't merit response messages, such as notifications in JSON-RPC. + // Servers may communicate this with 202 or 204 HTTPS status codes in the response. + // Others may (poorly?) send a 200 response but with an empty entity. + if (response.Content?.Headers.ContentLength > 0) + { + // Make the response available for receiving. + this.incomingMessages.Enqueue(response); + } + } + else + { + // Throw an exception because of the unexpected failure from the server without a JSON-RPC message attached. + response.EnsureSuccessStatusCode(); + } + } + } + + private static void VerifyThrowStatusCode(HttpStatusCode expected, HttpStatusCode actual) + { + if (expected != actual) + { + throw new BadRpcHeaderException($"Expected \"{(int)expected} {expected}\" response but received \"{(int)actual} {actual}\" instead."); + } + } +} \ No newline at end of file diff --git a/Socialvoid/Client/SocialvoidClient.cs b/Socialvoid/Client/SocialvoidClient.cs new file mode 100644 index 0000000..07a04a8 --- /dev/null +++ b/Socialvoid/Client/SocialvoidClient.cs @@ -0,0 +1,561 @@ +using System; +using System.Text.Encodings; +using System.Text; +using System.Net.Http; +using System.Collections.Generic; +using System.IO; +using StreamJsonRpc; +using StreamJsonRpc.Protocol; +using Socialvoid.Security; +using Socialvoid.JObjects; +using Socialvoid.Errors.ServerErrors; +using Socialvoid.Errors.AuthenticationErrors; +using Socialvoid.Errors.ValidationErrors; +using MType = System.Net.Http.Headers.MediaTypeHeaderValue; + +namespace Socialvoid.Client +{ + /// + /// Socialvoid client. + /// since: v0.0.0 + /// + public abstract class SocialvoidClient + { + //------------------------------------------------- + #region Constant's Region + /// + /// the content type of all of our http requests. + /// since: v0.0.0 + /// + protected internal const string ContentType = "application/json-rpc"; + /// + /// the username key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string UsernameKey = "username"; + /// + /// the password key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string PasswordKey = "password"; + /// + /// the otp key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string OtpKey = "otp"; + /// + /// the public hash key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string PublicHashKey = "public_hash"; + /// + /// the private hash key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string PrivateHashKey = "private_hash"; + /// + /// the platform key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string PlatformKey = "platform"; + /// + /// the name key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string NameKey = "name"; + /// + /// the version key in jsonrpc request params. + /// since: v0.0.0 + /// + protected const string VersionKey = "version"; + /// + /// authenticate_user method value. + /// since: v0.0.0 + /// + protected const string AuthenticateUserMethod = "session.authenticate_user"; + /// + /// authenticate_user method value. + /// since: v0.0.0 + /// + protected const string CreateSessionMethod = "session.create"; + /// + /// authenticate_user method value. + /// since: v0.0.0 + /// + protected const string SessionIDKey = "session_identification"; + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The public hash of the client. + /// since: v0.0.0 + /// + public string PublicHash { get; protected set; } + /// + /// The private hash of the client. + /// since: v0.0.0 + /// + public string PrivateHash { get; protected set; } + /// + /// The platform of the client. + /// since: v0.0.0 + /// + public string Platform { get; protected set; } + /// + /// The name of the client. + /// since: v0.0.0 + /// + public string ClientName { get; protected set; } + /// + /// The version of the client. + /// since: v0.0.0 + /// + public string Version { get; protected set; } + /// + /// + /// since: v0.0.0 + /// + public HttpClient HttpClient { get; protected set; } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + /// + /// since: v0.0.0 + /// + protected JsonMessageFormatter _formatter = new(Encoding.UTF8); + /// + /// the endpoint url of socialvoid servers. + /// since: v0.0.0 + /// + protected internal string _endpoint = "http://socialvoid.qlg1.com:5601/"; + /// + /// Session object of this client. + /// since: v0.0.0 + /// + protected internal SessionEstablished _session; + /// + /// if the client should send an otp answer in the next request, + /// this field should be set to true. + /// since: v0.0.0 + /// + protected bool _should_otp; + /// + /// the last otp value of the client which should be sent in the + /// next jsonrpc request. + /// since: v0.0.0 + /// + protected string _otp; + /// + /// since: v0.0.0 + /// + protected readonly MType _contentTypeValue = MType.Parse(ContentType); + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of the class. + /// since: v0.0.0 + /// + /// + /// the public hash of the client. + /// + /// + /// the private hash of the client. + /// + /// + /// the platform of the client. + /// + /// + /// the client name. + /// + /// + /// the version of the client. + /// + protected SocialvoidClient(string publicHash, string privateHash, + string platform, string name, string version) + { + PublicHash = publicHash; + PrivateHash = privateHash; + Platform = platform; + ClientName = name; + Version = version; + HttpClient = new(); + } + + + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + + /// + /// CreateSession method (session.create), establishes a new session + /// to the network. + /// Please do notice that new and unauthenticated sessions + /// expires after 10 minutes of inactivity, authenticating to the session + /// will increase the expiration time to 72 hours of inactivity. This timer + /// is reset whenever the session is used in one way or another. + /// since: v0.0.0 + /// + /// + /// Thrown if the server encounters an internal error. + /// + /// + /// Thrown if the parameter passed as client name is not valid. + /// + /// + /// Thrown if the parameter passed as public hash is not valid. + /// + /// + /// Thrown if the parameter passed as private hash is not valid. + /// + /// + /// Thrown if the parameter passed as platform is not valid. + /// + /// + /// Thrown if the parameter passed as version is not valid. + /// + public virtual SessionEstablished CreateSession() + { + JArgs args = new(){ + {PublicHashKey, PublicHash}, + {PrivateHashKey, PrivateHash}, + {PlatformKey, Platform}, + //{NameKey, ClientName}, + {VersionKey, Version}, + }; + + + var request = GetRpcRequest(CreateSessionMethod, args); + + var message = new HttpRequestMessage(HttpMethod.Post, _endpoint); + message.Content = SerializeContent(request); + message.Content.Headers.ContentType = _contentTypeValue; + var jresp = ParseContent(message); + + return null; + } + /// + /// AuthenticateUser method (session.authenticate_user), + /// Authenticates a user via a Username and Password combination. + /// Optionally two-factor authentication if the account has enabled it. + /// Once authenticated, the session will be able to access methods that + /// requires authentication and preform operations as the authenticated + /// user. + /// since: v0.0.0 + /// + /// + /// The Session Identification object. + /// + /// + /// The username of the user to authenticate to. + /// + /// + /// The password used to authenticate to this account. + /// + /// + /// The optional one-time password used to authenticate to this account. + /// It will be ignored by server if empty or larger than 64 characters. + /// + /// + /// Thrown if the server encounters an internal error. + /// + /// + /// Thrown if the authentication fails. + /// + /// + /// Thrown if the user is already authenticated. + /// + /// + /// Thrown if the user is not able to authenticate. + /// + /// + /// Thrown if the session challenge answer is invalid. + /// + /// + /// Thrown if the username or password is incorrect. + /// + /// + /// Thrown if the two-factor authentication code is incorrect. + /// + /// + /// Thrown if the user is not authenticated and the private access token is required. + /// + /// + /// Thrown if the session has expired. + /// + /// + /// Thrown if two-factor authentication is required. + /// + public virtual void AuthenticateUser(SessionIdentification sessionID, + string username, string password, string otp = null) + { + JArgs args = new(){ + {UsernameKey, username}, + {PasswordKey, password}, + {SessionIDKey, sessionID}, + }; + + // check if the passed-by otp argument is valid or not. + // if yes, ignore _otp field and use user's specified otp value. + // otherwise check for _should_otp and see if we should send an + // otp answer or not. + if (IsOtpValid(otp)) + { + args.Add(OtpKey, otp); + } + else if (_should_otp && IsOtpValid(otp)) + { + // after adding otp answer to args, don't forget to set + // _should_otp to false (and _otp to null). + args.Add(OtpKey, _otp); + _should_otp = false; + _otp = null; + } + + var request = GetRpcRequest(AuthenticateUserMethod, args); + + var message = new HttpRequestMessage(HttpMethod.Post, _endpoint); + message.Content = SerializeContent(request); + message.Content.Headers.ContentType = _contentTypeValue; + var resp = HttpClient.Send(message); + var contentStr = ReadFromContent(resp.Content); + + Console.WriteLine(contentStr); + } + + + #endregion + //------------------------------------------------- + #region Get Method's Region + /// + /// Gets the session of this if and only + /// if you have already established a session (or has loaded it from a file); + /// oterwise it will just return a null object instead of throwing an exception. + /// since: v0.0.0 + /// + public virtual SessionEstablished GetSession() + { + return _session; + } + /// + /// since: v0.0.0 + /// + /// + /// the method. + /// + /// + /// the arguments. + /// + /// + /// the request ID. + /// + /// + /// set it to `true` if you want this request to have requestID parameter + /// set. (if the passed-by id paramater is null, this method will generate + /// a new id itself.) + /// + protected internal JRequest GetRpcRequest(string method, + JArgs args = null, + Nullable id = null, + bool useID = true) + { + if (string.IsNullOrWhiteSpace(method)) + { + throw new ArgumentException( + "method name in a rpc request cannot be null or empty", + nameof(method)); + } + if (useID && (id == null)) + { + id = DateTime.Now.Ticks; + } + + return useID && id != null && id.HasValue ? + new() + { + Method = method, + Arguments = args, + ID = id.Value, + } : + new() + { + Method = method, + Arguments = args, + }; + } + + /// + /// since: v0.0.0 + /// + protected StringContent SerializeContent(JRequest request) + { + return new(request.Serialize()); + } + /// + /// Parses the content of a as a + /// . + /// + /// + /// + protected internal JResponse ParseContent( + HttpRequestMessage message, + bool ex = true) + where VType : class + { + if (HttpClient == null) + { + throw new InvalidOperationException("HttpClient wasn't initialized"); + } + var resp = HttpClient.Send(message); + if (resp == null) + { + throw new InvalidOperationException("HttpClient.Send returned null"); + } + + return ParseContent(resp.Content, ex); + } + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + /// + /// Creates a new instance of the class. + /// since: v0.0.0 + /// + /// + /// the public hash of the client. + /// + /// + /// the private hash of the client. + /// + /// + /// the platform of the client. + /// + /// + /// the client name. + /// + /// + /// the version of the client. + /// + public static SocialvoidClient GetClient(string publicHash, string privateHash, + string platform, string name, string version) + { + if (string.IsNullOrWhiteSpace(publicHash) || publicHash.Length != 64) + { + throw new ArgumentException( + "publicHash parameter is invalid", + nameof(publicHash)); + } + if (string.IsNullOrWhiteSpace(privateHash) || privateHash.Length != 64) + { + throw new ArgumentException( + "privateHash parameter is invalid", + nameof(privateHash)); + } + if (string.IsNullOrWhiteSpace(platform)) + { + throw new ArgumentException( + "platform cannot be null or empty", + nameof(platform)); + } + if (string.IsNullOrWhiteSpace(version)) + { + throw new ArgumentException( + "version cannot be null or empty", + nameof(version)); + } + return new SvClient(publicHash, privateHash, platform, name, version); + } + + /// + /// Checks if a string can be sent as a TOTOP answer or not. + /// since: v0.0.0 + /// + /// + /// the otp string to check. + /// + /// + /// true if the otp string is valid; otherwise false. + /// + protected internal static bool IsOtpValid(string otp) + { + return !(string.IsNullOrWhiteSpace(otp) || otp.Length > 64); + } + /// + /// reads the content of a as a string. + /// returns null if the stream cannot be read. + /// + /// + /// + protected internal static string ReadFromContent(HttpContent content) + { + var stream = content.ReadAsStream(); + if (stream == null || !stream.CanRead) + { + return null; + } + + return new StreamReader(stream).ReadToEnd(); + } + /// + /// Parses the content of a as a + /// . + /// + /// + /// + protected internal static JResponse ParseContent( + HttpContent content, + bool ex = true) + where VType : class + { + var jresp = JResponse.Deserialize(ReadFromContent(content)); + if (ex && jresp.HasError()) + { + throw jresp.GetException(); + } + + return jresp; + } + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Client/SvClient.cs b/Socialvoid/Client/SvClient.cs new file mode 100644 index 0000000..59a8071 --- /dev/null +++ b/Socialvoid/Client/SvClient.cs @@ -0,0 +1,84 @@ +using System; + +namespace Socialvoid.Client +{ + internal sealed class SvClient : SocialvoidClient + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + // some members here + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + public SvClient(string publicHash, string privateHash, + string platform, string name, string version) : + base(publicHash, privateHash, platform, name, version) + { + ; + } + + + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + // some methods here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/AuthenticationErrors/AlreadyAuthenticatedException.cs b/Socialvoid/Errors/AuthenticationErrors/AlreadyAuthenticatedException.cs new file mode 100644 index 0000000..1295340 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/AlreadyAuthenticatedException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the client is attempting + /// to authenticate when already authenticated. + /// Since: v0.0.0 + /// + public sealed class AlreadyAuthenticatedException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client is attempting to + /// authenticate while it's already authenticated. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.AlreadyAuthenticated; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal AlreadyAuthenticatedException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/AuthenticationFailureException.cs b/Socialvoid/Errors/AuthenticationErrors/AuthenticationFailureException.cs new file mode 100644 index 0000000..8344b02 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/AuthenticationFailureException.cs @@ -0,0 +1,88 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the authentication process failed + /// for some unexpected reason; you need to see the exception message + /// for further details. + /// Since: v0.0.0 + /// + public sealed class AuthenticationFailureException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the authentication process failed + /// for some unexpected reason; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.AuthenticationFailure; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal AuthenticationFailureException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/AuthenticationNotApplicableException.cs b/Socialvoid/Errors/AuthenticationErrors/AuthenticationNotApplicableException.cs new file mode 100644 index 0000000..5d72633 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/AuthenticationNotApplicableException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the user does not support + /// this method of authentication; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class AuthenticationNotApplicableException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the user does not support this method + /// of authentication; please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.AuthenticationNotApplicable; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal AuthenticationNotApplicableException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/BadSessionChallengeAnswerException.cs b/Socialvoid/Errors/AuthenticationErrors/BadSessionChallengeAnswerException.cs new file mode 100644 index 0000000..d446888 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/BadSessionChallengeAnswerException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the given session challenge answer + /// is incorrect or out of sync. + /// Since: v0.0.0 + /// + public sealed class BadSessionChallengeAnswerException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the given session challenge answer + /// is incorrect or out of sync. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.BadSessionChallengeAnswer; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal BadSessionChallengeAnswerException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/IncorrectLoginCredentialsException.cs b/Socialvoid/Errors/AuthenticationErrors/IncorrectLoginCredentialsException.cs new file mode 100644 index 0000000..e9832dd --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/IncorrectLoginCredentialsException.cs @@ -0,0 +1,84 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the given login credentials + /// are incorrect. + /// Since: v0.0.0 + /// + public sealed class IncorrectLoginCredentialsException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the given login credentials are incorrect. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.IncorrectLoginCredentials; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal IncorrectLoginCredentialsException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/IncorrectTwoFactorAuthenticationCodeException.cs b/Socialvoid/Errors/AuthenticationErrors/IncorrectTwoFactorAuthenticationCodeException.cs new file mode 100644 index 0000000..dd028ac --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/IncorrectTwoFactorAuthenticationCodeException.cs @@ -0,0 +1,86 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the given two-factor + /// authentication code is incorrect. + /// Since: v0.0.0 + /// + public sealed class IncorrectTwoFactorAuthenticationCodeException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the given two-factor authentication code + /// is incorrect. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.IncorrectTwoFactorAuthenticationCode; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal IncorrectTwoFactorAuthenticationCodeException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/NotAuthenticatedException.cs b/Socialvoid/Errors/AuthenticationErrors/NotAuthenticatedException.cs new file mode 100644 index 0000000..46d4ba9 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/NotAuthenticatedException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the client attempts to + /// invoke a method that requires authentication. + /// Since: v0.0.0 + /// + public sealed class NotAuthenticatedException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client attempts + /// to invoke a method that requires authentication. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.NotAuthenticated; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal NotAuthenticatedException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/PrivateAccessTokenRequiredException.cs b/Socialvoid/Errors/AuthenticationErrors/PrivateAccessTokenRequiredException.cs new file mode 100644 index 0000000..b15675d --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/PrivateAccessTokenRequiredException.cs @@ -0,0 +1,88 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the user/entity uses a + /// Private Access Token to authenticate and the client attempted + /// to authenticate in another way. + /// Since: v0.0.0 + /// + public sealed class PrivateAccessTokenRequiredException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the user/entity uses a + /// Private Access Token to authenticate and the client attempted + /// to authenticate in another way. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.PrivateAccessTokenRequired; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal PrivateAccessTokenRequiredException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/README.md b/Socialvoid/Errors/AuthenticationErrors/README.md new file mode 100644 index 0000000..4241c35 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/README.md @@ -0,0 +1,19 @@ +# Authentication Errors + +These errors are raised when anything related to authentication has failed, +this can include things from when trying to authenticate to session +challenge errors. + +| Name | Code | Hex Code | Deprecated | Versions | Description | +|--------------------------------------|------|----------|------------|----------|--------------------------------------------------------------------------------------------------------------------------------------| +| IncorrectLoginCredentials | 8704 | 0x02200 | No | 1.0 | The given login credentials are incorrect | +| IncorrectTwoFactorAuthenticationCode | 8705 | 0x02201 | No | 1.0 | The given two-factor authentication code is incorrect | +| AuthenticationNotApplicable | 8706 | 0x02202 | No | 1.0 | Raised when the user does not support this method of authentication, see the message for further details | +| SessionNotFound | 8707 | 0x02203 | No | 1.0 | Raised when the requested session was not found in the network | +| NotAuthenticated | 8708 | 0x02204 | No | 1.0 | Raised when the client attempts to invoke a method that requires authentication | +| PrivateAccessTokenRequired | 8709 | 0x02205 | No | 1.0 | Raised when the user/entity uses a Private Access Token to authenticate and the client attempted to authenticate in another way. | +| AuthenticationFailure | 8710 | 0x02206 | No | 1.0 | The authentication process failed for some unexpected reason, see the message for further details. | +| BadSessionChallengeAnswer | 8711 | 0x02207 | No | 1.0 | The given session challenge answer is incorrect or out of sync. | +| TwoFactorAuthenticationRequired | 8712 | 0x02208 | No | 1.0 | Two-Factor Authentication is required, the client must repeat the same request but provide a Two-Factor authentication code as well. | +| AlreadyAuthenticated | 8713 | 0x02209 | No | 1.0 | The client is attempting to authenticate when already authenticated | +| SessionExpired | 8714 | 0x0220a | No | 1.0 | Raised when trying to use a session that has expired | \ No newline at end of file diff --git a/Socialvoid/Errors/AuthenticationErrors/SessionExpiredException.cs b/Socialvoid/Errors/AuthenticationErrors/SessionExpiredException.cs new file mode 100644 index 0000000..422518f --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/SessionExpiredException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the client tried to use a session + /// that has been expired. + /// Since: v0.0.0 + /// + public sealed class SessionExpiredException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client tried to use a session + /// that has been expired. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.SessionExpired; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal SessionExpiredException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/SessionNotFoundException.cs b/Socialvoid/Errors/AuthenticationErrors/SessionNotFoundException.cs new file mode 100644 index 0000000..855c9e2 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/SessionNotFoundException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the requested session can + /// not be found in the database on server-side. + /// Since: v0.0.0 + /// + public sealed class SessionNotFoundException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the requested session was + /// not found in the database on server-side. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.SessionNotFound; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal SessionNotFoundException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/AuthenticationErrors/TwoFactorAuthenticationRequiredException.cs b/Socialvoid/Errors/AuthenticationErrors/TwoFactorAuthenticationRequiredException.cs new file mode 100644 index 0000000..e6252d5 --- /dev/null +++ b/Socialvoid/Errors/AuthenticationErrors/TwoFactorAuthenticationRequiredException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.AuthenticationErrors +{ + /// + /// This exception will be raised when the Two-Factor Authentication + /// is required and so the client must repeat the same request + /// but provide a Two-Factor authentication code as well. + /// Since: v0.0.0 + /// + public sealed class TwoFactorAuthenticationRequiredException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The + /// error code will be returned because the Two-Factor Authentication + /// is required and so the client must repeat the same request + /// but provide a Two-Factor authentication code as well. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.TwoFactorAuthenticationRequired; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal TwoFactorAuthenticationRequiredException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ErrorCodes.cs b/Socialvoid/Errors/ErrorCodes.cs new file mode 100644 index 0000000..99374d9 --- /dev/null +++ b/Socialvoid/Errors/ErrorCodes.cs @@ -0,0 +1,328 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors +{ + /// + /// All error codes received from the Socialvoid servers. + /// Since: v0.0.0 + /// + public enum ErrorCodes + { + //------------------------------------------------- + #region Unknown Error + /// + /// This error code will be returned when the error is not + /// implimented on client-side at all. + /// Since: v0.0.0 + /// + UnknownError = 0, + #endregion + //------------------------------------------------- + #region Validation Errors + /// + /// This error code will be returned when the given username + /// is invalid and does not meet the specification. + /// Since: v0.0.0 + /// + /// + InvalidUsername = 8448, + /// + /// This error code will be returned when the given password is + /// invalid and/or insecure and does not meet the specification. + /// Since: v0.0.0 + /// + InvalidPassword = 8449, + /// + /// This error code will be returned when the First Name provided + /// contains invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidFirstName = 8450, + /// + /// This error code will be returned when the Last Name provided + /// contains invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidLastName = 8451, + /// + /// This error code will be returned when the Biography is too long or + /// contains invalid characters; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidBiography = 8452, + /// + /// This error code will be returned when the given username + /// is already registered in the server and cannot be used. + /// Since: v0.0.0 + /// + UsernameAlreadyExists = 8453, + /// + /// This error code will be returned when the client provided + /// an invalid peer identification as input. + /// Since: v0.0.0 + /// + InvalidPeerInput = 8454, + /// + /// This error code will be returned when the post contains + /// invalid characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidPostText = 8455, + /// + /// This error code will be returned when the client's public hash + /// is invalid and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + InvalidClientPublicHash = 8456, + /// + /// This error code will be returned when the client's private hash + /// is invalid and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + InvalidClientPrivateHash = 8457, + /// + /// This error code will be returned when the version is invalid + /// or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidVersion = 8459, + /// + /// This error code will be returned when the client name contains + /// invalid characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidClientName = 8460, + /// + /// This error code will be returned when the session identification + /// object is invalid; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidSessionIdentification = 8461, + + /// + /// This error code will be returned when the platform name contains + /// invalid characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + InvalidPlatform = 8464, + #endregion + //------------------------------------------------- + #region Authentication Errors + /// + /// This error code will be returned when the given login credentials + /// are incorrect. + /// Since: v0.0.0 + /// + /// + IncorrectLoginCredentials = 8704, + /// + /// This error code will be returned when the given two-factor + /// authentication code is incorrect. + /// Since: v0.0.0 + /// + IncorrectTwoFactorAuthenticationCode = 8705, + /// + /// This error code will be returned when the user does not support + /// this method of authentication; + /// please see the message for further details. + /// Since: v0.0.0 + /// + AuthenticationNotApplicable = 8706, + /// + /// This error code will be returned when the requested session + /// was not found in the database on server-side. + /// Since: v0.0.0 + /// + SessionNotFound = 8707, + /// + /// This error code will be returned when the client attempts + /// to invoke a method that requires authentication. + /// Since: v0.0.0 + /// + NotAuthenticated = 8708, + /// + /// This error code will be returned when the user/entity uses + /// a Private Access Token to authenticate and the client + /// attempted to authenticate in another way. + /// Since: v0.0.0 + /// + PrivateAccessTokenRequired = 8709, + /// + /// This error code will be returned when the authentication process + /// failed for some unexpected reason; + /// please see the message for further details. + /// Since: v0.0.0 + /// + AuthenticationFailure = 8710, + /// + /// This error code will be returned when the given session + /// challenge answer is incorrect or out of sync. + /// Since: v0.0.0 + /// + BadSessionChallengeAnswer = 8711, + /// + /// This error code will be returned when the Two-Factor + /// Authentication is required and so the client must repeat + /// the same request but provide a Two-Factor authentication + /// code as well. + /// Since: v0.0.0 + /// + TwoFactorAuthenticationRequired = 8712, + /// + /// This error code will be returned when the client is attempting + /// to authenticate when already authenticated. + /// Since: v0.0.0 + /// + AlreadyAuthenticated = 8713, + /// + /// This error code will be returned when trying to use a + /// session that has been expired. + /// Since: v0.0.0 + /// + SessionExpired = 8714, + #endregion + //------------------------------------------------- + #region Media Errors + // TODO: This part is a work in progress, + // media has yet to be implemented on the server-side. + #endregion + //------------------------------------------------- + #region Network Errors + /// + /// This error code will be returned when the requested user entity + /// was not found on the server-side. + /// Since: v0.0.0 + /// + /// + PeerNotFound = 12544, + /// + /// This error code will be returned when the client requested + /// a post that isn't found (or does not exist on the server-side). + /// Since: v0.0.0 + /// + PostNotFound = 12545, + /// + /// This error code will be returned when the client requested a post + /// that was deleted. + /// Since: v0.0.0 + /// + PostDeleted = 12546, + /// + /// This error code will be returned when the client attempts to + /// repost a post that has already been reposted (by the same user). + /// Since: v0.0.0 + /// + AlreadyReposted = 12547, + /// + /// This error code will be returned when there was an error while + /// trying to upload one or more files to the server. + /// Since: v0.0.0 + /// + FileUploadError = 12548, + #endregion + //------------------------------------------------- + #region Server Errors + /// + /// This error code will be returned when there was an unexpected + /// error while trying to process your request. + /// Since: v0.0.0 + /// + /// + InternalServerError = 16384, + #endregion + //------------------------------------------------- + #region RPC Errors + /// + /// Execution of the server method was aborted due to a cancellation request from + /// the client. + /// Since: v0.0.0 + /// + RequestCanceled = -32800, + /// + /// Invalid JSON was received by the server. An error occurred on the server while + /// parsing the JSON text. + /// Since: v0.0.0 + /// + ParseError = -32700, + /// + /// Internal JSON-RPC error. + /// Since: v0.0.0 + /// + InternalError = -32603, + /// + /// Invalid method parameter(s). + /// Since: v0.0.0 + /// + InvalidParams = -32602, + /// + /// The method does not exist / is not available. + /// Since: v0.0.0 + /// + MethodNotFound = -32601, + /// + /// The JSON object sent is not a valid Request object. + /// Since: v0.0.0 + /// + InvalidRequest = -32600, + /// + /// Indicates the RPC call was made but the target threw an exception. + /// Since: v0.0.0 + /// + InvocationErrorWithException = -32004, + /// + /// Indicates a response could not be serialized as the application intended. + /// Since: v0.0.0 + /// + ResponseSerializationFailure = -32003, + /// + /// Indicates a request was made to a remotely marshaled object that never existed + /// or has already been disposed of. + /// Since: v0.0.0 + /// + NoMarshaledObjectFound = -32001, + /// + /// Indicates the RPC call was made but the target threw an exception. + /// Since: v0.0.0 + /// + InvocationError = -32000 + #endregion + } +} + diff --git a/Socialvoid/Errors/GeneralException.cs b/Socialvoid/Errors/GeneralException.cs new file mode 100644 index 0000000..ab76174 --- /dev/null +++ b/Socialvoid/Errors/GeneralException.cs @@ -0,0 +1,227 @@ +using System; +using Socialvoid.Errors.RPCErrors; +using Socialvoid.Errors.ServerErrors; +using Socialvoid.Errors.NetworkErrors; +using Socialvoid.Errors.ValidationErrors; +using Socialvoid.Errors.AuthenticationErrors; + +namespace Socialvoid.Errors +{ + /// + /// + /// Since: v0.0.0 + /// + [Serializable] + public class GeneralException : Exception + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code of this exception which is received from + /// the server. + /// + /// This property needs to be overrided in specific exception + /// classes of this library. + /// + /// Since: v0.0.0 + /// + public virtual ErrorCodes ErrorCode { get; } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + /// + /// the error message received from the server. + /// + + internal GeneralException(string message) : base(message) + { + + } + /// + /// Creates a new instance of using + /// the specified error message and erro code. + /// Since: v0.0.0 + /// + /// + /// the error message received from the server. + /// + /// + /// the error code received from the server. + /// + private GeneralException(string message, ErrorCodes code) : base(message) + { + ErrorCode = code; + } + + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + /// + /// GetException will return a new exception based on the + /// error code received from the server with the specified + /// error message. + /// Since: v0.0.0 + /// + public static GeneralException GetException(string m, ErrorCodes err) + { + return err switch + { + // Unknown Error + ErrorCodes.UnknownError => new(m), + // Validation Errors + ErrorCodes.InvalidUsername => + new InvalidUsernameException(m), + ErrorCodes.InvalidPassword => + new InvalidPasswordException(m), + ErrorCodes.InvalidFirstName => + new InvalidFirstNameException(m), + ErrorCodes.InvalidLastName => + new InvalidLastNameException(m), + ErrorCodes.InvalidBiography => + new InvalidBiographyException(m), + ErrorCodes.UsernameAlreadyExists => + new UsernameAlreadyExistsException(m), + ErrorCodes.InvalidPeerInput => + new InvalidPeerInputException(m), + ErrorCodes.InvalidPostText => + new InvalidPostTextException(m), + ErrorCodes.InvalidClientPublicHash => + new InvalidClientPublicHashException(m), + ErrorCodes.InvalidClientPrivateHash => + new InvalidClientPrivateHashException(m), + ErrorCodes.InvalidVersion => + new InvalidVersionException(m), + ErrorCodes.InvalidClientName => + new InvalidClientNameException(m), + ErrorCodes.InvalidSessionIdentification => + new InvalidSessionIdentificationException(m), + ErrorCodes.InvalidPlatform => + new InvalidPlatformException(m), + // Authentication Errors + ErrorCodes.IncorrectLoginCredentials => + new IncorrectLoginCredentialsException(m), + ErrorCodes.IncorrectTwoFactorAuthenticationCode => + new IncorrectTwoFactorAuthenticationCodeException(m), + ErrorCodes.AuthenticationNotApplicable => + new AuthenticationNotApplicableException(m), + ErrorCodes.SessionNotFound => + new SessionNotFoundException(m), + ErrorCodes.NotAuthenticated => + new NotAuthenticatedException(m), + ErrorCodes.PrivateAccessTokenRequired => + new PrivateAccessTokenRequiredException(m), + ErrorCodes.AuthenticationFailure => + new AuthenticationFailureException(m), + ErrorCodes.BadSessionChallengeAnswer => + new BadSessionChallengeAnswerException(m), + ErrorCodes.TwoFactorAuthenticationRequired => + new TwoFactorAuthenticationRequiredException(m), + ErrorCodes.AlreadyAuthenticated => + new AlreadyAuthenticatedException(m), + ErrorCodes.SessionExpired => + new SessionExpiredException(m), + // Media Errors + // Network Errors + ErrorCodes.PeerNotFound => + new PeerNotFoundException(m), + ErrorCodes.PostNotFound => + new PostNotFoundException(m), + ErrorCodes.PostDeleted => + new PostDeletedException(m), + ErrorCodes.AlreadyReposted => + new AlreadyRepostedException(m), + ErrorCodes.FileUploadError => + new FileUploadErrorException(m), + // Server Errors + ErrorCodes.InternalServerError => + new InternalServerErrorException(m), + // RPC Errors + ErrorCodes.RequestCanceled => + new RequestCanceledException(m), + ErrorCodes.ParseError => + new ParseErrorException(m), + ErrorCodes.InternalError => + new InternalErrorException(m), + ErrorCodes.InvalidParams => + new InvalidParamsException(m), + ErrorCodes.MethodNotFound => + new MethodNotFoundException(m), + ErrorCodes.InvalidRequest => + new InvalidRequestException(m), + ErrorCodes.InvocationErrorWithException => + new InvocationErrorWithExException(m), + ErrorCodes.ResponseSerializationFailure => + new ResponseSerializationFailureException(m), + ErrorCodes.NoMarshaledObjectFound => + new NoMarshaledObjectFound(m), + ErrorCodes.InvocationError => + new InvocationErrorException(m), + + // an unknown error code? + _ => new(m, err) + }; + } + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/MediaErrors/README.md b/Socialvoid/Errors/MediaErrors/README.md new file mode 100644 index 0000000..884a654 --- /dev/null +++ b/Socialvoid/Errors/MediaErrors/README.md @@ -0,0 +1,3 @@ +# MediaErrors + +This part is a work in progress, media has yet to be implemented. \ No newline at end of file diff --git a/Socialvoid/Errors/NetworkErrors/AlreadyRepostedException.cs b/Socialvoid/Errors/NetworkErrors/AlreadyRepostedException.cs new file mode 100644 index 0000000..c2ee1dd --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/AlreadyRepostedException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.NetworkErrors +{ + /// + /// This exception will be raised when the client attempts to repost a + /// post that has already been reposted (by the same user). + /// Since: v0.0.0 + /// + public sealed class AlreadyRepostedException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client attempted to repost a + /// post that has already been reposted (by the same user). + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.AlreadyReposted; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal AlreadyRepostedException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/NetworkErrors/FileUploadErrorException.cs b/Socialvoid/Errors/NetworkErrors/FileUploadErrorException.cs new file mode 100644 index 0000000..6d5297d --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/FileUploadErrorException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.NetworkErrors +{ + /// + /// This exception will be raised when there was an error while trying to + /// upload one or more files to the server. + /// Since: v0.0.0 + /// + public sealed class FileUploadErrorException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because there was an error while trying to + /// upload one or more files to the server. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.FileUploadError; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal FileUploadErrorException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/NetworkErrors/PeerNotFoundException.cs b/Socialvoid/Errors/NetworkErrors/PeerNotFoundException.cs new file mode 100644 index 0000000..4c86ded --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/PeerNotFoundException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.NetworkErrors +{ + /// + /// This exception will be raised when the requested user entity + /// can not be not found on the server-side. + /// Since: v0.0.0 + /// + public sealed class PeerNotFoundException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the requested user entity was not found + /// on the server-side. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.PeerNotFound; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal PeerNotFoundException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/NetworkErrors/PostDeletedException.cs b/Socialvoid/Errors/NetworkErrors/PostDeletedException.cs new file mode 100644 index 0000000..54b0984 --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/PostDeletedException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.NetworkErrors +{ + /// + /// This exception will be raised when the client requests a post that + /// is deleted. + /// Since: v0.0.0 + /// + public sealed class PostDeletedException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client requested a post that + /// was deleted. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.PostDeleted; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal PostDeletedException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/NetworkErrors/PostNotFoundException.cs b/Socialvoid/Errors/NetworkErrors/PostNotFoundException.cs new file mode 100644 index 0000000..6399f74 --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/PostNotFoundException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.NetworkErrors +{ + /// + /// This exception will be raised when the client requests a post that + /// isn't found (or does not exist on the server-side). + /// Since: v0.0.0 + /// + public sealed class PostNotFoundException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client requested a post that + /// isn't found (or does not exist on the server-side). + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.PostNotFound; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal PostNotFoundException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/NetworkErrors/README.md b/Socialvoid/Errors/NetworkErrors/README.md new file mode 100644 index 0000000..7b0e3bb --- /dev/null +++ b/Socialvoid/Errors/NetworkErrors/README.md @@ -0,0 +1,12 @@ +# NetworkErrors + +These are the catch-all errors when dealing with the network, from +finding peers, following them, posting, etc. + +| Name | Code | Hex Code | Deprecated | Versions | Description | +|-----------------|-------|----------|------------|----------|----------------------------------------------------------------------------------------| +| PeerNotFound | 12544 | 0x03100 | No | 1.0 | The requested user entity was not found in the network | +| PostNotFound | 12545 | 0x03101 | No | 1.0 | Raised when the client requested a post that isn't found | +| PostDeleted | 12546 | 0x03102 | No | 1.0 | Raised when the client requested a post that was deleted | +| AlreadyReposted | 12547 | 0x03103 | No | 1.0 | Raised when the client attempts to repost a post that has already been reposted | +| FileUploadError | 12548 | 0x03104 | No | 1.0 | Raised when there was an error while trying to upload one or more files to the network | \ No newline at end of file diff --git a/Socialvoid/Errors/README.md b/Socialvoid/Errors/README.md new file mode 100644 index 0000000..763c913 --- /dev/null +++ b/Socialvoid/Errors/README.md @@ -0,0 +1,61 @@ +# Errors + +Socialvoid has it's own unique set of error codes aside from the ones +used by the standard of the RCP server. while your client should handle +standard error codes of the RCP protcol; if you are building a Socialvoid +client then it's important that your client can handle and represent these +errors returned by the Socialvoid Server. + +These errors are designed to explain what the issue is to the client or +user, in cases the client use these errors to automatically correct their +request but some errors may be caused by users as well. so it's important +that your client can understand and catch these errors accordingly. + + +## Error Codes + +Errors come in three components. + + - Name + - Code + - Message + +### Name +The name is the name of the error, it can be anything from `PeerNotFound` +to `InternalServerError`, this makes it easier for programming languages +to use a try catch statement to catch specific errors. + +### Code +The error code is an alternative way to identify the error when the +name is not available or trying to catch a wide range of specific errors. +These are usually represented in integers. + +### Message +A message explains more details about the error, while the same error +can occur for Situation A and B; Situation B may have a different reason +for the same error. This should not be used as a way to identify the error +and usually serves the purpose of troubleshooting or displaying the error +to the user. + +-------------------------------------------------------------------------- + +## Error Types + +Errors are split into sections to make it more easier to manage, you can +either identify errors indivdually by their error code or by range. + +| Section | Set | Range | Description | +|-----------------------|-----|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Validation Errors | 21 | 8448 - 8703 | Errors that returns when the given parameters or data is invalid in some way or another | +| Authentication Errors | 22 | 8704 - 8979 | Errors related to authentication/session management, these errors are usually returned when there was an error while trying to authenticate or there are session errors such as the session being expired. | +| Media Errors | 23 | 8960 - 12543 | Errors related to the media on the network, errors are usually returned if your client uploads bad media files or for some reason there is an error related to the media content on the network. | +| Network Errors | 31 | 12544 - 16383 | Errors related to actions on the network, peers not being found, posts not being found, incorrect permissions, rate limits, etc. | +| Server Errors | 40 | 16384 - *(?) | Errors related to the server, unexpected errors, servers related to administrators/moderators performing administrative tasks on the server | + +## Error Codes + + - [Validation Errors](ValidationErrors.md) 8448 - 8703 + - [Authentication Errors](AuthenticationErrors.md) 8704 - 8979 + - [Media Errors](MediaErrors.md) 8960 - 12543 + - [Network Errors](NetworkErrors.md) 12544 - 16383 + - [Server Errors](ServerErrors.md) 16384 - *(?) \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/InternalErrorException.cs b/Socialvoid/Errors/RPCErrors/InternalErrorException.cs new file mode 100644 index 0000000..352490f --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/InternalErrorException.cs @@ -0,0 +1,84 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when an internal JSON-RPC error + /// happens at the server-side. + /// Since: v0.0.0 + /// + public sealed class InternalErrorException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because of an internal JSON-RPC error. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InternalError; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InternalErrorException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/InvalidParamsException.cs b/Socialvoid/Errors/RPCErrors/InvalidParamsException.cs new file mode 100644 index 0000000..168379e --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/InvalidParamsException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when invalid method parameter(s) is + /// received by socialvoid's servers. + /// Since: v0.0.0 + /// + public sealed class InvalidParamsException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because invalid method parameter(s) is + /// received by socialvoid's servers. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidParams; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidParamsException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/InvalidRequestException.cs b/Socialvoid/Errors/RPCErrors/InvalidRequestException.cs new file mode 100644 index 0000000..b11474a --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/InvalidRequestException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when the JSON object sent to + /// the socialvoid's server is not a valid Request object. + /// Since: v0.0.0 + /// + public sealed class InvalidRequestException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the JSON object sent is not a + /// valid Request object. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidRequest; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidRequestException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/InvocationErrorException.cs b/Socialvoid/Errors/RPCErrors/InvocationErrorException.cs new file mode 100644 index 0000000..5ff32b2 --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/InvocationErrorException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when the RPC call was made but the target + /// threw an exception. + /// Since: v0.0.0 + /// + public sealed class InvocationErrorException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the RPC call was made but the target + /// threw an exception. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvocationError; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvocationErrorException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/InvocationErrorWithExException.cs b/Socialvoid/Errors/RPCErrors/InvocationErrorWithExException.cs new file mode 100644 index 0000000..f10a036 --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/InvocationErrorWithExException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when the RPC call was made but + /// the target threw an exception. + /// Since: v0.0.0 + /// + public sealed class InvocationErrorWithExException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the RPC call was made but + /// the target threw an exception. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvocationErrorWithException; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvocationErrorWithExException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/MethodNotFoundException.cs b/Socialvoid/Errors/RPCErrors/MethodNotFoundException.cs new file mode 100644 index 0000000..ca5a07f --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/MethodNotFoundException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when the method does not exist / is + /// not available. + /// Since: v0.0.0 + /// + public sealed class MethodNotFoundException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the method does not exist / is + /// not available. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.MethodNotFound; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal MethodNotFoundException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/NoMarshaledObjectFoundException.cs b/Socialvoid/Errors/RPCErrors/NoMarshaledObjectFoundException.cs new file mode 100644 index 0000000..26911b4 --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/NoMarshaledObjectFoundException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when a request is made to a remotely + /// marshaled object that never existed or has already been disposed of. + /// Since: v0.0.0 + /// + public sealed class NoMarshaledObjectFound : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because a request was made to a remotely marshaled object + /// that never existed or has already been disposed of. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.NoMarshaledObjectFound; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal NoMarshaledObjectFound(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/ParseErrorException.cs b/Socialvoid/Errors/RPCErrors/ParseErrorException.cs new file mode 100644 index 0000000..994a506 --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/ParseErrorException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when invalid JSON is received by the server. + /// An error occurred on the server while parsing the JSON text. + /// Since: v0.0.0 + /// + public sealed class ParseErrorException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because invalid JSON was received by the server. + /// An error occurred on the server while parsing the JSON text. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.ParseError; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal ParseErrorException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/RequestCanceledException.cs b/Socialvoid/Errors/RPCErrors/RequestCanceledException.cs new file mode 100644 index 0000000..27485e7 --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/RequestCanceledException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when execution of the server method is + /// aborted due to a cancellation request from the client. + /// Since: v0.0.0 + /// + public sealed class RequestCanceledException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because execution of the server method was aborted + /// due to a cancellation request from the client. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.RequestCanceled; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal RequestCanceledException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/RPCErrors/ResponseSerializationFailureException.cs b/Socialvoid/Errors/RPCErrors/ResponseSerializationFailureException.cs new file mode 100644 index 0000000..7a7734b --- /dev/null +++ b/Socialvoid/Errors/RPCErrors/ResponseSerializationFailureException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.RPCErrors +{ + /// + /// This exception will be raised when a response cannot not be serialized + /// as the application intended. + /// Since: v0.0.0 + /// + public sealed class ResponseSerializationFailureException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because a response could not be serialized + /// as the application intended. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.ResponseSerializationFailure; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal ResponseSerializationFailureException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/ServerErrors/InternalServerErrorException.cs b/Socialvoid/Errors/ServerErrors/InternalServerErrorException.cs new file mode 100644 index 0000000..40fdc61 --- /dev/null +++ b/Socialvoid/Errors/ServerErrors/InternalServerErrorException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ServerErrors +{ + /// + /// This exception will be raised when there is an unexpected error + /// while server tried to process our request. + /// Since: v0.0.0 + /// + public sealed class InternalServerErrorException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because there was an unexpected error + /// while trying to process your request. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InternalServerError; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InternalServerErrorException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Errors/ServerErrors/README.md b/Socialvoid/Errors/ServerErrors/README.md new file mode 100644 index 0000000..5347eef --- /dev/null +++ b/Socialvoid/Errors/ServerErrors/README.md @@ -0,0 +1,8 @@ +# ServerErrors + +These errors are usually rasied as a last resort when something is wrong +with the server. + +| Name | Code | Hex Code | Deprecated | Versions | Description | +|---------------------|-------|----------|------------|----------|---------------------------------------------------------------------------------| +| InternalServerError | 16384 | 0x04000 | No | 1.0 | Raised when there was an unexpected error while trying to process your request. | \ No newline at end of file diff --git a/Socialvoid/Errors/ValidationErrors/InvalidBiographyException.cs b/Socialvoid/Errors/ValidationErrors/InvalidBiographyException.cs new file mode 100644 index 0000000..b40d6e9 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidBiographyException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the Biography is too long + /// or contains invalid characters; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidBiographyException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the Biography is too long + /// or contains invalid characters; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidBiography; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidBiographyException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidClientNameException.cs b/Socialvoid/Errors/ValidationErrors/InvalidClientNameException.cs new file mode 100644 index 0000000..79e4ed6 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidClientNameException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the client name contains invalid + /// characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidClientNameException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client name contains invalid + /// characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidClientName; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidClientNameException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidClientPrivateHashException.cs b/Socialvoid/Errors/ValidationErrors/InvalidClientPrivateHashException.cs new file mode 100644 index 0000000..52e2d59 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidClientPrivateHashException.cs @@ -0,0 +1,86 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the client's private hash is invalid + /// and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + public sealed class InvalidClientPrivateHashException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client's private hash is invalid + /// and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidClientPrivateHash; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal InvalidClientPrivateHashException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidClientPublicHashException.cs b/Socialvoid/Errors/ValidationErrors/InvalidClientPublicHashException.cs new file mode 100644 index 0000000..dd2326f --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidClientPublicHashException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the client's public hash is invalid + /// and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + public sealed class InvalidClientPublicHashException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client's public hash is invalid + /// and cannot be identified as a sha256. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidClientPublicHash; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidClientPublicHashException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidFirstNameException.cs b/Socialvoid/Errors/ValidationErrors/InvalidFirstNameException.cs new file mode 100644 index 0000000..833d054 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidFirstNameException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the First Name provided contains + /// invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidFirstNameException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the First Name provided contains + /// invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidFirstName; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidFirstNameException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidLastNameException.cs b/Socialvoid/Errors/ValidationErrors/InvalidLastNameException.cs new file mode 100644 index 0000000..4074998 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidLastNameException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the Last Name provided contains + /// invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidLastNameException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the Last Name provided contains + /// invalid characters and or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidLastName; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidLastNameException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidPasswordException.cs b/Socialvoid/Errors/ValidationErrors/InvalidPasswordException.cs new file mode 100644 index 0000000..8228b08 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidPasswordException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the given password is invalid and/or + /// insecure and does not meet the specification. + /// Since: v0.0.0 + /// + public sealed class InvalidPasswordException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the given password is invalid and/or + /// insecure and does not meet the specification. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidPassword; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidPasswordException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidPeerInputException.cs b/Socialvoid/Errors/ValidationErrors/InvalidPeerInputException.cs new file mode 100644 index 0000000..9324f1d --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidPeerInputException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the client provide an invalid + /// peer identification as input. + /// Since: v0.0.0 + /// + public sealed class InvalidPeerInputException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the client provided an invalid + /// peer identification as input. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidPeerInput; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidPeerInputException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidPlatformException.cs b/Socialvoid/Errors/ValidationErrors/InvalidPlatformException.cs new file mode 100644 index 0000000..8332162 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidPlatformException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the platform name contains invalid + /// characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidPlatformException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the platform name contains invalid + /// characters or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidPlatform; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidPlatformException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidPostTextException.cs b/Socialvoid/Errors/ValidationErrors/InvalidPostTextException.cs new file mode 100644 index 0000000..9ddf005 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidPostTextException.cs @@ -0,0 +1,87 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the post contains invalid + /// characters or is too long; + /// please see the exception message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidPostTextException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the post contains invalid characters + /// or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidPostText; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidPostTextException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidSessionIdentificationException.cs b/Socialvoid/Errors/ValidationErrors/InvalidSessionIdentificationException.cs new file mode 100644 index 0000000..2c0f1ed --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidSessionIdentificationException.cs @@ -0,0 +1,88 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the session identification + /// object is invalid; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public sealed class InvalidSessionIdentificationException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The + /// error code will be returned because the session identification + /// object is invalid; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidSessionIdentification; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of + /// . + /// Since: v0.0.0 + /// + internal InvalidSessionIdentificationException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidUsernameException.cs b/Socialvoid/Errors/ValidationErrors/InvalidUsernameException.cs new file mode 100644 index 0000000..ee8e928 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidUsernameException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the given username is invalid + /// and does not meet the specification. + /// Since: v0.0.0 + /// + public sealed class InvalidUsernameException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the given username is invalid and + /// does not meet the specifications. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidUsername; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidUsernameException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/InvalidVersionException.cs b/Socialvoid/Errors/ValidationErrors/InvalidVersionException.cs new file mode 100644 index 0000000..d2480e2 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/InvalidVersionException.cs @@ -0,0 +1,85 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the given username is invalid + /// and does not meet the specification. + /// Since: v0.0.0 + /// + public sealed class InvalidVersionException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned because the version is invalid or is too long; + /// please see the message for further details. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidVersion; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal InvalidVersionException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} diff --git a/Socialvoid/Errors/ValidationErrors/README.md b/Socialvoid/Errors/ValidationErrors/README.md new file mode 100644 index 0000000..512e76f --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/README.md @@ -0,0 +1,21 @@ +# Validation Errors + +These are errors raised when your client passes on parameters or data +that is invalid in some way or another. + +| Name | Code | Hex Code | Deprecated | Versions | Description | +|------------------------------|------|----------|------------|----------|-------------------------------------------------------------------------------------------------------------| +| InvalidUsername | 8448 | 0x02100 | No | 1.0 | The given username is invalid and does not meet the specification | +| InvalidPassword | 8449 | 0x02101 | No | 1.0 | The given password is invalid and/or insecure and does not meet the specification | +| InvalidFirstName | 8450 | 0x02102 | No | 1.0 | The First Name provided contains invalid characters and or is too long, see the message for further details | +| InvalidLastName | 8451 | 0x02103 | No | 1.0 | The Last Name provided contains invalid characters and or is too long, see the message for further details | +| InvalidBiography | 8452 | 0x02104 | No | 1.0 | The Biography is too long or contains invalid characters, see the message for further details | +| UsernameAlreadyExists | 8453 | 0x02105 | No | 1.0 | The username is already registered in the network and cannot be used | +| InvalidPeerInput | 8454 | 0x02106 | No | 1.0 | The client provided an invalid peer identification as input | +| InvalidPostText | 8455 | 0x02107 | No | 1.0 | The post contains invalid characters or is too long, see the message for further details | +| InvalidClientPublicHash | 8456 | 0x02108 | No | 1.0 | The client's public hash is invalid and cannot be identified as a sha256 | +| InvalidClientPrivateHash | 8457 | 0x02109 | No | 1.0 | The client's private hash is invalid and cannot be identified as a sha256 | +| InvalidPlatform | 8464 | 0x02110 | No | 1.0 | The platform name contains invalid characters or is too long, see the message for further details | +| InvalidVersion | 8459 | 0x0210b | No | 1.0 | The version is invalid or is too long, see the message for further details | +| InvalidClientName | 8460 | 0x0210c | No | 1.0 | The client name contains invalid characters or is too long, see the message for further details | +| InvalidSessionIdentification | 8461 | 0x0210d | No | 1.0 | The session identification object is invalid, see the message for further details | \ No newline at end of file diff --git a/Socialvoid/Errors/ValidationErrors/UsernameAlreadyExistsException.cs b/Socialvoid/Errors/ValidationErrors/UsernameAlreadyExistsException.cs new file mode 100644 index 0000000..e635dc7 --- /dev/null +++ b/Socialvoid/Errors/ValidationErrors/UsernameAlreadyExistsException.cs @@ -0,0 +1,86 @@ +/* + * This file is part of Socialvoid.NET Project (https://github.com/Intellivoid/Socialvoid.NET). + * Copyright (c) 2021 Socialvoid.NET Authors. + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this source code of library. + * If not, see . + */ + +namespace Socialvoid.Errors.ValidationErrors +{ + /// + /// This exception will be raised when the given username is invalid + /// and does not meet the specification. + /// Since: v0.0.0 + /// + public sealed class UsernameAlreadyExistsException : GeneralException + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The error code + /// will be returned + /// because the given username is invalid and + /// does not meet the specifications. + /// Since: v0.0.0 + /// + public override ErrorCodes ErrorCode + { + get + { + return ErrorCodes.InvalidUsername; + } + } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// Creates a new instance of . + /// Since: v0.0.0 + /// + internal UsernameAlreadyExistsException(string message) : base(message) + { + ; + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Icon.ico b/Socialvoid/Icon.ico new file mode 100644 index 0000000..2d4d72b Binary files /dev/null and b/Socialvoid/Icon.ico differ diff --git a/Socialvoid/Icon.png b/Socialvoid/Icon.png new file mode 100644 index 0000000..7bfa7cd Binary files /dev/null and b/Socialvoid/Icon.png differ diff --git a/Socialvoid/JObjects/JArgs.cs b/Socialvoid/JObjects/JArgs.cs new file mode 100644 index 0000000..a02e789 --- /dev/null +++ b/Socialvoid/JObjects/JArgs.cs @@ -0,0 +1,81 @@ +using System; +using System.Text.Json.Serialization; +using System.Collections.Generic; + +namespace Socialvoid.JObjects +{ + /// + /// A simple object. + /// since: v0.0.0 + /// + [Serializable] + public class JArgs: Dictionary + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/JObjects/JError.cs b/Socialvoid/JObjects/JError.cs new file mode 100644 index 0000000..636490d --- /dev/null +++ b/Socialvoid/JObjects/JError.cs @@ -0,0 +1,94 @@ +using System; +using System.Text.Json.Serialization; + +namespace Socialvoid.JObjects +{ + /// + /// A object which contains basic information + /// about an error returned by the server. + /// since: v0.0.0 + /// + [Serializable] + public sealed class JError + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The response error code. + /// since: v0.0.0 + /// + [JsonPropertyName("code")] + public int Code { get; set; } + /// + /// The error message. + /// since: v0.0.0 + /// + [JsonPropertyName("message")] + public string Message { get; set; } + + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/JObjects/JRequest.cs b/Socialvoid/JObjects/JRequest.cs new file mode 100644 index 0000000..105c58a --- /dev/null +++ b/Socialvoid/JObjects/JRequest.cs @@ -0,0 +1,122 @@ +using System; +using System.Text.Json.Serialization; +using System.Text.Json; + +namespace Socialvoid.JObjects +{ + /// + /// A object which contains basic information + /// about an error returned by the server. + /// since: v0.0.0 + /// + [Serializable] + public sealed class JRequest + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The JSON-RPC version. Should be equal to "2.0". + /// since: v0.0.0 + /// + [JsonPropertyName("jsonrpc")] + public string JsonRPC { get; set; } = "2.0"; + /// + /// The error message. + /// since: v0.0.0 + /// + [JsonPropertyName("method")] + public string Method { get; set; } + /// + /// The error message. + /// since: v0.0.0 + /// + [JsonPropertyName("id")] + public long ID { get; set; } + /// + /// The error message. + /// since: v0.0.0 + /// + [JsonPropertyName("params")] + public JArgs Arguments { get; set; } + + + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + /// + /// Changes the ID property of this value to DateTime.Now.Ticks. + /// since: v0.0.0 + /// + public void ChangeID() + { + ID = DateTime.Now.Ticks; + } + #endregion + //------------------------------------------------- + #region Get Method's Region + /// + /// Serializes this request as a string. + /// since: v0.0.0 + /// + public string Serialize() + { + return JsonSerializer.Serialize(this); + } + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/JObjects/JResponse.cs b/Socialvoid/JObjects/JResponse.cs new file mode 100644 index 0000000..2a8d82f --- /dev/null +++ b/Socialvoid/JObjects/JResponse.cs @@ -0,0 +1,145 @@ +using System; +using System.Text.Json.Serialization; +using Socialvoid.Errors; +using System.Text.Json; + +namespace Socialvoid.JObjects +{ + /// + /// A with a specified result type. + /// since: v0.0.0 + /// + [Serializable] + public sealed class JResponse where T: class + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The Json-rpc version. + /// since: v0.0.0 + /// + [JsonPropertyName("jsonrpc")] + public string RPCVersion { get; set; } + + /// + /// The Json-rpc request id. + /// since: v0.0.0 + /// + [JsonPropertyName("id")] + public long ID { get; set; } + /// + /// The results. + /// since: v0.0.0 + /// + [JsonPropertyName("result")] + public T Result { get; set; } + /// + /// The results. + /// since: v0.0.0 + /// + [JsonPropertyName("error")] + public JError Error { get; set; } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + /// + /// Checks if the current response has error or not. + /// since: v0.0.0 + /// + public bool HasError() + { + return Error != null; + } + /// + /// Will convert the current property of this value + /// to a . + /// since: v0.0.0 + /// + /// + /// returns a if and only if the + /// property is not null; otherwise returns null. + /// + public GeneralException GetException() + { + if (!HasError()) + { + return null; + } + + + return GeneralException.GetException(Error.Message, + (ErrorCodes)Error.Code); + } + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + /// + /// Will convert a json string to a . + /// since: v0.0.0 + /// + /// + /// returns a value. + /// + public static JResponse Deserialize(string text) + { + return JsonSerializer.Deserialize>(text); + } + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Methods/CreateSession.cs b/Socialvoid/Methods/CreateSession.cs new file mode 100644 index 0000000..d154560 --- /dev/null +++ b/Socialvoid/Methods/CreateSession.cs @@ -0,0 +1,10 @@ +namespace Socialvoid.Methods +{ + class CreateSession + { + public static bool Do(string public_hash, string private_hash, string platform, string version) + { + return true; + } + } +} diff --git a/Socialvoid/Security/SessionEstablished.cs b/Socialvoid/Security/SessionEstablished.cs new file mode 100644 index 0000000..5144fdf --- /dev/null +++ b/Socialvoid/Security/SessionEstablished.cs @@ -0,0 +1,136 @@ +using System.Text.Json.Serialization; + +namespace Socialvoid.Security +{ + /// + /// A object contains basic information + /// about the session that the server has created for us. + /// since: v0.0.0 + /// + public sealed class SessionEstablished + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The ID of the session obtained when establishing a session. + /// since: v0.0.0 + /// + [JsonPropertyName("id")] + public string SessionID { get; internal set; } + /// + /// The Public Hash of the client used when establishing the session. + /// since: v0.0.0 + /// + [JsonPropertyName("challenge")] + internal string ChallengeSecret { get; set; } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// + /// + private SessionEstablished() + { + ;// make is private, so user use `EstablishNew` static method. + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + /// + /// This method will return the challenge secret received from the + /// server. + /// since: v0.0.0 + /// + /// + /// null if this object doesn't have any challenge secret; + /// otherwise a valid challenge secret. + /// + public string GetChallengeSecret() + { + return string.IsNullOrWhiteSpace(ChallengeSecret) ? + null : ChallengeSecret; + } + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + /// + /// Establishes a new session. + /// since: v0.0.0 + /// + /// + /// the session id returned from the server or being stored in + /// a file. + /// + /// + /// The challenge secret returned from the server. + /// it can be null. + /// please do notice that when you are going to load an already + /// existing session from a file, this parameter should remain null. + /// + /// + /// A new instance of class. + /// + public static SessionEstablished EstablishNew(string id, string challenge = null) + { + return new() + { + SessionID = id, + ChallengeSecret = challenge, + }; + } + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Security/SessionIdentification.cs b/Socialvoid/Security/SessionIdentification.cs new file mode 100644 index 0000000..6524d6e --- /dev/null +++ b/Socialvoid/Security/SessionIdentification.cs @@ -0,0 +1,106 @@ +namespace Socialvoid.Security +{ + /// + /// A SessionIdentification object allows the client to identify the + /// session it's using and prove that it is the owner of the session; + /// it proves as a identification effort and security effort. + /// Most methods that requires authentication or some sort of identity + /// will require you to pass on this object as a parameter under + /// `session_identification`; missing parameters or invalid security values + /// will cause the request to fail as it's validated upon request. + /// since: v0.0.0 + /// + public sealed class SessionIdentification + { + //------------------------------------------------- + #region Constant's Region + // some members here + #endregion + //------------------------------------------------- + #region static Properties Region + // some members here + #endregion + //------------------------------------------------- + #region Properties Region + /// + /// The ID of the session obtained when establishing a session. + /// since: v0.0.0 + /// + public string SessionID { get; internal set; } + /// + /// The Public Hash of the client used when establishing the session. + /// since: v0.0.0 + /// + public string ClientPublicHash { get; internal set; } + /// + /// The session challenge answer revolving around the client's + /// private hash, the same client used to establish the session. + /// since: v0.0.0 + /// + public string ChallengeAnswer { get; internal set; } + #endregion + //------------------------------------------------- + #region static field's Region + // some members here + #endregion + //------------------------------------------------- + #region field's Region + // some members here + #endregion + //------------------------------------------------- + #region static event field's Region + // some members here + #endregion + //------------------------------------------------- + #region event field's Region + // some members here + #endregion + //------------------------------------------------- + #region Constructor's Region + /// + /// + /// + public SessionIdentification() + { + + } + #endregion + //------------------------------------------------- + #region Destructor's Region + // some members here + #endregion + //------------------------------------------------- + #region Initialize Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Graphical Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region event Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region overrided Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region ordinary Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Get Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region Set Method's Region + // some methods here + #endregion + //------------------------------------------------- + #region static Method's Region + // some methods here + #endregion + //------------------------------------------------- + } +} \ No newline at end of file diff --git a/Socialvoid/Socialvoid.csproj b/Socialvoid/Socialvoid.csproj new file mode 100644 index 0000000..530b1a3 --- /dev/null +++ b/Socialvoid/Socialvoid.csproj @@ -0,0 +1,161 @@ + + + + + + Socialvoid + Socialvoid + The official Socialvoid RPC Library written for C# + en-US + + net5.0 + SovialVoid + 0.0.1 + Socialvoid Team + https://github.com/intellivoid/Socialvoid.NET + https://github.com/intellivoid/Socialvoid.NET + https://github.com/intellivoid/Socialvoid.NET/raw/master/Socialvoid/Icon.ico + Icon.png + git + true + true + true + true + LICENSE + + + + 1701;1702;1705 + + + + + $(DefineConstants);__LINUX__ + $(DefineConstants);__WINDOWS__ + $(DefineConstants);__UAP__ + $(DefineConstants);__ANDROID__ + $(DefineConstants);__IOS__ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Client/AuthenticateUser.cs b/Tests/Client/AuthenticateUser.cs new file mode 100644 index 0000000..4f28111 --- /dev/null +++ b/Tests/Client/AuthenticateUser.cs @@ -0,0 +1,71 @@ +using System; +using Socialvoid.Errors; +using Socialvoid.Client; +using Socialvoid.Errors.ServerErrors; +using Socialvoid.Errors.NetworkErrors; +using Socialvoid.Errors.ValidationErrors; +using NUnit.Framework; + + +namespace Tests.Client +{ + [TestFixture] + public class ClientTest + { + [TestCase("test1: the given login credentials are incorrect.", 8704)] + [TestCase("test2: the given two-factor authentication code is incorrect.", 8705)] + [TestCase("test3: the user 'aliwoto' does not support this method of authentication", 8706)] + [TestCase("test4: the requested session was not found in the database on server-side.", 8707)] + public void AuthenticationErrorsTest(string message, int errorCode) + { + try + { + CreateException(message, errorCode); + } + catch (GeneralException ex) + { + Log("got exception of type", ex.GetType(), "with error code of", ex.ErrorCode); + if (ex.Message != message || (int)ex.ErrorCode != errorCode) + { + + throw; + } + } + } + + [TestCase( + "4c7148caff498d24deee6c8325f1c15773d637ed76c3a4056e00b77b2beb3097", // public hash + "866d3218b239d39c174fa2b16f54e0fa58f9c69fce8c2d941c12a47a7bc75229", // private hash + "Linux", // platform + "Test .NET RCP Client", // the name + "1.0.0.0" // version + )] + public void AuthenticateUserTest(string publicHash, string privateHash, + string platform, string name, string version) + { + var myClient = + SocialvoidClient.GetClient(publicHash, + privateHash, platform, name, version); + myClient.CreateSession(); + myClient.AuthenticateUser(new(), "aliwoto", "12345678"); + } + + + + private void CreateException(string message, int code) + { + throw GeneralException.GetException(message, (ErrorCodes)code); + } + + private void Log(params object[] objs) + { + foreach (var obj in objs) + { + Console.Write(obj); + Console.Write(" "); + } + + Console.Write("\n"); + } + } +} \ No newline at end of file diff --git a/Tests/Client/client_info.json b/Tests/Client/client_info.json new file mode 100644 index 0000000..a136956 --- /dev/null +++ b/Tests/Client/client_info.json @@ -0,0 +1,8 @@ +{ + "endpoint": "http://127.0.0.1:5001/", + "public_hash": "4c7148caff498d24deee6c8325f1c15773d637ed76c3a4056e00b77b2beb3097", + "private_hash": "866d3218b239d39c174fa2b16f54e0fa58f9c69fce8c2d941c12a47a7bc75229", + "platform": "Linux", + "name": "Test Python RCP Client", + "version": "1.0.0.0" +} \ No newline at end of file diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 8280024..bc3117f 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -63,6 +63,7 @@ +