diff options
| author | DASHU <385321165@qq.com> | 2024-07-02 16:02:31 +0800 |
|---|---|---|
| committer | fiatjaf_ <fiatjaf@gmail.com> | 2024-10-07 07:57:03 -0300 |
| commit | 7bb8997be5f8cbe1004e7c75724feaa56ccd08de (patch) | |
| tree | 6fba9ed4bd54917d904b9d065212f90f04e6d2e8 | |
| parent | e830a73cbd9a39e28757c11b208731773baac089 (diff) | |
fix some info of nip55 to be same as other nips
| -rw-r--r-- | 55.md | 124 |
1 files changed, 89 insertions, 35 deletions
| @@ -101,10 +101,10 @@ launcher.launch(intent) | |||
| 101 | context.startActivity(intent) | 101 | context.startActivity(intent) |
| 102 | ``` | 102 | ``` |
| 103 | - result: | 103 | - result: |
| 104 | - If the user approved intent it will return the **npub** in the signature field | 104 | - If the user approved intent it will return the **pubkey** in the signature field |
| 105 | 105 | ||
| 106 | ```kotlin | 106 | ```kotlin |
| 107 | val npub = intent.data?.getStringExtra("signature") | 107 | val pubkey = intent.data?.getStringExtra("signature") |
| 108 | // The package name of the signer application | 108 | // The package name of the signer application |
| 109 | val packageName = intent.data?.getStringExtra("package") | 109 | val packageName = intent.data?.getStringExtra("package") |
| 110 | ``` | 110 | ``` |
| @@ -118,8 +118,8 @@ launcher.launch(intent) | |||
| 118 | intent.putExtra("type", "sign_event") | 118 | intent.putExtra("type", "sign_event") |
| 119 | // To handle results when not waiting between intents | 119 | // To handle results when not waiting between intents |
| 120 | intent.putExtra("id", event.id) | 120 | intent.putExtra("id", event.id) |
| 121 | // Send the current logged in user npub | 121 | // Send the current logged in user pubkey |
| 122 | intent.putExtra("current_user", npub) | 122 | intent.putExtra("current_user", pubkey) |
| 123 | 123 | ||
| 124 | context.startActivity(intent) | 124 | context.startActivity(intent) |
| 125 | ``` | 125 | ``` |
| @@ -142,10 +142,10 @@ launcher.launch(intent) | |||
| 142 | intent.putExtra("type", "nip04_encrypt") | 142 | intent.putExtra("type", "nip04_encrypt") |
| 143 | // to control the result in your application in case you are not waiting the result before sending another intent | 143 | // to control the result in your application in case you are not waiting the result before sending another intent |
| 144 | intent.putExtra("id", "some_id") | 144 | intent.putExtra("id", "some_id") |
| 145 | // Send the current logged in user npub | 145 | // Send the current logged in user pubkey |
| 146 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 146 | intent.putExtra("current_user", account.keyPair.pubkey) |
| 147 | // Send the hex pubKey that will be used for encrypting the data | 147 | // Send the hex pubkey that will be used for encrypting the data |
| 148 | intent.putExtra("pubKey", pubKey) | 148 | intent.putExtra("pubkey", pubkey) |
| 149 | 149 | ||
| 150 | context.startActivity(intent) | 150 | context.startActivity(intent) |
| 151 | ``` | 151 | ``` |
| @@ -167,10 +167,10 @@ launcher.launch(intent) | |||
| 167 | intent.putExtra("type", "nip44_encrypt") | 167 | intent.putExtra("type", "nip44_encrypt") |
| 168 | // to control the result in your application in case you are not waiting the result before sending another intent | 168 | // to control the result in your application in case you are not waiting the result before sending another intent |
| 169 | intent.putExtra("id", "some_id") | 169 | intent.putExtra("id", "some_id") |
| 170 | // Send the current logged in user npub | 170 | // Send the current logged in user pubkey |
| 171 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 171 | intent.putExtra("current_user", account.keyPair.pubkey) |
| 172 | // Send the hex pubKey that will be used for encrypting the data | 172 | // Send the hex pubkey that will be used for encrypting the data |
| 173 | intent.putExtra("pubKey", pubKey) | 173 | intent.putExtra("pubkey", pubkey) |
| 174 | 174 | ||
| 175 | context.startActivity(intent) | 175 | context.startActivity(intent) |
| 176 | ``` | 176 | ``` |
| @@ -192,10 +192,10 @@ launcher.launch(intent) | |||
| 192 | intent.putExtra("type", "nip04_decrypt") | 192 | intent.putExtra("type", "nip04_decrypt") |
| 193 | // to control the result in your application in case you are not waiting the result before sending another intent | 193 | // to control the result in your application in case you are not waiting the result before sending another intent |
| 194 | intent.putExtra("id", "some_id") | 194 | intent.putExtra("id", "some_id") |
| 195 | // Send the current logged in user npub | 195 | // Send the current logged in user pubkey |
| 196 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 196 | intent.putExtra("current_user", account.keyPair.pubkey) |
| 197 | // Send the hex pubKey that will be used for decrypting the data | 197 | // Send the hex pubkey that will be used for decrypting the data |
| 198 | intent.putExtra("pubKey", pubKey) | 198 | intent.putExtra("pubkey", pubkey) |
| 199 | 199 | ||
| 200 | context.startActivity(intent) | 200 | context.startActivity(intent) |
| 201 | ``` | 201 | ``` |
| @@ -217,10 +217,10 @@ launcher.launch(intent) | |||
| 217 | intent.putExtra("type", "nip04_decrypt") | 217 | intent.putExtra("type", "nip04_decrypt") |
| 218 | // to control the result in your application in case you are not waiting the result before sending another intent | 218 | // to control the result in your application in case you are not waiting the result before sending another intent |
| 219 | intent.putExtra("id", "some_id") | 219 | intent.putExtra("id", "some_id") |
| 220 | // Send the current logged in user npub | 220 | // Send the current logged in user pubkey |
| 221 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 221 | intent.putExtra("current_user", account.keyPair.pubkey) |
| 222 | // Send the hex pubKey that will be used for decrypting the data | 222 | // Send the hex pubkey that will be used for decrypting the data |
| 223 | intent.putExtra("pubKey", pubKey) | 223 | intent.putExtra("pubkey", pubkey) |
| 224 | 224 | ||
| 225 | context.startActivity(intent) | 225 | context.startActivity(intent) |
| 226 | ``` | 226 | ``` |
| @@ -233,6 +233,29 @@ launcher.launch(intent) | |||
| 233 | val id = intent.data?.getStringExtra("id") | 233 | val id = intent.data?.getStringExtra("id") |
| 234 | ``` | 234 | ``` |
| 235 | 235 | ||
| 236 | - **get_relays** | ||
| 237 | - params: | ||
| 238 | |||
| 239 | ```kotlin | ||
| 240 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("nostrsigner:")) | ||
| 241 | intent.`package` = "com.example.signer" | ||
| 242 | intent.putExtra("type", "get_relays") | ||
| 243 | // to control the result in your application in case you are not waiting the result before sending another intent | ||
| 244 | intent.putExtra("id", "some_id") | ||
| 245 | // Send the current logged in user pubkey | ||
| 246 | intent.putExtra("current_user", account.keyPair.pubkey) | ||
| 247 | |||
| 248 | context.startActivity(intent) | ||
| 249 | ``` | ||
| 250 | - result: | ||
| 251 | - If the user approved intent it will return the **signature** and **id** fields | ||
| 252 | |||
| 253 | ```kotlin | ||
| 254 | val relayJsonText = intent.data?.getStringExtra("signature") | ||
| 255 | // the id you sent | ||
| 256 | val id = intent.data?.getStringExtra("id") | ||
| 257 | ``` | ||
| 258 | |||
| 236 | - **decrypt_zap_event** | 259 | - **decrypt_zap_event** |
| 237 | - params: | 260 | - params: |
| 238 | 261 | ||
| @@ -242,8 +265,8 @@ launcher.launch(intent) | |||
| 242 | intent.putExtra("type", "decrypt_zap_event") | 265 | intent.putExtra("type", "decrypt_zap_event") |
| 243 | // to control the result in your application in case you are not waiting the result before sending another intent | 266 | // to control the result in your application in case you are not waiting the result before sending another intent |
| 244 | intent.putExtra("id", "some_id") | 267 | intent.putExtra("id", "some_id") |
| 245 | // Send the current logged in user npub | 268 | // Send the current logged in user pubkey |
| 246 | intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) | 269 | intent.putExtra("current_user", account.keyPair.pubkey) |
| 247 | context.startActivity(intent) | 270 | context.startActivity(intent) |
| 248 | ``` | 271 | ``` |
| 249 | - result: | 272 | - result: |
| @@ -259,7 +282,7 @@ launcher.launch(intent) | |||
| 259 | 282 | ||
| 260 | 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. | 283 | 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. |
| 261 | 284 | ||
| 262 | 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 | 285 | If the user did not check the "remember my choice" option, the pubkey is not in Signer Application or the signer type is not recognized the `contentResolver` will return null |
| 263 | 286 | ||
| 264 | For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json | 287 | For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json |
| 265 | 288 | ||
| @@ -282,7 +305,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 282 | ) | 305 | ) |
| 283 | ``` | 306 | ``` |
| 284 | - result: | 307 | - result: |
| 285 | - Will return the **npub** in the signature column | 308 | - Will return the **pubkey** in the signature column |
| 286 | 309 | ||
| 287 | ```kotlin | 310 | ```kotlin |
| 288 | if (result == null) return | 311 | if (result == null) return |
| @@ -290,7 +313,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 290 | if (result.moveToFirst()) { | 313 | if (result.moveToFirst()) { |
| 291 | val index = it.getColumnIndex("signature") | 314 | val index = it.getColumnIndex("signature") |
| 292 | if (index < 0) return | 315 | if (index < 0) return |
| 293 | val npub = it.getString(index) | 316 | val pubkey = it.getString(index) |
| 294 | } | 317 | } |
| 295 | ``` | 318 | ``` |
| 296 | 319 | ||
| @@ -300,7 +323,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 300 | ```kotlin | 323 | ```kotlin |
| 301 | val result = context.contentResolver.query( | 324 | val result = context.contentResolver.query( |
| 302 | Uri.parse("content://com.example.signer.SIGN_EVENT"), | 325 | Uri.parse("content://com.example.signer.SIGN_EVENT"), |
| 303 | listOf("$eventJson", "", "${logged_in_user_npub}"), | 326 | listOf("$eventJson", "", "${logged_in_user_pubkey}"), |
| 304 | null, | 327 | null, |
| 305 | null, | 328 | null, |
| 306 | null | 329 | null |
| @@ -326,7 +349,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 326 | ```kotlin | 349 | ```kotlin |
| 327 | val result = context.contentResolver.query( | 350 | val result = context.contentResolver.query( |
| 328 | Uri.parse("content://com.example.signer.NIP04_ENCRYPT"), | 351 | Uri.parse("content://com.example.signer.NIP04_ENCRYPT"), |
| 329 | listOf("$plainText", "${hex_pub_key}", "${logged_in_user_npub}"), | 352 | listOf("$plainText", "${hex_pub_key}", "${logged_in_user_pubkey}"), |
| 330 | null, | 353 | null, |
| 331 | null, | 354 | null, |
| 332 | null | 355 | null |
| @@ -350,7 +373,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 350 | ```kotlin | 373 | ```kotlin |
| 351 | val result = context.contentResolver.query( | 374 | val result = context.contentResolver.query( |
| 352 | Uri.parse("content://com.example.signer.NIP44_ENCRYPT"), | 375 | Uri.parse("content://com.example.signer.NIP44_ENCRYPT"), |
| 353 | listOf("$plainText", "${hex_pub_key}", "${logged_in_user_npub}"), | 376 | listOf("$plainText", "${hex_pub_key}", "${logged_in_user_pubkey}"), |
| 354 | null, | 377 | null, |
| 355 | null, | 378 | null, |
| 356 | null | 379 | null |
| @@ -374,7 +397,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 374 | ```kotlin | 397 | ```kotlin |
| 375 | val result = context.contentResolver.query( | 398 | val result = context.contentResolver.query( |
| 376 | Uri.parse("content://com.example.signer.NIP04_DECRYPT"), | 399 | Uri.parse("content://com.example.signer.NIP04_DECRYPT"), |
| 377 | listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_npub}"), | 400 | listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_pubkey}"), |
| 378 | null, | 401 | null, |
| 379 | null, | 402 | null, |
| 380 | null | 403 | null |
| @@ -398,7 +421,7 @@ If the user chose to always reject the event, signer application will return the | |||
| 398 | ```kotlin | 421 | ```kotlin |
| 399 | val result = context.contentResolver.query( | 422 | val result = context.contentResolver.query( |
| 400 | Uri.parse("content://com.example.signer.NIP44_DECRYPT"), | 423 | Uri.parse("content://com.example.signer.NIP44_DECRYPT"), |
| 401 | listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_npub}"), | 424 | listOf("$encryptedText", "${hex_pub_key}", "${logged_in_user_pubkey}"), |
| 402 | null, | 425 | null, |
| 403 | null, | 426 | null, |
| 404 | null | 427 | null |
| @@ -416,13 +439,37 @@ If the user chose to always reject the event, signer application will return the | |||
| 416 | } | 439 | } |
| 417 | ``` | 440 | ``` |
| 418 | 441 | ||
| 442 | - **get_relays** | ||
| 443 | - params: | ||
| 444 | |||
| 445 | ```kotlin | ||
| 446 | val result = context.contentResolver.query( | ||
| 447 | Uri.parse("content://com.example.signer.GET_RELAYS"), | ||
| 448 | listOf("${logged_in_user_pubkey}"), | ||
| 449 | null, | ||
| 450 | null, | ||
| 451 | null | ||
| 452 | ) | ||
| 453 | ``` | ||
| 454 | - result: | ||
| 455 | - Will return the **signature** column | ||
| 456 | |||
| 457 | ```kotlin | ||
| 458 | if (result == null) return | ||
| 459 | |||
| 460 | if (result.moveToFirst()) { | ||
| 461 | val index = it.getColumnIndex("signature") | ||
| 462 | val relayJsonText = it.getString(index) | ||
| 463 | } | ||
| 464 | ``` | ||
| 465 | |||
| 419 | - **decrypt_zap_event** | 466 | - **decrypt_zap_event** |
| 420 | - params: | 467 | - params: |
| 421 | 468 | ||
| 422 | ```kotlin | 469 | ```kotlin |
| 423 | val result = context.contentResolver.query( | 470 | val result = context.contentResolver.query( |
| 424 | Uri.parse("content://com.example.signer.DECRYPT_ZAP_EVENT"), | 471 | Uri.parse("content://com.example.signer.DECRYPT_ZAP_EVENT"), |
| 425 | listOf("$eventJson", "", "${logged_in_user_npub}"), | 472 | listOf("$eventJson", "", "${logged_in_user_pubkey}"), |
| 426 | null, | 473 | null, |
| 427 | null, | 474 | null, |
| 428 | null | 475 | null |
| @@ -472,28 +519,35 @@ Android intents and browser urls have limitations, so if you are using the `retu | |||
| 472 | - params: | 519 | - params: |
| 473 | 520 | ||
| 474 | ```js | 521 | ```js |
| 475 | window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&callbackUrl=https://example.com/?event=`; | 522 | window.href = `nostrsigner:${plainText}?pubkey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&callbackUrl=https://example.com/?event=`; |
| 476 | ``` | 523 | ``` |
| 477 | 524 | ||
| 478 | - **nip44_encrypt** | 525 | - **nip44_encrypt** |
| 479 | - params: | 526 | - params: |
| 480 | 527 | ||
| 481 | ```js | 528 | ```js |
| 482 | window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&callbackUrl=https://example.com/?event=`; | 529 | window.href = `nostrsigner:${plainText}?pubkey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&callbackUrl=https://example.com/?event=`; |
| 483 | ``` | 530 | ``` |
| 484 | 531 | ||
| 485 | - **nip04_decrypt** | 532 | - **nip04_decrypt** |
| 486 | - params: | 533 | - params: |
| 487 | 534 | ||
| 488 | ```js | 535 | ```js |
| 489 | window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&callbackUrl=https://example.com/?event=`; | 536 | window.href = `nostrsigner:${encryptedText}?pubkey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&callbackUrl=https://example.com/?event=`; |
| 490 | ``` | 537 | ``` |
| 491 | 538 | ||
| 492 | - **nip44_decrypt** | 539 | - **nip44_decrypt** |
| 493 | - params: | 540 | - params: |
| 494 | 541 | ||
| 495 | ```js | 542 | ```js |
| 496 | window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&callbackUrl=https://example.com/?event=`; | 543 | window.href = `nostrsigner:${encryptedText}?pubkey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&callbackUrl=https://example.com/?event=`; |
| 544 | ``` | ||
| 545 | |||
| 546 | - **get_relays** | ||
| 547 | - params: | ||
| 548 | |||
| 549 | ```js | ||
| 550 | window.href = `nostrsigner:?compressionType=none&returnType=signature&type=get_relays&callbackUrl=https://example.com/?event=`; | ||
| 497 | ``` | 551 | ``` |
| 498 | 552 | ||
| 499 | - **decrypt_zap_event** | 553 | - **decrypt_zap_event** |