From b8f2e14e6dc6b688605e55c86e68ac17b53338f0 Mon Sep 17 00:00:00 2001 From: Vivek Ganesan Date: Thu, 11 May 2023 20:39:40 +0530 Subject: [PATCH 001/156] Add user experience recommendation about NIP-07 Invoking NIP-07 methods as a part of page-load event listener creates intermittent issues due to race conditions between the browser's extension script and the client's page scripts. --- 07.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/07.md b/07.md index 3b7a1d29..0fe81217 100644 --- a/07.md +++ b/07.md @@ -22,6 +22,11 @@ async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertex async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 ``` +### User experience recommendation +Due to the way browsers load the extensions, it may take some time for `window.nostr` object will be fully ready to accept requests. Hence, it is a good idea to run the first `window.nostr` interaction on a user action on the web page (like a button click), and not during the page load. + +Calling the `window.nostr` based methods during the page load runs the risk of intermittent issues due to race conditions between the client page's script and the extension's script + ### Implementation - [horse](https://github.com/fiatjaf/horse) (Chrome and derivatives) From 9bf8bb0054f236533c8bc04f6a2966970c7d5bd9 Mon Sep 17 00:00:00 2001 From: Vivek Ganesan Date: Tue, 16 May 2023 04:05:24 +0530 Subject: [PATCH 002/156] Update 07.md Implemented review inputs --- 07.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/07.md b/07.md index 0fe81217..b350d0c0 100644 --- a/07.md +++ b/07.md @@ -22,8 +22,8 @@ async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertex async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 ``` -### User experience recommendation -Due to the way browsers load the extensions, it may take some time for `window.nostr` object will be fully ready to accept requests. Hence, it is a good idea to run the first `window.nostr` interaction on a user action on the web page (like a button click), and not during the page load. +### Recommendation to Implementers +When `window.nostr` is injected by a browser extension, it may not be fully available until a certain point in the page's lifecycle. Hence, it is a good idea to invoke the first `window.nostr` based functionality after a user-action on the web page (like a button click), and not during the page load. Calling the `window.nostr` based methods during the page load runs the risk of intermittent issues due to race conditions between the client page's script and the extension's script From 86e44b75eb166b600affdc5248e0fe246a6ebe9b Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 8 Nov 2023 10:22:43 -0300 Subject: [PATCH 003/156] Android Signer Application nip --- 100.md | 495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 495 insertions(+) create mode 100644 100.md diff --git a/100.md b/100.md new file mode 100644 index 00000000..3b8bc8ee --- /dev/null +++ b/100.md @@ -0,0 +1,495 @@ +# NIP-100 + +## Android Signer Application + +`draft` `optional` `author:greenart7c3` + +This NIP describes a method for 2-way communication between a android signer and any Nostr client on Android. The Android signer is an Android Application and the Client can be a Web Client or an Android Application. + +# Usage for Android applications + +The Android signer uses Intents and Content Resolvers to communicate between applications. + +To be able to use The Android signer in your application you should add the package name of the signer to your AndroidManifest.xml: + +```xml + + + +``` + +## Using Intents + +To get the result back from the Signer Appication you should use registerForActivityResult or rememberLauncherForActivityResult in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. + +Create the Intent using the **nostrsigner** scheme: + +```kotlin +val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$content")) +``` + +* Set the Signer package name + +```kotlin +intent.`package` = "com.example.signer" +``` + +### Methods + +- **get_public_key** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "get_public_key") + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **npub** in the signature field + + ```kotlin + val npub = intent.data?.getStringExtra("signature") + ``` + +- **sign_event** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$eventJson")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "sign_event") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", event.id) + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature**, **id** and **event** fields + + ```kotlin + val signature = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + val signedEventJson = intent.data?.getStringExtra("event") + ``` + +- **nip04_encrypt** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$plaintext")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "nip04_encrypt") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", "some_id") + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + // Send the hex pubKey that will be used for encrypting the data + intent.putExtra("pubKey", pubKey) + + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature** and **id** fields + + ```kotlin + val encryptedText = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + ``` + +- **nip44_encrypt** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$plaintext")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "nip44_encrypt") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", "some_id") + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + // Send the hex pubKey that will be used for encrypting the data + intent.putExtra("pubKey", pubKey) + + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature** and **id** fields + + ```kotlin + val encryptedText = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + ``` + +- **nip04_decrypt** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$encryptedText")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "nip04_decrypt") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", "some_id") + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + // Send the hex pubKey that will be used for decrypting the data + intent.putExtra("pubKey", pubKey) + + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature** and **id** fields + + ```kotlin + val plainText = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + ``` + +- **nip44_decrypt** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$encryptedText")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "nip04_decrypt") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", "some_id") + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + // Send the hex pubKey that will be used for decrypting the data + intent.putExtra("pubKey", pubKey) + + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature** and **id** fields + + ```kotlin + val plainText = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + ``` + +- **decrypt_zap_event** + - params: + + ```kotlin + val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$eventJson")) + intent.`package` = "com.example.signer" + intent.putExtra("type", "decrypt_zap_event") + // to control the result in your application in case you are not waiting the result before sending another intent + intent.putExtra("id", "some_id") + // Send the current logged in user npub + intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + context.startActivity(intent) + ``` + - result: + - If the user approved intent it will return the **signature** and **id** fields + + ```kotlin + val eventJson = intent.data?.getStringExtra("signature") + // the id you sent + val id = intent.data?.getStringExtra("id") + ``` + +## Using Content Resolver + +To get the result back from Signer Application you should use contentResolver.query in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. + +If the user did not check the remember my choice option, the npub is not in Signer Application or the signer type is not recognized the contentResolver will return null + +For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json + +For the other types Signer Application returns the column "signature" + +### Methods + +- **get_public_key** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.GET_PUBLIC_KEY"), + listOf("login"), + null, + null, + null + ) + ``` + - result: + - Will return the **npub** in the signature column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + if (index < 0) return + val npub = it.getString(index) + } + ``` + +- **sign_event** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.SIGN_EVENT"), + listOf("$eventJson", "", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** and the **event** columns + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val indexJson = it.getColumnIndex("event") + val signature = it.getString(index) + val eventJson = it.getString(indexJson) + } + ``` + +- **nip04_encrypt** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.NIP04_ENCRYPT"), + listOf("$plainText", "${hex_pub_key}", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val encryptedText = it.getString(index) + } + ``` + +- **nip44_encrypt** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.NIP44_ENCRYPT"), + listOf("$plainText", "${hex_pub_key}", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val encryptedText = it.getString(index) + } + ``` + +- **nip04_decrypt** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.NIP04_DECRYPT"), + listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val encryptedText = it.getString(index) + } + ``` + +- **nip44_decrypt** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.NIP44_DECRYPT"), + listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val encryptedText = it.getString(index) + } + ``` + +- **decrypt_zap_event** + - params: + + ```kotlin + val result = context.contentResolver.query( + Uri.parse("content://com.example.signer.DECRYPT_ZAP_EVENT"), + listOf("$eventJson", "", "${logged_in_user_npub}"), + null, + null, + null + ) + ``` + - result: + - Will return the **signature** column + + ```kotlin + if (result == null) return + + if (result.moveToFirst()) { + val index = it.getColumnIndex("signature") + val eventJson = it.getString(index) + } + ``` + +# Usage for Web Applications + +Since web applications can't receive a result from the intent you should add a modal to paste the signature or the event json or create a callback url. + +If you send the callback url parameter Signer Application will send the result to the url. + +If you don't send a callback url Signer Application will copy the result to the clipboard. + +You can configure the returnType to be **signature** or **event**. + +Android intents and browsers url has limitations, so if you are using the returnType of **event** consider using the parameter **compressionType=gzip** that will return "Signer1" + Base 64 gzip encoded event json + +## Methods + +- **get_public_key** + - params: + + ```js + const intent = `intent:#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=get_public_key;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **sign_event** + - params: + + ```js + const intent = `intent:${eventJson}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=sign_event;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **nip04_encrypt** + - params: + + ```js + const intent = `intent:${plainText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip04_encrypt;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **nip44_encrypt** + - params: + + ```js + const intent = `intent:${plainText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_encrypt;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **nip04_decrypt** + - params: + + ```js + const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_encrypt;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **nip44_decrypt** + - params: + + ```js + const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_decrypt;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +- **decrypt_zap_event** + - params: + + ```js + const intent = `intent:${eventJson}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=decrypt_zap_event;S.callbackUrl=https://example.com/?event=;end`; + + window.href = intent; + ``` + +## Example + +```js + + + + + + Document + + +

Test

