@authon/react-native-wallet 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +251 -2
  3. package/android/build.gradle +40 -0
  4. package/android/consumer-rules.pro +10 -0
  5. package/android/src/main/AndroidManifest.xml +8 -0
  6. package/android/src/main/java/dev/authon/reactnative/wallet/AuthonWalletModule.kt +235 -0
  7. package/android/src/vendor/GENERATED.md +4 -0
  8. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/AndroidCapabilityProbe.kt +86 -0
  9. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/AuthonWallet.kt +218 -0
  10. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Bitcoin.kt +296 -0
  11. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Bytes.kt +74 -0
  12. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Chains.kt +157 -0
  13. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/CredentialManagerPasskeys.kt +192 -0
  14. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Der.kt +17 -0
  15. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/DeviceStore.kt +170 -0
  16. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/DialogWalletApprover.kt +141 -0
  17. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Eip712.kt +176 -0
  18. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Encodings.kt +133 -0
  19. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/EvmAccount.kt +45 -0
  20. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/EvmTransaction.kt +180 -0
  21. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/GfTables.kt +44 -0
  22. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/HdWallet.kt +130 -0
  23. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Http.kt +86 -0
  24. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/JsValues.kt +83 -0
  25. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/KeystoreDeviceStore.kt +236 -0
  26. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Prf.kt +111 -0
  27. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Proof.kt +134 -0
  28. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Shamir.kt +106 -0
  29. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/SignSummary.kt +335 -0
  30. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Solana.kt +195 -0
  31. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Tron.kt +184 -0
  32. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/WalletApi.kt +361 -0
  33. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/WalletCapabilities.kt +91 -0
  34. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/WalletError.kt +74 -0
  35. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/WalletOps.kt +551 -0
  36. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/WalletTypes.kt +78 -0
  37. package/android/src/vendor/kotlin/dev/authon/sdk/wallet/Xrp.kt +193 -0
  38. package/build/authonContext.d.ts +19 -0
  39. package/build/authonContext.d.ts.map +1 -0
  40. package/build/authonContext.js +20 -0
  41. package/build/authonContext.js.map +1 -0
  42. package/build/client.d.ts +92 -0
  43. package/build/client.d.ts.map +1 -0
  44. package/build/client.js +431 -0
  45. package/build/client.js.map +1 -0
  46. package/build/errors.d.ts +25 -0
  47. package/build/errors.d.ts.map +1 -0
  48. package/build/errors.js +15 -0
  49. package/build/errors.js.map +1 -0
  50. package/build/index.d.ts +7 -0
  51. package/build/index.d.ts.map +1 -0
  52. package/build/index.js +4 -0
  53. package/build/index.js.map +1 -0
  54. package/build/native.d.ts +43 -0
  55. package/build/native.d.ts.map +1 -0
  56. package/build/native.js +12 -0
  57. package/build/native.js.map +1 -0
  58. package/build/types.d.ts +167 -0
  59. package/build/types.d.ts.map +1 -0
  60. package/build/types.js +3 -0
  61. package/build/types.js.map +1 -0
  62. package/build/useAuthonWallet.d.ts +25 -0
  63. package/build/useAuthonWallet.d.ts.map +1 -0
  64. package/build/useAuthonWallet.js +77 -0
  65. package/build/useAuthonWallet.js.map +1 -0
  66. package/expo-module.config.json +9 -0
  67. package/ios/AuthonReactNativeWallet.podspec +41 -0
  68. package/ios/AuthonWalletModule.swift +233 -0
  69. package/ios/vendor/AuthonWallet/AuthonWallet.swift +232 -0
  70. package/ios/vendor/AuthonWallet/Capabilities.swift +149 -0
  71. package/ios/vendor/AuthonWallet/Chains/Bitcoin.swift +296 -0
  72. package/ios/vendor/AuthonWallet/Chains/Solana.swift +207 -0
  73. package/ios/vendor/AuthonWallet/Chains/Tron.swift +181 -0
  74. package/ios/vendor/AuthonWallet/Chains/XRP.swift +191 -0
  75. package/ios/vendor/AuthonWallet/Crypto/BIP39Wordlist.swift +262 -0
  76. package/ios/vendor/AuthonWallet/Crypto/Chains.swift +278 -0
  77. package/ios/vendor/AuthonWallet/Crypto/HDKey.swift +108 -0
  78. package/ios/vendor/AuthonWallet/Crypto/Secp256k1.swift +128 -0
  79. package/ios/vendor/AuthonWallet/Crypto/Shamir.swift +123 -0
  80. package/ios/vendor/AuthonWallet/EVM/Address.swift +57 -0
  81. package/ios/vendor/AuthonWallet/EVM/EvmAccount.swift +48 -0
  82. package/ios/vendor/AuthonWallet/EVM/Transaction.swift +165 -0
  83. package/ios/vendor/AuthonWallet/EVM/TypedData.swift +193 -0
  84. package/ios/vendor/AuthonWallet/Support/BigInteger.swift +220 -0
  85. package/ios/vendor/AuthonWallet/Support/Bytes.swift +89 -0
  86. package/ios/vendor/AuthonWallet/Support/JSONValue.swift +341 -0
  87. package/ios/vendor/AuthonWallet/UI/WalletApprover.swift +250 -0
  88. package/ios/vendor/AuthonWallet/Wallet/Backup.swift +69 -0
  89. package/ios/vendor/AuthonWallet/Wallet/DeviceStore.swift +351 -0
  90. package/ios/vendor/AuthonWallet/Wallet/Passkeys.swift +190 -0
  91. package/ios/vendor/AuthonWallet/Wallet/Proof.swift +143 -0
  92. package/ios/vendor/AuthonWallet/Wallet/Shares.swift +116 -0
  93. package/ios/vendor/AuthonWallet/Wallet/Summary.swift +342 -0
  94. package/ios/vendor/AuthonWallet/Wallet/WalletAPI.swift +361 -0
  95. package/ios/vendor/AuthonWallet/Wallet/WalletOps.swift +654 -0
  96. package/ios/vendor/AuthonWallet/WalletError.swift +84 -0
  97. package/ios/vendor/CKeccak/LICENSE +22 -0
  98. package/ios/vendor/CKeccak/README.md +30 -0
  99. package/ios/vendor/CKeccak/byte_order.h +59 -0
  100. package/ios/vendor/CKeccak/include/ckeccak.h +13 -0
  101. package/ios/vendor/CKeccak/memzero.c +75 -0
  102. package/ios/vendor/CKeccak/memzero.h +8 -0
  103. package/ios/vendor/CKeccak/options.h +99 -0
  104. package/ios/vendor/CKeccak/ripemd160.c +343 -0
  105. package/ios/vendor/CKeccak/ripemd160.h +22 -0
  106. package/ios/vendor/CKeccak/sha3.c +413 -0
  107. package/ios/vendor/CKeccak/sha3.h +89 -0
  108. package/ios/vendor/CMonocypher/LICENCE.md +173 -0
  109. package/ios/vendor/CMonocypher/README.md +27 -0
  110. package/ios/vendor/CMonocypher/include/monocypher-ed25519.h +140 -0
  111. package/ios/vendor/CMonocypher/include/monocypher.h +321 -0
  112. package/ios/vendor/CMonocypher/monocypher-ed25519.c +500 -0
  113. package/ios/vendor/CMonocypher/monocypher.c +2956 -0
  114. package/ios/vendor/CSecp256k1/COPYING +19 -0
  115. package/ios/vendor/CSecp256k1/README.md +35 -0
  116. package/ios/vendor/CSecp256k1/build/precomputed_ecmult.c +3 -0
  117. package/ios/vendor/CSecp256k1/build/precomputed_ecmult_gen.c +3 -0
  118. package/ios/vendor/CSecp256k1/build/secp256k1.c +3 -0
  119. package/ios/vendor/CSecp256k1/include/secp256k1.h +899 -0
  120. package/ios/vendor/CSecp256k1/include/secp256k1_preallocated.h +134 -0
  121. package/ios/vendor/CSecp256k1/include/secp256k1_recovery.h +113 -0
  122. package/ios/vendor/CSecp256k1/src/assumptions.h +87 -0
  123. package/ios/vendor/CSecp256k1/src/checkmem.h +102 -0
  124. package/ios/vendor/CSecp256k1/src/ecdsa.h +21 -0
  125. package/ios/vendor/CSecp256k1/src/ecdsa_impl.h +304 -0
  126. package/ios/vendor/CSecp256k1/src/eckey.h +25 -0
  127. package/ios/vendor/CSecp256k1/src/eckey_impl.h +92 -0
  128. package/ios/vendor/CSecp256k1/src/ecmult.h +61 -0
  129. package/ios/vendor/CSecp256k1/src/ecmult_const.h +38 -0
  130. package/ios/vendor/CSecp256k1/src/ecmult_const_impl.h +399 -0
  131. package/ios/vendor/CSecp256k1/src/ecmult_gen.h +143 -0
  132. package/ios/vendor/CSecp256k1/src/ecmult_gen_impl.h +341 -0
  133. package/ios/vendor/CSecp256k1/src/ecmult_impl.h +853 -0
  134. package/ios/vendor/CSecp256k1/src/field.h +350 -0
  135. package/ios/vendor/CSecp256k1/src/field_10x26.h +57 -0
  136. package/ios/vendor/CSecp256k1/src/field_10x26_impl.h +1232 -0
  137. package/ios/vendor/CSecp256k1/src/field_5x52.h +62 -0
  138. package/ios/vendor/CSecp256k1/src/field_5x52_impl.h +522 -0
  139. package/ios/vendor/CSecp256k1/src/field_5x52_int128_impl.h +274 -0
  140. package/ios/vendor/CSecp256k1/src/field_impl.h +457 -0
  141. package/ios/vendor/CSecp256k1/src/group.h +212 -0
  142. package/ios/vendor/CSecp256k1/src/group_impl.h +974 -0
  143. package/ios/vendor/CSecp256k1/src/hash.h +44 -0
  144. package/ios/vendor/CSecp256k1/src/hash_impl.h +299 -0
  145. package/ios/vendor/CSecp256k1/src/hsort.h +33 -0
  146. package/ios/vendor/CSecp256k1/src/hsort_impl.h +125 -0
  147. package/ios/vendor/CSecp256k1/src/int128.h +90 -0
  148. package/ios/vendor/CSecp256k1/src/int128_impl.h +18 -0
  149. package/ios/vendor/CSecp256k1/src/int128_native.h +19 -0
  150. package/ios/vendor/CSecp256k1/src/int128_native_impl.h +94 -0
  151. package/ios/vendor/CSecp256k1/src/int128_struct.h +14 -0
  152. package/ios/vendor/CSecp256k1/src/int128_struct_impl.h +205 -0
  153. package/ios/vendor/CSecp256k1/src/modinv32.h +43 -0
  154. package/ios/vendor/CSecp256k1/src/modinv32_impl.h +725 -0
  155. package/ios/vendor/CSecp256k1/src/modinv64.h +47 -0
  156. package/ios/vendor/CSecp256k1/src/modinv64_impl.h +780 -0
  157. package/ios/vendor/CSecp256k1/src/modules/recovery/main_impl.h +159 -0
  158. package/ios/vendor/CSecp256k1/src/precomputed_ecmult.c +16456 -0
  159. package/ios/vendor/CSecp256k1/src/precomputed_ecmult.h +38 -0
  160. package/ios/vendor/CSecp256k1/src/precomputed_ecmult_gen.c +1779 -0
  161. package/ios/vendor/CSecp256k1/src/precomputed_ecmult_gen.h +26 -0
  162. package/ios/vendor/CSecp256k1/src/scalar.h +105 -0
  163. package/ios/vendor/CSecp256k1/src/scalar_4x64.h +19 -0
  164. package/ios/vendor/CSecp256k1/src/scalar_4x64_impl.h +1000 -0
  165. package/ios/vendor/CSecp256k1/src/scalar_8x32.h +19 -0
  166. package/ios/vendor/CSecp256k1/src/scalar_8x32_impl.h +816 -0
  167. package/ios/vendor/CSecp256k1/src/scalar_impl.h +321 -0
  168. package/ios/vendor/CSecp256k1/src/scalar_low.h +24 -0
  169. package/ios/vendor/CSecp256k1/src/scalar_low_impl.h +206 -0
  170. package/ios/vendor/CSecp256k1/src/scratch.h +44 -0
  171. package/ios/vendor/CSecp256k1/src/scratch_impl.h +99 -0
  172. package/ios/vendor/CSecp256k1/src/secp256k1.c +831 -0
  173. package/ios/vendor/CSecp256k1/src/selftest.h +32 -0
  174. package/ios/vendor/CSecp256k1/src/util.h +451 -0
  175. package/ios/vendor/GENERATED.md +4 -0
  176. package/package.json +66 -3
  177. package/src/authonContext.ts +30 -0
  178. package/src/client.ts +459 -0
  179. package/src/errors.ts +58 -0
  180. package/src/index.ts +26 -0
  181. package/src/native.ts +52 -0
  182. package/src/types.ts +171 -0
  183. package/src/useAuthonWallet.ts +103 -0
