Git Product home page Git Product logo

ton-connect's Introduction

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

ton-connect's People

Contributors

bogoslavskiy avatar hiyorimi avatar oleganza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ton-connect's Issues

yarn compile fails

Bug Type

Functional

Reproduction steps

When running npm run compile or yarn compile the job fails
with the output

Actual result

➜  sdk git:(main) npm run compile

> [email protected] compile
> ttsc

src/ton-connect/core/models/index.ts:2:41 - error TS2307: Cannot find module './transaction-request' or its corresponding type declarations.

2 export type { TransactionRequest } from './transaction-request';
                                          ~~~~~~~~~~~~~~~~~~~~~~~

src/ton-connect/core/models/index.ts:3:34 - error TS2307: Cannot find module './sign-request' or its corresponding type declarations.

3 export type { SignRequest } from './sign-request';
                                   ~~~~~~~~~~~~~~~~

src/widget/widget-controller.ts:30:9 - error TS2322: Type 'SendTransactionResponse' is not assignable to type 'boolean'.

30         return this.connector.sendTransaction(tx);
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/widget/widget-controller.ts:41:9 - error TS2322: Type 'SignMessageResponse' is not assignable to type 'string'.

41         return this.connector.sign(signRequest);
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 4 errors in 2 files.

Errors  Files
     2  src/ton-connect/core/models/index.ts:2
     2  src/widget/widget-controller.ts:30
     
     ```

### Expected result

Should be compile typescript

### Suggested Severity

Critical

### Device

Node.js  Version
v17.8.0

### Additional Context

_No response_

Ton Connect 2.0 plan

UPDATE: Ton connect 2.0 is moved to a separate github org: https://github.com/ton-connect

Use-cases to focus on

Primary: mobile dapps serverless or via Telegram bots (TWA) working together with mobile native wallets.

Secondary:

  • server applications,
  • desktop web- or standalone apps with mobile wallets,
  • web dapps running as extensions within the mobile wallet.

Tertiary: web-apps working with a chrome extension, and non-native wallets.

Architecture

  1. Each wallet provides a bridging service for the app to connect with. User selects a wallet explicitly in the "Connect with TON" prompt.
  2. SSE and POST requests over the bridge.
  3. Sessions can be re-started at whim by the dapp.
  4. Single SDK to initiate connections.
  5. Separate starting points for connecting a wallet (passing over the unauthenticated wallet address) & signing in.

Checklist

  • Define the JS API for initiating connections and setting up the prompt.
  • Define the format for wallets' descriptions with their bridge addresses, icons and names.
  • Ton Connect prompt design and layout (buttons, modal window with wallet buttons, pending confirmation window). Moved to a separate library; we'll focus on pure API in initial release.
  • Message encoding connect requests and responses: connect, sign in, sign tx.
  • Define a mechanism for attaching TON.DNS records immutably - as DNS items or via a separate registry. Serverless dapps don't have their own backend and do not use DNS authentication.

License question.

Is it ok to use this? to auth the users of our dApp with tonkeeper, need to ask to respect your opinion, since there isn´t a license

Hamster kombet

Bug Type

Other

Reproduction steps

1
7F09DA88-213E-426B-90F4-6A2BB7921E76

Actual result

withdrawal

Expected result

my tonkeeper to not connect

Suggested Severity

Medium

Device

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional Context

80689754

Tunkeeper login bug and 4-digit password

Bug Type

Other

Reproduction steps


IMG_20240605_190410_261

Actual result

Unfortunately, there is a bug and that is when some users change their phone password (those with many wallets) the wallet is locked and the entered 4-digit password is not entered into the wallet. Tried all the 4 digit codes and sure enough I entered the code to enter the wallet correctly but it won't enter the wallet. I had made 50 wallets and it was hard to get a screenshot of all 24 words, but unfortunately the wallet won't open anymore and the bug is still there. Not me, but many people have this problem. I don't know the reason for not logging in to Tenkeeper with a 4-digit password, but it doesn't log in with my own password, and in fact with no password. Please fix this bug in the next update.

Expected result

Please fix this 4-digit password problem so that you can enter the wallet without any problems by entering the 4-digit password, and even for those who have this problem before and cannot enter their wallets, in the next update, this problem will definitely be fixed and the wallet will be returned. Access your money. I don't know the exact details of this bug, but I know it exists and many users have this problem. Please check and fix this problem. Thanks.

Suggested Severity

Critical

Device

Desktop (please complete the following information):

  • OS: [Android]
  • Browser [Tonkeeper wallet ]
  • Version [640]

Smartphone (please complete the following information):

  • Device: [Samsung Galaxy A13]
  • OS: [Android 13 ]
  • Browser [Chrome]
  • Version [...]

Additional Context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.