+ + + + +``` \ No newline at end of file From 70a722b5d6526bf871a06290df8833492ac77b92 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 29 Nov 2023 11:22:26 -0300 Subject: [PATCH 004/156] add permissions --- 100.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/100.md b/100.md index 3b8bc8ee..56b8a91c 100644 --- a/100.md +++ b/100.md @@ -43,6 +43,17 @@ intent.`package` = "com.example.signer" val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) intent.`package` = "com.example.signer" intent.putExtra("type", "get_public_key") + // You can send some default permissions for the user authorize for ever + val permissions = listOf( + Permission( + "sign_event", + 22242 + ), + Permission( + "nip44_decrypt" + ) + ) + intent.putExtra("permissions", permissions.toJson()) context.startActivity(intent) ``` - result: From e050386b849d0d293903a46646c89233bf19f489 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 29 Nov 2023 11:23:14 -0300 Subject: [PATCH 005/156] signer can return the application package name when sign in --- 100.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/100.md b/100.md index 56b8a91c..2c7b8f96 100644 --- a/100.md +++ b/100.md @@ -61,6 +61,8 @@ intent.`package` = "com.example.signer" ```kotlin val npub = intent.data?.getStringExtra("signature") + // The package name of the signer application + val packageName = intent.data?.getStringExtra("package") ``` - **sign_event** From ae0fd96907d0767f07fb54ca1de9f197c600cb27 Mon Sep 17 00:00:00 2001 From: Daniel Cadenas Date: Fri, 8 Dec 2023 13:19:54 -0300 Subject: [PATCH 006/156] Fix Authorization header string The previous auth header was for an event in which the tag is `url` instead of `u` so it was not matching the event provided as an example --- 98.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/98.md b/98.md index ca523042..be425b28 100644 --- a/98.md +++ b/98.md @@ -55,7 +55,8 @@ Using the `Authorization` HTTP header, the `kind 27235` event MUST be `base64` e Example HTTP Authorization header: ``` -Authorization: Nostr eyJpZCI6ImZlOTY0ZTc1ODkwMzM2MGYyOGQ4NDI0ZDA5MmRhODQ5NGVkMjA3Y2JhODIzMTEwYmUzYTU3ZGZlNGI1Nzg3MzQiLCJwdWJrZXkiOiI2M2ZlNjMxOGRjNTg1ODNjZmUxNjgxMGY4NmRkMDllMThiZmQ3NmFhYmMyNGEwMDgxY2UyODU2ZjMzMDUwNGVkIiwiY29udGVudCI6IiIsImtpbmQiOjI3MjM1LCJjcmVhdGVkX2F0IjoxNjgyMzI3ODUyLCJ0YWdzIjpbWyJ1cmwiLCJodHRwczovL2FwaS5zbm9ydC5zb2NpYWwvYXBpL3YxL241c3AvbGlzdCJdLFsibWV0aG9kIiwiR0VUIl1dLCJzaWciOiI1ZWQ5ZDhlYzk1OGJjODU0Zjk5N2JkYzI0YWMzMzdkMDA1YWYzNzIzMjQ3NDdlZmU0YTAwZTI0ZjRjMzA0MzdmZjRkZDgzMDg2ODRiZWQ0NjdkOWQ2YmUzZTVhNTE3YmI0M2IxNzMyY2M3ZDMzOTQ5YTNhYWY4NjcwNWMyMjE4NCJ9 +Authorization: Nostr +eyJpZCI6ImZlOTY0ZTc1ODkwMzM2MGYyOGQ4NDI0ZDA5MmRhODQ5NGVkMjA3Y2JhODIzMTEwYmUzYTU3ZGZlNGI1Nzg3MzQiLCJwdWJrZXkiOiI2M2ZlNjMxOGRjNTg1ODNjZmUxNjgxMGY4NmRkMDllMThiZmQ3NmFhYmMyNGEwMDgxY2UyODU2ZjMzMDUwNGVkIiwiY29udGVudCI6IiIsImtpbmQiOjI3MjM1LCJjcmVhdGVkX2F0IjoxNjgyMzI3ODUyLCJ0YWdzIjpbWyJ1IiwiaHR0cHM6Ly9hcGkuc25vcnQuc29jaWFsL2FwaS92MS9uNXNwL2xpc3QiXSxbIm1ldGhvZCIsIkdFVCJdXSwic2lnIjoiNWVkOWQ4ZWM5NThiYzg1NGY5OTdiZGMyNGFjMzM3ZDAwNWFmMzcyMzI0NzQ3ZWZlNGEwMGUyNGY0YzMwNDM3ZmY0ZGQ4MzA4Njg0YmVkNDY3ZDlkNmJlM2U1YTUxN2JiNDNiMTczMmNjN2QzMzk0OWEzYWFmODY3MDVjMjIxODQifQ ``` ## Reference Implementations From 46a81d9c25874aac0af4b26fa6641bcca9a70053 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:31:13 +0100 Subject: [PATCH 007/156] Clarify summarization language The initial language is misleading as it is not clear the tags are to be used on any event outside of the kind it defines until the bottom of the NIP. --- 32.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/32.md b/32.md index be4e8724..60e108e7 100644 --- a/32.md +++ b/32.md @@ -6,8 +6,7 @@ Labeling `draft` `optional` -A label is a `kind 1985` event that is used to label other entities. This supports a number of use cases, -including distributed moderation, collection management, license assignment, and content classification. +A label uses two new indexable tags to label events. Additionally, it adds a new event kind, `kind 1985`, that is used to label other entities. This supports a number of use cases, including distributed moderation, collection management, license assignment, and content classification. This NIP introduces two new tags: From 81fd5deff652fe0c70a8b654d947fe05aa0a1f72 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:24:20 +0100 Subject: [PATCH 008/156] Update language --- 32.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/32.md b/32.md index 60e108e7..eafb06ff 100644 --- a/32.md +++ b/32.md @@ -6,7 +6,7 @@ Labeling `draft` `optional` -A label uses two new indexable tags to label events. Additionally, it adds a new event kind, `kind 1985`, that is used to label other entities. This supports a number of use cases, including distributed moderation, collection management, license assignment, and content classification. +This NIP defines two new indexable tags to label events and a new event kind (kind:1985) to attach those labels to existing events. This supports several use cases, including distributed moderation, collection management, license assignment, and content classification. This NIP introduces two new tags: From c3fbda5ee0002629791d6e29a721e03e6b06f605 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:25:02 +0100 Subject: [PATCH 009/156] Remove redundant language --- 32.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/32.md b/32.md index eafb06ff..e4f6aa28 100644 --- a/32.md +++ b/32.md @@ -8,7 +8,7 @@ Labeling This NIP defines two new indexable tags to label events and a new event kind (kind:1985) to attach those labels to existing events. This supports several use cases, including distributed moderation, collection management, license assignment, and content classification. -This NIP introduces two new tags: +New Tags: - `L` denotes a label namespace - `l` denotes a label From 71061e9e83cbd06b775c8e27eab38dc831f078a3 Mon Sep 17 00:00:00 2001 From: Sandwich <299465+dskvr@users.noreply.github.com> Date: Fri, 29 Dec 2023 21:03:53 +0100 Subject: [PATCH 010/156] Commit suggestion Co-authored-by: hodlbod --- 32.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/32.md b/32.md index e4f6aa28..bff3b801 100644 --- a/32.md +++ b/32.md @@ -6,7 +6,7 @@ Labeling `draft` `optional` -This NIP defines two new indexable tags to label events and a new event kind (kind:1985) to attach those labels to existing events. This supports several use cases, including distributed moderation, collection management, license assignment, and content classification. +This NIP defines two new indexable tags to label events and a new event kind (`kind:1985`) to attach those labels to existing events. This supports several use cases, including distributed moderation, collection management, license assignment, and content classification. New Tags: From c55678b30740c1aa4aa968239fb21fb05c38a92c Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 22 Jan 2024 11:25:25 -0300 Subject: [PATCH 011/156] change androidmanifest.xml, add rejected collumn if user chose to always reject some event kind --- 100.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/100.md b/100.md index 2c7b8f96..cddb8066 100644 --- a/100.md +++ b/100.md @@ -10,14 +10,32 @@ This NIP describes a method for 2-way communication between a android signer and The Android signer uses Intents and Content Resolvers to communicate between applications. -To be able to use The Android signer in your application you should add the package name of the signer to your AndroidManifest.xml: +To be able to use The Android signer in your application you should this to your AndroidManifest.xml: ```xml - + + + + + ``` +Then you can use this function to check if there's a signer application installed: + +```kotlin +fun isExternalSignerInstalled(context: Context): Boolean { + val intent = + Intent().apply { + action = Intent.ACTION_VIEW + data = Uri.parse("nostrsigner:") + } + val infos = context.packageManager.queryIntentActivities(intent, 0) + return infos.size > 0 +} +``` + ## Using Intents To get the result back from the Signer Appication you should use registerForActivityResult or rememberLauncherForActivityResult in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. @@ -221,6 +239,8 @@ For the SIGN_EVENT type Signer Application returns two columns "signature" and " For the other types Signer Application returns the column "signature" +If the user chose to always reject the event signer application will return the column "rejected" and you should not open signer application + ### Methods - **get_public_key** From f549b66f67dffea317efbe192631503dfdac2e9d Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Thu, 26 Oct 2023 10:06:29 -0700 Subject: [PATCH 012/156] Deprecate nip 45 --- 45.md | 2 ++ README.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/45.md b/45.md index 780dfb6b..56d0f101 100644 --- a/45.md +++ b/45.md @@ -1,3 +1,5 @@ +> __Warning__ `unrecommended`: deprecated + NIP-45 ====== diff --git a/README.md b/README.md index 10b1dfb7..0862723d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-40: Expiration Timestamp](40.md) - [NIP-42: Authentication of clients to relays](42.md) - [NIP-44: Versioned Encryption](44.md) -- [NIP-45: Counting results](45.md) +- [NIP-45: Counting results](45.md) --- **unrecommended**: deprecated - [NIP-46: Nostr Connect](46.md) - [NIP-47: Wallet Connect](47.md) - [NIP-48: Proxy Tags](48.md) From ded4c1659ce838625705f86bb563df7507d52503 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 14 Feb 2024 14:37:42 -0300 Subject: [PATCH 013/156] fix typo --- 100.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/100.md b/100.md index cddb8066..ee5149ae 100644 --- a/100.md +++ b/100.md @@ -468,7 +468,7 @@ Android intents and browsers url has limitations, so if you are using the return - params: ```js - const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_encrypt;S.callbackUrl=https://example.com/?event=;end`; + const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip04_decrypt;S.callbackUrl=https://example.com/?event=;end`; window.href = intent; ``` From bf7294b22362539eda549d8a7fd0d85261f40b3f Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Fri, 8 Mar 2024 07:59:54 -0300 Subject: [PATCH 014/156] Removed author --- 100.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/100.md b/100.md index ee5149ae..bf773962 100644 --- a/100.md +++ b/100.md @@ -2,7 +2,7 @@ ## Android Signer Application -`draft` `optional` `author:greenart7c3` +`draft` `optional` This NIP describes a method for 2-way communication between a android signer and any Nostr client on Android. The Android signer is an Android Application and the Client can be a Web Client or an Android Application. From 07074d8ba2615609fb702030151e191edcc91909 Mon Sep 17 00:00:00 2001 From: greenart7c3 <115044884+greenart7c3@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:20:19 -0300 Subject: [PATCH 015/156] Apply suggestions from code review Co-authored-by: dluvian <133484344+dluvian@users.noreply.github.com> --- 100.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/100.md b/100.md index bf773962..06d6b355 100644 --- a/100.md +++ b/100.md @@ -4,13 +4,13 @@ `draft` `optional` -This NIP describes a method for 2-way communication between a android signer and any Nostr client on Android. The Android signer is an Android Application and the Client can be a Web Client or an Android Application. +This NIP describes a method for 2-way communication between an Android signer and any Nostr client on Android. The Android signer is an Android Application and the client can be a web client or an Android application. # Usage for Android applications The Android signer uses Intents and Content Resolvers to communicate between applications. -To be able to use The Android signer in your application you should this to your AndroidManifest.xml: +To be able to use the Android signer in your application you should add this to your AndroidManifest.xml: ```xml @@ -38,7 +38,7 @@ fun isExternalSignerInstalled(context: Context): Boolean { ## Using Intents -To get the result back from the Signer Appication you should use registerForActivityResult or rememberLauncherForActivityResult in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. +To get the result back from the Signer Application you should use `registerForActivityResult` or `rememberLauncherForActivityResult` in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. Create the Intent using the **nostrsigner** scheme: From 4842f8612f55d9c11ef228338f6ef6f658e788a1 Mon Sep 17 00:00:00 2001 From: greenart7c3 <115044884+greenart7c3@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:00:30 -0300 Subject: [PATCH 016/156] Apply suggestions from code review Co-authored-by: dluvian <133484344+dluvian@users.noreply.github.com> --- 100.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/100.md b/100.md index 06d6b355..386ec802 100644 --- a/100.md +++ b/100.md @@ -46,7 +46,7 @@ Create the Intent using the **nostrsigner** scheme: val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$content")) ``` -* Set the Signer package name +Set the Signer package name: ```kotlin intent.`package` = "com.example.signer" @@ -61,14 +61,14 @@ intent.`package` = "com.example.signer" val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) intent.`package` = "com.example.signer" intent.putExtra("type", "get_public_key") - // You can send some default permissions for the user authorize for ever + // You can send some default permissions for the user to authorize for ever val permissions = listOf( Permission( - "sign_event", - 22242 + type = "sign_event", // Is it type? + kind = 22242 // Is it kind? ), Permission( - "nip44_decrypt" + type = "nip44_decrypt" ) ) intent.putExtra("permissions", permissions.toJson()) @@ -90,10 +90,10 @@ intent.`package` = "com.example.signer" val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$eventJson")) intent.`package` = "com.example.signer" intent.putExtra("type", "sign_event") - // to control the result in your application in case you are not waiting the result before sending another intent + // To handle results when not waiting between intents intent.putExtra("id", event.id) // Send the current logged in user npub - intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) + intent.putExtra("current_user", npub) context.startActivity(intent) ``` @@ -102,7 +102,7 @@ intent.`package` = "com.example.signer" ```kotlin val signature = intent.data?.getStringExtra("signature") - // the id you sent + // The id you sent val id = intent.data?.getStringExtra("id") val signedEventJson = intent.data?.getStringExtra("event") ``` @@ -233,13 +233,13 @@ intent.`package` = "com.example.signer" To get the result back from Signer Application you should use contentResolver.query in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. -If the user did not check the remember my choice option, the npub is not in Signer Application or the signer type is not recognized the contentResolver will return null +If the user did not check the "remember my choice" option, the npub is not in Signer Application or the signer type is not recognized the `contentResolver` will return null For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json For the other types Signer Application returns the column "signature" -If the user chose to always reject the event signer application will return the column "rejected" and you should not open signer application +If the user chose to always reject the event, signer application will return the column "rejected" and you should not open signer application ### Methods @@ -416,15 +416,15 @@ If the user chose to always reject the event signer application will return the # Usage for Web Applications -Since web applications can't receive a result from the intent you should add a modal to paste the signature or the event json or create a callback url. +Since web applications can't receive a result from the intent, you should add a modal to paste the signature or the event json or create a callback url. -If you send the callback url parameter Signer Application will send the result to the url. +If you send the callback url parameter, Signer Application will send the result to the url. -If you don't send a callback url Signer Application will copy the result to the clipboard. +If you don't send a callback url, Signer Application will copy the result to the clipboard. -You can configure the returnType to be **signature** or **event**. +You can configure the `returnType` to be **signature** or **event**. -Android intents and browsers url has limitations, so if you are using the returnType of **event** consider using the parameter **compressionType=gzip** that will return "Signer1" + Base 64 gzip encoded event json +Android intents and browser urls have limitations, so if you are using the `returnType` of **event** consider using the parameter **compressionType=gzip** that will return "Signer1" + Base64 gzip encoded event json ## Methods From 6b26ebe6c5c9834549aa9adec0d066bc5c6aae88 Mon Sep 17 00:00:00 2001 From: greenart7c3 <115044884+greenart7c3@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:01:03 -0300 Subject: [PATCH 017/156] Update 100.md --- 100.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/100.md b/100.md index 386ec802..79ced802 100644 --- a/100.md +++ b/100.md @@ -64,8 +64,8 @@ intent.`package` = "com.example.signer" // You can send some default permissions for the user to authorize for ever val permissions = listOf( Permission( - type = "sign_event", // Is it type? - kind = 22242 // Is it kind? + type = "sign_event", + kind = 22242 ), Permission( type = "nip44_decrypt" @@ -525,4 +525,4 @@ Android intents and browser urls have limitations, so if you are using the `retu -``` \ No newline at end of file +``` From a2aaa3c00b18e2e11dceae9400cd6fc429562622 Mon Sep 17 00:00:00 2001 From: greenart7c3 <115044884+greenart7c3@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:10:25 -0300 Subject: [PATCH 018/156] add example of rememberLauncherForActivityResult --- 100.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/100.md b/100.md index 79ced802..24bf09f1 100644 --- a/100.md +++ b/100.md @@ -40,6 +40,24 @@ fun isExternalSignerInstalled(context: Context): Boolean { To get the result back from the Signer Application you should use `registerForActivityResult` or `rememberLauncherForActivityResult` in Kotlin. If you are using another framework check the documentation of your framework or a third party library to get the result. +```kotlin +val launcher = rememberLauncherForActivityResult( + contract = ActivityResultContracts.StartActivityForResult(), + onResult = { result -> + if (result.resultCode != Activity.RESULT_OK) { + Toast.makeText( + context, + "Sign request rejected", + Toast.LENGTH_SHORT + ).show() + } else { + val signature = activityResult.data?.getStringExtra("signature") + // Do something with signature ... + } + } +) +``` + Create the Intent using the **nostrsigner** scheme: ```kotlin @@ -52,6 +70,12 @@ Set the Signer package name: intent.`package` = "com.example.signer" ``` +Send the Intent: + +```kotlin +launcher.launch(intent) +``` + ### Methods - **get_public_key** From 527f62d0106e6cfee10fe5e58ee54f0f99a57fac Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 19 Mar 2024 05:59:29 -0700 Subject: [PATCH 019/156] relax requirements for NIP 32 L tags --- 32.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/32.md b/32.md index be4e8724..46414736 100644 --- a/32.md +++ b/32.md @@ -20,7 +20,7 @@ Label Namespace Tag An `L` tag can be any string, but publishers SHOULD ensure they are unambiguous by using a well-defined namespace (such as an ISO standard) or reverse domain name notation. -`L` tags are REQUIRED in order to support searching by namespace rather than by a specific tag. The special `ugc` +`L` tags are RECOMMENDED in order to support searching by namespace rather than by a specific tag. The special `ugc` ("user generated content") namespace MAY be used when the label content is provided by an end user. `L` tags starting with `#` indicate that the label target should be associated with the label's value. @@ -29,7 +29,7 @@ This is a way of attaching standard nostr tags to events, pubkeys, relays, urls, Label Tag ---- -An `l` tag's value can be any string. `l` tags MUST include a `mark` matching an `L` tag value in the same event. +An `l` tag's value can be any string. If using an `L` tag, `l` tags MUST include a `mark` matching an `L` tag value in the same event. Label Target ---- @@ -42,7 +42,7 @@ or topics respectively. As with NIP-01, a relay hint SHOULD be included when usi Content ------- -Labels should be short, meaningful strings. Longer discussions, such as for a review, or an +Labels should be short, meaningful strings. Longer discussions, such as for an explanation of why something was labeled the way it was, should go in the event's `content` field. Self-Reporting From e97df1410391dd04fdbf9695932275a9d763940c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=AA=E7=8C=AB?= Date: Sat, 13 Apr 2024 12:39:24 +0900 Subject: [PATCH 020/156] Kind mute sets --- 51.md | 1 + 1 file changed, 1 insertion(+) diff --git a/51.md b/51.md index 95acbc81..b151facd 100644 --- a/51.md +++ b/51.md @@ -48,6 +48,7 @@ Aside from their main identifier, the `"d"` tag, sets can optionally have a `"ti | Bookmark sets | 30003 | user-defined bookmarks categories , for when bookmarks must be in labeled separate groups | `"e"` (kind:1 notes), `"a"` (kind:30023 articles), `"t"` (hashtags), `"r"` (URLs) | | Curation sets | 30004 | groups of articles picked by users as interesting and/or belonging to the same category | `"a"` (kind:30023 articles), `"e"` (kind:1 notes) | | Curation sets | 30005 | groups of videos picked by users as interesting and/or belonging to the same category | `"a"` (kind:34235 videos) | +| Kind mute sets | 30007 | mute pubkeys by kinds
`"d"` tag MUST be the kind string | `"p"` (pubkeys) | | Interest sets | 30015 | interest topics represented by a bunch of "hashtags" | `"t"` (hashtags) | | Emoji sets | 30030 | categorized emoji groups | `"emoji"` (see [NIP-30](30.md)) | | Release artifact sets | 30063 | groups of files of a software release | `"e"` (kind:1063 [file metadata](94.md) events), `"i"` (application identifier, typically reverse domain notation), `"version"` | From 280eb498e0ac56b8f9356c1b7a88cc8b31579801 Mon Sep 17 00:00:00 2001 From: Oscar Merry Date: Fri, 19 Apr 2024 14:30:45 +0100 Subject: [PATCH 021/156] Draft External Content IDs --- 24.md | 1 + XX.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 XX.md diff --git a/24.md b/24.md index 449101af..a17b334c 100644 --- a/24.md +++ b/24.md @@ -40,4 +40,5 @@ tags These tags may be present in multiple event kinds. Whenever a different meaning is not specified by some more specific NIP, they have the following meanings: - `r`: a web URL the event is referring to in some way + - `i`: an external id the event is referring to in some way - see [NIP-XX](XX.md) - `title`: title of the event diff --git a/XX.md b/XX.md new file mode 100644 index 00000000..8751d947 --- /dev/null +++ b/XX.md @@ -0,0 +1,31 @@ +NIP-XX +====== + +External Content IDs +------------------------- + +`draft` `optional` + +There are certain established global content identifiers that would be useful to reference in nostr events so that clients can query all events assosiated with these ids. + +- Book [ISBNs](https://en.wikipedia.org/wiki/ISBN) +- Podcast [GUIDs](https://podcastnamespace.org/tag/guid) +- Movie [EIDRs](https://www.eidr.org) + +Since the `i` tag is already used for similar references in kind-0 metadata events it makes sense to use it for these content ids as well. + + +## Supported IDs + +### Books: + +- Book ISBN: `["i", "book:isbn:123"]` + +### Podcasts: + +- Podcast Feed GUID: `["i", "podcast:guid:123"]` +- Podcast Item GUID: `["i", "podcast:item:guid:123"]` + +### Movies: + +- Movie EIDR: `["i", "movie:eidr:123"]` \ No newline at end of file From b21e996a89a9fe2acb09136792c75b1dd8eb59f8 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 29 Apr 2024 08:55:55 -0300 Subject: [PATCH 022/156] Change web app methods do use nostrsigner: instead of intent: --- 100.md | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/100.md b/100.md index 06d6b355..99feebf0 100644 --- a/100.md +++ b/100.md @@ -432,63 +432,49 @@ Android intents and browsers url has limitations, so if you are using the return - params: ```js - const intent = `intent:#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=get_public_key;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:?compressionType=none;returnType=signature;type=get_public_key;callbackUrl=https://example.com/?event=`; ``` - **sign_event** - params: ```js - const intent = `intent:${eventJson}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=sign_event;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${eventJson}?compressionType=none;returnType=signature;type=sign_event;callbackUrl=https://example.com/?event=`; ``` - **nip04_encrypt** - params: ```js - const intent = `intent:${plainText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip04_encrypt;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip04_encrypt;callbackUrl=https://example.com/?event=`; ``` - **nip44_encrypt** - params: ```js - const intent = `intent:${plainText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_encrypt;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip44_encrypt;callbackUrl=https://example.com/?event=`; ``` - **nip04_decrypt** - params: ```js - const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip04_decrypt;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip04_decrypt;callbackUrl=https://example.com/?event=`; ``` - **nip44_decrypt** - params: ```js - const intent = `intent:${encryptedText}#Intent;scheme=nostrsigner;S.pubKey=${hex_pub_key};S.compressionType=none;S.returnType=signature;S.type=nip44_decrypt;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip44_decrypt;callbackUrl=https://example.com/?event=`; ``` - **decrypt_zap_event** - params: ```js - const intent = `intent:${eventJson}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=decrypt_zap_event;S.callbackUrl=https://example.com/?event=;end`; - - window.href = intent; + window.href = `nostrsigner:${eventJson}?compressionType=none;returnType=signature;type=decrypt_zap_event;callbackUrl=https://example.com/?event=`; ``` ## Example @@ -518,7 +504,7 @@ Android intents and browsers url has limitations, so if you are using the return } let encodedJson = encodeURIComponent(JSON.stringify(json)) var newAnchor = document.createElement("a"); - newAnchor.href = `intent:${encodedJson}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=sign_event;S.callbackUrl=https://example.com/?event=;end`; + newAnchor.href = `nostrsigner:${encodedJson}?compressionType=none;returnType=signature;type=sign_event;callbackUrl=https://example.com/?event=`; newAnchor.textContent = "Open External Signer"; document.body.appendChild(newAnchor) } From ff24a56355471761d89399167a75a74e3bbb5677 Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Mon, 29 Apr 2024 09:25:04 -0300 Subject: [PATCH 023/156] ; -> & --- 100.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/100.md b/100.md index 571d1eb2..4a304c3a 100644 --- a/100.md +++ b/100.md @@ -456,49 +456,49 @@ Android intents and browser urls have limitations, so if you are using the `retu - params: ```js - window.href = `nostrsigner:?compressionType=none;returnType=signature;type=get_public_key;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:?compressionType=none&returnType=signature&type=get_public_key&callbackUrl=https://example.com/?event=`; ``` - **sign_event** - params: ```js - window.href = `nostrsigner:${eventJson}?compressionType=none;returnType=signature;type=sign_event;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${eventJson}?compressionType=none&returnType=signature&type=sign_event&callbackUrl=https://example.com/?event=`; ``` - **nip04_encrypt** - params: ```js - window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip04_encrypt;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&callbackUrl=https://example.com/?event=`; ``` - **nip44_encrypt** - params: ```js - window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip44_encrypt;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&callbackUrl=https://example.com/?event=`; ``` - **nip04_decrypt** - params: ```js - window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip04_decrypt;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&callbackUrl=https://example.com/?event=`; ``` - **nip44_decrypt** - params: ```js - window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key};compressionType=none;returnType=signature;type=nip44_decrypt;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&callbackUrl=https://example.com/?event=`; ``` - **decrypt_zap_event** - params: ```js - window.href = `nostrsigner:${eventJson}?compressionType=none;returnType=signature;type=decrypt_zap_event;callbackUrl=https://example.com/?event=`; + window.href = `nostrsigner:${eventJson}?compressionType=none&returnType=signature&type=decrypt_zap_event&callbackUrl=https://example.com/?event=`; ``` ## Example @@ -528,7 +528,7 @@ Android intents and browser urls have limitations, so if you are using the `retu } let encodedJson = encodeURIComponent(JSON.stringify(json)) var newAnchor = document.createElement("a"); - newAnchor.href = `nostrsigner:${encodedJson}?compressionType=none;returnType=signature;type=sign_event;callbackUrl=https://example.com/?event=`; + newAnchor.href = `nostrsigner:${encodedJson}?compressionType=none&returnType=signature&type=sign_event&callbackUrl=https://example.com/?event=`; newAnchor.textContent = "Open External Signer"; document.body.appendChild(newAnchor) } From b7bb46ac038bc5411f55bfa7646259da203c13c3 Mon Sep 17 00:00:00 2001 From: Oscar Merry Date: Thu, 9 May 2024 12:27:43 +0100 Subject: [PATCH 024/156] Use ISANs for Movies, Include Actual Examples --- XX.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/XX.md b/XX.md index 8751d947..eebaeedb 100644 --- a/XX.md +++ b/XX.md @@ -10,7 +10,7 @@ There are certain established global content identifiers that would be useful to - Book [ISBNs](https://en.wikipedia.org/wiki/ISBN) - Podcast [GUIDs](https://podcastnamespace.org/tag/guid) -- Movie [EIDRs](https://www.eidr.org) +- Movie [ISANs](https://en.wikipedia.org/wiki/International_Standard_Audiovisual_Number) Since the `i` tag is already used for similar references in kind-0 metadata events it makes sense to use it for these content ids as well. @@ -19,13 +19,17 @@ Since the `i` tag is already used for similar references in kind-0 metadata even ### Books: -- Book ISBN: `["i", "book:isbn:123"]` +- Book ISBN: `["i", "book:isbn:9780765382030"]` - https://isbnsearch.org/isbn/9780765382030 + +Book ISBNs MUST be referenced _**without hyphens**_ as many book search APIs return the ISBNs without hyphens. Removing hypens from ISBNs is trivial, whereas adding the hyphens back in is non-trivial requiring a library. ### Podcasts: -- Podcast Feed GUID: `["i", "podcast:guid:123"]` -- Podcast Item GUID: `["i", "podcast:item:guid:123"]` +- Podcast RSS Feed GUID: `["i", "podcast:guid:c90e609a-df1e-596a-bd5e-57bcc8aad6cc"]` - https://podcastindex.org/podcast/c90e609a-df1e-596a-bd5e-57bcc8aad6cc +- Podcast RSS Item GUID: `["i", "podcast:item:guid:d98d189b-dc7b-45b1-8720-d4b98690f31f"]` ### Movies: -- Movie EIDR: `["i", "movie:eidr:123"]` \ No newline at end of file +- Movie ISAN: `["i", "movie:isan:0000-0000-401A-0000-7"]` - https://web.isan.org/public/en/isan/0000-0000-401A-0000-7 + +Movie ISANs SHOULD be referenced _**without the version part**_ as the versions / edits of movies are not relevant. More info on ISAN parts here - https://support.isan.org/hc/en-us/articles/360002783131-Records-relations-and-hierarchies-in-the-ISAN-Registry \ No newline at end of file From d33b223c6afe2be3d197d2cdb4686961a6fb2b29 Mon Sep 17 00:00:00 2001 From: Oscar Merry Date: Thu, 16 May 2024 20:44:45 +0100 Subject: [PATCH 025/156] Remove Media Type Prefix --- XX.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XX.md b/XX.md index eebaeedb..4b51c67f 100644 --- a/XX.md +++ b/XX.md @@ -19,7 +19,7 @@ Since the `i` tag is already used for similar references in kind-0 metadata even ### Books: -- Book ISBN: `["i", "book:isbn:9780765382030"]` - https://isbnsearch.org/isbn/9780765382030 +- Book ISBN: `["i", "isbn:9780765382030"]` - https://isbnsearch.org/isbn/9780765382030 Book ISBNs MUST be referenced _**without hyphens**_ as many book search APIs return the ISBNs without hyphens. Removing hypens from ISBNs is trivial, whereas adding the hyphens back in is non-trivial requiring a library. @@ -30,6 +30,6 @@ Book ISBNs MUST be referenced _**without hyphens**_ as many book search APIs ret ### Movies: -- Movie ISAN: `["i", "movie:isan:0000-0000-401A-0000-7"]` - https://web.isan.org/public/en/isan/0000-0000-401A-0000-7 +- Movie ISAN: `["i", "isan:0000-0000-401A-0000-7"]` - https://web.isan.org/public/en/isan/0000-0000-401A-0000-7 Movie ISANs SHOULD be referenced _**without the version part**_ as the versions / edits of movies are not relevant. More info on ISAN parts here - https://support.isan.org/hc/en-us/articles/360002783131-Records-relations-and-hierarchies-in-the-ISAN-Registry \ No newline at end of file From 8d6d58871542dfcbb3f9d5d610a13a1e17358e58 Mon Sep 17 00:00:00 2001 From: kieran Date: Tue, 14 May 2024 13:59:59 +0100 Subject: [PATCH 026/156] nip96 list uploads --- 96.md | 108 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 40 deletions(-) diff --git a/96.md b/96.md index f7d901fd..4203b63e 100644 --- a/96.md +++ b/96.md @@ -84,46 +84,43 @@ it must use the "api_url" field instead. See https://github.com/aljazceru/awesome-nostr#nip-96-file-storage-servers. + +## Auth + +When indicated, `clients` must add an [NIP-98](98.md) `Authorization` header (**optionally** with the encoded `payload` tag set to the base64-encoded 256-bit SHA-256 hash of the file - not the hash of the whole request body). + ## Upload -A file can be uploaded one at a time to `https://your-file-server.example/custom-api-path` (route from `https://your-file-server.example/.well-known/nostr/nip96.json` "api_url" field) as `multipart/form-data` content type using `POST` method with the file object set to the `file` form data field. +`POST $api_url` as `multipart/form-data`. -`Clients` must add an [NIP-98](98.md) `Authorization` header (**optionally** with the encoded `payload` tag set to the base64-encoded 256-bit SHA-256 hash of the file - not the hash of the whole request body). -If using an html form, use an `Authorization` form data field instead. +**AUTH required** -These following **optional** form data fields MAY be used by `servers` and SHOULD be sent by `clients`: -- `expiration`: string of the UNIX timestamp in seconds. Empty string if file should be stored forever. The server isn't required to honor this; -- `size`: string of the file byte size. This is just a value the server can use to reject early if the file size exceeds the server limits; -- `alt`: (recommended) strict description text for visibility-impaired users; -- `caption`: loose description; -- `media_type`: "avatar" or "banner". Informs the server if the file will be used as an avatar or banner. If absent, the server will interpret it as a normal upload, without special treatment; +List of form fields: +- `file`: **REQUIRED** the file to upload +- `caption`: **RECOMMENDED** loose description; +- `expiration`: UNIX timestamp in seconds. Empty string if file should be stored forever. The server isn't required to honor this. +- `size`: File byte size. This is just a value the server can use to reject early if the file size exceeds the server limits. +- `alt`: **RECOMMENDED** strict description text for visibility-impaired users. +- `media_type`: "avatar" or "banner". Informs the server if the file will be used as an avatar or banner. If absent, the server will interpret it as a normal upload, without special treatment. - `content_type`: mime type such as "image/jpeg". This is just a value the server can use to reject early if the mime type isn't supported. - Others custom form data fields may be used depending on specific `server` support. The `server` isn't required to store any metadata sent by `clients`. -Note for `clients`: if using an HTML form, it is important for the `file` form field to be the **last** one, or be re-ordered right before sending or be appended as the last field of XHR2's FormData object. - The `filename` embedded in the file may not be honored by the `server`, which could internally store just the SHA-256 hash value as the file name, ignoring extra metadata. -The hash is enough to uniquely identify a file, that's why it will be used on the "download" and "delete" routes. +The hash is enough to uniquely identify a file, that's why it will be used on the `download` and `delete` routes. -The `server` MUST link the user's `pubkey` string (which is embedded in the decoded header value) as the owner of the file so to later allow them to delete the file. -Note that if a file with the same hash of a previously received file (so the same file) is uploaded by another user, the server doesn't need to store the new file. -It should just add the new user's `pubkey` to the list of the owners of the already stored file with said hash (if it wants to save space by keeping just one copy of the same file, because multiple uploads of the same file results in the same file hash). +The `server` MUST link the user's `pubkey` string as the owner of the file so to later allow them to delete the file. -The `server` MAY also store the `Authorization` header/field value (decoded or not) for accountability purpose as this proves that the user with the unique pubkey did ask for the upload of the file with a specific hash. However, storing the pubkey is sufficient to establish ownership. +### Response codes -The `server` MUST reject with 413 Payload Too Large if file size exceeds limits. - -The `server` MUST reject with 400 Bad Request status if some fields are invalid. - -The `server` MUST reply to the upload with 200 OK status if the `payload` tag value contains an already used SHA-256 hash (if file is already owned by the same pubkey) or reject the upload with 403 Forbidden status if it isn't the same of the received file. - -The `server` MAY reject the upload with 402 Payment Required status if the user has a pending payment (Payment flow is not strictly required. Server owners decide if the storage is free or not. Monetization schemes may be added later to correlated NIPs.). - -On successful uploads the `server` MUST reply with **201 Created** HTTP status code or **202 Accepted** if a `processing_url` field is added -to the response so that the `client` can follow the processing status (see [Delayed Processing](#delayed-processing) section). +- `200 OK`: File upload exists, but is successful (Existing hash) +- `201 Created`: File upload successful (New hash) +- `202 Accepted`: File upload is awaiting processing, see [Delayed Processing](#delayed-processing) section +- `413 Payload Too Large`: File size exceeds limit +- `400 Bad Request`: Form data is invalid or not supported. +- `403 Forbidden`: User is not allowed to upload or the uploaded file hash didnt match the hash included in the `Authorization` header `payload` tag. +- `402 Payment Required`: Payment is required by the server, **this flow is undefined**. The upload response is a json object as follows: @@ -179,11 +176,13 @@ The upload response is a json object as follows: Note that if the server didn't apply any transformation to the received file, both `nip94_event.tags.*.ox` and `nip94_event.tags.*.x` fields will have the same value. The server MUST link the saved file to the SHA-256 hash of the **original** file before any server transformations (the `nip94_event.tags.*.ox` tag value). The **original** file's SHA-256 hash will be used to identify the saved file when downloading or deleting it. -`Clients` may upload the same file to one or many `servers`. +`clients` may upload the same file to one or many `servers`. After successful upload, the `client` may optionally generate and send to any set of nostr `relays` a [NIP-94](94.md) event by including the missing fields. Alternatively, instead of using NIP-94, the `client` can share or embed on a nostr note just the above url. +`clients` may also use the tags from the `nip94_event` to construct an `imeta` tag + ### Delayed Processing Sometimes the server may want to place the uploaded file in a processing queue for deferred file processing. @@ -219,7 +218,7 @@ However, for all file actions, such as download and deletion, the **original** f ## Download -`Servers` must make available the route `https://your-file-server.example/custom-api-path/(.ext)` (route taken from `https://your-file-server.example/.well-known/nostr/nip96.json` "api_url" or "download_url" field) with `GET` method for file download. +`GET $api_url/(.ext)` The primary file download url informed at the upload's response field `nip94_event.tags.*.url` can be that or not (it can be any non-standard url the server wants). @@ -227,17 +226,17 @@ If not, the server still MUST also respond to downloads at the standard url mentioned on the previous paragraph, to make it possible for a client to try downloading a file on any NIP-96 compatible server by knowing just the SHA-256 file hash. -Note that the "\" part is from the **original** file, **not** from the **transformed** file if the uploaded file went through any server transformation. +Note that the "\" part is from the **original** file, **not** from the **transformed** file if the uploaded file went through any server transformation. Supporting ".ext", meaning "file extension", is required for `servers`. It is optional, although recommended, for `clients` to append it to the path. When present it may be used by `servers` to know which `Content-Type` header to send (e.g.: "Content-Type": "image/png" for ".png" extension). The file extension may be absent because the hash is the only needed string to uniquely identify a file. -Example: `https://your-file-server.example/custom-api-path/719171db19525d9d08dd69cb716a18158a249b7b3b3ec4bbdec5698dca104b7b.png` +Example: `$api_url/719171db19525d9d08dd69cb716a18158a249b7b3b3ec4bbdec5698dca104b7b.png` ### Media Transformations -`Servers` may respond to some media transformation query parameters and ignore those they don't support by serving +`servers` may respond to some media transformation query parameters and ignore those they don't support by serving the original media file without transformations. #### Image Transformations @@ -245,23 +244,23 @@ the original media file without transformations. ##### Resizing Upon upload, `servers` may create resized image variants, such as thumbnails, respecting the original aspect ratio. -`Clients` may use the `w` query parameter to request an image version with the desired pixel width. -`Servers` can then serve the variant with the closest width to the parameter value +`clients` may use the `w` query parameter to request an image version with the desired pixel width. +`servers` can then serve the variant with the closest width to the parameter value or an image variant generated on the fly. -Example: `https://your-file-server.example/custom-api-path/.png?w=32` +Example: `$api_url/.png?w=32` ## Deletion -`Servers` must make available the route `https://deletion.domain/deletion-path/(.ext)` (route taken from `https://your-file-server.example/.well-known/nostr/nip96.json` "api_url" field) with `DELETE` method for file deletion. +`DELETE $api_url/(.ext)` -Note that the "\" part is from the **original** file, **not** from the **transformed** file if the uploaded file went through any server transformation. +**AUTH required** + +Note that the `/` part is from the **original** file, **not** from the **transformed** file if the uploaded file went through any server transformation. The extension is optional as the file hash is the only needed file identification. -`Clients` should send a `DELETE` request to the server deletion route in the above format. It must include a NIP-98 `Authorization` header. - -The `server` should reject deletes from users other than the original uploader. The `pubkey` encoded on the header value identifies the user. +The `server` should reject deletes from users other than the original uploader with the appropriate http response code (403 Forbidden). It should be noted that more than one user may have uploaded the same file (with the same hash). In this case, a delete must not really delete the file but just remove the user's `pubkey` from the file owners list (considering the server keeps just one copy of the same file, because multiple uploads of the same file results in the same file hash). @@ -275,6 +274,35 @@ The successful response is a 200 OK one with just basic JSON fields: } ``` +## Listing files + +`GET $api_url` + +**AUTH required** + +Returns a list of files linked to the authenticated users pubkey. + +Example Response: +```js +[ + { + "id": "", + "nip94_event": {...}, + "expires": 1715691139, // unix timestamp + "size": 123456, + "alt": "a meme that makes you laugh", + "caption": "haha funny meme" + }, + ... +] +``` + +`` is the **original hash**, ie. `ox` + +`nip94_event` is the same as in the upload result. + +`alt` / `caption` are optional. + ## Selecting a Server Note: HTTP File Storage Server developers may skip this section. This is meant for client developers. From bd9c7a1b8e372b3c8e518861b1f4ea5c92ef1888 Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 20 May 2024 21:38:36 +0100 Subject: [PATCH 027/156] add pagination / drop duplicate fields --- 96.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/96.md b/96.md index 4203b63e..e882870e 100644 --- a/96.md +++ b/96.md @@ -1,8 +1,6 @@ -NIP-96 -====== +# NIP-96 -HTTP File Storage Integration ------------------------------ +## HTTP File Storage Integration `draft` `optional` @@ -84,8 +82,7 @@ it must use the "api_url" field instead. See https://github.com/aljazceru/awesome-nostr#nip-96-file-storage-servers. - -## Auth +## Auth When indicated, `clients` must add an [NIP-98](98.md) `Authorization` header (**optionally** with the encoded `payload` tag set to the base64-encoded 256-bit SHA-256 hash of the file - not the hash of the whole request body). @@ -96,6 +93,7 @@ When indicated, `clients` must add an [NIP-98](98.md) `Authorization` header (** **AUTH required** List of form fields: + - `file`: **REQUIRED** the file to upload - `caption`: **RECOMMENDED** loose description; - `expiration`: UNIX timestamp in seconds. Empty string if file should be stored forever. The server isn't required to honor this. @@ -276,22 +274,27 @@ The successful response is a 200 OK one with just basic JSON fields: ## Listing files -`GET $api_url` +`GET $api_url?page=x&count=y` **AUTH required** Returns a list of files linked to the authenticated users pubkey. Example Response: + ```js [ - { + { "id": "", - "nip94_event": {...}, - "expires": 1715691139, // unix timestamp - "size": 123456, - "alt": "a meme that makes you laugh", - "caption": "haha funny meme" + "nip94_event": { + "tags": [ + ["size", "123456"], + ["alt", "a meme that makes you laugh"], + ["expiration", "1715691139"] + // ...other metadata + ] + "content": "haha funny meme" // caption + } }, ... ] @@ -301,7 +304,10 @@ Example Response: `nip94_event` is the same as in the upload result. -`alt` / `caption` are optional. +### Query args + +- `page` page number (`offset=page*count`) +- `count` number of items per page ## Selecting a Server From 17593a41ab7ca51305db07cbfe1866f88e790206 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 27 May 2024 14:52:49 +0100 Subject: [PATCH 028/156] NIP-96: no transform (#1262) * no_transform * Update 96.md Co-authored-by: Santos <34815293+sant0s12@users.noreply.github.com> --------- Co-authored-by: Santos <34815293+sant0s12@users.noreply.github.com> --- 96.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/96.md b/96.md index e882870e..c8b3170b 100644 --- a/96.md +++ b/96.md @@ -101,6 +101,7 @@ List of form fields: - `alt`: **RECOMMENDED** strict description text for visibility-impaired users. - `media_type`: "avatar" or "banner". Informs the server if the file will be used as an avatar or banner. If absent, the server will interpret it as a normal upload, without special treatment. - `content_type`: mime type such as "image/jpeg". This is just a value the server can use to reject early if the mime type isn't supported. +- `no_transform`: "true" asks server not to transform the file and serve the uploaded file as is, may be rejected. Others custom form data fields may be used depending on specific `server` support. The `server` isn't required to store any metadata sent by `clients`. @@ -110,6 +111,8 @@ The hash is enough to uniquely identify a file, that's why it will be used on th The `server` MUST link the user's `pubkey` string as the owner of the file so to later allow them to delete the file. +`no_transform` can be used to replicate a file to multiple servers for redundancy, clients can use the [server list](#selecting-a-server) to find alternative servers which might contain the same file. When uploading a file and requesting `no_transform` clients should check that the hash matches in the response in order to detect if the file was modified. + ### Response codes - `200 OK`: File upload exists, but is successful (Existing hash) From 8199b795716a253655db5f7cce7463202e0d47d0 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 27 May 2024 08:31:29 -0700 Subject: [PATCH 029/156] Raise bar for NIP implementation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0af4f06..ffa6393e 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ Please update these lists when proposing NIPs introducing new event kinds. ## Criteria for acceptance of NIPs -1. They should be implemented in at least two clients and one relay -- when applicable. +1. They should be fully implemented in at least two clients and one relay -- when applicable. 2. They should make sense. 3. They should be optional and backwards-compatible: care must be taken such that clients and relays that choose to not implement them do not stop working when interacting with the ones that choose to. 4. There should be no more than one way of doing the same thing. From 244666ed0d6cb13b7459e9710ad3ab67bec61b4c Mon Sep 17 00:00:00 2001 From: Basanta Goswami <36882714+basantagoswami@users.noreply.github.com> Date: Sun, 25 Feb 2024 02:43:07 +0530 Subject: [PATCH 030/156] small nitpicks --- 02.md | 4 +++- 25.md | 3 +-- 53.md | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/02.md b/02.md index 8b0aee15..4029b222 100644 --- a/02.md +++ b/02.md @@ -8,7 +8,9 @@ Follow List A special event with kind `3`, meaning "follow list" is defined as having a list of `p` tags, one for each of the followed/known profiles one is following. -Each tag entry should contain the key for the profile, a relay URL where events from that key can be found (can be set to an empty string if not needed), and a local name (or "petname") for that profile (can also be set to an empty string or not provided), i.e., `["p", <32-bytes hex key>,
, ]`. The `content` can be anything and should be ignored. +Each tag entry should contain the key for the profile, a relay URL where events from that key can be found (can be set to an empty string if not needed), and a local name (or "petname") for that profile (can also be set to an empty string or not provided), i.e., `["p", <32-bytes hex key>,
, ]`. + +The `.content` is not used. For example: diff --git a/25.md b/25.md index 7cc96b5f..698f3fb0 100644 --- a/25.md +++ b/25.md @@ -67,8 +67,7 @@ content as an emoji if shortcode is specified. "tags": [ ["emoji", "soapbox", "https://gleasonator.com/emoji/Gleasonator/soapbox.png"] ], - "pubkey": "79c2cae114ea28a981e7559b4fe7854a473521a8d22a66bbab9fa248eb820ff6", - "created_at": 1682790000 + ...other fields } ``` diff --git a/53.md b/53.md index fad2622f..0b1cb813 100644 --- a/53.md +++ b/53.md @@ -77,7 +77,7 @@ Event `kind:1311` is live chat's channel message. Clients MUST include the `a` t ## Use Cases -Common use cases include meeting rooms/workshops, watch-together activities, or event spaces, such as [live.snort.social](https://live.snort.social) and [nostrnests.com](https://nostrnests.com). +Common use cases include meeting rooms/workshops, watch-together activities, or event spaces, such as [zap.stream](https://zap.stream). ## Example From 5c796c19fd6330628a0b328bfcf5270cb2bc3aff Mon Sep 17 00:00:00 2001 From: Asai Toshiya Date: Wed, 29 May 2024 13:08:31 +0900 Subject: [PATCH 031/156] NIP-38: move description of content to Live Statuses section --- 38.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/38.md b/38.md index 911d5b18..4f2c06d2 100644 --- a/38.md +++ b/38.md @@ -46,6 +46,8 @@ Any other status types can be used but they are not defined by this NIP. The status MAY include an `r`, `p`, `e` or `a` tag linking to a URL, profile, note, or parameterized replaceable event. +The `content` MAY include emoji(s), or [NIP-30](30.md) custom emoji(s). If the `content` is an empty string then the client should clear the status. + # Client behavior Clients MAY display this next to the username on posts or profiles to provide live user status information. @@ -57,5 +59,3 @@ Clients MAY display this next to the username on posts or profiles to provide li * Nostr music streaming services that update your music status when you're listening * Podcasting apps that update your music status when you're listening to a podcast, with a link for others to listen as well * Clients can use the system media player to update playing music status - -The `content` MAY include emoji(s), or [NIP-30](30.md) custom emoji(s). If the `content` is an empty string then the client should clear the status. From 7bf5e327f7c0fef06173b10c3300767acd20d884 Mon Sep 17 00:00:00 2001 From: kieran Date: Wed, 29 May 2024 14:26:00 +0100 Subject: [PATCH 032/156] update list response --- 96.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/96.md b/96.md index c8b3170b..2f253516 100644 --- a/96.md +++ b/96.md @@ -286,26 +286,29 @@ Returns a list of files linked to the authenticated users pubkey. Example Response: ```js -[ - { - "id": "", - "nip94_event": { +{ + "count": 1, // server page size, eg. max(1, min(server_max_page_size, arg_count)) + "total": 1, // total number of files + "page": 0, // the current page number + "files": [ + { "tags": [ + ["ox": "719171db19525d9d08dd69cb716a18158a249b7b3b3ec4bbdec5698dca104b7b"], + ["x": "5d2899290e0e69bcd809949ee516a4a1597205390878f780c098707a7f18e3df"], ["size", "123456"], ["alt", "a meme that makes you laugh"], - ["expiration", "1715691139"] + ["expiration", "1715691139"], // ...other metadata ] - "content": "haha funny meme" // caption - } - }, - ... -] + "content": "haha funny meme", // caption + "created_at": 1715691130 // upload timestmap + }, + ... + ] +} ``` -`` is the **original hash**, ie. `ox` - -`nip94_event` is the same as in the upload result. +`files` contains an array of NIP-94 events ### Query args From 0ff2fa3212ca66e3f7177da431084d4fde9386cd Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 8 Jan 2024 09:53:23 -0800 Subject: [PATCH 033/156] Add title to NIP 72, mention cross-posting and clarify moderation options --- 72.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/72.md b/72.md index 4bafce06..968a9eda 100644 --- a/72.md +++ b/72.md @@ -10,7 +10,7 @@ The goal of this NIP is to create moderator-approved public communities around a # Community Definition -`kind:34550` SHOULD include any field that helps define the community and the set of moderators. `relay` tags MAY be used to describe the preferred relay to download requests and approvals. +`Kind:34550` SHOULD include any field that helps define the community and the set of moderators. `relay` tags MAY be used to describe the preferred relay to download requests and approvals. A community definition event's `d` tag MAY double as its name, but if a `name` tag is provided, it SHOULD be displayed instead of the `d` tag. ```jsonc { @@ -18,6 +18,7 @@ The goal of this NIP is to create moderator-approved public communities around a "kind": 34550, "tags": [ ["d", ""], + ["name", ""], ["description", ""], ["image", "", "x"], @@ -38,9 +39,9 @@ The goal of this NIP is to create moderator-approved public communities around a } ``` -# New Post Request +# Community Posts -Any Nostr event can be submitted to a community by anyone for approval. Clients MUST add the community's `a` tag to the new post event in order to be presented for the moderator's approval. +Any Nostr event can be posted to a community. Clients MUST add one or more community `a` tags, each with a recommended relay. ```jsonc { @@ -53,11 +54,13 @@ Any Nostr event can be submitted to a community by anyone for approval. Clients } ``` -Community management clients MAY filter all mentions to a given `kind:34550` event and request moderators to approve each submission. Moderators MAY delete his/her approval of a post at any time using event deletions (See [NIP-09](09.md)). +# Moderation -# Post Approval by moderators +An approval event MUST include one or more community `a` tags, an `e` or `a` tag pointing to the post, and the `p` tag of the author of the post (for approval notifications). `a` tag prefixes can be used to disambiguate between community and replaceable event pointers (community `a` tags always begin with `34550`). -The post-approval event MUST include `a` tags of the communities the moderator is posting into (one or more), the `e` tag of the post and `p` tag of the author of the post (for approval notifications). The event SHOULD also include the stringified `post request` event inside the `.content` ([NIP-18-style](18.md)) and a `k` tag with the original post's event kind to allow filtering of approved posts by kind. +The event SHOULD also include the JSON-stringified `post request` event inside the `.content`, and a `k` tag with the original post's event kind to allow filtering of approved posts by kind. + +Moderators MAY delete their approval of a post at any time using NIP 09 event deletions. ```jsonc { @@ -76,13 +79,21 @@ The post-approval event MUST include `a` tags of the communities the moderator i It's recommended that multiple moderators approve posts to avoid deleting them from the community when a moderator is removed from the owner's list. In case the full list of moderators must be rotated, the new moderator set must sign new approvals for posts in the past or the community will restart. The owner can also periodically copy and re-sign of each moderator's approval events to make sure posts don't disappear with moderators. -Post Approvals of replaceable events can be created in three ways: (i) by tagging the replaceable event as an `e` tag if moderators want to approve each individual change to the repleceable event; (ii) by tagging the replaceable event as an `a` tag if the moderator authorizes the replaceable event author to make changes without additional approvals and (iii) by tagging the replaceable event with both its `e` and `a` tag which empowers clients to display the original and updated versions of the event, with appropriate remarks in the UI. Since relays are instructed to delete old versions of a replaceable event, the `.content` of an `e`-approval MUST have the specific version of the event or Clients might not be able to find that version of the content anywhere. +Approvals of replaceable events can be created in three ways: -Clients SHOULD evaluate any non-`34550:*` `a` tag as posts to be included in all `34550:*` `a` tags. +1. By tagging the replaceable event as an `e` tag if moderators want to approve each individual change to the replaceable event +2. By tagging the replaceable event as an `a` tag if the moderator authorizes the replaceable event author to make changes without additional approvals and +3. By tagging the replaceable event with both its `e` and `a` tag which empowers clients to display the original and updated versions of the event, with appropriate remarks in the UI. + +Since relays are instructed to delete old versions of a replaceable event, the `content` of an approval using an `e` tag MUST have the specific version of the event or clients might not be able to find that version of the content anywhere. + +# Cross-posting + +Clients MAY support cross-posting between communities by posting a NIP 18 `kind 6` or `kind 16` repost to one or more communities using `a` tags as described above. The `content` of the repost MUST be the original event, not the approval event. # Displaying -Community clients SHOULD display posts that have been approved by at least 1 moderator or by the community owner. +Clients SHOULD display posts that have been approved by at least 1 moderator or by the community owner. Clients MAY disregard moderation and fetch community posts directly. The following filter displays the approved posts. From 42932deb0a9265de0b668e3f34a418177c1b8d2f Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 5 Feb 2024 09:26:14 -0800 Subject: [PATCH 034/156] Do more to clarify moderation --- 72.md | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/72.md b/72.md index 968a9eda..cb1db227 100644 --- a/72.md +++ b/72.md @@ -6,7 +6,7 @@ Moderated Communities (Reddit Style) `draft` `optional` -The goal of this NIP is to create moderator-approved public communities around a topic. It defines the replaceable event `kind:34550` to define the community and the current list of moderators/administrators. Users that want to post into the community, simply tag any Nostr event with the community's `a` tag. Moderators issue an approval event `kind:4550` that links the community with the new post. +The goal of this NIP is to enable public communities. It defines the replaceable event `kind:34550` to define the community and the current list of moderators/administrators. Users that want to post into the community, simply tag any Nostr event with the community's `a` tag. Moderators may issue an approval event `kind:4550`. # Community Definition @@ -39,7 +39,7 @@ The goal of this NIP is to create moderator-approved public communities around a } ``` -# Community Posts +# Posting to a community Any Nostr event can be posted to a community. Clients MUST add one or more community `a` tags, each with a recommended relay. @@ -56,6 +56,8 @@ Any Nostr event can be posted to a community. Clients MUST add one or more commu # Moderation +Anyone may issue an approval event to express their opinion that a post is appropriate for a community. Clients MAY choose which approval events to honor, but SHOULD at least use ones published by the group's defined moderators. + An approval event MUST include one or more community `a` tags, an `e` or `a` tag pointing to the post, and the `p` tag of the author of the post (for approval notifications). `a` tag prefixes can be used to disambiguate between community and replaceable event pointers (community `a` tags always begin with `34550`). The event SHOULD also include the JSON-stringified `post request` event inside the `.content`, and a `k` tag with the original post's event kind to allow filtering of approved posts by kind. @@ -90,23 +92,3 @@ Since relays are instructed to delete old versions of a replaceable event, the ` # Cross-posting Clients MAY support cross-posting between communities by posting a NIP 18 `kind 6` or `kind 16` repost to one or more communities using `a` tags as described above. The `content` of the repost MUST be the original event, not the approval event. - -# Displaying - -Clients SHOULD display posts that have been approved by at least 1 moderator or by the community owner. Clients MAY disregard moderation and fetch community posts directly. - -The following filter displays the approved posts. - -```json -[ - "REQ", - "_", - { - "authors": ["", "", "", "", ...], - "kinds": [4550], - "#a": ["34550::"], - } -] -``` - -Clients MAY hide approvals by blocked moderators at the user's request. From 1dc8d1857172d74e81097f34f1f5c58bcc29ac51 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Thu, 30 May 2024 12:24:58 -0700 Subject: [PATCH 035/156] Fix conflicts --- 72.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/72.md b/72.md index cb1db227..d19b80b4 100644 --- a/72.md +++ b/72.md @@ -89,6 +89,8 @@ Approvals of replaceable events can be created in three ways: Since relays are instructed to delete old versions of a replaceable event, the `content` of an approval using an `e` tag MUST have the specific version of the event or clients might not be able to find that version of the content anywhere. +Clients SHOULD evaluate any non-`34550:*` `a` tag as posts to be approved for all `34550:*` `a` tags. + # Cross-posting Clients MAY support cross-posting between communities by posting a NIP 18 `kind 6` or `kind 16` repost to one or more communities using `a` tags as described above. The `content` of the repost MUST be the original event, not the approval event. From 30a5723f88f3c6e001bdd453de38144ba2f8f0b4 Mon Sep 17 00:00:00 2001 From: Asai Toshiya Date: Fri, 31 May 2024 12:43:13 +0900 Subject: [PATCH 036/156] BREAKING.md: add NIP-71 change --- BREAKING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BREAKING.md b/BREAKING.md index 7b48ee0d..720d27b1 100644 --- a/BREAKING.md +++ b/BREAKING.md @@ -5,6 +5,7 @@ reverse chronological order. | Date | Commit | NIP | Change | | ----------- | --------- | -------- | ------ | +| 2024-05-25 | [5d1d1c17](https://github.com/nostr-protocol/nips/commit/5d1d1c17) | [NIP-71](71.md) | 'aes-256-gcm' tag was removed | | 2024-04-30 | [bad88262](https://github.com/nostr-protocol/nips/commit/bad88262) | [NIP-34](34.md) | 'earliest-unique-commit' tag was removed (use 'r' tag instead) | | 2024-02-25 | [4a171cb0](https://github.com/nostr-protocol/nips/commit/4a171cb0) | [NIP-18](18.md) | quote repost should use `q` tag | | 2024-02-21 | [c6cd655c](https://github.com/nostr-protocol/nips/commit/c6cd655c) | [NIP-46](46.md) | Params were stringified | From fcc1b0baf653d70402b2f379eeb5d881885aae00 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 2 Jun 2024 16:38:01 -0500 Subject: [PATCH 037/156] Link `r` tag in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffa6393e..c9368afb 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ Please update these lists when proposing NIPs introducing new event kinds. | `L` | label namespace | -- | [32](32.md) | | `m` | MIME type | -- | [94](94.md) | | `q` | event id (hex) | relay URL | [18](18.md) | -| `r` | a reference (URL, etc) | petname | | +| `r` | a reference (URL, etc) | petname | [24](24.md) | | `r` | relay url | marker | [65](65.md) | | `t` | hashtag | -- | | | `alt` | summary | -- | [31](31.md) | From fd2b5d2bfbb5dd95df4d8e3535845d6b77658da0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 2 Jun 2024 18:19:42 -0500 Subject: [PATCH 038/156] NIP-32: fix markdown link --- 32.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/32.md b/32.md index 92497a61..32358b50 100644 --- a/32.md +++ b/32.md @@ -158,4 +158,4 @@ Appendix: Known Ontologies Below is a non-exhaustive list of ontologies currently in widespread use. -- (social.ontolo.categories)[https://ontolo.social/] +- [social.ontolo.categories](https://ontolo.social/) From 23d605140bdbe6ccc43c6ebbcd2412a05ff262fa Mon Sep 17 00:00:00 2001 From: Asai Toshiya Date: Tue, 4 Jun 2024 10:57:24 +0900 Subject: [PATCH 039/156] README: add NIP-100 to list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c9368afb..bd787847 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/nos - [NIP-96: HTTP File Storage Integration](96.md) - [NIP-98: HTTP Auth](98.md) - [NIP-99: Classified Listings](99.md) +- [NIP-100: Android Signer Application](100.md) ## Event Kinds | kind | description | NIP | From a6dfc7b5e513ea3070abcded3608b28e4d4a1512 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 5 Jun 2024 15:24:43 -0300 Subject: [PATCH 040/156] fix broken nip number. --- 100.md => 55.md | 42 +++++++++++++++++++++--------------------- README.md | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) rename 100.md => 55.md (98%) diff --git a/100.md b/55.md similarity index 98% rename from 100.md rename to 55.md index 4a304c3a..4565e8c3 100644 --- a/100.md +++ b/55.md @@ -1,4 +1,4 @@ -# NIP-100 +# NIP-55 ## Android Signer Application @@ -118,7 +118,7 @@ launcher.launch(intent) intent.putExtra("id", event.id) // Send the current logged in user npub intent.putExtra("current_user", npub) - + context.startActivity(intent) ``` - result: @@ -144,7 +144,7 @@ launcher.launch(intent) intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) // Send the hex pubKey that will be used for encrypting the data intent.putExtra("pubKey", pubKey) - + context.startActivity(intent) ``` - result: @@ -169,7 +169,7 @@ launcher.launch(intent) intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) // Send the hex pubKey that will be used for encrypting the data intent.putExtra("pubKey", pubKey) - + context.startActivity(intent) ``` - result: @@ -179,7 +179,7 @@ launcher.launch(intent) val encryptedText = intent.data?.getStringExtra("signature") // the id you sent val id = intent.data?.getStringExtra("id") - ``` + ``` - **nip04_decrypt** - params: @@ -194,7 +194,7 @@ launcher.launch(intent) intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) // Send the hex pubKey that will be used for decrypting the data intent.putExtra("pubKey", pubKey) - + context.startActivity(intent) ``` - result: @@ -204,7 +204,7 @@ launcher.launch(intent) val plainText = intent.data?.getStringExtra("signature") // the id you sent val id = intent.data?.getStringExtra("id") - ``` + ``` - **nip44_decrypt** - params: @@ -219,7 +219,7 @@ launcher.launch(intent) intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) // Send the hex pubKey that will be used for decrypting the data intent.putExtra("pubKey", pubKey) - + context.startActivity(intent) ``` - result: @@ -229,7 +229,7 @@ launcher.launch(intent) val plainText = intent.data?.getStringExtra("signature") // the id you sent val id = intent.data?.getStringExtra("id") - ``` + ``` - **decrypt_zap_event** - params: @@ -251,7 +251,7 @@ launcher.launch(intent) val eventJson = intent.data?.getStringExtra("signature") // the id you sent val id = intent.data?.getStringExtra("id") - ``` + ``` ## Using Content Resolver @@ -364,7 +364,7 @@ If the user chose to always reject the event, signer application will return the val index = it.getColumnIndex("signature") val encryptedText = it.getString(index) } - ``` + ``` - **nip04_decrypt** - params: @@ -388,7 +388,7 @@ If the user chose to always reject the event, signer application will return the val index = it.getColumnIndex("signature") val encryptedText = it.getString(index) } - ``` + ``` - **nip44_decrypt** - params: @@ -412,7 +412,7 @@ If the user chose to always reject the event, signer application will return the val index = it.getColumnIndex("signature") val encryptedText = it.getString(index) } - ``` + ``` - **decrypt_zap_event** - params: @@ -436,7 +436,7 @@ If the user chose to always reject the event, signer application will return the val index = it.getColumnIndex("signature") val eventJson = it.getString(index) } - ``` + ``` # Usage for Web Applications @@ -464,42 +464,42 @@ Android intents and browser urls have limitations, so if you are using the `retu ```js window.href = `nostrsigner:${eventJson}?compressionType=none&returnType=signature&type=sign_event&callbackUrl=https://example.com/?event=`; - ``` + ``` - **nip04_encrypt** - params: ```js window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&callbackUrl=https://example.com/?event=`; - ``` + ``` - **nip44_encrypt** - params: ```js window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&callbackUrl=https://example.com/?event=`; - ``` + ``` - **nip04_decrypt** - params: ```js window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&callbackUrl=https://example.com/?event=`; - ``` + ``` - **nip44_decrypt** - params: ```js window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&callbackUrl=https://example.com/?event=`; - ``` + ``` - **decrypt_zap_event** - params: ```js window.href = `nostrsigner:${eventJson}?compressionType=none&returnType=signature&type=decrypt_zap_event&callbackUrl=https://example.com/?event=`; - ``` + ``` ## Example @@ -513,7 +513,7 @@ Android intents and browser urls have limitations, so if you are using the `retu

Test

- +