@qntx/wallet-native 0.0.0-stage → 0.5.2
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.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +123 -2
- package/WalletNative.podspec +74 -0
- package/android/CMakeLists.txt +99 -0
- package/android/build.gradle +177 -0
- package/android/consumer-rules.pro +4 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +29 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/AppLifecycle.kt +35 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/KernelPbkdf2.java +59 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/Keystore.kt +280 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/Passkey.kt +147 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/VaultDirectory.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/WalletNativePackage.java +30 -0
- package/cpp/host/HybridKernelHost.cpp +162 -0
- package/cpp/host/HybridKernelHost.hpp +49 -0
- package/cpp/host/KernelFile.cpp +120 -0
- package/cpp/host/KernelFile.hpp +24 -0
- package/cpp/host/Keystore.hpp +70 -0
- package/cpp/host/Lifecycle.cpp +77 -0
- package/cpp/host/Lifecycle.hpp +71 -0
- package/cpp/host/Passkey.hpp +39 -0
- package/cpp/host/VaultDirectory.hpp +16 -0
- package/cpp/platform/KeystoreAndroid.cpp +175 -0
- package/cpp/platform/KeystoreIos.mm +300 -0
- package/cpp/platform/LifecycleAndroid.cpp +55 -0
- package/cpp/platform/LifecycleIos.mm +36 -0
- package/cpp/platform/PasskeyAndroid.cpp +118 -0
- package/cpp/platform/PasskeyIos.mm +20 -0
- package/cpp/platform/VaultDirectory.mm +58 -0
- package/cpp/platform/VaultDirectoryAndroid.cpp +35 -0
- package/cpp/runtime/KernelBackends.cpp +297 -0
- package/cpp/runtime/KernelBackends.hpp +20 -0
- package/cpp/runtime/KernelBuffer.cpp +12 -0
- package/cpp/runtime/KernelBuffer.hpp +96 -0
- package/cpp/runtime/KernelGlobals.cpp +535 -0
- package/cpp/runtime/KernelGlobals.hpp +107 -0
- package/cpp/runtime/KernelJs.cpp +155 -0
- package/cpp/runtime/KernelJs.hpp +81 -0
- package/cpp/runtime/KernelKeystore.cpp +224 -0
- package/cpp/runtime/KernelKeystore.hpp +28 -0
- package/cpp/runtime/KernelPasskey.cpp +137 -0
- package/cpp/runtime/KernelPasskey.hpp +23 -0
- package/cpp/runtime/KernelRuntime.cpp +496 -0
- package/cpp/runtime/KernelRuntime.hpp +94 -0
- package/cpp/runtime/platform/KernelPbkdf2.cpp +198 -0
- package/cpp/runtime/platform/KernelPbkdf2.hpp +38 -0
- package/dist/index.d.mts +44 -0
- package/dist/index.mjs +170 -0
- package/dist/index.mjs.map +1 -0
- package/kernel/generated/kernel-entry.js +42967 -0
- package/kernel/generated/kernel.manifest.json +80 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/WalletNative+autolinking.cmake +81 -0
- package/nitrogen/generated/android/WalletNative+autolinking.gradle +27 -0
- package/nitrogen/generated/android/WalletNativeOnLoad.cpp +49 -0
- package/nitrogen/generated/android/WalletNativeOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/WalletNativeOnLoad.kt +35 -0
- package/nitrogen/generated/ios/WalletNative+autolinking.rb +62 -0
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/WalletNativeAutolinking.mm +35 -0
- package/nitrogen/generated/ios/WalletNativeAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridKernelHostSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridKernelHostSpec.hpp +69 -0
- package/nitrogen/generated/shared/c++/KernelExitReason.hpp +84 -0
- package/package.json +65 -4
- package/react-native.config.js +14 -0
- package/scripts/compile-kernel.mjs +118 -0
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 QuantX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @qntx/wallet-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React Native host for [`@qntx/wallet`](https://www.npmjs.com/package/@qntx/wallet): runs the
|
|
4
|
+
wallet kernel on its own Hermes runtime on a separate thread (the Nitro `KernelHost` object
|
|
5
|
+
shuttles CBOR messages to it across JSI), keeps the
|
|
6
|
+
encrypted vault under the platform's never-backed-up directory, and makes the platform keystore
|
|
7
|
+
(Secure Enclave on iOS, Android Keystore) the vault factor — every unlock and every signing
|
|
8
|
+
request is gated by a system user-presence prompt rendered with kernel-owned text.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @qntx/wallet-native @qntx/wallet @qntx/nostr-native @qntx/spark-native
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Peer dependencies (exact `@qntx/*` pins are required — the host/kernel protocol and the bundled
|
|
15
|
+
kernel artifacts are built against those releases):
|
|
16
|
+
|
|
17
|
+
| package | range |
|
|
18
|
+
| ---------------------------- | ---------------- |
|
|
19
|
+
| `@qntx/wallet` | `0.4.0` (exact) |
|
|
20
|
+
| `@qntx/nostr-native` | `0.15.3` (exact) |
|
|
21
|
+
| `@qntx/spark-native` | `0.5.2` (exact) |
|
|
22
|
+
| `react-native` | `~0.88.0` |
|
|
23
|
+
| `react-native-nitro-modules` | `~0.37.1` |
|
|
24
|
+
|
|
25
|
+
The package registers one Nitro hybrid object, `KernelHost`. Everything else the kernel needs —
|
|
26
|
+
keystore, passkey ceremonies, lifecycle, pbkdf2, the vault directory — is injected as JSI host
|
|
27
|
+
objects inside the kernel runtime and is never registered with Nitro. **No Nitro patch or
|
|
28
|
+
`nitro::install` call is needed in the consuming app.**
|
|
29
|
+
|
|
30
|
+
## Expo configuration
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// app.config.ts
|
|
34
|
+
export default {
|
|
35
|
+
ios: {
|
|
36
|
+
bundleIdentifier: "com.example.app",
|
|
37
|
+
infoPlist: { NSFaceIDUsageDescription: "Verify your identity to unlock your wallet" },
|
|
38
|
+
},
|
|
39
|
+
android: { package: "com.example.app" },
|
|
40
|
+
plugins: [
|
|
41
|
+
["expo-build-properties", { ios: { useFrameworks: "static" }, android: { minSdkVersion: 30 } }],
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `ios.infoPlist.NSFaceIDUsageDescription` — required: the keystore evaluates device-owner
|
|
47
|
+
presence through `LAContext`, which needs the Face ID purpose string.
|
|
48
|
+
- `ios.useFrameworks: "static"` is supported.
|
|
49
|
+
- `android.minSdkVersion: 30` — required: per-use Keystore keys that accept a biometric _or_ the
|
|
50
|
+
device credential need API 30 (`setUserAuthenticationParameters` semantics).
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { createNativeWallet } from "@qntx/wallet-native";
|
|
56
|
+
|
|
57
|
+
const wallet = await createNativeWallet({
|
|
58
|
+
passkey: {
|
|
59
|
+
rpId: "example.com",
|
|
60
|
+
rpName: "Example",
|
|
61
|
+
walletSalt: "example/wallet",
|
|
62
|
+
vaultSalt: "example/vault",
|
|
63
|
+
backupSalt: "example/backup",
|
|
64
|
+
},
|
|
65
|
+
autoLock: { platform: "native", backgroundSeconds: 60 },
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- `passkey` — relying-party config for the passkey _wallet_ flow (create/restore with a synced
|
|
70
|
+
passkey). `rpId`, `walletSalt` and `vaultSalt` are permanent identifiers: changing them makes
|
|
71
|
+
existing passkey factors and passkey-derived wallets unrecoverable. `backupSalt` is the PRF
|
|
72
|
+
salt for the cloud-backup factor — a third, distinct permanent label.
|
|
73
|
+
- `autoLock` — must be `{ platform: "native", backgroundSeconds }`. The native host owns the
|
|
74
|
+
signal: it calls `host.lock()` when the app has spent `backgroundSeconds` in the background.
|
|
75
|
+
A platform authentication prompt on screen does **not** count as background time.
|
|
76
|
+
|
|
77
|
+
## Passkey domains
|
|
78
|
+
|
|
79
|
+
Passkey wallets need the platform's domain association:
|
|
80
|
+
|
|
81
|
+
- **iOS** — `webcredentials:<rpId>` associated domain (requires a paid developer account; free
|
|
82
|
+
signing cannot hold the entitlement). **Native iOS passkeys are not implemented yet** — the
|
|
83
|
+
ceremony returns `factor-unavailable`, so `createWithPasskey`/`restoreWithPasskey` cannot be
|
|
84
|
+
offered on iOS; ship mnemonic restore.
|
|
85
|
+
- **Android** — Credential Manager resolves the RP against
|
|
86
|
+
`https://<rpId>/.well-known/assetlinks.json` with
|
|
87
|
+
`delegate_permission/common.get_login_creds` naming the app's package and SHA-256 signing
|
|
88
|
+
certificate. Android passkeys are implemented via `androidx.credentials`.
|
|
89
|
+
|
|
90
|
+
## Vault storage and backup
|
|
91
|
+
|
|
92
|
+
- **iOS** — the vault image lives under `Application Support/qntx-wallet/`, created with
|
|
93
|
+
`NSFileProtectionComplete` and `NSURLIsExcludedFromBackupKey`. Device-to-device migration and
|
|
94
|
+
iCloud backups must not carry the vault: it is bound to this device's hardware factor, which
|
|
95
|
+
cannot leave the Secure Enclave.
|
|
96
|
+
- **Android** — the vault image lives under `noBackupFilesDir/qntx-wallet`, excluded from
|
|
97
|
+
Auto Backup by construction.
|
|
98
|
+
|
|
99
|
+
## Security notes
|
|
100
|
+
|
|
101
|
+
- The hardware vault factor is the only factor kind on this platform. Unlock, vault creation,
|
|
102
|
+
mnemonic/key export, wallet deletion, cloud-backup enable, reset and every `chain.sign` /
|
|
103
|
+
`spark.approve` request open a platform authentication ceremony with kernel-owned prompt text
|
|
104
|
+
(Simplified Chinese under a `zh*` locale, English otherwise).
|
|
105
|
+
- `vault.reset` authenticates the device owner first, then erases the vault and all hardware
|
|
106
|
+
keys. Devices without a lock screen return `factor-unavailable` — the host should send the
|
|
107
|
+
user to set one up.
|
|
108
|
+
- `chain.sign` prompts _before_ any secret derivation: the kernel normalizes and decodes the
|
|
109
|
+
intent, shows the prompt, and only then touches key material.
|
|
110
|
+
- The kernel serializes ceremonies — two concurrent signing requests cannot race two system
|
|
111
|
+
prompts.
|
|
112
|
+
- `kernel/generated/kernel.manifest.json` inside the package records the kernel bundle's
|
|
113
|
+
SHA-256 and every pinned protocol dependency; `scripts/compile-kernel.mjs` verifies it when
|
|
114
|
+
the host is natively built and fails the build on a mismatch. At kernel start the host
|
|
115
|
+
checks each backend's `abiVersion`.
|
|
116
|
+
- On the iOS simulator the Secure Enclave token and the `.privateKeyUsage` flag are compiled
|
|
117
|
+
out, so ceremonies run on software keys through the same code path. The app must be
|
|
118
|
+
code-signed (the default ad-hoc "Sign to Run Locally" identity suffices) — an unsigned
|
|
119
|
+
binary fails every `SecItem` call with `errSecMissingEntitlement` (-34018), surfaced as
|
|
120
|
+
`unavailable`.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT OR Apache-2.0
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "WalletNative"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = "https://github.com/qntx/wallet"
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/qntx/wallet.git" }
|
|
15
|
+
# Swift pods (V1Probe's Nitrogen bridge) depend on this — a module map is required.
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.source_files = [
|
|
19
|
+
"cpp/runtime/**/*.{h,hpp,c,cpp,mm}",
|
|
20
|
+
"cpp/host/**/*.{h,hpp,c,cpp,mm}",
|
|
21
|
+
"cpp/platform/**/*.{h,hpp,c,cpp,mm}",
|
|
22
|
+
]
|
|
23
|
+
s.public_header_files = "cpp/**/*.hpp"
|
|
24
|
+
s.header_mappings_dir = "cpp"
|
|
25
|
+
|
|
26
|
+
s.pod_target_xcconfig = {
|
|
27
|
+
"DEFINES_MODULE" => "YES",
|
|
28
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
29
|
+
"HEADER_SEARCH_PATHS" => [
|
|
30
|
+
'"$(PODS_TARGET_SRCROOT)/cpp"',
|
|
31
|
+
'"$(PODS_ROOT)/hermes-engine/destroot/include"',
|
|
32
|
+
'"$(PODS_ROOT)/Headers/Public/SparkNative"',
|
|
33
|
+
'"$(DERIVED_FILE_DIR)/qntx-kernel"',
|
|
34
|
+
].join(' '),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Compile the shipped kernel-entry.js to bytecode with the app's own hermesc —
|
|
38
|
+
# Hermes only loads its own bytecode version, so precompiled hbc cannot ship.
|
|
39
|
+
# kernel.hpp lands in DERIVED_FILE_DIR/qntx-kernel (a header search path).
|
|
40
|
+
s.script_phase = {
|
|
41
|
+
:name => "Compile Kernel Bytecode",
|
|
42
|
+
:script => <<~SH,
|
|
43
|
+
if [ -z "$REACT_NATIVE_PATH" ]; then
|
|
44
|
+
echo "REACT_NATIVE_PATH is not set"
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
|
|
48
|
+
"$NODE_BINARY" "$PODS_TARGET_SRCROOT/scripts/compile-kernel.mjs" \
|
|
49
|
+
"$DERIVED_FILE_DIR/qntx-kernel" "$REACT_NATIVE_PATH"
|
|
50
|
+
SH
|
|
51
|
+
:execution_position => :before_compile,
|
|
52
|
+
:input_files => [
|
|
53
|
+
"$(PODS_TARGET_SRCROOT)/kernel/generated/kernel-entry.js",
|
|
54
|
+
"$(PODS_TARGET_SRCROOT)/kernel/generated/kernel.manifest.json",
|
|
55
|
+
"$(PODS_TARGET_SRCROOT)/scripts/compile-kernel.mjs",
|
|
56
|
+
],
|
|
57
|
+
:output_files => ["$(DERIVED_FILE_DIR)/qntx-kernel/kernel.hpp"],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# The kernel's backends.spark binds the qs_* C ABI; the prebuilt
|
|
61
|
+
# QntxSpark.xcframework ships inside the SparkNative pod.
|
|
62
|
+
s.frameworks = "LocalAuthentication", "Security"
|
|
63
|
+
|
|
64
|
+
s.dependency 'NostrNative'
|
|
65
|
+
s.dependency 'SparkNative'
|
|
66
|
+
s.dependency 'React-jsi'
|
|
67
|
+
s.dependency 'React-callinvoker'
|
|
68
|
+
s.dependency 'React-hermes'
|
|
69
|
+
s.dependency 'hermes-engine'
|
|
70
|
+
|
|
71
|
+
load 'nitrogen/generated/ios/WalletNative+autolinking.rb'
|
|
72
|
+
add_nitrogen_files(s)
|
|
73
|
+
install_modules_dependencies(s)
|
|
74
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
project(WalletNative)
|
|
2
|
+
cmake_minimum_required(VERSION 3.16)
|
|
3
|
+
|
|
4
|
+
set(PACKAGE_NAME WalletNative)
|
|
5
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
+
|
|
8
|
+
file(GLOB_RECURSE runtime_files CONFIGURE_DEPENDS
|
|
9
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp/runtime/*.cpp"
|
|
10
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp/host/*.cpp"
|
|
11
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp/platform/*.cpp"
|
|
12
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/*.cpp"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
add_library(${PACKAGE_NAME} SHARED ${runtime_files})
|
|
16
|
+
target_include_directories(${PACKAGE_NAME} PUBLIC
|
|
17
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp"
|
|
18
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp/host"
|
|
19
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../cpp/platform"
|
|
20
|
+
"${CMAKE_CURRENT_BINARY_DIR}/qntx-kernel"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Compile the shipped kernel bundle to bytecode with the app's own hermesc —
|
|
24
|
+
# Hermes only loads its own bytecode version, so precompiled hbc cannot ship.
|
|
25
|
+
# The app's react-native root is passed explicitly (-DQNTX_REACT_NATIVE_PATH)
|
|
26
|
+
# so the script resolves the app's own hermesc version.
|
|
27
|
+
find_program(NODE_EXECUTABLE node REQUIRED)
|
|
28
|
+
if(NOT QNTX_REACT_NATIVE_PATH)
|
|
29
|
+
message(FATAL_ERROR "QNTX_REACT_NATIVE_PATH is not set — the consuming app must pass -DQNTX_REACT_NATIVE_PATH=<react-native dir>")
|
|
30
|
+
endif()
|
|
31
|
+
set(KERNEL_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qntx-kernel/kernel.hpp")
|
|
32
|
+
add_custom_command(
|
|
33
|
+
OUTPUT ${KERNEL_HEADER}
|
|
34
|
+
COMMAND ${NODE_EXECUTABLE}
|
|
35
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/compile-kernel.mjs"
|
|
36
|
+
"${CMAKE_CURRENT_BINARY_DIR}/qntx-kernel"
|
|
37
|
+
"${QNTX_REACT_NATIVE_PATH}"
|
|
38
|
+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../kernel/generated/kernel-entry.js"
|
|
39
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../kernel/generated/kernel.manifest.json"
|
|
40
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/../scripts/compile-kernel.mjs"
|
|
41
|
+
COMMENT "Compiling the kernel bytecode (hermesc)"
|
|
42
|
+
VERBATIM
|
|
43
|
+
)
|
|
44
|
+
add_custom_target(qntx-kernel-bytecode DEPENDS ${KERNEL_HEADER})
|
|
45
|
+
add_dependencies(${PACKAGE_NAME} qntx-kernel-bytecode)
|
|
46
|
+
|
|
47
|
+
# The kernel's backends.spark binds the qs_* C ABI: the prebuilt
|
|
48
|
+
# libqntx_spark.so + header ship inside the app's @qntx/spark-native package
|
|
49
|
+
# (dir passed as -DQNTX_SPARK_NATIVE_PATH, resolved like the react-native dir).
|
|
50
|
+
if(NOT QNTX_SPARK_NATIVE_PATH)
|
|
51
|
+
message(FATAL_ERROR "QNTX_SPARK_NATIVE_PATH is not set — the consuming app must pass -DQNTX_SPARK_NATIVE_PATH=<@qntx/spark-native dir>")
|
|
52
|
+
endif()
|
|
53
|
+
set(QNTX_SPARK_LIBDIR "${QNTX_SPARK_NATIVE_PATH}/android/src/main/jniLibs/${ANDROID_ABI}")
|
|
54
|
+
if(NOT EXISTS "${QNTX_SPARK_LIBDIR}/libqntx_spark.so")
|
|
55
|
+
message(FATAL_ERROR "libqntx_spark.so for ${ANDROID_ABI} not found in ${QNTX_SPARK_LIBDIR}")
|
|
56
|
+
endif()
|
|
57
|
+
# The .so carries SONAME since 0.5.1, so the path link records the soname in
|
|
58
|
+
# DT_NEEDED — the loader resolves it from the packaged jniLibs. GLOBAL: this
|
|
59
|
+
# target's link libraries are transitive (plain signature), so
|
|
60
|
+
# add_subdirectory consumers (v1-probe) see and link the same imported target.
|
|
61
|
+
add_library(qntx_spark SHARED IMPORTED GLOBAL)
|
|
62
|
+
set_target_properties(qntx_spark PROPERTIES
|
|
63
|
+
IMPORTED_LOCATION "${QNTX_SPARK_LIBDIR}/libqntx_spark.so")
|
|
64
|
+
target_include_directories(${PACKAGE_NAME} PRIVATE "${QNTX_SPARK_NATIVE_PATH}/include")
|
|
65
|
+
|
|
66
|
+
find_package(qntx_nostr-native REQUIRED CONFIG)
|
|
67
|
+
|
|
68
|
+
# Adds the nitrogen-generated sources, the BUILDING_..._GENERATED_CMAKE_PROJECT
|
|
69
|
+
# define they require, and the fbjni/ReactAndroid/NitroModules prefab links.
|
|
70
|
+
include(${CMAKE_CURRENT_SOURCE_DIR}/../nitrogen/generated/android/WalletNative+autolinking.cmake)
|
|
71
|
+
|
|
72
|
+
# Same Hermes link pattern as react-native-worklets 0.10.1: the hermes-engine
|
|
73
|
+
# prefab target is hermesvm on RN >= 0.82 and libhermes before that. The version
|
|
74
|
+
# minor comes from the ReactAndroid prefab config.
|
|
75
|
+
find_package(hermes-engine REQUIRED CONFIG)
|
|
76
|
+
|
|
77
|
+
# The generated autolinking.cmake already defines the FOLLY flags this module
|
|
78
|
+
# needs; the runtime only adds RN_SERIALIZABLE_STATE. (folly-flags.cmake itself
|
|
79
|
+
# is only reachable relative to the consuming app's node_modules, which this
|
|
80
|
+
# module cannot assume when it is built standalone.)
|
|
81
|
+
target_compile_definitions(${PACKAGE_NAME} PRIVATE -DRN_SERIALIZABLE_STATE)
|
|
82
|
+
|
|
83
|
+
find_library(LOG_LIB log)
|
|
84
|
+
|
|
85
|
+
target_link_libraries(
|
|
86
|
+
${PACKAGE_NAME}
|
|
87
|
+
fbjni::fbjni
|
|
88
|
+
ReactAndroid::jsi
|
|
89
|
+
qntx_spark
|
|
90
|
+
qntx_nostr-native::NostrNative
|
|
91
|
+
${LOG_LIB}
|
|
92
|
+
android
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 82)
|
|
96
|
+
target_link_libraries(${PACKAGE_NAME} hermes-engine::hermesvm)
|
|
97
|
+
else()
|
|
98
|
+
target_link_libraries(${PACKAGE_NAME} hermes-engine::libhermes)
|
|
99
|
+
endif()
|