web3go-xyz / web3go.xyz

Discovery data value of Web3
Apache License 2.0
10 stars 4 forks source link

SignIn with Web3 Wallet #27

Closed happyJ2024 closed 1 year ago

happyJ2024 commented 2 years ago

PolkaSignIn https://github.com/litentry/PolkaSignIn --- 这只是一个示例, 如何做钱包登录的.

账户系统升级, 把邮箱注册的去掉, 登陆页可能不再需要.

比如 以太坊地址, 输入以太坊地址, 通过 Metamask 验证该地址, 成功后, 将以太坊地址与 Polkadot地址形成关联关系.

happyJ2024 commented 2 years ago

signin api:

  1. POST https://web3go.xyz/portal/user/web3_nonce
    
    //request
    {
    "identityNetwork": "polkadot"
    }

//response { "identityNetwork": "polkadot", "callbackEndpoint": "/web3_challenge", "scope": [ "address" ], "challenge": "challenge message to signin at 2022-01-19T13:08:21.864Z", "nonce": "web3-signin-1642597701864-2d679b" }


2.  POST  https://web3go.xyz/portal/user/web3_challenge

//request { "identityNetwork": "polkadot", "scope": ["address","balance"], "challenge": "challenge message to signin at 2022-01-19T13:08:21.864Z", "signature": "0x1ea2596a8e675e5c00c1088bcdeb95c1db3e75152d31cce6d120a5892eb39b0d112da3c6069715bcac6ac212bad4d9da048517161ad9240ddedd817553f6af8e", "address": "5GsNYEXtBfGBN4buJEqRtGtonJkgq8Uo2dex3zqLcnwwfy3n", "nonce": "web3-signin-1642597701864-2d679b" }

//response { "identityNetwork": "polkadot", "scope": [ "address", "balance" ], "challenge": "challenge message to signin at 2022-01-19T13:08:21.864Z", "signature": "0x1ea2596a8e675e5c00c1088bcdeb95c1db3e75152d31cce6d120a5892eb39b0d112da3c6069715bcac6ac212bad4d9da048517161ad9240ddedd817553f6af8e", "address": "5GsNYEXtBfGBN4buJEqRtGtonJkgq8Uo2dex3zqLcnwwfy3n", "nonce": "web3-signin-1642597701864-2d679b", "verified": true, "extra": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IjVHc05ZRVh0QmZHQk40YnVKRXFSdEd0b25Ka2dxOFVvMmRleDN6cUxjbnd3ZnkzbiIsInN1YiI6IjI4IiwiaWF0IjoxNjQyNjAyNzU2LCJleHAiOjE2NDMyMDc1NTZ9.JdVPTvoHtxhx_osEKSJJUMrvY78fdFquqANL33R2XDs" }

-- extra 即是token, 接下来就可以调用 getUserInfo接口获取当前用户信息


3.  POST https://web3go.xyz/portal/user/web3_sign_out

//request

//response true

-- 这个接口目前没什么实际作用, 可省略调用

happyJ2024 commented 2 years ago

user address bundle api:

  1. POST https://web3go.xyz/portal/user/getAddressBundle
    
    //request

//response [ { "address_type": "ethereum", "address": "0x87DB37bbD0cE0A94119B212bC76BCdD6588800", "id": "1", "user_id": 28, "bundle_created_time": "2022-01-19T14:14:17.000Z" }
]


2. POST   https://web3go.xyz/portal/user/addAddressBundle

//request { "id": 0, "user_id": 28, "address_type": "ethereum", "address": "0x87DB37bbD0cE0A94119B212bC76BCdD6588800", "bundle_created_time": "2022-01-19T14:14:16.957Z" } //response { "id": 5, "user_id": 28, "address_type": "ethereum", "address": "0x87DB37bbD0cE0A94119B212bC76BCdD6588800", "bundle_created_time": "2022-01-19T14:14:16.957Z" }


3. POST   https://web3go.xyz/portal/user/removeAddressBundle

//request { "id": 5, "user_id": 28, "address_type": "ethereum", "address": "0x87DB37bbD0cE0A94119B212bC76BCdD6588800", "bundle_created_time": "2022-01-19T14:14:16.957Z" } //response true