[Dev] Bun.shでSteemKeychainの学習用サイトをつくる

in #japanese2 months ago

こんにちは、@yasuです。

SteemKeychainの学習のために、Bun.shでhttpサーバを作成した。
最小限度の機能のみ実装。

image.png

image.png image.png

サーバー側ログ

image.png

サーバー側ソース抜粋
image.png

クライアント側ソース抜粋
image.png

① サーバーから nonce を取得

const nonceRes = await fetch(`/api/get-nonce?username=${username}`);
const { nonce, error } = await nonceRes.json();

② Keychain で署名を作成

steem_keychain.requestSignBuffer(username, message, "Posting", async (res) => {
    if (!res.success) {
         resultEl.textContent = "署名に失敗しました。";
         return;
    }
     const signature = res.result;
     const publicKey = res.publicKey;

③ Bunサーバーに署名を送信して検証

const verifyRes = await fetch("/api/verify", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ username, message, signature, publicKey }),
});
Sort:  

Congratulations, your post has been manually
upvoted by @steem-bingo trail

Thank you for joining us to play bingo.

STEEM-BINGO, a new game on Steem that rewards the player! 💰

Try out the new games on Steem 4.jpg

How to join, read here

DEVELOPED BY XPILAR TEAM - @xpilar.witness