Tim Bouma on Nostr: I did something similar: - User enters npub to authorize - Server visually displays ...
I did something similar:
- User enters npub to authorize
- Server visually displays one-time code and also send encrypted DMs to user
- User visually confirms DM code is same and replies ‘OK’ if satisfied.
- Server listens for decrypted DM ‘OK’ from npub where event.created_at > DM sent event created at.
- If ‘OK’, sets a status login ok for one time query
- Browser client polls for one time status, if login True, session cookie is set for logged in, status is cleared.
I had this all working for NIP-04, upgrading to NIP-17.
Published at
2024-10-17 19:11:22Event JSON
{
"id": "c96a77626b80f826193c036c9c4f5f851a20bb7b36f7ddd042ec7fbb9c0909bb",
"pubkey": "06b7819d7f1c7f5472118266ed7bca8785dceae09e36ea3a4af665c6d1d8327c",
"created_at": 1729192282,
"kind": 1,
"tags": [
[
"e",
"b1575b3172d43a30db7767ac73442afd81e1b76678d12d8c09e5ea4e610a7f49",
"",
"root"
],
[
"e",
"a2aa1045fd1244778631e78eb7c82f8c07540ecf515d6052d10ab58dd9bab18d",
"",
"reply"
],
[
"p",
"99bb5591c9116600f845107d31f9b59e2f7c7e09a1ff802e84f1d43da557ca64"
],
[
"p",
"3356de61b39647931ce8b2140b2bab837e0810c0ef515bbe92de0248040b8bdd"
]
],
"content": "I did something similar:\n- User enters npub to authorize\n- Server visually displays one-time code and also send encrypted DMs to user \n- User visually confirms DM code is same and replies ‘OK’ if satisfied. \n- Server listens for decrypted DM ‘OK’ from npub where event.created_at \u003e DM sent event created at.\n- If ‘OK’, sets a status login ok for one time query\n- Browser client polls for one time status, if login True, session cookie is set for logged in, status is cleared. \n\nI had this all working for NIP-04, upgrading to NIP-17.",
"sig": "da24d56e0224561dcf9d6d67fd549731473057e729ac9e3c1d111f27a1df7a5d43da5cda17591de19eb6db88878b4ce68a0edde3d9aa0b8dbaff3c0ed741f446"
}