@@ -0,0 +1,193 @@
1
+ // GENERATED by scripts/sync-native-wallet.mjs from kotlin/authon/src/main/kotlin/dev/authon/sdk/wallet/Xrp.kt. Do not edit: change the source and run the script.
2
+ package dev.authon.sdk.wallet
3
+
4
+ import org.web3j.crypto.ECKeyPair
5
+ import org.web3j.crypto.Sign
6
+ import java.math.BigInteger
7
+ import java.security.MessageDigest
8
+
9
+ /**
10
+ * XRP Ledger signing (NATIVE.md section 12, `apps/wallet/src/xrp.ts`). The app sends the
11
+ * encodeForSigning output (prefix STX\0); the SDK decodes it only to describe it and signs
12
+ * SHA-512Half(blob) with secp256k1, DER, low S, uppercase hex like ripple-keypairs.
13
+ */
14
+ internal object Xrp {
15
+ const val MAX_BLOB = 4096
16
+ private val PREFIX = byteArrayOf(0x53, 0x54, 0x58, 0x00)
17
+ private val MASK: BigInteger = BigInteger("3fffffffffffffff", 16)
18
+
19
+ private fun invalid(why: String = "not a valid XRP signing blob") = walletError(WalletErrorCode.INVALID_REQUEST, why)
20
+
21
+ class Tx {
22
+ var transactionType: Int? = null
23
+ var account: String? = null
24
+ var destination: String? = null
25
+ /** Drops; null for an issued-token amount (only meaningful when [amountSet]). */
26
+ var amount: BigInteger? = null
27
+ var amountSet = false
28
+ var fee: BigInteger? = null
29
+ var feeSet = false
30
+ var sequence: Long? = null
31
+ var destinationTag: Long? = null
32
+ var lastLedgerSequence: Long? = null
33
+ var signingPubKey: ByteArray? = null
34
+ val memos = mutableListOf<String>()
35
+ }
36
+
37
+ fun address(accountId: ByteArray): String {
38
+ if (accountId.size != 20) throw invalid()
39
+ return Base58.encodeCheck(byteArrayOf(0) + accountId, Base58.XRP)
40
+ }
41
+
42
+ fun addressOfPublicKey(compressed: ByteArray) = address(Chains.hash160Of(compressed))
43
+
44
+ private class Reader(val b: ByteArray) {
45
+ var pos = 0
46
+ val done get() = pos >= b.size
47
+
48
+ fun u8(): Int {
49
+ if (pos >= b.size) throw invalid()
50
+ return b[pos++].toInt() and 0xff
51
+ }
52
+
53
+ fun take(n: Int): ByteArray {
54
+ if (pos + n > b.size) throw invalid()
55
+ return b.copyOfRange(pos, pos + n).also { pos += n }
56
+ }
57
+
58
+ fun uint(n: Int): Long = take(n).fold(0L) { v, x -> v * 256 + (x.toLong() and 0xff) }
59
+
60
+ fun vl(): ByteArray {
61
+ val b1 = u8()
62
+ return when {
63
+ b1 <= 192 -> take(b1)
64
+ b1 <= 240 -> take(193 + (b1 - 193) * 256 + u8())
65
+ b1 <= 254 -> take(12481 + (b1 - 241) * 65536 + u8() * 256 + u8())
66
+ else -> throw invalid()
67
+ }
68
+ }
69
+
70
+ fun field(): Pair<Int, Int> {
71
+ val x = u8()
72
+ var type = x shr 4
73
+ var code = x and 0x0f
74
+ if (type == 0) type = u8()
75
+ if (code == 0) code = u8()
76
+ return type to code
77
+ }
78
+ }
79
+
80
+ private fun amount(r: Reader): BigInteger? {
81
+ val head = r.b.getOrNull(r.pos)?.toInt()?.and(0xff) ?: throw invalid()
82
+ if (head and 0x80 != 0) {
83
+ r.take(48)
84
+ return null
85
+ }
86
+ return BigInteger(1, r.take(8)).and(MASK)
87
+ }
88
+
89
+ private class Parser(val r: Reader) {
90
+ var memoTarget: MutableList<String>? = null
91
+
92
+ fun readObject(tx: Tx?, depth: Int) {
93
+ if (depth > 4) throw invalid()
94
+ while (!r.done) {
95
+ val (type, code) = r.field()
96
+ if (type == 14 && code == 1) return
97
+ if (type == 15 && code == 1) return
98
+ when (type) {
99
+ 1 -> { val v = r.uint(2); if (tx != null && code == 2) tx.transactionType = v.toInt() }
100
+ 2 -> {
101
+ val v = r.uint(4)
102
+ if (tx != null) when (code) {
103
+ 4 -> tx.sequence = v
104
+ 14 -> tx.destinationTag = v
105
+ 27 -> tx.lastLedgerSequence = v
106
+ }
107
+ }
108
+ 3 -> r.take(8)
109
+ 4 -> r.take(16)
110
+ 5 -> r.take(32)
111
+ 16 -> r.take(1)
112
+ 17 -> r.take(20)
113
+ 6 -> {
114
+ val v = amount(r)
115
+ if (tx != null && code == 1) { tx.amount = v; tx.amountSet = true }
116
+ else if (tx != null && code == 8) { tx.fee = v; tx.feeSet = true }
117
+ }
118
+ 7 -> {
119
+ val v = r.vl()
120
+ if (tx != null && code == 3) tx.signingPubKey = v
121
+ else if (tx == null && code == 13) memoTarget?.add(String(v, Charsets.UTF_8))
122
+ }
123
+ 8 -> {
124
+ val v = r.vl()
125
+ if (tx != null && code == 1) tx.account = address(v)
126
+ else if (tx != null && code == 3) tx.destination = address(v)
127
+ }
128
+ 14 -> readObject(null, depth + 1)
129
+ 15 -> {
130
+ val prev = memoTarget
131
+ if (tx != null && code == 9) memoTarget = tx.memos
132
+ readObject(null, depth + 1)
133
+ memoTarget = prev
134
+ }
135
+ else -> throw invalid("XRP field type $type is not supported")
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ fun parse(blob: ByteArray): Tx {
142
+ if (blob.size < 5 || blob.size > MAX_BLOB || !blob.copyOf(4).contentEquals(PREFIX)) throw invalid()
143
+ val tx = Tx()
144
+ Parser(Reader(blob.copyOfRange(4, blob.size))).readObject(tx, 0)
145
+ if (tx.transactionType == null || tx.account.isNullOrEmpty() || tx.signingPubKey == null) throw invalid()
146
+ return tx
147
+ }
148
+
149
+ private fun xrp(drops: BigInteger): String {
150
+ val (whole, rem) = drops.divideAndRemainder(BigInteger.valueOf(1_000_000))
151
+ val frac = rem.toString().padStart(6, '0').trimEnd('0')
152
+ return "$whole${if (frac.isEmpty()) "" else ".$frac"} XRP"
153
+ }
154
+
155
+ private val TYPES = mapOf(0 to "Payment", 3 to "AccountSet", 7 to "OfferCreate", 8 to "OfferCancel", 12 to "SetRegularKey", 20 to "TrustSet")
156
+
157
+ fun summarize(tx: Tx, signer: String, signerPublicKey: ByteArray): SignSummary {
158
+ if (tx.account != signer) throw walletError(WalletErrorCode.ADDRESS_MISMATCH, "the transaction account is not the signing account")
159
+ if (tx.signingPubKey?.contentEquals(signerPublicKey) != true) {
160
+ throw walletError(WalletErrorCode.INVALID_REQUEST, "SigningPubKey must be the signing account public key")
161
+ }
162
+ val type = tx.transactionType!!
163
+ val rows = mutableListOf(
164
+ SignRow("Network", "XRP Ledger"),
165
+ SignRow("Account", signer, mono = true),
166
+ SignRow("Type", TYPES[type] ?: "Type $type"),
167
+ )
168
+ val warnings = mutableListOf<String>()
169
+ if (type == 0) {
170
+ if (tx.amountSet && tx.amount == null) {
171
+ rows += SignRow("Send", "Issued token amount")
172
+ warnings += "Issued-token payments cannot be described in detail."
173
+ } else if (tx.amountSet) {
174
+ rows += SignRow("Send", xrp(tx.amount!!))
175
+ }
176
+ tx.destination?.takeIf { it.isNotEmpty() }?.let { rows += SignRow("To", it, mono = true) }
177
+ tx.destinationTag?.let { rows += SignRow("Destination tag", it.toString()) }
178
+ } else {
179
+ warnings += "${TYPES[type] ?: "This"} transaction cannot be described in detail. Approve only if you trust the app."
180
+ }
181
+ for (m in tx.memos) rows += SignRow("Memo", m)
182
+ if (tx.feeSet && tx.fee != null) rows += SignRow("Network fee", xrp(tx.fee!!))
183
+ tx.sequence?.let { rows += SignRow("Sequence", it.toString()) }
184
+ tx.lastLedgerSequence?.let { rows += SignRow("Valid until ledger", it.toString()) }
185
+ return SignSummary(SignSummary.Kind.TRANSACTION, "XRP Ledger transaction", rows, null, warnings, SignRisk.HIGH)
186
+ }
187
+
188
+ fun sign(blob: ByteArray, privateKey: ByteArray): Map<String, String> {
189
+ val hash = MessageDigest.getInstance("SHA-512").digest(blob).copyOf(32)
190
+ val sig = Sign.signMessage(hash, ECKeyPair.create(privateKey), false)
191
+ return mapOf("signature" to Bytes.toHex(Der.encode(sig.r, sig.s)).uppercase())
192
+ }
193
+ }
@@ -0,0 +1,19 @@
1
+ import { type Context } from 'react';
2
+ /** The part of @authon/react-native's AuthonContext value the wallet uses. */
3
+ export interface AuthonSession {
4
+ isLoaded?: boolean;
5
+ isSignedIn?: boolean;
6
+ userId?: string | null;
7
+ getToken?: () => string | null;
8
+ client?: {
9
+ refreshToken?: () => Promise<{
10
+ accessToken?: string;
11
+ } | null>;
12
+ };
13
+ }
14
+ /**
15
+ * @authon/react-native is an optional peer: Metro resolves this require when the package is
16
+ * installed, and the catch keeps apps without it working (they pass getToken instead).
17
+ */
18
+ export declare function getAuthonContext(): Context<AuthonSession | null>;
19
+ //# sourceMappingURL=authonContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authonContext.d.ts","sourceRoot":"","sources":["../src/authonContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAIpD,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC;YAAE,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC;CAC5E;AAKD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAShE"}
@@ -0,0 +1,20 @@
1
+ import { createContext } from 'react';
2
+ const missing = createContext(null);
3
+ let cached;
4
+ /**
5
+ * @authon/react-native is an optional peer: Metro resolves this require when the package is
6
+ * installed, and the catch keeps apps without it working (they pass getToken instead).
7
+ */
8
+ export function getAuthonContext() {
9
+ if (cached)
10
+ return cached;
11
+ try {
12
+ const mod = require('@authon/react-native');
13
+ cached = mod?.AuthonContext ?? missing;
14
+ }
15
+ catch {
16
+ cached = missing;
17
+ }
18
+ return cached;
19
+ }
20
+ //# sourceMappingURL=authonContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authonContext.js","sourceRoot":"","sources":["../src/authonContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAapD,MAAM,OAAO,GAAG,aAAa,CAAuB,IAAI,CAAC,CAAC;AAC1D,IAAI,MAAiD,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,sBAAsB,CAAkE,CAAC;QAC7G,MAAM,GAAG,GAAG,EAAE,aAAa,IAAI,OAAO,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,OAAO,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,92 @@
1
+ import type { AuthonWalletOptions, EIP1193Provider, EmbeddedWallet, Hex, TypedDataPayload, WalletAccount, WalletAppConfig, WalletCapabilities, WalletChain, WalletChainSignRequest, WalletChangeListener, WalletMessage, WalletSignOptions, WalletTransactionRequest } from './types';
2
+ /**
3
+ * The Authon embedded wallet in a React Native app. Signing runs in the native Swift / Kotlin
4
+ * wallet; JS only sees addresses, signatures, status and devices.
5
+ */
6
+ export declare class AuthonWalletClient {
7
+ private readonly id;
8
+ private readonly options;
9
+ private readonly listeners;
10
+ private readonly accountAddresses;
11
+ private configured;
12
+ private ensuring;
13
+ /** Bumped by dispose(); results of calls started before it are dropped (DISPOSED). */
14
+ private generation;
15
+ constructor(options: AuthonWalletOptions);
16
+ /** App registration and wallet settings (does not need a session). */
17
+ appConfig(): Promise<WalletAppConfig>;
18
+ /**
19
+ * Whether this device and app can use the wallet, before sign-in (no session, creates nothing,
20
+ * opens no UI). `ready === 'unavailable'`: tell the user before signing in; `unknown`: continue
21
+ * but expect that feature to fail. Answers for release builds (test options are ignored).
22
+ */
23
+ capabilities(): Promise<WalletCapabilities>;
24
+ /** The signed-in user's wallet, or null when there is none yet. */
25
+ get(): Promise<EmbeddedWallet | null>;
26
+ /** Same as `get()` (the frame method is `wallet.status`). */
27
+ status(): Promise<EmbeddedWallet | null>;
28
+ /** Creates the wallet (two-phase on the server), or returns the existing one. */
29
+ create(): Promise<EmbeddedWallet>;
30
+ /** Returns the wallet, creating it first when the user has none. Concurrent calls share one request. */
31
+ ensure(): Promise<EmbeddedWallet>;
32
+ /** True when the wallet exists and has a passkey backup. */
33
+ isProtected(): Promise<boolean>;
34
+ /**
35
+ * Addresses of accounts `start`..`start + count - 1` (public, no approval) on `chain` (default
36
+ * `evm`). Signing is EVM only for now; other chains are for receiving and display.
37
+ */
38
+ getAccounts(options?: {
39
+ start?: number;
40
+ count?: number;
41
+ chain?: WalletChain;
42
+ }): Promise<WalletAccount[]>;
43
+ /**
44
+ * EIP-191 personal_sign. The native approval sheet / dialog shows the full text first when the
45
+ * project requires confirmation (default); rejecting gives USER_CANCELLED and nothing is signed.
46
+ */
47
+ signMessage(message: WalletMessage, options?: WalletSignOptions): Promise<Hex>;
48
+ /** EIP-712 v4 typed data. */
49
+ signTypedData(typedData: TypedDataPayload, options?: WalletSignOptions): Promise<Hex>;
50
+ /** Signs a legacy, EIP-2930 or EIP-1559 transaction and returns the serialized signed transaction. */
51
+ signTransaction(tx: WalletTransactionRequest, options?: WalletSignOptions): Promise<Hex>;
52
+ /**
53
+ * Signs an app-built transaction on another chain (NATIVE.md section 12): Solana `{ signature }`,
54
+ * TRON `{ signature, txID }`, Bitcoin `{ psbt, txHex? }`, XRP `{ signature }`. The native approval
55
+ * UI shows what the transaction does (unknown programs / contracts are shown as high risk).
56
+ */
57
+ signChainTransaction(request: WalletChainSignRequest): Promise<Record<string, string>>;
58
+ /** Creates the passkey backup (iOS 18+ / Android with PRF support). Needs an approved app registration. */
59
+ protect(): Promise<void>;
60
+ /** Replaces a legacy backup with a verifiable one, on a device that holds the wallet. */
61
+ upgradeBackup(): Promise<void>;
62
+ /**
63
+ * Restores the wallet on this install with the backup passkey. By default this install is added
64
+ * as another device; `resetOtherDevices: true` re-splits the key and revokes every other device.
65
+ */
66
+ restore(options?: {
67
+ resetOtherDevices?: boolean;
68
+ }): Promise<void>;
69
+ /** Revokes a device (signed with this install's device key). */
70
+ revokeDevice(deviceId: string): Promise<void>;
71
+ onChange(listener: WalletChangeListener): () => void;
72
+ /** A minimal EIP-1193 provider (same methods as @authon/js). */
73
+ provider(chainId: number): EIP1193Provider;
74
+ /**
75
+ * Call on sign-out: releases the native instance, rejects calls in flight with DISPOSED and
76
+ * forgets cached account addresses. The device share stays on the device. Like @authon/js, the
77
+ * client can be used again afterwards (it reconnects on the next call).
78
+ */
79
+ dispose(): void;
80
+ private native;
81
+ private token;
82
+ private call;
83
+ private unwrap;
84
+ /** For accounts other than 0 the native wallet needs the expected address and refuses on mismatch. */
85
+ private account;
86
+ /** A different wallet (another user) invalidates the cached account addresses. */
87
+ private remember;
88
+ private refresh;
89
+ private notify;
90
+ }
91
+ export declare function createAuthonWallet(options: AuthonWalletOptions): AuthonWalletClient;
92
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EAEd,GAAG,EACH,gBAAgB,EAChB,aAAa,EAGb,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAuFjB;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgC;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmC;IAC7D,OAAO,C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