upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/55.md
diff options
context:
space:
mode:
Diffstat (limited to '55.md')
-rw-r--r--55.md178
1 files changed, 116 insertions, 62 deletions
diff --git a/55.md b/55.md
index c0ee957..54dc44a 100644
--- a/55.md
+++ b/55.md
@@ -53,8 +53,8 @@ val launcher = rememberLauncherForActivityResult(
53 Toast.LENGTH_SHORT 53 Toast.LENGTH_SHORT
54 ).show() 54 ).show()
55 } else { 55 } else {
56 val signature = activityResult.data?.getStringExtra("signature") 56 val result = activityResult.data?.getStringExtra("result")
57 // Do something with signature ... 57 // Do something with result ...
58 } 58 }
59 } 59 }
60) 60)
@@ -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 result field
105 105
106 ```kotlin 106 ```kotlin
107 val npub = intent.data?.getStringExtra("signature") 107 val pubkey = intent.data?.getStringExtra("result")
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,16 +118,16 @@ 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 ```
126 - result: 126 - result:
127 - If the user approved intent it will return the **signature**, **id** and **event** fields 127 - If the user approved intent it will return the **result**, **id** and **event** fields
128 128
129 ```kotlin 129 ```kotlin
130 val signature = intent.data?.getStringExtra("signature") 130 val signature = intent.data?.getStringExtra("result")
131 // The id you sent 131 // The id you sent
132 val id = intent.data?.getStringExtra("id") 132 val id = intent.data?.getStringExtra("id")
133 val signedEventJson = intent.data?.getStringExtra("event") 133 val signedEventJson = intent.data?.getStringExtra("event")
@@ -142,18 +142,18 @@ 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 ```
152 - result: 152 - result:
153 - If the user approved intent it will return the **signature** and **id** fields 153 - If the user approved intent it will return the **result** and **id** fields
154 154
155 ```kotlin 155 ```kotlin
156 val encryptedText = intent.data?.getStringExtra("signature") 156 val encryptedText = intent.data?.getStringExtra("result")
157 // the id you sent 157 // the id you sent
158 val id = intent.data?.getStringExtra("id") 158 val id = intent.data?.getStringExtra("id")
159 ``` 159 ```
@@ -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,18 +192,18 @@ 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 ```
202 - result: 202 - result:
203 - If the user approved intent it will return the **signature** and **id** fields 203 - If the user approved intent it will return the **result** and **id** fields
204 204
205 ```kotlin 205 ```kotlin
206 val plainText = intent.data?.getStringExtra("signature") 206 val plainText = intent.data?.getStringExtra("result")
207 // the id you sent 207 // the id you sent
208 val id = intent.data?.getStringExtra("id") 208 val id = intent.data?.getStringExtra("id")
209 ``` 209 ```
@@ -217,18 +217,41 @@ 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 ```
227 - result: 227 - result:
228 - If the user approved intent it will return the **signature** and **id** fields 228 - If the user approved intent it will return the **result** and **id** fields
229 229
230 ```kotlin 230 ```kotlin
231 val plainText = intent.data?.getStringExtra("signature") 231 val plainText = intent.data?.getStringExtra("result")
232 // the id you sent
233 val id = intent.data?.getStringExtra("id")
234 ```
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 **result** and **id** fields
252
253 ```kotlin
254 val relayJsonText = intent.data?.getStringExtra("result")
232 // the id you sent 255 // the id you sent
233 val id = intent.data?.getStringExtra("id") 256 val id = intent.data?.getStringExtra("id")
234 ``` 257 ```
@@ -242,15 +265,15 @@ 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:
250 - If the user approved intent it will return the **signature** and **id** fields 273 - If the user approved intent it will return the **result** and **id** fields
251 274
252 ```kotlin 275 ```kotlin
253 val eventJson = intent.data?.getStringExtra("signature") 276 val eventJson = intent.data?.getStringExtra("result")
254 // the id you sent 277 // the id you sent
255 val id = intent.data?.getStringExtra("id") 278 val id = intent.data?.getStringExtra("id")
256 ``` 279 ```
@@ -259,11 +282,11 @@ launcher.launch(intent)
259 282
260To 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. 283To 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
262If 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 285If 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
264For the SIGN_EVENT type Signer Application returns two columns "signature" and "event". The column event is the signed event json 287For the SIGN_EVENT type Signer Application returns two columns "result" and "event". The column event is the signed event json
265 288
266For the other types Signer Application returns the column "signature" 289For the other types Signer Application returns the column "result"
267 290
268If the user chose to always reject the event, signer application will return the column "rejected" and you should not open signer application 291If the user chose to always reject the event, signer application will return the column "rejected" and you should not open signer application
269 292
@@ -282,15 +305,15 @@ 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 result column
286 309
287 ```kotlin 310 ```kotlin
288 if (result == null) return 311 if (result == null) return
289 312
290 if (result.moveToFirst()) { 313 if (result.moveToFirst()) {
291 val index = it.getColumnIndex("signature") 314 val index = it.getColumnIndex("result")
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,20 +323,20 @@ 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
307 ) 330 )
308 ``` 331 ```
309 - result: 332 - result:
310 - Will return the **signature** and the **event** columns 333 - Will return the **result** and the **event** columns
311 334
312 ```kotlin 335 ```kotlin
313 if (result == null) return 336 if (result == null) return
314 337
315 if (result.moveToFirst()) { 338 if (result.moveToFirst()) {
316 val index = it.getColumnIndex("signature") 339 val index = it.getColumnIndex("result")
317 val indexJson = it.getColumnIndex("event") 340 val indexJson = it.getColumnIndex("event")
318 val signature = it.getString(index) 341 val signature = it.getString(index)
319 val eventJson = it.getString(indexJson) 342 val eventJson = it.getString(indexJson)
@@ -326,20 +349,20 @@ 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
333 ) 356 )
334 ``` 357 ```
335 - result: 358 - result:
336 - Will return the **signature** column 359 - Will return the **result** column
337 360
338 ```kotlin 361 ```kotlin
339 if (result == null) return 362 if (result == null) return
340 363
341 if (result.moveToFirst()) { 364 if (result.moveToFirst()) {
342 val index = it.getColumnIndex("signature") 365 val index = it.getColumnIndex("result")
343 val encryptedText = it.getString(index) 366 val encryptedText = it.getString(index)
344 } 367 }
345 ``` 368 ```
@@ -350,20 +373,20 @@ 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
357 ) 380 )
358 ``` 381 ```
359 - result: 382 - result:
360 - Will return the **signature** column 383 - Will return the **result** column
361 384
362 ```kotlin 385 ```kotlin
363 if (result == null) return 386 if (result == null) return
364 387
365 if (result.moveToFirst()) { 388 if (result.moveToFirst()) {
366 val index = it.getColumnIndex("signature") 389 val index = it.getColumnIndex("result")
367 val encryptedText = it.getString(index) 390 val encryptedText = it.getString(index)
368 } 391 }
369 ``` 392 ```
@@ -374,20 +397,20 @@ 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
381 ) 404 )
382 ``` 405 ```
383 - result: 406 - result:
384 - Will return the **signature** column 407 - Will return the **result** column
385 408
386 ```kotlin 409 ```kotlin
387 if (result == null) return 410 if (result == null) return
388 411
389 if (result.moveToFirst()) { 412 if (result.moveToFirst()) {
390 val index = it.getColumnIndex("signature") 413 val index = it.getColumnIndex("result")
391 val encryptedText = it.getString(index) 414 val encryptedText = it.getString(index)
392 } 415 }
393 ``` 416 ```
@@ -398,44 +421,68 @@ 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
405 ) 428 )
406 ``` 429 ```
407 - result: 430 - result:
408 - Will return the **signature** column 431 - Will return the **result** column
409 432
410 ```kotlin 433 ```kotlin
411 if (result == null) return 434 if (result == null) return
412 435
413 if (result.moveToFirst()) { 436 if (result.moveToFirst()) {
414 val index = it.getColumnIndex("signature") 437 val index = it.getColumnIndex("result")
415 val encryptedText = it.getString(index) 438 val encryptedText = it.getString(index)
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 **result** column
456
457 ```kotlin
458 if (result == null) return
459
460 if (result.moveToFirst()) {
461 val index = it.getColumnIndex("result")
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
429 ) 476 )
430 ``` 477 ```
431 - result: 478 - result:
432 - Will return the **signature** column 479 - Will return the **result** column
433 480
434 ```kotlin 481 ```kotlin
435 if (result == null) return 482 if (result == null) return
436 483
437 if (result.moveToFirst()) { 484 if (result.moveToFirst()) {
438 val index = it.getColumnIndex("signature") 485 val index = it.getColumnIndex("result")
439 val eventJson = it.getString(index) 486 val eventJson = it.getString(index)
440 } 487 }
441 ``` 488 ```
@@ -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**