mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Add React Native snippets
This commit is contained in:
25
snippets/react-native/lnurl_auth.ts
Normal file
25
snippets/react-native/lnurl_auth.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
InputTypeVariant,
|
||||
lnurlAuth,
|
||||
LnUrlCallbackStatusVariant,
|
||||
parseInput
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleLnurlAuth = async () => {
|
||||
// ANCHOR: lnurl-auth
|
||||
// Endpoint can also be of the form:
|
||||
// keyauth://domain.com/auth?key=val
|
||||
const lnurlAuthUrl =
|
||||
"lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
|
||||
|
||||
const input = await parseInput(lnurlAuthUrl)
|
||||
if (input.type === InputTypeVariant.LN_URL_AUTH) {
|
||||
const result = await lnurlAuth(input.data)
|
||||
if (result.type === LnUrlCallbackStatusVariant.OK) {
|
||||
console.log("Successfully authenticated")
|
||||
} else {
|
||||
console.log("Failed to authenticate")
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: lnurl-auth
|
||||
}
|
||||
Reference in New Issue
Block a user