diff options
| author | greenart7c3 <115044884+greenart7c3@users.noreply.github.com> | 2024-03-18 15:00:30 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 15:00:30 -0300 |
| commit | 4842f8612f55d9c11ef228338f6ef6f658e788a1 (patch) | |
| tree | 63279ac33a5df77d4c6de4b2744e659495913525 | |
| parent | 07074d8ba2615609fb702030151e191edcc91909 (diff) | |
Apply suggestions from code review
Co-authored-by: dluvian <133484344+dluvian@users.noreply.github.com>
| -rw-r--r-- | 100.md | 30 |
1 files changed, 15 insertions, 15 deletions
| @@ -46,7 +46,7 @@ Create the Intent using the **nostrsigner** scheme: | |||
| 46 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$content")) | 46 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$content")) |
| 47 | ``` | 47 | ``` |
| 48 | 48 | ||
| 49 | * Set the Signer package name | 49 | Set the Signer package name: |
| 50 | 50 | ||
| 51 | ```kotlin | 51 | ```kotlin |
| 52 | intent.`package` = "com.example.signer" | 52 | intent.`package` = "com.example.signer" |
| @@ -61,14 +61,14 @@ intent.`package` = "com.example.signer" | |||
| 61 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) | 61 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) |
| 62 | intent.`package` = "com.example.signer" | 62 | intent.`package` = "com.example.signer" |
| 63 | intent.putExtra("type", "get_public_key") | 63 | intent.putExtra("type", "get_public_key") |
| 64 | // You can send some default permissions for the user authorize for ever | 64 | // You can send some default permissions for the user to authorize for ever |
| 65 | val permissions = listOf( | 65 | val permissions = listOf( |
| 66 | Permission( | 66 | Permission( |
| 67 | "sign_event", | 67 | type = "sign_event", // Is it type? |
| 68 | 22242 | 68 | kind = 22242 // Is it kind? |
| 69 | ), | 69 | ), |
| 70 | Permission( | 70 | Permission( |
| 71 | "nip44_decrypt" | 71 | type = "nip44_decrypt" |
| 72 | ) | 72 | ) |
| 73 | ) | 73 | ) |
| 74 | intent.putExtra("permissions", permissions.toJson()) | 74 | intent.putExtra("permissions", permissions.toJson()) |
| @@ -90,10 +90,10 @@ intent.`package` = "com.example.signer" | |||
| 90 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$eventJson")) | 90 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:$eventJson")) |
| 91 | intent.`package` = "com.example.signer" | 91 | intent.`package` = "com.example.signer" |
| 92 | intent.putExtra("type", "sign_event") | 92 | intent.putExtra("type", "sign_event") |
| 93 | // to control the result in your application in case you are not waiting the result before sending another intent | 93 | // To handle results when not waiting between intents |
| 94 | intent.putExtra("id", event.id) | 94 | intent.putExtra("id", event.id) |
| 95 | // Send the current logged in user npub | 95 | // Send the current logged in user npub |
| 96 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 96 | intent.putExtra("current_user", npub) |
| 97 | 97 | ||
| 98 | context.startActivity(intent) | 98 | context.startActivity(intent) |
| 99 | ``` | 99 | ``` |
| @@ -102,7 +102,7 @@ intent.`package` = "com.example.signer" | |||
| 102 | 102 | ||
| 103 | ```kotlin | 103 | ```kotlin |
| 104 | val signature = intent.data?.getStringExtra("signature") | 104 | val signature = intent.data?.getStringExtra("signature") |
| 105 | // the id you sent | 105 | // The id you sent |
| 106 | val id = intent.data?.getStringExtra("id") | 106 | val id = intent.data?.getStringExtra("id") |
| 107 | val signedEventJson = intent.data?.getStringExtra("event") | 107 | val signedEventJson = intent.data?.getStringExtra("event") |
| 108 | ``` | 108 | ``` |
| @@ -233,13 +233,13 @@ intent.`package` = "com.example.signer" | |||
| 233 | 233 | ||
| 234 | 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. | 234 | 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. |
| 235 | 235 | ||
| 236 | 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 | 236 | 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 |
| 237 | 237 | ||
| 238 | For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json | 238 | For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json |
| 239 | 239 | ||
| 240 | For the other types Signer Application returns the column "signature" | 240 | For the other types Signer Application returns the column "signature" |
| 241 | 241 | ||
| 242 | If the user chose to always reject the event signer application will return the column "rejected" and you should not open signer application | 242 | If the user chose to always reject the event, signer application will return the column "rejected" and you should not open signer application |
| 243 | 243 | ||
| 244 | ### Methods | 244 | ### Methods |
| 245 | 245 | ||
| @@ -416,15 +416,15 @@ If the user chose to always reject the event signer application will return the | |||
| 416 | 416 | ||
| 417 | # Usage for Web Applications | 417 | # Usage for Web Applications |
| 418 | 418 | ||
| 419 | 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. | 419 | 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. |
| 420 | 420 | ||
| 421 | If you send the callback url parameter Signer Application will send the result to the url. | 421 | If you send the callback url parameter, Signer Application will send the result to the url. |
| 422 | 422 | ||
| 423 | If you don't send a callback url Signer Application will copy the result to the clipboard. | 423 | If you don't send a callback url, Signer Application will copy the result to the clipboard. |
| 424 | 424 | ||
| 425 | You can configure the returnType to be **signature** or **event**. | 425 | You can configure the `returnType` to be **signature** or **event**. |
| 426 | 426 | ||
| 427 | 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 | 427 | 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 |
| 428 | 428 | ||
| 429 | ## Methods | 429 | ## Methods |
| 430 | 430 | ||