GitHub - tonkeeper/ton-connect: Login protocol for Tonkeeper

Posted by Someone 2024.06.03 01:38  •  Comments (64)  • 

Skip to content

Navigation Menu

Toggle navigation Sign in Product Actions Automate any workflow Packages Host and manage packages Security Find and fix vulnerabilities Codespaces Instant dev environments Copilot Write better code with AI Code review Manage code changes Issues Plan and track work Discussions Collaborate outside of code Explore All features Documentation GitHub Skills Blog Solutions For Enterprise Teams Startups Education By Solution CI/CD & Automation DevOps DevSecOps Resources Learning Pathways White papers, Ebooks, Webinars Customer Stories Partners Open Source GitHub Sponsors Fund open source developers The ReadME Project GitHub community articles Repositories Topics Trending Collections Enterprise Enterprise platform AI-powered developer platform Available add-ons Advanced Security Enterprise-grade security features Copilot Enterprise Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to

Search code, repositories, users, issues, pull requests

Search syntax tips

Provide feedback

Cancel Submit feedback

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} tonkeeper / ton-connect Public Notifications You must be signed in to change notification settings Fork 19 Star 110

Login protocol for Tonkeeper

License

Apache-2.0 license 110 stars 19 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings Code Issues 2 Pull requests 7 Actions Projects 0 Security Insights Additional navigation options Code Issues Pull requests Actions Projects Security Insights

tonkeeper/ton-connect

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.   main Branches Tags Go to file Code

Folders and files

Name Name Last commit message Last commit date

Latest commit

 

History

44 Commits

.github/ ISSUE_TEMPLATE

.github/ ISSUE_TEMPLATE

   

server-example

server-example

   

tonconnect-server

tonconnect-server

   

tonlogin-client

tonlogin-client

   

.gitignore

.gitignore

   

LICENSE.txt

LICENSE.txt

   

README.md

README.md

   

TonConnectSpecification.md

TonConnectSpecification.md

    View all files

Repository files navigation

README Apache-2.0 license

TON Connect v1

⚠️ Migrate to version 2

Please go to TON Connect v2 for a newer protocol that offers a seamless bridge API and does not require the app to receive callbacks from the wallet.

Deprecated TON Connect v1 spec

📄 TON Connect v1 Specification

How to run the demo

cd server-example yarn install yarn start

Install Ton Connect Server

$ yarn add @tonapps/tonconnect-server

Generate Static Secret

$ npx tonconnect-generate-sk

Put generated static secret to env vars or config

How to use the server API

import { TonConnectServer , AuthRequestTypes } from '@tonapps/tonconnect-server' ; // Create a TonConnectServer instance configured with a static secret. const tonconnect = new TonConnectServer ( { staticSecret : process . env . TONCONNECT_SECRET } ) ; // When we need to authenticate the user, create an authentication request: const request = tonconnect . createRequest ( { image_url : 'https://ddejfvww7sqtk.cloudfront.net/images/landing/ton-nft-tegro-dog/avatar/image_d0315e1461.jpg' , callback_url : ` ${ hostname } /tonconnect` , items : [ { type : AuthRequestTypes . ADDRESS , required : true } , { type : AuthRequestTypes . OWNERSHIP , required : true } ] , } ) ; res . send ( request ) ; // Example: Tonkeeper deeplink: // Provide the user with the URL to download that request. const requestURL = `example.com/myrequest` ; const deeplinkURL = `https://app.tonkeeper.com/ton-login/ ${ requestURL } ` ;

Decode Auth Response

try { const response = tonconnect . decodeResponse ( req . query . tonlogin ) ; console . log ( 'response' , response ) ; for ( let payload of response . payload ) { switch ( payload . type ) { case AuthRequestTypes . OWNERSHIP : const isVerified = await tonconnect . verifyTonOwnership ( payload , response . client_id ) ; if ( isVerified ) { console . log ( `ton-ownership is verified for ${ payload . address } ` ) ; } else { console . log ( `ton-ownership is NOT verified` ) ; } break ; case AuthRequestTypes . ADDRESS : console . log ( `ton-address ${ payload . address } ` ) ; break ; } } } catch ( err ) { console . log ( err ) ; }

AuthPayload specification

About

Login protocol for Tonkeeper

Resources

Readme

License

Apache-2.0 license Activity Custom properties

Stars

110 stars

Watchers

10 watching

Forks

19 forks Report repository

Releases

No releases published

Packages 0

No packages published

Contributors 3

Languages

TypeScript 94.3% Handlebars 4.6% JavaScript 1.1%

Footer

© 2024 GitHub, Inc.

Footer navigation

Terms Privacy Security Status Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time.