-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
232 additions
and
109 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Telegram.Bot.Extensions.Passport/Decryption/IDecrypter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
46 changes: 0 additions & 46 deletions
46
src/Telegram.Bot.Extensions.Passport/Request/AuthorizationRequest.cs
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
src/Telegram.Bot.Extensions.Passport/Request/AuthorizationRequestParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// ReSharper disable CommentTypo | ||
// ReSharper disable CheckNamespace | ||
// ReSharper disable StringLiteralTypo | ||
|
||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Telegram.Bot.Passport.Request | ||
{ | ||
/// <summary> | ||
/// Parameters for making a Telegram Passport authorization request | ||
/// </summary> | ||
public class AuthorizationRequestParameters | ||
{ | ||
/// <summary> | ||
/// Unique identifier for the bot. You can get it from bot token. For example, for the bot token | ||
/// "1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy", the bot id is 1234567. | ||
/// </summary> | ||
public int BotId { get; } | ||
|
||
/// <summary> | ||
/// Public key of the bot | ||
/// </summary> | ||
public string PublicKey { get; } | ||
|
||
/// <summary> | ||
/// Bot-specified nonce. | ||
/// Important: For security purposes it should be a cryptographically secure unique identifier of the request. | ||
/// In particular, it should be long enough and it should be generated using a cryptographically secure | ||
/// pseudorandom number generator. You should never accept credentials with the same nonce twice. | ||
/// </summary> | ||
public string Nonce { get; } | ||
|
||
/// <summary> | ||
/// Description of the data you want to request | ||
/// </summary> | ||
public PassportScope PassportScope { get; } | ||
|
||
/// <summary> | ||
/// Query string part of the URI generated from the parameters | ||
/// </summary> | ||
public string Query { get; } | ||
|
||
/// <summary> | ||
/// Authorization request URI | ||
/// </summary> | ||
public string Uri => "tg://resolve?" + Query; | ||
|
||
/// <summary> | ||
/// Authorization request URI for Android devices | ||
/// </summary> | ||
public string AndroidUri => "tg:resolve?" + Query; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of <see cref="AuthorizationRequestParameters"/> | ||
/// </summary> | ||
/// <param name="botId"> | ||
/// Unique identifier for the bot. You can get it from bot token. For example, for the bot token | ||
/// "1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy", the bot id is 1234567. | ||
/// </param> | ||
/// <param name="publicKey">Public key of the bot</param> | ||
/// <param name="nonce"> | ||
/// Bot-specified nonce. | ||
/// Important: For security purposes it should be a cryptographically secure unique identifier of the request. | ||
/// In particular, it should be long enough and it should be generated using a cryptographically secure | ||
/// pseudorandom number generator. You should never accept credentials with the same nonce twice. | ||
/// </param> | ||
/// <param name="scope">Description of the data you want to request</param> | ||
public AuthorizationRequestParameters( | ||
int botId, | ||
string publicKey, | ||
string nonce, | ||
PassportScope scope | ||
) | ||
{ | ||
BotId = botId; | ||
PublicKey = publicKey ?? throw new ArgumentNullException(nameof(publicKey)); | ||
Nonce = nonce ?? throw new ArgumentNullException(nameof(nonce)); | ||
PassportScope = scope ?? throw new ArgumentNullException(nameof(PassportScope)); | ||
|
||
var scopeJson = JsonConvert.SerializeObject(scope); | ||
|
||
Query = "domain=telegrampassport" + | ||
$"&bot_id={System.Uri.EscapeDataString(botId + "")}" + | ||
$"&scope={System.Uri.EscapeDataString(scopeJson)}" + | ||
$"&public_key={System.Uri.EscapeDataString(publicKey)}" + | ||
$"&nonce={System.Uri.EscapeDataString(nonce)}"; | ||
} | ||
|
||
/// <summary> | ||
/// Converts the parameters to their "tg://" URI string representation | ||
/// </summary> | ||
/// <returns>URI representation of this request</returns> | ||
public override string ToString() => Uri; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
src/Telegram.Bot.Extensions.Passport/Telegram.Bot.Extensions.Passport.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks> | ||
<VersionPrefix>0.1.0</VersionPrefix> | ||
<VersionSuffix>alpha</VersionSuffix> | ||
<VersionPrefix>1.0.0</VersionPrefix> | ||
<!--<VersionSuffix></VersionSuffix>--> | ||
<LangVersion>latest</LangVersion> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
<GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
<Title>Passport Extension for Telegram Bot API Client</Title> | ||
<Description>The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.</Description> | ||
<Title>Telegram Passport Extension for Telegram Bot API Client</Title> | ||
<Description> | ||
Telegram Passport is a unified authorization method for services that require personal identification. | ||
This package provides extension methods for Telegram Passport API and decryption utilities for | ||
Telegram Passport encrypted data. | ||
</Description> | ||
<Authors>TelegramBots</Authors> | ||
<Copyright>Copyright © Telegram Bots 2018</Copyright> | ||
<PackageIconUrl>https://telegram.org/file/811140058/2/7GzMJk4Ij54/a1649c56fa9f805828</PackageIconUrl> | ||
<RepositoryUrl>https://github.com/TelegramBots/Telegram.Bot.Extensions.Passport</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/TelegramBots/Telegram.Bot.Extensions.Passport</PackageProjectUrl> | ||
<PackageLicenseUrl>https://raw.githubusercontent.com/TelegramBots/Telegram.Bot.Extensions.Passport/master/LICENSE</PackageLicenseUrl> | ||
<RepositoryUrl>https://github.com/TelegramBots/Telegram.Bot.Extensions.Passport</RepositoryUrl> | ||
<PackageTags>Telegram;Bot;Api;Passport</PackageTags> | ||
<PackageIconUrl>https://raw.githubusercontent.com/TelegramBots/Telegram.Bot.Extensions.Passport/master/package-icon.gif</PackageIconUrl> | ||
<PackageTags>Telegram;Bot;Api;Passport;Telegram Passport</PackageTags> | ||
</PropertyGroup> | ||
<ItemGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<ProjectReference Include="..\..\deps\Telegram.Bot\src\Telegram.Bot\Telegram.Bot.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(Configuration)' == 'Release'"> | ||
<PackageReference Include="Telegram.Bot" Version="14.9.0" /> | ||
<PackageReference Include="Telegram.Bot" Version="14.10.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.