GM #siamstr

เมื่อวานผมรู้สึกพูดไม่ค่อยรู้เรื่องตอนอธิบายเรื่อง NIP-07 เลยขอมาแก้ตัวตรงนี้นะครับ

NIP-07 (window.nostr capability for web browsers) ได้มีการนำเสนอเกี่ยวกับ window.nostr โดยมันช่วยให้ เว็บเบราว์เซอร์ หรือ extension และ เว็บไซน์หรือเว็บแอพ สามารถเข้ามามีปฏิสัมพันธ์กับ Nostr ได้

โดยมีฟังก์ชันการทำงานหลัก ๆ 2 อย่างดังนี้:

- window.nostr.getPublicKey(): ใช้ในการขอ Npub (มันส่งกลับในรูป Hex นะครับเผื่อใครไปลองแล้วงงว่าคำไมค่าไม่มีคำว่า npub)

- window.nostr.signEvent(event): ใช้ในการส่ง unsign event ไปยัง extension เพื่อทำการเซ็น

นอกจากนี้ยังมีฟังก์ชันการทำงานอื่น ๆ ที่สามารถทำได้เช่น

- การขอรายการรีเลย์: window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} }

จะตอบกลับเป็น รายการรีเลย์และนโยบายของมัน(อณุญาติให้อ่านหรือเขียนมั้ย)

- ตระกูลการส่ง DM:

window.nostr.nip44.encrypt(pubkey, plaintext): string // returns ciphertext as specified in nip-44

window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes ciphertext as specified in nip-44

หัวบวมแล้วครับหลาม

Reply to this note

Please Login to reply.