Apply suggestions from code review

Co-authored-by: dluvian <133484344+dluvian@users.noreply.github.com>
This commit is contained in:
greenart7c3 2024-03-18 15:00:30 -03:00 committed by GitHub
parent 07074d8ba2
commit 4842f8612f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

30
100.md
View File

@ -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