mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 07:37:12 +01:00
adds NFC-Based transient accounts.
Refactors the login screen
This commit is contained in:
@@ -48,6 +48,12 @@ object Nip19Bech32 {
|
||||
KIND(3),
|
||||
}
|
||||
|
||||
val nip19PlusNip46regex =
|
||||
Pattern.compile(
|
||||
"(nostr:)?@?(nsec1|npub1|nevent1|naddr1|note1|nprofile1|nrelay1|nembed1|ncryptsec1)([qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)([\\S]*)",
|
||||
Pattern.CASE_INSENSITIVE,
|
||||
)
|
||||
|
||||
val nip19regex =
|
||||
Pattern.compile(
|
||||
"(nostr:)?@?(nsec1|npub1|nevent1|naddr1|note1|nprofile1|nrelay1|nembed1)([qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)([\\S]*)",
|
||||
@@ -110,6 +116,26 @@ object Nip19Bech32 {
|
||||
val event: Event,
|
||||
) : Entity
|
||||
|
||||
fun tryParseAndClean(uri: String?): String? {
|
||||
if (uri == null) return null
|
||||
|
||||
try {
|
||||
val matcher = nip19PlusNip46regex.matcher(uri)
|
||||
if (!matcher.find()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val type = matcher.group(2) // npub1
|
||||
val key = matcher.group(3) // bech32
|
||||
|
||||
return type + key
|
||||
} catch (e: Throwable) {
|
||||
Log.e("NIP19 Parser", "Issue trying to Decode NIP19 $uri: ${e.message}", e)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
fun uriToRoute(uri: String?): ParseReturn? {
|
||||
if (uri == null) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user