mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-12 15:09:07 -05:00
updated to use new json based scheme
This commit is contained in:
parent
fa95a31def
commit
de2ea2b4ee
74
NIP-XXXX.md
74
NIP-XXXX.md
|
@ -1,46 +1,76 @@
|
|||
|
||||
# NIP-XXXX: Nostr Data Sharing URI Scheme
|
||||
|
||||
**Author**: Christian Moss
|
||||
**Status**: Draft
|
||||
**Type**: Standards Track
|
||||
**Author**: Christian Moss
|
||||
**Status**: Draft
|
||||
**Type**: Standards Track
|
||||
**Created**: 2023-05-02
|
||||
|
||||
## Abstract
|
||||
|
||||
This NIP proposes a new URI scheme for apps to share data, such as text or images, between Nostr clients.
|
||||
|
||||
## Motivation
|
||||
|
||||
It is commonplace in apps, such as games or photo libraries, to share one's achievements and moments on social network platforms like Twitter or Facebook in order to receive recognition and/or interaction from a community. Given the culture of "zapping" and gifting sats in Nostr, it would make sense to create a protocol that allows users to frictionlessly share an image and/or text with a Nostr client. For example, a user could achieve a high score on a mobile game, click a button in the game, which would then open up the user's Nostr client on their mobile device, allowing them to post a screenshot and caption of their achievement. Other players could then zap the user sats in recognition of this achievement.
|
||||
It is commonplace in apps, such as games or photo libraries, to share one's achievements and moments on social network platforms like Twitter or Facebook to receive recognition and/or interaction from a community. Given the culture of "zapping" and gifting sats in Nostr, it would make sense to create a protocol that allows users to share an image and/or text with a Nostr client frictionlessly. For example, a user could achieve a high score on a mobile game, click a button in the game, which would then open up the user's Nostr client on their mobile device, allowing them to post a screenshot and caption of their achievement. Other players could then zap the user sats in recognition of this achievement.
|
||||
|
||||
## Specification
|
||||
|
||||
The proposed URI scheme format is as follows:
|
||||
|
||||
It was previously proposed to use a URI scheme such as
|
||||
``nostr-share://?parameter=value¶meter2=value2``
|
||||
|
||||
The parameters supported in this URI scheme include: 1. `msg`: A string of the message to be shared. 2. `img`: A URL to an image hosted elsewhere (URL encoded) or an image represented as a Base64 encoded string. ### Usage To share a text message, the URI would look like this:
|
||||
Where parameter1 and parameter2 would be something like img, msg, etc., denoting the type of media to be shared.
|
||||
|
||||
``nostr-share://?msg=Hello%20World``
|
||||
However, after feedback, it was considered a better approach to keep it more generic and include a single JSON blob as the main parameter in line with Nostr notes.
|
||||
|
||||
To share an image (in Base64 format), the URI would look like this:
|
||||
An additional "hint" parameter would also be added to allow the recommendation for a particular relay.
|
||||
|
||||
``nostr-share://?img=data:image/png;base64,iVBORw0KG...``
|
||||
or
|
||||
``nostr-share://?msg=Hello%20World&img=https%3A%2F%2Fi.imgur.com%2FaI24Z3F.jpeg``
|
||||
Resulting in
|
||||
|
||||
To share both, it would look like this:
|
||||
``nostr-share://?msg={urlEscapedJSON}&hint={urlEscapedRelayUrl}``
|
||||
|
||||
``nostr-share://?msg=Hello%20World&img=data:image/png;base64,iVBORw0KG...``
|
||||
or
|
||||
``nostr-share://?msg=Hello%20World&img=https%3A%2F%2Fi.imgur.com%2FaI24Z3F.jpeg``
|
||||
The JSON by default should include at least the following parameters:
|
||||
|
||||
``text`` contains a message to be displayed analogous to a tweet or post.
|
||||
``imageUrl`` contains an image URL to be loaded by the receiving Nostr client.
|
||||
``videoUrl`` contains a video URL to be loaded by the receiving Nostr client.
|
||||
``imageBase64`` contains an image encoded as a base64 string to be displayed by the receiving Nostr client.
|
||||
|
||||
Applications that support this URI scheme should be able to parse the `msg` parameter and display the data accordingly. For text, the application should display the message as plain text, and for binary data, the application should decode the Base64 string and display the appropriate content.
|
||||
|
||||
|
||||
In order to contain more images and messages, the JSON could be expanded to contain ``text2`` ``imageUrl2``
|
||||
|
||||
Example JSON:
|
||||
``{
|
||||
"text": "What sounds does an ostrich make?",
|
||||
"imgUrl": "https://pbs.twimg.com/profile_images/1604195803748306944/LxHDoJ7P_400x400.jpg",
|
||||
"videoUrl": "https://i.imgur.com/WC7LW4t.mp4",
|
||||
"imageBase64": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAbElEQVQYGWOc6nznPwMOkLVHmWGay12wLBMONWBhmCIQhwVF4T9Ghqx9SihCMMUIE//jVgTSiVDI+B/uHhQjoRwUq5n/s+JUjDARqPMv429shoHF4CaCggIbwPQMFlVz3J7AReEmwnTCZdAYAGPIHXIm/AOjAAAAAElFTkSuQmCC"
|
||||
}``
|
||||
|
||||
Example encoded URI:
|
||||
``nostr-share://?msg=%7B%22text%22%3A%22What+sounds+does+an+ostrich+make%3F%22%2C%22imgUrl%22%3A%22https%3A%2F%2Fpbs.twimg.com%2Fprofile_images%2F1604195803748306944%2FLxHDoJ7P_400x400.jpg%22%2C%22videoUrl%22%3A%22https%3A%2F%2Fi.imgur.com%2FWC7LW4t.mp4%22%2C%22imageBase64%22%3A%22%22%7D&hint=wss%3A%2F%2Fnostr.zebedee.cloud``
|
||||
|
||||
Clients implementing this NIP should register the `nostr-share` URI scheme with the operating system, enabling other applications to share data directly with the client.
|
||||
|
||||
## Example Implementation
|
||||
|
||||
I have develop a sample integration in the form of 2 apps.
|
||||
|
||||
The first app is an example game that generates the nostr-share URI containing a message, imageUrl, base64 encoded image, a video URL, as well as a route hint.
|
||||
|
||||
https://github.com/mandelmonkey/nostr-share-sample-game
|
||||
|
||||
![Nostr Game](https://i.imgur.com/ym6azwT.jpg)
|
||||
|
||||
The second app is an Android app which receives the nostr-share data and displays the media.
|
||||
|
||||
![Nostr Client](https://i.imgur.com/qmFYUmz.jpg)
|
||||
|
||||
![Nostr Client](https://i.imgur.com/MCItlcV.jpg)
|
||||
|
||||
https://github.com/mandelmonkey/nostr-share-wallet-demo
|
||||
|
||||
## Cavaets
|
||||
|
||||
In practice as long as any base64image is small or replaced with an image url this is not a major limitation
|
||||
|
||||
## Copyright
|
||||
|
||||
This NIP is licensed under the Creative Commons Attribution 4.0 International License.
|
||||
This NIP is licensed under the Creative Commons Attribution 4.0 International License.
|
Loading…
Reference in New Issue
Block a user